Documentation
¶
Overview ¶
Package mcp provides Model Context Protocol client connections and tool registration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractServer ¶
ExtractServer parses an MCP tool name (mcp__server__tool) and returns the server name and short tool name. Returns ok=false for non-MCP names.
Types ¶
type Result ¶
type Result struct {
Name string // Server name
Session *Session // non-nil on success
Error error // non-nil on failure
}
Result holds the outcome of connecting to a single MCP server.
func ConnectAll ¶
func ConnectAll(ctx context.Context, servers map[string]Server, progress func(name string)) []Result
ConnectAll connects to multiple MCP servers in parallel. progress is called (if non-nil) when each server connection starts. Returns a result for every server (both successes and failures).
func (Result) StatusDisplay ¶
StatusDisplay returns a formatted connection status string.
type Server ¶
type Server struct {
Disabled bool `yaml:"disabled"` // true = skip connection (default false = enabled)
Deferred bool `yaml:"deferred"` // true = all tools from this server are deferred
Type string `yaml:"type" validate:"omitempty,oneof=http stdio"` // "http" or "stdio"
URL string `yaml:"url"` // For HTTP transport
Command string `yaml:"command"` // For STDIO transport
Args []string `yaml:"args"` // For STDIO transport
Env env.Env `yaml:"env"` // Environment variables
Headers map[string]string `yaml:"headers"` // For HTTP transport
Timeout time.Duration `yaml:"timeout"` // Connection timeout
Condition string `yaml:"condition"` // condition expression for conditional inclusion
Source string `yaml:"-"` // file path this server was loaded from
}
Server represents an MCP server configuration.
func (Server) Display ¶
Display returns a human-readable summary of the server's connection target. For HTTP: the URL. For STDIO: command + args.
func (Server) EffectiveType ¶
EffectiveType returns the transport type, defaulting to "stdio".
type Session ¶
type Session struct {
Name string // Server name for tool prefixing
Client client.MCPClient // Active MCP client
MCPTools []mcplib.Tool // Discovered MCP tools
}
Session represents a connected MCP server session.
func NewSession ¶
NewSession connects to a server and discovers its tools.
type Tool ¶
Tool wraps an MCP tool to implement the tool.Tool interface.
func (*Tool) Description ¶
Description returns the MCP tool's description.
func (*Tool) Sandboxable ¶
Sandboxable returns false because MCP tools execute on remote servers.