Documentation
¶
Overview ¶
Package mcp implements a client for the Model Context Protocol. It supports connecting to MCP servers via stdio (subprocess) transport, discovering tools, and invoking them on behalf of the primary model.
Index ¶
- type MCPClient
- func (c *MCPClient) CallTool(_ context.Context, serverName, toolName string, args json.RawMessage) (string, error)
- func (c *MCPClient) Close() error
- func (c *MCPClient) Connect(ctx context.Context) error
- func (c *MCPClient) ToToolDefinitions() []provider.ToolDefinition
- func (c *MCPClient) Tools() []MCPTool
- type MCPTool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MCPClient ¶
type MCPClient struct {
// contains filtered or unexported fields
}
MCPClient manages connections to one or more MCP servers.
func NewMCPClient ¶
func NewMCPClient(configs []config.MCPServerConfig) *MCPClient
NewMCPClient creates a new MCP client from the given server configurations. No connections are made until Connect is called.
func (*MCPClient) CallTool ¶
func (c *MCPClient) CallTool(_ context.Context, serverName, toolName string, args json.RawMessage) (string, error)
CallTool invokes a tool on the specified MCP server and returns the text result.
func (*MCPClient) ToToolDefinitions ¶
func (c *MCPClient) ToToolDefinitions() []provider.ToolDefinition
ToToolDefinitions converts discovered MCP tools to provider.ToolDefinition format so they can be sent to the primary model alongside built-in tools. Tool names are prefixed with "mcp_{serverName}_" to avoid collisions.