用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/publieople/hermes-config-kit --skill rust-mcp-server命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | rust-mcp-server |
| description | 用 Rust 写 MCP server(rmcp crate)并暴露 CLI/工具为 MCP tools。 |
| category | mcp |
| tags | ["mcp","rust","rmcp","stdio","ai-agent","protocol"] |
用 rmcp crate 把现有 Rust 工具/CLI 暴露为 MCP tools,让协议系 agent 能调用。MCP 是 CLI 的薄适配层——core 只暴露 CLI/函数,server 只做包装。
[dependencies]
rmcp = { version = "3.1", features = ["server", "transport-io", "macros"] }
schemars = { version = "1.0", features = ["derive"] } # ← 必须 1.0,见坑表
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
anyhow = "1"
features 名:server + transport-io(stdio)。没有 server-stdio feature(不存在,写了会 resolve 冲突)。查真实 feature 列表:crates.io/api/v1/crates/rmcp/<version> 的 JSON。
use rmcp::{
ServerHandler, ServiceExt,
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
tool, tool_handler, tool_router,
};
use rmcp::schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
pub struct MyServer { tool_router: ToolRouter<Self> }
impl MyServer {
pub fn new() -> Self { Self { tool_router: Self::tool_router() } }
}
#[tool_handler(router = self.tool_router)]
impl ServerHandler for MyServer {}
#[derive(Serialize, Deserialize, JsonSchema)]
struct ListParam { #[serde(default)] category: Option<String> }
#[tool_router(router = tool_router)]
impl MyServer {
/// 工具描述(agent 看到的就是这个)。
#[tool(name = "list_items", description = "List items. Returns JSON array.")]
pub async fn list_items(&self, p: Parameters<ListParam>) -> String {
// 返回 String(JSON 文本),MCP 会包成 text content
serde_json::to_string(&vec![, , ]).()
}
}
() anyhow::<()> {
= MyServer::().(rmcp::transport::io::()).?;
running.().?;
(())
}
import subprocess, json, select
p = subprocess.Popen(['./target/debug/my-mcp'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1)
def send(o): p.stdin.write(json.dumps(o) + '\n'); p.stdin.flush()
def recv(t=3):
r,_,_ = select.select([p.stdout], [], [], t)
return p.stdout.readline().strip() if r else None
send({"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"t","version":"1"}}})
print("init:", recv())
send({"jsonrpc":"2.0","method":"notifications/initialized"})
send({"jsonrpc":"2.0","id":2,"method":"tools/list"})
print("tools:", recv(5))
stdio 传输是 JSON-Lines(每行一个 JSON + \n),不是 Content-Length 帧。
见 references/rmcp-3.1-pitfalls.md。高频要点:
JsonSchema 和 rmcp 的 Parameters<T> 类型不兼容 → trait bound unsatisfied。要么 rmcp::schemars::JsonSchema(derive 宏要独立 schemars 开 derive feature),要么独立 schemars 1.0 + derive。RunningService::waiting().await 必须调用:serve() 返回后 main 一结束 RunningService 被 drop → 连接关闭 → 进程退出。症状:init 响应正常,但 tools/list 时 BrokenPipe。这是本会话最隐蔽的坑。#[tool(aggr)] 属性:参数就是 Parameters<T> 类型,直接作为 fn 参数,不要加任何 attribute。references/rmcp-3.1-pitfalls.md — rmcp 3.1 完整坑位(版本、宏、stdio、进程生命周期)