Rust文档查询服务器

一个用于从docs.rs获取Rust crate文档的Model Context Protocol (MCP)服务器,提供crate查找、符号检查和文档阅读功能。

  • by vexxvakan
  • TypeScript
  • 本地部署
  • 13 星标
  • 更新于
在 GitHub 查看 vexxvakan/mcp-docsrs

使用说明

Docs.rs MCP服务器

A. 模型上下文协议 (MCP)服务器 获取Rust crate文档 从 docs.rs

特性 • 入门指南 • 工具 • 贡献 • 致谢 • 许可证

特性

  • 查找新板条箱 -通过精确名称、部分匹配或模糊查询搜索板条箱,以发现相关库
  • 检查板条箱符号 -检查机箱内的结构、特征、函数和任何其他符号
  • 审查板条箱摘要 -获取机箱概述及其结构和公共API表面
  • 阅读完整文档 -阅读机箱级文档

入门指南

使用预构建的可执行文件

从以下网址下载适用于您平台的最新版本 发布 页面:

Linux

  • x64/AMD64(GLIBC): mcp-docsrs-linux-x64 -适用于Ubuntu、Debian、Fedora等。
  • ARM64(GLIBC): mcp-docsrs-linux-arm64 -对于ARM64系统,AWS Graviton
  • x64/AMD64(必须): mcp-docsrs-linux-x64-musl -对于Alpine Linux,Docker容器(需要libstdc++)
  • ARM64(棉质): mcp-docsrs-linux-arm64-musl -对于ARM64上的Alpine,最小容器(需要libstdc++)

macOS

  • 英特尔: mcp-docsrs-darwin-x64 -适用于基于Intel的Mac
  • 苹果芯片: mcp-docsrs-darwin-arm64 -适用于M系列Mac

视窗

  • x64: mcp-docsrs-windows-x64.exe -适用于64位Windows

使用Docker

拉取并运行最新的多拱形映像(支持x64和ARM64):

# Pull the latest image
docker pull ghcr.io/vexxvakan/mcp-docsrs:latest

# Run the server
docker run --rm -i ghcr.io/vexxvakan/mcp-docsrs:latest

# Run with custom configuration
docker run --rm -i ghcr.io/vexxvakan/mcp-docsrs:latest \
  --cache-ttl 7200000 --max-cache-size 200

可用标签:

  • latest -最新稳定版本(多拱形)
  • v1.0.0 -特定版本(多拱形)

MCP设置

客户端 命令
食品法典委员会 codex mcp add docsrs -- path/to/mcp-docsrs
克劳德代码 claude mcp add --transport stdio docsrs -- path/to/mcp-docsrs
Gemini CLI gemini mcp add -s user docsrs path/to/mcp-docsrs
OpenCode 运行 opencode mcp add,选择本地MCP服务器,然后将其指向 path/to/mcp-docsrs.
VS代码 打开命令面板(Cmd/Ctrl+Shift+P) → MCP: Add Server → 选择 Workspace 或 User → Command (stdio) → enter path/to/mcp-docsrs.
光标 打开设置(Cmd/Ctrl+Shift+J) → Tools & Integrations → New MCP Server → 选择本地/stdio服务器→ enter path/to/mcp-docsrs.

添加服务器后,如果客户端没有立即发现工具,请重新启动客户端。

配置

使用环境变量或命令行参数配置服务器:

变量 CLI标志 默认值 描述
CACHE_TTL --cache-ttl 3600000 缓存生存时间(毫秒)
MAX_CACHE_SIZE --max-cache-size 100 缓存条目的最大数量
REQUEST_TIMEOUT --request-timeout 30000 HTTP请求超时(毫秒)
DB_PATH --db-path :内存: SQLite数据库文件的路径

工具

服务器公开了四个MCP工具:

板条箱

crate_lookup

从docs.rs检索具有其结构和公共API表面的机箱概览。

参数 类型 必填 说明
crateName string Yes 要检查的Rust板条箱的名称
version string 否 特定版本或semver范围,例如 "1.0.0" 或 "~4"
target string 否 目标平台,例如 "i686-pc-windows-msvc"
formatVersion number 否 Rustdoc JSON格式版本
{
  "tool": "crate_lookup",
  "arguments": {
    "crateName": "tokio",
    "version": "1.48.0"
  }
}

crate_docs

从docs.rs检索机箱级文档页面。

参数 类型 必填 说明
crateName string Yes 要检查的Rust板条箱的名称
version string 否 特定版本或semver范围,例如 "1.0.0" 或 "~4"
target string 否 目标平台,例如 "i686-pc-windows-msvc"
formatVersion number 否 Rustdoc JSON格式版本
{
  "tool": "crate_docs",
  "arguments": {
    "crateName": "serde"
  }
}

crate_find

在crates.io中搜索匹配的crates,并使用模糊和部分名称匹配返回排名结果。

参数 类型 必填 说明
query string 是 搜索板条箱名称
limit number 否 返回的最大结果数。默认为 10
{
  "tool": "crate_find",
  "arguments": {
    "query": "rustdoc json",
    "limit": 5
  }
}

符号

symbol_lookup

检索机箱内一个符号的结构化符号元数据。

参数 类型 必填 说明
crateName string Yes Rust机箱的名称
symbolType string Yes Rustdoc符号类型,例如 "struct", "function",或 "trait"
symbolname string Yes 符号名称或路径,例如 "runtime::Runtime" 或 "spawn"
version string 否 特定版本或semver范围
target string 否 目标平台
{
  "tool": "symbol_lookup",
  "arguments": {
    "crateName": "tokio",
    "symbolType": "struct",
    "symbolname": "runtime::Runtime"
  }
}

symbol_docs

检索板条箱内一个符号的完整文档正文。

参数 类型 必填 说明
crateName string Yes Rust机箱的名称
symbolType string Yes Rustdoc符号类型,例如 "struct", "function",或 "trait"
symbolname string Yes 符号名称或路径,例如 "runtime::Runtime" 或 "spawn"
version string 否 特定版本或semver范围
target string 否 目标平台
{
  "tool": "symbol_docs",
  "arguments": {
    "crateName": "tokio",
    "symbolType": "struct",
    "symbolname": "runtime::Runtime"
  }
}

贡献

致谢

许可证

此项目根据Apache许可证2.0获得许可。看 许可证 对于许可证文本和 通知 有关归因的详细信息。


由以下材料制成❤️ Rust社区

报告Bug • 请求功能