Documentation
¶
Overview ¶
Package mcp implements a minimal MCP (Model Context Protocol) client. It supports stdio transport only — the most common MCP deployment pattern. Only the tools capability is implemented: tools/list and tools/call.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a synchronous JSON-RPC 2.0 connection over a stdio transport. It is NOT safe for concurrent use — Errata calls tools sequentially.
func NewConn ¶
NewConn wraps the given reader/writer as a JSON-RPC 2.0 connection. The caller is responsible for providing the subprocess stdin (w) and stdout (r) from exec.Cmd.
func (*Conn) Call ¶
Call sends a request with the given method and params, reads the response, and unmarshals result into out (if non-nil).
func (*Conn) CallTool ¶
CallTool calls tools/call with the given tool name and arguments. Returns the concatenated text from all content items.
type Dispatcher ¶
type Dispatcher = tools.MCPDispatcher
Dispatcher is an alias for tools.MCPDispatcher — a function that executes an MCP tool call.
type MCPTool ¶
type MCPTool struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]any `json:"inputSchema"`
}
MCPTool is one entry from a tools/list response.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns all running MCP server subprocesses.
func StartServers ¶
func StartServers(configs []ServerConfig, env []string) ( extra []tools.ToolDef, dispatchers map[string]Dispatcher, warnings []string, mgr *Manager, )
StartServers launches the given MCP servers, performs the MCP handshake, and discovers their tools. Returns:
- extra []tools.ToolDef: tool definitions to append to Errata's active set
- dispatchers map[toolName]Dispatcher: call-time dispatch table
- warnings []string: human-readable messages for servers that failed to start
On per-server failure a warning is appended and that server is skipped; the function never returns a fatal error so Errata can start without MCP.
type ServerConfig ¶
type ServerConfig struct {
// Name is a human-readable label used in logging.
Name string
// Args is the command and its arguments to launch the server subprocess.
// e.g. ["npx", "@exa-ai/exa-mcp-server"]
Args []string
}
ServerConfig holds the configuration for a single MCP server.
func ParseServerConfigs ¶
func ParseServerConfigs(raw string) []ServerConfig
ParseServerConfigs parses the ERRATA_MCP_SERVERS env-var format:
name1:cmd1 arg1 arg2,name2:cmd2
Each entry is "name:command args..." separated by commas. Returns an empty slice for an empty input string.