Skip to main content

Module protocol

Module protocol 

Source
Expand description

MCP protocol types — JSON-RPC 2.0 and Model Context Protocol messages.

This module is a functional core: pure data types with serde serialization. No IO, no side effects. All parsing and building happens through serde_json.

Structs§

InitializeResult
The result of initialize.
JsonRpcError
The error object inside a JSON-RPC error response.
JsonRpcErrorResponse
A JSON-RPC 2.0 error response.
JsonRpcRequest
A JSON-RPC 2.0 request (or notification when id is None).
JsonRpcResponse
A JSON-RPC 2.0 success response.
ServerCapabilities
Server capabilities advertised during initialization.
ServerInfo
Server info returned during initialization.
ToolCallParams
Parameters for tools/call.
ToolCallResult
The result of tools/call.
ToolDefinition
A tool definition returned by tools/list.
ToolListResult
The result of tools/list.
ToolResultContent
A single content item in a tool result.
ToolsCapability
Indicates the server supports tools.

Constants§

INTERNAL_ERROR
INVALID_PARAMS
INVALID_REQUEST
METHOD_NOT_FOUND
PARSE_ERROR

Functions§

build_initialize_result
Build the initialize result for this server.
error_response
Build a JSON-RPC error response.
error_response_with_data
Build a JSON-RPC error response with extra data.
parse_request
Parse a raw JSON string into a JsonRpcRequest.
success_response
Build a JSON-RPC success response.
tool_result_error
Build an error tool result.
tool_result_json
Build a JSON tool result (serializes value to pretty-printed text).
tool_result_text
Build a successful text tool result.