Module core

Source
Expand description

Core JSON-RPC 2.0 message structures for MCP communication.

This module provides the fundamental JSON-RPC message types that form the foundation of all MCP communication. These types strictly follow the JSON-RPC 2.0 specification with MCP-specific extensions.

§Message Types

  • Request: Client-to-server messages expecting a response
  • Response: Server-to-client messages in reply to requests
  • Notification: One-way messages that don’t expect responses
  • Error: Error responses for failed requests

§Examples

use mcp_probe_core::messages::core::{JsonRpcRequest, JsonRpcResponse, JsonRpcError};
use serde_json::json;

// Create a request
let request = JsonRpcRequest::new(
    "1".to_string(),
    "tools/list".to_string(),
    json!({}),
);

// Create a success response
let response = JsonRpcResponse::success("1".to_string(), json!({"tools": []}));

// Create an error response
let error_response = JsonRpcResponse::error(
    "1".to_string(),
    JsonRpcError::method_not_found("unknown_method"),
);

Structs§

JsonRpcError
JSON-RPC 2.0 error object.
JsonRpcNotification
JSON-RPC 2.0 notification message.
JsonRpcRequest
JSON-RPC 2.0 request message.
JsonRpcResponse
JSON-RPC 2.0 response message.

Enums§

JsonRpcMessage
Enum for any JSON-RPC message type.
RequestId
Request ID for JSON-RPC messages.

Type Aliases§

JsonRpcId
Type alias for request IDs to match client code expectations.