Crate turul_mcp_protocol

Crate turul_mcp_protocol 

Source
Expand description

§Model Context Protocol (MCP) - Current Version

The official Rust implementation of the Model Context Protocol specification.

This crate provides a stable API that aliases the current version of the MCP specification, ensuring your code stays up-to-date with the latest protocol version while maintaining compatibility. Currently implements MCP 2025-06-18 specification.

Crates.io Documentation License

§Installation

[dependencies]
turul-mcp-protocol = "0.2"

§Quick Start

use turul_mcp_protocol::prelude::*;

// Create tools, resources, prompts
let tool = Tool::new("calculator", ToolSchema::object());
let resource = Resource::new("file://data.json", "data");
let prompt = Prompt::new("code_review");

// Handle requests and responses
let request = InitializeRequest::new(
    McpVersion::CURRENT,
    ClientCapabilities::default(),
    Implementation::new("my-client", "1.0.0")
);

§Protocol Types

This crate provides all core MCP types:

  • Tools: Tool, CallToolRequest, CallToolResult
  • Resources: Resource, ReadResourceRequest, ResourceContent
  • Prompts: Prompt, GetPromptRequest, PromptMessage
  • Notifications: ProgressNotification, LoggingMessage
  • Protocol: InitializeRequest, McpVersion, ServerCapabilities
  • Errors: McpError, JsonRpcError, error codes

§Use Cases

  • MCP Server Development: Use with turul-mcp-server
  • MCP Client Development: Use with turul-mcp-client
  • Protocol Parsing: Direct protocol message handling
  • Type Definitions: Reference implementation for MCP types

§Version Mapping

This CrateMCP SpecImplementation Crate
0.2.x2025-06-18turul-mcp-protocol-2025-06-18

Currently aliases: turul-mcp-protocol-2025-06-18

Modules§

completion
MCP Completion Protocol Types
content
Content types for MCP 2025-06-18 specification
elicitation
MCP Elicitation Protocol Types
initialize
MCP Initialize Protocol Types
json_rpc
JSON-RPC 2.0 Implementation for MCP 2025-06-18
logging
MCP Logging Protocol Types
meta
_meta Field Support for MCP 2025-06-18
notifications
MCP Notifications Protocol Types
param_extraction
Parameter extraction utilities for MCP protocol
ping
MCP Ping Protocol Types
prelude
prompts
MCP Prompts Protocol Types
resources
MCP Resources Protocol Types
roots
MCP Roots Protocol Types
sampling
MCP Sampling Protocol Types
schema
JSON Schema Support for MCP
tools
MCP Tools Protocol Types
traits
Traits for JSON-RPC types as per MCP specification (2025-06-18)
version
MCP Protocol Version Support

Macros§

impl_serde_extractor
Macro to implement SerdeParamExtractor for any Params type that implements Deserialize

Structs§

