Documentation
¶
Index ¶
- type CallToolResult
- type Client
- func (c *Client) Call(ctx context.Context, method string, params interface{}) (json.RawMessage, error)
- func (c *Client) CallTool(ctx context.Context, name string, args json.RawMessage) (CallToolResult, error)
- func (c *Client) Close() error
- func (c *Client) Initialize(ctx context.Context) error
- func (c *Client) ListTools(ctx context.Context) ([]ToolInfo, error)
- func (c *Client) Notify(method string, params interface{}) error
- func (c *Client) Start() error
- type JSONRPCError
- type JSONRPCRequest
- type JSONRPCResponse
- type MCPTool
- type Manager
- type ToolContent
- type ToolInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallToolResult ¶
type CallToolResult struct {
Content []ToolContent `json:"content"`
IsError bool `json:"isError"`
}
CallToolResult holds the result of a tools/call request.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages an MCP server process communicating via stdio JSON-RPC.
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, method string, params interface{}) (json.RawMessage, error)
Call sends a JSON-RPC request and awaits the response.
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, args json.RawMessage) (CallToolResult, error)
CallTool executes a specific tool on the MCP server.
func (*Client) Initialize ¶
Initialize performs the MCP protocol handshake.
type JSONRPCError ¶
type JSONRPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data,omitempty"`
}
JSONRPCError holds JSON-RPC error payload.
func (*JSONRPCError) Error ¶
func (e *JSONRPCError) Error() string
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID *uint64 `json:"id,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
JSONRPCRequest represents a standard JSON-RPC 2.0 request.
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID *uint64 `json:"id,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error *JSONRPCError `json:"error,omitempty"`
}
JSONRPCResponse represents a standard JSON-RPC 2.0 response.
type MCPTool ¶
type MCPTool struct {
// contains filtered or unexported fields
}
MCPTool adapts an MCP tool to the tools.Tool interface.
func NewMCPTool ¶
NewMCPTool creates a tools.Tool adapter for an MCP tool.
func (*MCPTool) RequiresApproval ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager coordinates all configured MCP clients.
func NewManager ¶
func NewManager(servers map[string]config.MCPServerConfig) *Manager
NewManager creates a new MCP Manager with server configurations.
func (*Manager) AddServer ¶
func (m *Manager) AddServer(name string, cfg config.MCPServerConfig)
AddServer saves a new server configuration.
func (*Manager) CloseAll ¶
func (m *Manager) CloseAll()
CloseAll closes all active MCP client connections.
func (*Manager) ListServers ¶
func (m *Manager) ListServers() map[string]config.MCPServerConfig
ListServers returns all configured server names and configs.
func (*Manager) RemoveServer ¶
RemoveServer removes a server configuration.
type ToolContent ¶
ToolContent is a piece of output returned from an MCP tool call.