Documentation
¶
Overview ¶
Package mcp is a small Model Context Protocol client. It attaches to an MCP server, lists the tools that server offers, and calls them, so tomo can pick up typed tools from the wider ecosystem without wiring each one by hand. The protocol is JSON-RPC 2.0. The client speaks over a transport: stdio.go frames each message as one line of JSON over a subprocess pipe, and http.go POSTs each message to a URL. The Client itself is transport-agnostic.
Index ¶
- type Client
- func (c *Client) CallTool(ctx context.Context, name string, args json.RawMessage) (string, 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) Tools(ctx context.Context, class tool.Class) ([]tool.Tool, error)
- type Server
- type ToolInfo
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 is one live connection to an MCP server.
func StartHTTP ¶
StartHTTP attaches to an MCP server reachable over HTTP. name prefixes its tools; an empty name falls back to the URL host. headers are sent on every request, so an auth token can travel with them. No connection is opened until the first call; run Initialize before listing tools.
func StartStdio ¶
func StartStdio(ctx context.Context, name, command string, args []string, env map[string]string) (*Client, error)
StartStdio launches an MCP server as a subprocess and returns a client that speaks over its stdin and stdout. The server's stderr is forwarded to tomo's, so its own logging stays visible.
func (*Client) CallTool ¶
CallTool invokes a tool by its server-side name and returns the text of its result. A tool that reports an error returns that text as the error.
func (*Client) Initialize ¶
Initialize performs the MCP handshake: an initialize request followed by the initialized notification. It must run before any tool call.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the other side of the wire: it exposes a set of tomo tools over MCP so any client, Claude Code among them, can call them. It speaks JSON-RPC 2.0 over one stream, framing each message as a line of JSON, and handles one request at a time.