Rust MCP framework for building AI agents. Connect agents to any MCP server (Playwright, filesystem, databases) with support for Claude and OpenAI. Multi-server support, HTTP and stdio transports.
A Rust framework for building AI agents that can use any MCP server. Includes:
- Agent framework with LLM integration (Claude, OpenAI)
- MCP client with multi-transport support (HTTP, stdio)
- MCP server implementation
- Web-based inspector for testing
| Feature | Status |
|---|---|
| MCP Server | Done |
| MCP Client | Done |
| AI Agent | Done |
| Web Inspector | Done |
| Claude Integration | Done |
| OpenAI Integration | Done |
| Browser Automation | Done |
| Session Management | Done |
| Resources | Planned |
| Prompts | Planned |
| Authentication | Planned |
• echo - String echo utility
• calculator - Math: add, subtract, multiply, divide, power, sqrt
• get_weather - Weather lookup for cities worldwide
• search_text - Find pattern occurrences in text
• string_length - Get character count
• text_reverse - Reverse text strings
• json_parser - Validate and format JSON
• http_status - Look up HTTP status codes
# Requires Rust 1.70+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shgit clone https://github.com/koki7o/mcp-framework
cd mcp-framework
# Create .env for API keys (optional but recommended)
cp .env.example .env
# Edit .env and add ANTHROPIC_API_KEY or OPENAI_API_KEYMinimal Server (1 tool):
cargo runServer with 8 Tools + Inspector UI:
cargo run --example server_with_tools
# Visit: http://localhost:8123AI Agent with Claude:
# Requires ANTHROPIC_API_KEY in .env
cargo run --example anthropic_agent_demo_with_tools --releaseAI Agent with OpenAI:
# Requires OPENAI_API_KEY in .env
cargo run --example openai_agent_demo_with_tools --releaseBrowser Automation (OpenAI):
# Requires OPENAI_API_KEY in .env
# Install: npm install -g @playwright/mcp@latest && npx playwright install firefox
cargo run --example browser_agent_openaiBrowser Automation (Claude):
# Requires ANTHROPIC_API_KEY in .env
# Install: npm install -g @playwright/mcp@latest && npx playwright install firefox
cargo run --example browser_agent_anthropicuse mcp_framework::prelude::*;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<()> {
mcp_framework::load_env();
let client = McpClient::new("http://localhost:3000");
let llm = AnthropicAdapter::from_env("claude-sonnet-4-5-20250929".to_string())?;
let mut agent = Agent::new(client, Arc::new(llm), AgentConfig::default());
let response = agent.run("What is 15 + 27?").await?;
println!("{}", response);
Ok(())
}Run Examples:
cargo run --example anthropic_agent_demo_with_tools --release- Claude democargo run --example openai_agent_demo_with_tools --release- OpenAI demo
use mcp_framework::prelude::*;
use mcp_framework::server::{McpServer, ServerConfig, ToolHandler};
use std::sync::Arc;
struct MyToolHandler;
#[async_trait::async_trait]
impl ToolHandler for MyToolHandler {
async fn execute(&self, name: &str, arguments: serde_json::Value)
-> Result<Vec<ResultContent>> {
match name {
"greet" => Ok(vec![ResultContent::Text {
text: format!("Hello, {}!", arguments.get("name").and_then(|v| v.as_str()).unwrap_or("stranger"))
}]),
_ => Err(Error::ToolNotFound(name.to_string())),
}
}
}
#[tokio::main]
async fn main() -> Result<()> {
let config = ServerConfig {
name: "My Server".to_string(),
version: "1.0.0".to_string(),
capabilities: ServerCapabilities {
tools: Some(ToolsCapability { list_changed: Some(false) }),
resources: None, // Not implemented yet
prompts: None, // Not implemented yet
},
};
let server = McpServer::new(config, Arc::new(MyToolHandler));
server.register_tool(Tool {
name: "greet".to_string(),
description: Some("Greet someone".to_string()),
input_schema: None,
});
Ok(())
}Examples:
cargo run- Minimal server (1 tool)cargo run --example server_with_tools- Full example (8 tools + Inspector)
use mcp_framework::prelude::*;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<()> {
let client = McpClient::new("http://localhost:3000");
// List all tools
let tools = client.list_tools().await?;
println!("Available tools: {:?}", tools);
// Call a tool
let result = client.call_tool("echo", json!({
"message": "Hello, MCP!"
})).await?;
println!("Result: {:?}", result);
Ok(())
}Example:
cargo run --example client_usage- Full client usage example
Test and debug MCP servers with a web UI.
cargo run --example server_with_tools
# Open browser to: http://localhost:8123Features:
- View registered tools
- Test tools with auto-generated forms
- Request/response history
- Real-time output inspection
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Run specific test
cargo test test_name
# Run with release optimizations
cargo test --releaseContributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details
Made with ❤️ for the MCP community