Crates.io | rust_mcp |
lib.rs | rust_mcp |
version | 0.1.0 |
created_at | 2025-05-06 01:47:51.585883+00 |
updated_at | 2025-05-06 01:47:51.585883+00 |
description | rust_mcp |
homepage | |
repository | https://github.com/trevyn/rust_mcp |
max_upload_size | |
id | 1661797 |
size | 66,391 |
a minimal rust implementation of the model completion protocol (MCP) server for building ai assistant tools.
rust_mcp is a lightweight library that lets you build custom tools for ai assistants like claude using the model completion protocol. it handles the json-rpc communication layer and provides a simple api for registering tool handlers.
add to your project:
cargo add rust_mcp
import and use the library:
use rust_mcp::McpServer;
use serde_json::json;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// create a new mcp server
let mut server = McpServer::new("my-tool-server", "0.1.0");
// register your tools
server.add_tool(
"my_tool",
"Tool description",
your_schema,
your_handler
);
// start the server
server.run_stdio().await?
Ok(())
}
see the examples directory for complete working examples.
this library allows your tools to be used directly by ai assistants that support the model completion protocol, providing seamless integration with systems like claude code.
the server communicates over stdin/stdout using json-rpc messages defined by the mcp spec. tool handlers are async functions that take json parameters and return json results.