Documentation
¶
Overview ¶
Package mcp bridges Model Context Protocol clients to tool definitions (S13). Transport abstracts JSON-RPC over stdio, SSE, or other backends. Client initializes the MCP connection, lists tools, and invokes them. Bridge maps server tools to pkg/tools.Tool with the validated M48 schema subset and an execution wrapper.
Public MCP names match mcp-client/tools: stable identity is (server, raw) and the model-facing name is mcp__<server>__<raw>. Sanitization or truncation to the 64-character [A-Za-z0-9_-] limit appends an identity hash to prevent collisions.
Index ¶
Constants ¶
const MaxPublicNameLength = 64
MaxPublicNameLength limits function-name length.
Variables ¶
This section is empty.
Functions ¶
func MapSchema ¶
func MapSchema(m map[string]any) (*tools.JsonSchemaNode, error)
MapSchema converts JSON Schema maps to the validated M48 JsonSchemaNode subset. Only type, properties, required, items, enum, description, const, and default are mapped. Unsupported keywords such as anyOf fail closed.
func PublicToolName ¶
PublicToolName deterministically derives a public name from server and raw names.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge maps MCP server tools to pkg/tools.Tool.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client initializes MCP, lists tools, and invokes tools.
func (*Client) Initialize ¶
Initialize performs the MCP initialization handshake.
type MCPSchema ¶
type MCPSchema struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema map[string]any `json:"inputSchema"` // JSON Schema in object form.
}
MCPSchema describes a tool exposed by an MCP server.
type Request ¶
type Request struct {
ID uint64 `json:"id"`
Method string `json:"method"`
Params map[string]any `json:"params,omitempty"`
}
Request is a JSON-RPC request.
type Response ¶
type Response struct {
ID uint64 `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error json.RawMessage `json:"error,omitempty"`
}
Response is a JSON-RPC response preserving the raw result.