MCP Rust CLI server template

MCP Rust CLI server template

一个用于模型上下文协议的入门级服务器

简介

mcp-rs-template 是一个 Rust 实现的模型上下文协议(MCP)CLI服务器模板,帮助 LLM 应用无缝集成外部数据源和工具。

快速开始

  1. 克隆仓库

  2. 修改配置

    • 更新 Cargo.tomlsrc/mcp/mod.rs 中的项目信息
  3. 自定义处理器

    • src/mcp/prompts.rs: 提示处理
    • src/mcp/resources.rs: 资源处理
    • src/mcp/tools.rs: 工具处理
    • 或使用 src/mcp/templates/*.json 文件定义

运行服务器

# 启动 MCP 服务器
mcp-rs-template --mcp

# 查看可用资源、提示或工具
mcp-rs-template --resources
mcp-rs-template --prompts
mcp-rs-template --tools

在 Claude Desktop 中配置

  1. 打开 设置开发者编辑配置
  2. 添加服务器配置:
{
   "mcpServers": {
      "current-time": {
         "command": "mcp-rs-template",
         "args": ["--mcp"],
         "env": {
            "API_KEY": "xxxx"
         }
      }
   }
}
  1. 查看日志: tail -n 20 -f ~/Library/Logs/Claude/mcp*.log

了解更多