Skip to main content

Module protocol

Module protocol 

Source
Available on crate feature mcp only.
Expand description

JSON-RPC 2.0 + MCP protocol types (issue #420).

A minimal, hand-rolled subset of the Model Context Protocol — enough to serve initialize, tools/list, tools/call, resources/list, resources/read, and ping over any byte transport. Kept dependency-free (just serde_json) so the mcp feature adds no new crate tree.

Structs§

JsonRpcRequest
An incoming JSON-RPC request or notification.
ToolDef
A tool definition advertised via tools/list.

Constants§

INTERNAL_ERROR
INVALID_PARAMS
INVALID_REQUEST
METHOD_NOT_FOUND
PARSE_ERROR
JSON-RPC 2.0 standard error codes.
PROTOCOL_VERSION
MCP protocol version this server implements/advertises.

Functions§

error
Build an error response envelope for id.
error_no_id
An error whose id is unknown (e.g. an unparseable request): JSON-RPC requires id: null in that case.
success
Build a success response envelope for id with result.
tool_error
Wrap a tool error in the MCP tools/call content shape (isError: true).
tool_text
Wrap a tool’s textual result in the MCP tools/call content shape.