Help us shape the future of Go! Take the 2026 Go Developer Survey

mcp

package
v1.37.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProxyElicitationHandler

func NewProxyElicitationHandler() client.ElicitationHandler

func NewProxySamplingHandler

func NewProxySamplingHandler() client.SamplingHandler

NewProxySamplingHandler creates a new ProxySamplingHandler with the given MCP server.

Types

type Capabilities

type Capabilities struct {
	Sampling    client.SamplingHandler
	Elicitation client.ElicitationHandler
}

type McpConfig

type McpConfig struct {
	// Servers maps server names to their configurations
	Servers map[string]*ServerConfig `json:"servers"`
}

McpConfig represents the overall MCP configuration structure

type McpHost

type McpHost struct {
	// contains filtered or unexported fields
}

McpHost manages multiple MCP (Model Context Protocol) servers and their tools

func NewMcpHost

func NewMcpHost(options ...McpHostOption) *McpHost

NewMcpHost creates a new McpHost with the provided options

func (*McpHost) AllTools

func (h *McpHost) AllTools(ctx context.Context) ([]server.ServerTool, error)

func (*McpHost) Hooks

func (h *McpHost) Hooks() *server.Hooks

Hooks returns server hooks for the MCP host to manage client sessions

func (*McpHost) ServerTools

func (h *McpHost) ServerTools(ctx context.Context, serverName string) ([]server.ServerTool, error)

GetServerTools retrieves all tools from all connected MCP servers

func (*McpHost) Servers

func (h *McpHost) Servers() []string

Servers returns the names of all configured MCP servers

func (*McpHost) SetProxyServer

func (h *McpHost) SetProxyServer(server *server.MCPServer)

func (*McpHost) SetSession

func (h *McpHost) SetSession(session server.ClientSession)

func (*McpHost) Start

func (h *McpHost) Start(ctx context.Context) error

Start initializes and starts all configured MCP servers and their clients

func (*McpHost) Stop

func (h *McpHost) Stop() error

Stop stops all MCP clients and their associated servers

type McpHostOption

type McpHostOption func(*McpHost)

McpHostOption defines a functional option for configuring the McpHost

func WithCapabilities

func WithCapabilities(capabilities Capabilities) McpHostOption

WithServer adds a single server configuration to the MCP host

func WithServers

func WithServers(servers map[string]*ServerConfig) McpHostOption

WithServers configures the MCP host with a set of server configurations

type ProxyElicitationHandler

type ProxyElicitationHandler struct {
	// contains filtered or unexported fields
}

ProxyElicitationHandler is a proxy handler that forwards elicitation requests to an MCP server.

func (*ProxyElicitationHandler) Elicit

Elicit sends the elicitation request to the MCP server and returns the result.

type ProxySamplingHandler

type ProxySamplingHandler struct {
	// contains filtered or unexported fields
}

ProxySamplingHandler is a proxy handler that forwards sampling requests to an MCP server.

func (*ProxySamplingHandler) CreateMessage

CreateMessage sends the sampling request to the MCP server and returns the result.

type ServerConfig

type ServerConfig struct {
	// Type specifies the type of MCP server (e.g., "stdio", "http")
	Type string `json:"type"`
	// Url is the HTTP url of the MCP server
	Url string `json:"url"`
	// Command is the executable path or command to run the MCP server
	Command string `json:"command"`
	// Args are optional command-line arguments for the server command
	Args []string `json:"args,omitempty"`
	// Env are optional environment variables for the server process
	Env []string `json:"env,omitempty"`
}

ServerConfig represents an individual server configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL