Crate turul_http_mcp_server

Crate turul_http_mcp_server 

Source
Expand description

§HTTP MCP Server

This crate provides HTTP transport for Model Context Protocol (MCP) servers. It supports both modern Streamable HTTP (2025-03-26+) and legacy HTTP+SSE transports for maximum compatibility with all MCP clients.

§Supported Transports

  • Streamable HTTP (2025-03-26+): Recommended for production deployments
  • HTTP+SSE (2024-11-05): Legacy transport for backwards compatibility

§Features

  • Automatic protocol version detection and routing
  • CORS support for browser-based clients
  • Session management with cryptographically secure IDs
  • Graceful error handling and JSON-RPC 2.0 compliance

Re-exports§

pub use cors::CorsLayer;
pub use handler::McpHttpHandler;
pub use notification_bridge::BroadcastError;
pub use notification_bridge::NotificationBroadcaster;
pub use notification_bridge::SharedNotificationBroadcaster;
pub use notification_bridge::StreamManagerNotificationBroadcaster;
pub use protocol::extract_last_event_id;
pub use protocol::extract_protocol_version;
pub use protocol::extract_session_id;
pub use protocol::McpProtocolVersion;
pub use server::HttpMcpServer;
pub use server::HttpMcpServerBuilder;
pub use server::ServerConfig;
pub use server::ServerStats;
pub use session_handler::SessionMcpHandler;
pub use session_handler::SessionSseStream;
pub use stream_manager::StreamConfig;
pub use stream_manager::StreamError;
pub use stream_manager::StreamManager;
pub use stream_manager::StreamStats;
pub use streamable_http::StreamableHttpContext;
pub use streamable_http::StreamableHttpHandler;

Modules§

completion
MCP Completion Protocol Types
cors
CORS (Cross-Origin Resource Sharing) support
elicitation
MCP Elicitation Protocol Types
handler
HTTP request handler for MCP protocol
initialize
MCP Initialize Protocol Types
json_rpc
JSON-RPC 2.0 Implementation for MCP 2025-06-18
json_rpc_responses
JSON-RPC 2.0 response builders for HTTP transport
logging
MCP Logging Protocol Types
mcp_session
Streamable HTTP session management for MCP transport
meta
_meta Field Support for MCP 2025-06-18
notification_bridge
Notification Bridge - Connects NotificationBroadcaster to StreamManager
notifications
MCP Notifications Protocol Types
param_extraction
Parameter extraction utilities for MCP protocol
ping
MCP Ping Protocol Types
prompts
MCP Prompts Protocol Types
protocol
MCP Protocol Version Detection and Features
resources
MCP Resources Protocol Types
roots
MCP Roots Protocol Types
sampling
MCP Sampling Protocol Types
schema
JSON Schema Support for MCP
server
HTTP MCP Server with SessionStorage integration
session_handler
JSON-RPC 2.0 over HTTP handler for MCP requests with SessionStorage integration
sse
Server-Sent Events (SSE) support for MCP
stream_manager
Enhanced Stream Manager with MCP 2025-06-18 Resumability
streamable_http
Streamable HTTP Transport for MCP 2025-06-18
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§

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”
JsonRpcDispatcher
JSON-RPC method dispatcher
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/list_changed” (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/list_changed” (per MCP spec)
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/list_changed” (per MCP spec)
ServerCapabilities
Capabilities that a server may support
SubscribeRequest
Complete resources/subscribe request (per MCP spec)
Tool
Tool definition
ToolListChangedNotification
Method: “notifications/tools/list_changed” (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§

ElicitAction
User action in response to elicitation
HttpMcpError
HTTP MCP specific errors
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)
ResponseResult
Result data for a JSON-RPC response
StringFormat
String format constraints
ToolResult
Content item types that tools can return

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
JsonRpcHandler
Trait for handling JSON-RPC method calls
JsonRpcNotificationTrait
JsonRpcRequestTrait
JsonRpcResponseTrait
Params
RpcResult
WithMeta
Trait for types that can include _meta fields

Type Aliases§

McpResult
Common result type for MCP operations
Result
Result type for HTTP MCP operations