Expand description
JSON-RPC 2.0 protocol types for the Model Context Protocol.
This module provides the foundational JSON-RPC 2.0 types used for all MCP communication. These types handle message framing, request/response correlation, and notification delivery.
§Protocol Overview
MCP uses JSON-RPC 2.0 as its transport protocol. All messages are one of:
- Request: A method call expecting a response
- Response: A reply to a request (success or error)
- Notification: A one-way message with no response
§Example
use mcpkit_core::protocol::{Request, Response, RequestId};
// Create a request
let request = Request::new("tools/list", RequestId::Number(1));
// Parse a response
let json = r#"{"jsonrpc": "2.0", "id": 1, "result": {}}"#;
let response: Response = serde_json::from_str(json).unwrap();Structs§
- Cursor
- A cursor for paginated results.
- Notification
- A JSON-RPC 2.0 notification message.
- Request
- A JSON-RPC 2.0 request message.
- Response
- A JSON-RPC 2.0 response message.
Enums§
- Message
- A JSON-RPC 2.0 message (request, response, or notification).
- Progress
Token - A progress token for tracking long-running operations.
- Request
Id - A JSON-RPC request ID.
Constants§
- JSONRPC_
VERSION - The JSON-RPC version string. Always “2.0”.