rust-mcp-playground
rust-mcp-playground is an environment designed for experimenting with machine learning and automation projects using the Rust programming language. Users can easily execute code and observe results, making it ideal for learning and experimentation. Notably, it leverages Rust's performance for high-speed processing.
GitHub Stars
0
User Rating
Not Rated
Favorites
0
Views
25
Forks
0
Issues
0
Rust MCP Playground
A complete working implementation of the Model Context Protocol (MCP) in Rust, featuring both client and server components with full tool integration.
๐ Quick Start
Run the interactive calculator chat client:
cd projects/client
cargo run
This will:
- Automatically start the calculator server
- Connect to Claude via Anthropic API
- Provide a chat interface for mathematical operations
Example usage:
You: add 15 to 27
๐ค Assistant: 15 + 27 = 42
You: what's the square root of 144?
๐ค Assistant: โ144 = 12
๐ Project Structure
rust-mcp-playground/
โโโ projects/ # ๐ฏ Main implementations
โ โโโ client/ # Chat client with Anthropic integration
โ โ โโโ .env # ANTHROPIC_API_KEY configuration
โ โ โโโ src/main.rs # Full MCP client implementation
โ โโโ servers/calculator/ # Calculator MCP server
โ โโโ src/main.rs # 6 mathematical tools
โโโ references/ # ๐ Official examples
โ โโโ rust-mcp-sdk-examples/ # Complete SDK reference implementations
โโโ CLAUDE.md # Development guidance
โจ Features
๐งฎ Calculator Server
- 6 Mathematical Tools: add, subtract, multiply, divide, square, sqrt
- Error Handling: Division by zero, negative square roots, invalid inputs
- Input Validation: NaN and infinity checks
- MCP Protocol: Latest rmcp 0.2.1 with
#[tool_router]macros - Comprehensive Testing: Unit tests for all operations
๐ฌ Chat Client
- Natural Language Interface: Ask questions in plain English
- Tool Discovery: Automatically finds and uses server capabilities
- Anthropic Integration: Uses Claude for intelligent responses
- STDIO Transport: Manages server process lifecycle
- Environment Configuration: API key from
.envfile
๐ ๏ธ Technical Implementation
Built with the official Rust MCP SDK:
rmcp0.2.1 - Latest MCP implementation- Protocol Version: 2024-11-05 (current MCP standard)
- Transport: STDIO (standard for MCP integrations)
- Tool Registration: Declarative macros for clean implementation
Architecture:
// Server tool registration
#[tool_router]
impl Calculator {
#[tool(description = "Add two numbers together")]
fn add(&self, Parameters(AddRequest { a, b }): Parameters<AddRequest>)
-> Result<CallToolResult, McpError> { /* ... */ }
}
// Client spawns server and discovers tools automatically
let transport = TokioChildProcess::new(command)?;
let client = ().serve(transport).await?;
let tools = client.list_all_tools().await?; // Discovers all 6 calculator tools
๐ Prerequisites
Rust (edition 2024)
Anthropic API Key - Add to
projects/client/.env:ANTHROPIC_API_KEY=your_key_here
๐งช Development
Run tests:
cd projects/servers/calculator
cargo test
Build components independently:
# Server only
cd projects/servers/calculator
cargo build
# Client only
cd projects/client
cargo build
Debug server separately:
cd projects/servers/calculator
cargo run # Waits for STDIO input
๐ Learning Resources
- Official MCP SDK: https://github.com/modelcontextprotocol/rust-sdk
- MCP Specification: https://modelcontextprotocol.io/
- Reference Examples: See
references/rust-mcp-sdk-examples/for comprehensive examples
๐ฏ What Makes This Special
This isn't just example code - it's a fully functional MCP system that demonstrates:
โ
Real-world MCP integration with working tool discovery and execution
โ
Production-ready patterns with proper error handling and validation
โ
Modern Rust MCP development using the latest SDK features
โ
Complete client-server architecture with automatic process management
โ
Natural language interface powered by Claude's intelligence
Perfect for learning MCP concepts, building new MCP tools, or integrating MCP into existing applications!
0
Followers
0
Repositories
0
Gists
0
Total Contributions
๐ Terraform Model Context Protocol (MCP) Tool - An experimental CLI tool that enables AI assistants to manage and operate Terraform environments. Supports reading Terraform configurations, analyzing plans, applying configurations, and managing state with Claude Desktop integration. โก๏ธ
echokit_server is a high-performance server software built in Rust, offering efficient data processing and API management. Designed for developers, it boasts high scalability and adaptability for various applications. It is particularly well-suited for real-time data processing and microservices architecture.