types
MCP Protocol Types
Section titled “MCP Protocol Types”JSON-RPC 2.0 and MCP specification compliant data structures
- Fully compatible with FastMCP and other MCP implementations
- Standard OAuth 2.1 Bearer token authentication support
- Comprehensive tool, memory, and capability definitions
Structs
Section titled “Structs”JsonRpcRequest
Section titled “JsonRpcRequest”JSON-RPC 2.0 Request - Standard wire format for MCP
Fields
| Field | Type | Description |
|---|---|---|
jsonrpc | String | JSON-RPC version (always “2.0”) |
id | Option<serde_json::Value> | Request ID (optional for notifications) |
method | String | Method name (e.g., “tools/list”, “tools/call”) |
params | Option<serde_json::Value> | Method parameters (optional) |
Methods
fn new(method: &str, params: Option<serde_json::Value>, id: Option<serde_json::Value>) -> SelfCreate new JSON-RPC request
notification
Section titled “notification”fn notification(method: &str, params: Option<serde_json::Value>) -> SelfCreate notification (no response expected)
with_id
Section titled “with_id”fn with_id(method: &str, params: Option<serde_json::Value>, id: &str) -> SelfCreate request with string ID
JsonRpcResponse
Section titled “JsonRpcResponse”JSON-RPC 2.0 Response - Standard response format
Fields
| Field | Type | Description |
|---|---|---|
jsonrpc | String | JSON-RPC version (always “2.0”) |
id | Option<serde_json::Value> | Response ID (matches request ID) |
result | Option<serde_json::Value> | Success result (mutually exclusive with error) |
error | Option<JsonRpcError> | Error information (mutually exclusive with result) |
Methods
success
Section titled “success”fn success(id: Option<serde_json::Value>, result: serde_json::Value) -> SelfCreate success response
fn error(id: Option<serde_json::Value>, error: JsonRpcError) -> SelfCreate error response
JsonRpcError
Section titled “JsonRpcError”JSON-RPC 2.0 Error - Standard error format
Fields
| Field | Type | Description |
|---|---|---|
code | i32 | Error code (standard JSON-RPC error codes) |
message | String | Error message |
data | Option<serde_json::Value> | Additional error data (optional) |
Methods
method_not_found
Section titled “method_not_found”fn method_not_found(message: &str) -> SelfMethod not found (-32601)
invalid_params
Section titled “invalid_params”fn invalid_params(message: &str) -> SelfInvalid params (-32602)
internal_error
Section titled “internal_error”fn internal_error(message: &str) -> SelfInternal error (-32603)
InitializeRequest
Section titled “InitializeRequest”Initialize Request - MCP handshake
Fields
| Field | Type | Description |
|---|---|---|
protocol_version | String | Protocol version requested by client |
capabilities | ClientCapabilities | Client capabilities |
client_info | ClientInfo | Client information |
InitializeResult
Section titled “InitializeResult”Initialize Result - MCP handshake response
Fields
| Field | Type | Description |
|---|---|---|
protocol_version | String | Protocol version supported by server |
capabilities | ServerCapabilities | Server capabilities |
server_info | ServerInfo | Server information |
ClientInfo
Section titled “ClientInfo”Client Information
Fields
| Field | Type | Description |
|---|---|---|
name | String | Client name |
version | String | Client version |
description | Option<String> | Client description (optional) |
ServerInfo
Section titled “ServerInfo”Server Information
Fields
| Field | Type | Description |
|---|---|---|
name | String | Server name |
version | String | Server version |
description | Option<String> | Server description (optional) |
ClientCapabilities
Section titled “ClientCapabilities”Client Capabilities
Fields
| Field | Type | Description |
|---|---|---|
tools | Option<ToolCapabilities> | Tool execution support |
ServerCapabilities
Section titled “ServerCapabilities”Server Capabilities
Fields
| Field | Type | Description |
|---|---|---|
tools | Option<ToolCapabilities> | Tool execution support |
ToolCapabilities
Section titled “ToolCapabilities”Tool Capabilities
Fields
| Field | Type | Description |
|---|---|---|
supported | bool | Tool listing support |
ListToolsResult
Section titled “ListToolsResult”List Tools Result
Fields
| Field | Type | Description |
|---|---|---|
tools | Vec<Tool> | Available tools |
Tool Definition
Fields
| Field | Type | Description |
|---|---|---|
name | String | Tool name |
description | String | Tool description |
input_schema | serde_json::Value | JSON Schema for tool parameters |
Methods
simple
Section titled “simple”fn simple(name: &str, description: &str, parameters: &[&str]) -> SelfCreate simple tool with string parameters
CallToolRequest
Section titled “CallToolRequest”Call Tool Request
Fields
| Field | Type | Description |
|---|---|---|
name | String | Tool name to execute |
arguments | Option<serde_json::Value> | Tool arguments |
meta | Option<serde_json::Value> | Optional MCP request metadata. |
CallToolResult
Section titled “CallToolResult”Call Tool Result
Fields
| Field | Type | Description |
|---|---|---|
content | Vec<Content> | Tool execution result content |
is_error | Option<bool> | Whether execution resulted in error |
BearerToken
Section titled “BearerToken”Bearer Token Authentication
Fields
| Field | Type | Description |
|---|---|---|
access_token | String | OAuth 2.1 access token |
token_type | String | Token type (always “Bearer”) |
Methods
fn new(access_token: &str) -> SelfCreate new bearer token
to_authorization_header
Section titled “to_authorization_header”fn to_authorization_header(&self) -> StringFormat as Authorization header value
Content
Section titled “Content”Content - Multi-modal content representation
Variants
| Variant | Description |
|---|---|
Text { ... } |
Methods
fn text(text: &str) -> SelfCreate text content