This crate implements the following specifications:
- Spec: https://www.jsonrpc.org/specification
- Used for: Transport protocol over stdio (newline-delimited)
- Error codes: -32700 (parse), -32600 (invalid request), -32601 (method not found), -32602 (invalid params), -32603 (internal error)
- The
jsonrpcfield is validated to be exactly"2.0"on every request
- Spec: https://spec.modelcontextprotocol.io/
- Protocol version: 2024-11-05
- Transport: stdio
- Capabilities: tools
initialize— handshake, returns server capabilities and tool listnotifications/initialized— client acknowledgment (no response)ping— keep-alive, returns{}tools/list— enumerate available toolstools/call— invoke a tool by name
Requests other than initialize are rejected with -32600 until the handshake completes.
- Spec:
context-specs/core/mcp/context.resolve.md - Backed by
context-corecrate - Input:
cache(string),query(string),budget(integer, minimum 0) - Output:
SelectionResultfrom context-core (documents + selection metadata) - Domain errors use
McpErrorResponsewithisError: truein the tool result - Error messages use canonical text only — no paths, stack traces, or OS errors (per error_schema.md)
- Spec:
context-specs/core/mcp/error_schema.md - Frozen schema:
error.code(enum string) +error.message(non-empty string) - MCP error codes map to JSON-RPC codes via
McpErrorCode::json_rpc_code() McpErrorResponseconverts to bothJsonRpcError(protocol layer) andToolResult(tool layer)
Incoming messages are rejected if they exceed 1 MiB (returns parse error).
Blocking operations (spawn_blocking) are wrapped in a configurable timeout (default 30s, CONTEXT_TOOL_TIMEOUT_SECS). Timeout returns internal_error.
Cache names are validated before filesystem access:
.., leading/, leading\are rejected before touching disk- Both candidate and root are canonicalized (resolves symlinks)
- Canonical path must remain inside the canonical cache root