Cover image
Try Now
2025-03-18

Minimalistic Rust Implementation Of Model Context Protocol from Anthropic

3 years

Works with Finder

2

Github Watches

8

Github Forks

54

Github Stars

Model Context Protocol (MCP)

Minimalistic Rust Implementation Of Model Context Protocol(MCP).

Crates.io

Learn more about MCP: MCP

Minimalistic approach

Given it is still very early stage of MCP adoption, the goal is to remain agile and easy to understand. This implementation aims to capture the core idea of MCP while maintaining compatibility with Claude Desktop. Many optional features are not implemented yet.

Some guidelines:

  • use primitive building blocks and avoid framework if possible
  • keep it simple and stupid

Examples

Tools Example

Using a Tool trait for better compile time reusability.

impl Tool for CreateEntitiesTool {
    fn name(&self) -> String {
        "create_entities".to_string()
    }

    fn description(&self) -> String {
        "Create multiple new entities".to_string()
    }

    fn input_schema(&self) -> serde_json::Value {
        json!({
           "type":"object",
           "properties":{
              "entities":{
                 "type":"array",
                 "items":{
                    "type":"object",
                    "properties":{
                       "name":{"type":"string"},
                       "entityType":{"type":"string"},
                       "observations":{
                          "type":"array", "items":{"type":"string"}
                       }
                    },
                    "required":["name","entityType","observations"]
                 }
              }
           },
           "required":["entities"]
        })
    }

    fn call(&self, input: Option<serde_json::Value>) -> Result<CallToolResponse> {
        let args = input.unwrap_or_default();
        let entities = args
            .get("entities")
            .ok_or(anyhow::anyhow!("missing arguments `entities`"))?;
        let entities: Vec<Entity> = serde_json::from_value(entities.clone())?;
        let created = self.kg.lock().unwrap().create_entities(entities)?;
        self.kg
            .lock()
            .unwrap()
            .save_to_file(&self.memory_file_path)?;
        Ok(CallToolResponse {
            content: vec![ToolResponseContent::Text {
                text: json!(created).to_string(),
            }],
            is_error: None,
            meta: None,
        })
    }
}

Server Example

    let server = Server::builder(StdioTransport)
        .capabilities(ServerCapabilities {
            tools: Some(json!({})),
            ..Default::default()
        })
        .request_handler("tools/list", list_tools)
        .request_handler("tools/call", call_tool)
        .request_handler("resources/list", |_req: ListRequest| {
            Ok(ResourcesListResponse {
                resources: vec![],
                next_cursor: None,
                meta: None,
            })
        })
        .build();

Client Example

#[tokio::main]
async fn main() -> Result<()> {
    #[cfg(unix)]
    {
        // Create transport connected to cat command which will stay alive
        let transport = ClientStdioTransport::new("cat", &[])?;

        // Open transport
        transport.open()?;

        let client = ClientBuilder::new(transport).build();
        let client_clone = client.clone();
        tokio::spawn(async move { client_clone.start().await });
        let response = client
            .request(
                "echo",
                None,
                RequestOptions::default().timeout(Duration::from_secs(1)),
            )
            .await?;
        println!("{:?}", response);
    }
    #[cfg(windows)]
    {
        println!("Windows is not supported yet");
    }
    Ok(())
}

Other Sdks

Official

Community

For complete feature please refer to the MCP specification.

Features

Basic Protocol

  • Basic Message Types
  • Error and Signal Handling
  • Transport
    • Stdio
    • In Memory Channel (not yet supported in formal specification)
    • SSE
    • More compact serialization format (not yet supported in formal specification)
  • Utilities
    • Ping
    • Cancellation
    • Progress

Server

  • Tools
  • Prompts
  • Resources
    • Pagination
    • Completion

Client

For now use claude desktop as client.

Monitoring

  • Logging
  • Metrics

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Lists Tailwind CSS classes in monospaced font

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • apappascs
  • Discover the most comprehensive and up-to-date collection of MCP servers in the market. This repository serves as a centralized hub, offering an extensive catalog of open-source and proprietary MCP servers, complete with features, documentation links, and contributors.

  • ShrimpingIt
  • Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx

  • jae-jae
  • MCP server for fetch web page content using Playwright headless browser.

  • ravitemer
  • A powerful Neovim plugin for managing MCP (Model Context Protocol) servers

  • patruff
  • Bridge between Ollama and MCP servers, enabling local LLMs to use Model Context Protocol tools

  • pontusab
  • The Cursor & Windsurf community, find rules and MCPs

  • av
  • Effortlessly run LLM backends, APIs, frontends, and services with one command.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的LLM资料总结(Agent框架、辅助编程、数据处理、模型训练、模型推理、o1 模型、MCP、小语言模型、视觉语言模型) | Summary of the world's best LLM resources.

  • Mintplex-Labs
  • The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.

  • appcypher
  • Awesome MCP Servers - A curated list of Model Context Protocol servers

    Reviews

    5 (1)
    Avatar
    user_ZJF0GlBn
    2025-04-18

    I have been using the mcp-sdk by AntigmaLabs for a while now, and it has significantly streamlined my development process. The documentation is clear and the GitHub repository is well-maintained. If you're embarking on a project that requires reliable and efficient components, I highly recommend checking out the mcp-sdk. The community support is also robust, making it easier to troubleshoot and collaborate.