MCP Runner
About
MCP Runner is a Rust library for running and interacting with Model Context Protocol (MCP) servers locally. It provides a complete solution for managing MCP server processes, communicating via JSON-RPC, and optionally proxying Server-Sent Events (SSE) to enable client…
Details
- Author
- Streamline-TS
- GitHub stars
- 2
- Downloads
- 136
- Categories
- Other
Jump to
- Start and manage MCP server processes locally
- Configure multiple servers through a unified interface
- Communicate with MCP servers using JSON-RPC
- List and call tools exposed by MCP servers
- Access resources provided by MCP servers
- Proxy Server-Sent Events (SSE) to enable HTTP clients
Add mcp-runner = "0.3.1" to your Cargo.toml, then create a McpRunner from a JSON config file, a JSON string, or programmatically. Use start_all_with_proxy() to start servers and the SSE proxy, then get a client with get_client() to list tools or call them.
MCP Runner
A Rust library for running and interacting with Model Context Protocol (MCP) servers locally.
Overview
MCP Runner provides a complete solution for managing Model Context Protocol servers in Rust applications. It enables:
- Starting and managing MCP server processes
- Configuring multiple servers through a unified interface
- Communicating with MCP servers using JSON-RPC
- Listing and calling tools exposed by MCP servers
- Accessing resources provided by MCP servers
- Proxying Server-Sent Events (SSE) to enable clients to connect to MCP servers
Installation
Add this to your Cargo.toml:
[dependencies]
mcp-runner = "0.3.1"
Quick Start
Here's a simple example of using MCP Runner to start a server and call a tool:
use mcp_runner::{McpRunner, error::Result};
use serde::{Deserialize, Serialize};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<()> {
// Create runner from config file
let mut runner = McpRunner::from_config_file("config.json")?;
// Start all servers and the SSE proxy if configured
let (server_ids, proxy_started) = runner.start_all_with_proxy().await;
let server_ids = server_ids?;
if proxy_started {
println!("SSE proxy started successfully");
}
// Get client for interacting with a specific server
let server_id = runner.get_server_id("fetch")?;
let client = runner.get_client(server_id)?;
// Initialize the client
client.initialize().await?;
// List available tools
let tools = client.list_tools().await?;
println!("Available tools:");
for tool in tools {
println!(" - {}: {}", tool.name, tool.description);
}
// Call the fetch tool with structured input
let fetch_result = client.call_tool("fetch", &json!({
"url": "https://modelcontextprotocol.io"
})).await?;
println!("Fetch result: {}", fetch_result);
// Stop the server when done
runner.stop_server(server_id).await?;
Ok(())
}
Observability
This library uses the tracing crate for logging and diagnostics. To enable logging, ensure you have a tracing_subscriber configured in your application and set the RUST_LOG environment variable. For example:
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



