#communication #mcp #machine #server #protocols #api-bindings

tiny_mcp_server

A server implementation for the Machine Communication Protocol (MCP)

5 releases

Uses new Rust 2024

new 0.1.5 Mar 13, 2025
0.1.3 Mar 13, 2025
0.1.2 Mar 13, 2025
0.1.1 Mar 13, 2025
0.1.0 Mar 13, 2025

#1262 in Network programming

Download history

56 downloads per month

MIT/Apache

48KB
603 lines

MCP Server

Crates.io Documentation License: MIT OR Apache-2.0

A Rust implementation of the Machine Communication Protocol (MCP) server, designed for efficient and reliable communication between machines and tools.

Features

  • Multiple Transport Layers: Supports both stdio and Server-Sent Events (SSE) transports
  • Extensible Tool System: Easily register custom tools with the server
  • Type-Safe API: Leverages Rust's type system for safe and reliable communication
  • Asynchronous Design: Built on tokio for high-performance async I/O
  • Progress Reporting: Built-in support for streaming progress updates

Installation

Add this to your Cargo.toml:

[dependencies]
tiny_mcp_server = "0.1.0"

Quick Start

use serde_json::{Value, json};
use std::error::Error;
use tiny_mcp_server::*;

#[mcp_tool(
    description = "Greeting from tiny_mcp_server",
    version = "1.0.0",
    category = "testing"
)]
pub async fn say_hello(name: String) -> MCPResult<Value> {
    Ok(json!({
        "greeting": format!("Hello {name}")
    }))
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    server::start_stdio().await
}

The tiny_mcp_server crate re-exports all necessary dependencies, so you don't need to manually add tiny_mcp_macro, tiny_mcp_types, tiny_mcp_registry, inventory, or async-trait to your project.

Documentation

For more detailed documentation, see the API documentation.

Examples

Check out the examples directory for more usage examples:

  • stdio.rs: Example using stdio transport
  • sse.rs: Example using SSE transport
  • common/mod.rs: Various tool implementations demonstrating different features

License

This project is licensed under either of:

at your option.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Dependencies

~12–20MB
~278K SLoC