Documentation
¶
Overview ¶
Package mcp provides MCP client for external context sources.
Index ¶
- type Client
- func (c *Client) Call(ctx context.Context, method string, params any, result any) error
- func (c *Client) CallTool(ctx context.Context, name string, args map[string]any) ([]ToolContent, error)
- func (c *Client) Close() error
- func (c *Client) Initialize(ctx context.Context) error
- func (c *Client) ListTools(ctx context.Context) ([]Tool, error)
- func (c *Client) Notify(method string, params any) error
- type RPCError
- type Request
- type Response
- type Source
- type Tool
- type ToolContent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages communication with an MCP server.
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, args map[string]any) ([]ToolContent, error)
CallTool invokes a tool on the MCP server.
func (*Client) Initialize ¶
Initialize sends the initialize request to the MCP server.
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
RPCError represents a JSON-RPC error.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id"`
Method string `json:"method"`
Params any `json:"params,omitempty"`
}
Request represents a JSON-RPC request.
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
}
Response represents a JSON-RPC response.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source fetches context from an MCP server.
func NewSource ¶
func NewSource(name string, cfg ctx.MCPServerConfig) (*Source, error)
NewSource creates a new MCP source from configuration.
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema json.RawMessage `json:"inputSchema"`
}
Tool represents an MCP tool.
type ToolContent ¶
ToolContent represents content returned by a tool.
Click to show internal directories.
Click to hide internal directories.