Docs.rs
  • mcp-protocol-sdk-0.5.1
    • mcp-protocol-sdk 0.5.1
    • Permalink
    • Docs.rs crate page
    • MIT
    • Links
    • Homepage
    • Repository
    • crates.io
    • Source
    • Owners
    • Rishirandhawa
    • Dependencies
      • async-trait ^0.1.83 normal
      • axum ^0.8 normal optional
      • chrono ^0.4 normal optional
      • fastrand ^2.0 normal optional
      • futures ^0.3 normal optional
      • futures-util ^0.3 normal optional
      • jsonschema ^0.32 normal optional
      • reqwest ^0.12 normal optional
      • serde ^1.0 normal
      • serde_json ^1.0 normal
      • thiserror ^2.0 normal
      • tokio ^1.40 normal
      • tokio-stream ^0.1 normal optional
      • tokio-tungstenite ^0.27 normal optional
      • tower ^0.5 normal optional
      • tower-http ^0.6 normal optional
      • tracing ^0.1 normal
      • tracing-subscriber ^0.3 normal optional
      • url ^2.5 normal
      • uuid ^1.11 normal
      • chrono ^0.4 dev
      • criterion ^0.7 dev
      • futures ^0.3 dev
      • pretty_assertions ^1.4 dev
      • tempfile ^3.8 dev
      • tokio-test ^0.4 dev
    • Versions
    • 76.9% of the crate is documented
  • Platform
    • i686-unknown-linux-gnu
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Badges
    • Builds
    • Metadata
    • Shorthand URLs
    • Download
    • Rustdoc JSON
    • Build queue
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate mcp_protocol_sdk

mcp_protocol_sdk0.5.1

  • All Items

Sections

  • MCP Rust SDK (2025-06-18)
    • Features
    • Quick Start
    • Module Organization

Crate Items

  • Re-exports
  • Modules
  • Macros

Crates

  • mcp_protocol_sdk

Crate mcp_protocol_sdk

Source
Expand description

§MCP Rust SDK (2025-06-18)

A comprehensive Rust SDK for the Model Context Protocol (MCP) version 2025-06-18, providing both server and client implementations with full MCP specification compliance including audio content, annotations, and enhanced capabilities.

§Features

  • 🚀 High Performance: Built with Rust’s zero-cost abstractions and async/await
  • 🛡️ Type Safety: Leverages Rust’s type system to prevent runtime errors
  • 🔌 Multiple Transports: Support for STDIO, HTTP/SSE, and WebSocket transports
  • 🎯 Full MCP 2025-06-18 Compliance: Complete implementation of the latest MCP specification
  • 📚 Rich Ecosystem: Tools, resources, prompts, and sampling support
  • 🎵 Audio Support: NEW in 2025-06-18 - Audio content support for multimodal interactions
  • 🏷️ Annotations: NEW in 2025-06-18 - Tool and content annotations for enhanced metadata
  • 🔧 Autocompletion: NEW in 2025-06-18 - Argument autocompletion capabilities
  • 📁 Roots Support: NEW in 2025-06-18 - File system roots for enhanced resource access

§Quick Start

§Server Example

use mcp_protocol_sdk::{
    server::McpServer,
    core::{tool::ToolHandler, error::McpResult},
    protocol::types::{Content, CallToolResult},
};
use async_trait::async_trait;
use std::collections::HashMap;
use serde_json::Value;

struct EchoHandler;

#[async_trait]
impl ToolHandler for EchoHandler {
    async fn call(&self, arguments: HashMap<String, Value>) -> McpResult<CallToolResult> {
        let message = arguments.get("message")
            .and_then(|v| v.as_str())
            .unwrap_or("Hello, World!");
         
        Ok(CallToolResult {
            content: vec![Content::text(message)],
            is_error: Some(false),
            structured_content: None,
            meta: None,
        })
    }
}

#[tokio::main]
async fn main() -> McpResult<()> {
    let mut server = McpServer::new("echo-server".to_string(), "1.0.0".to_string());
     
    server.add_tool(
        "echo".to_string(),
        Some("Echo a message".to_string()),
        serde_json::json!({
            "type": "object",
            "properties": {
                "message": { "type": "string" }
            }
        }),
        EchoHandler,
    ).await?;
     
    Ok(())
}

§Module Organization

  • core: Core abstractions for resources, tools, prompts, and errors
  • protocol: MCP protocol types and message definitions (2025-06-18)
  • transport: Transport layer implementations (STDIO, HTTP, WebSocket)
  • server: MCP server implementation and lifecycle management
  • client: MCP client implementation and session management
  • utils: Utility functions and helpers

Re-exports§

pub use core::error::McpError;
pub use core::error::McpResult;
pub use protocol::types::*;

Modules§

client
MCP client implementation
core
Core abstractions and types for the MCP SDK
prelude
Prelude module for convenient imports (2025-06-18)
protocol
MCP protocol implementation (2025-06-18)
server
MCP server implementation
transport
Transport layer implementations
utils
Utility functions and helpers for the MCP Rust SDK

Macros§

param_schema
Macro for creating parameter validation schemas
tool
Helper macro for creating tools with schema validation
validated_tool
Create a validated tool with typed parameters

Results

Settings
Help
    module
    mcp_protocol_sdk::protocol
    MCP protocol implementation (2025-06-18)
    method
    mcp_protocol_sdk::core::error::McpError::protocol
    Create a new protocol error
    enum variant
    mcp_protocol_sdk::core::error::McpError::Protocol
    Protocol-level errors (invalid messages, unexpected …
    method
    mcp_protocol_sdk::core::error::McpError::protocol_error
    Create a protocol error (compatibility method)
    struct field
    mcp_protocol_sdk::transport::traits::TransportStats::protocol_errors
    Number of protocol errors
    struct field
    mcp_protocol_sdk::protocol::messages::InitializeParams::protocol_version
    Protocol version client supports
    struct field
    mcp_protocol_sdk::protocol::messages::InitializeResult::protocol_version
    Protocol version server supports
    constant
    mcp_protocol_sdk::protocol::types::PROTOCOL_VERSION
    extern crate
    mcp_protocol_sdk
    MCP Rust SDK (2025-06-18)
    constant
    mcp_protocol_sdk::protocol::MCP_PROTOCOL_VERSION
    constant
    mcp_protocol_sdk::protocol::types::LATEST_PROTOCOL_VERSION
    MCP Protocol version (2025-06-18)
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.