Annotations
Generic annotations structure (matches TypeScript Annotations) Used across all MCP types that support client annotations
BlobResourceContents
Binary resource contents (matches TypeScript BlobResourceContents exactly)
CallToolRequest
Complete tools/call request (matches TypeScript CallToolRequest interface)
CallToolResult
Result for tools/call (per MCP spec)
CancelledNotification
Method: “notifications/cancelled”
ClientCapabilities
Capabilities that a client may support
ElicitCreateParams
Parameters for elicitation/create request (per MCP spec)
ElicitCreateRequest
Complete elicitation/create request (matches TypeScript ElicitRequest interface)
ElicitResult
The client’s response to an elicitation request (per MCP spec)
ElicitationBuilder
Builder for creating common elicitation patterns
ElicitationSchema
Restricted schema for elicitation (only primitive types, no nesting) - per MCP spec
EmptyParams
EmptyResult
Empty result for successful operations (per MCP spec)
GetPromptRequest
Complete prompts/get request (matches TypeScript GetPromptRequest interface)
GetPromptResult
Result for prompts/get (per MCP spec)
Implementation
Describes the name and version of an MCP implementation
InitializeRequest
Parameters for initialize request
InitializeResult
Result payload for initialize (per MCP spec)
InitializedNotification
Method: “notifications/initialized”
JsonRpcError
JSON-RPC 2.0 error object
JsonRpcNotification
A JSON-RPC 2.0 notification (no response expected)
JsonRpcRequest
A standard JSON-RPC 2.0 request
JsonRpcResponse
A standard JSON-RPC 2.0 response
ListPromptsRequest
Complete prompts/list request (matches TypeScript ListPromptsRequest interface)
ListPromptsResult
Result for prompts/list (per MCP spec)
ListResourcesRequest
Complete resources/list request (matches TypeScript ListResourcesRequest interface)
ListResourcesResult
Result for resources/list (per MCP spec)
ListToolsRequest
Complete tools/list request (matches TypeScript ListToolsRequest interface)
ListToolsResult
Result for tools/list (per MCP spec) - extends PaginatedResult
LoggingMessageNotification
Method: “notifications/message”
LoggingMessageNotificationParams
Meta
Structured _meta field for MCP 2025-06-18
MetaCursor
Cursor for pagination support
Notification
Base notification structure following MCP TypeScript specification
NotificationParams
Base notification parameters that can include _meta
PaginatedResponse
Helper for pagination responses
PingRequest
Request for ping (per MCP spec)
ProgressNotification
Method: “notifications/progress”
ProgressNotificationParams
ProgressResponse
Helper for progress responses
ProgressToken
Progress token for tracking long-running operations
Prompt
A prompt descriptor (matches TypeScript Prompt interface exactly)
PromptArgument
Argument definition for prompts (extends BaseMetadata per MCP spec)
PromptListChangedNotification
Method: “notifications/prompts/listChanged” (per MCP spec)
PromptMessage
Message content for prompts (matches MCP PromptMessage interface exactly)
ReadResourceRequest
Complete resources/read request (matches TypeScript ReadResourceRequest interface)
ReadResourceResult
Result for resources/read (per MCP spec)
RequestParams
JSON-RPC params object with optional _meta and method-specific arguments
Resource
A resource descriptor (matches TypeScript Resource interface) Resource extends BaseMetadata, so it includes name and title fields
ResourceListChangedNotification
Method: “notifications/resources/listChanged” (per MCP spec)
ResourceReference
Resource reference for resource links (matches TypeScript Resource interface)
ResourceSubscription
Resource subscription parameters
ResourceUpdatedNotification
Method: “notifications/resources/updated”
ResourceUpdatedNotificationParams
ResultWithMeta
A generic result wrapper that combines data with optional _meta information
RootsListChangedNotification
Method: “notifications/roots/listChanged” (per MCP spec)
ServerCapabilities
Capabilities that a server may support
SubscribeRequest
Complete resources/subscribe request (per MCP spec)
TextResourceContents
Text resource contents (matches TypeScript TextResourceContents exactly)
Tool
Tool definition
ToolListChangedNotification
Method: “notifications/tools/listChanged” (per MCP spec)
ToolSchema
JSON Schema definition for tool input/output (matches TypeScript spec exactly) Must be an object with type: “object”, properties, and required fields
UnsubscribeRequest
Complete resources/unsubscribe request (per MCP spec)

Enums§

ContentBlock
Content block union type matching MCP 2025-06-18 specification exactly
ElicitAction
User action in response to elicitation
JsonRpcMessage
Unified JSON-RPC message type
JsonSchema
A JSON Schema definition
LegacyRequestParams
Parameters for a JSON-RPC request
McpError
MCP-specific errors
McpVersion
Supported MCP protocol versions
PrimitiveSchemaDefinition
Restricted schema definitions that only allow primitive types without nested objects or arrays (per MCP spec).
RequestId
A uniquely identifying ID for a JSON-RPC request. Can be a string or a number, but never null.
ResourceContent
Union type for resource contents (matches TypeScript union)
ResourceContents
Resource contents union type (matches TypeScript TextResourceContents | BlobResourceContents)
ResponseResult
Result data for a JSON-RPC response
StringFormat
String format constraints

Constants§

CURRENT_VERSION
The current MCP protocol version implemented by this crate
MCP_VERSION
The MCP protocol version implemented by this crate

Traits§

HasData
HasDataParam
HasMeta
HasMetaParam
HasProgressTokenParam
JsonRpcNotificationTrait
JsonRpcRequestTrait
JsonRpcResponseTrait
Params
RpcResult
WithMeta
Trait for types that can include _meta fields

Type Aliases§

McpResult
Common result type for MCP operations
ToolResult
Tool result type - an alias for ContentBlock to maintain backward compatibility while ensuring MCP 2025-06-18 specification compliance