README
🚀 MCP生锈CLI服务器模板
模型上下文协议(MCP)是一个开放协议,它能够让LLM应用程序与外部数据源和工具实现无缝集成。不管是构建AI驱动的IDE、增强聊天界面,还是创建自定义AI工作流程,MCP都提供了一种标准化方式,用以连接LLM和其所需的上下文。mcp - rs - template则是一个简单的应用程序模板,它展示了如何在Rust中实现MCP CLI服务器。
🚀 快速开始
使用模板的步骤
- 克隆仓库。
- 修改
Cargo.toml和src/mcp/mod.rs中的项目信息。 - 修改服务器处理程序:
src/mcp/prompts.rs:提示处理程序。src/mcp/resources.rs:资源处理程序。src/mcp/tools.rs:工具处理程序。
- 若您更倾向于使用JSON文件来处理提示、资源和工具,请修改
src/mcp/templates/*.json。
基于的库
mcp - rs - template基于[rust - rpc - router](https://github.com/jeremychone/rust - rpc - router),这是一个Rust中的JSON - RPC路由库。
✨ 主要特性
CLI选项
--mcp:启用MCP服务器。--resources:显示资源。--prompts:显示提示。--tools:显示工具。
📚 详细文档
在Claude Desktop中使用MCP CLI服务器的方法
- 编辑
claude_desktop_config.json:Claude Desktop ->设置->开发者->编辑配置。 - 在
servers部分添加以下配置:
{
"mcpServers": {
"current - time": {
"command": "mcp - rs - template",
"args": [
"--mcp"
],
"env": {
"API_KEY": "xxxx"
}
}
}
}
查看MCP日志
如果想检查MCP日志,请使用tail -n 20 -f ~/Library/Logs/Claude/mcp*.log。
📄 参考资料
- MCP规范:https://spec.modelcontextprotocol.io/
- 模型上下文协议(MCP):https://modelcontextprotocol.io/introduction
- rpc - router:JSON - RPC路由库 - https://github.com/jeremychone/rust - rpc - router/
- Zed context_server:https://github.com/zed - industries/zed/tree/main/crates/context_server
Scan to join WeChat group