Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you’re building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need.
mcp-rs-template is a simple application template that demonstrates how to implement MCP CLI server in Rust.
- Clone the repository
- Modify project information in
Cargo.toml
andsrc/mcp/mod.rs
- Modify server handlers:
src/mcp/prompts.rs
: prompts handlerssrc/mcp/resources.rs
: resources handlerssrc/mcp/tools.rs
: tools handlers
- Modify
src/mcp/templates/*.json
if you prefer to use json files for prompts, resources, and tools
mcp-rs-template is based on rust-rpc-router, a JSON-RPC routing library for Rust.
--mcp
: Enable MCP server--resources
: display resources--prompts
: display prompts--tools
: display tools
- Edit
claude_desktop_config.json
: Claude Desktop ->Settings
->Developer
->Edit Config
- Add the following configuration to the
servers
section:
{
"mcpServers": {
"current-time": {
"command": "mcp-rs-template",
"args": [
"--mcp"
],
"env": {
"API_KEY": "xxxx"
}
}
}
}
If you want to check MCP log, please use tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
.
- MCP Specification: https://spec.modelcontextprotocol.io/
- Model Context Protocol (MCP): https://modelcontextprotocol.io/introduction
- rpc-router: json-rpc routing library - https://github.com/jeremychone/rust-rpc-router/
- Zed context_server: https://github.com/zed-industries/zed/tree/main/crates/context_server