MCP Discovery 是一个用 Rust 编写的命令行工具,用于自动发现并记录 MCP Server(Model Context Protocol Server)的能力信息。它可以将服务器的工具、资源和功能输出到终端,或保存为多种格式的文件。
简单理解:MCP Discovery 之于 MCP Server,就像 Swagger 之于 REST API。
| 类比 | REST API 生态 | MCP Server 生态 |
|---|---|---|
| 协议/规范 | OpenAPI Specification | Model Context Protocol |
| 文档生成工具 | Swagger / OpenAPI Generator | MCP Discovery |
| 自动生成内容 | API endpoints、参数、响应格式 | Tools、Resources、Capabilities |
| 输出格式 | HTML (Swagger UI)、JSON | Markdown、HTML、TXT、自定义模板 |
什么是 MCP(Model Context Protocol)?
MCP 是一个标准化协议,用于 AI 模型与外部工具、资源之间的交互。一个 MCP Server 可以暴露多种能力:
- Tools(工具):可供模型调用的函数/操作
- Resources(资源):可供模型读取的数据源
- Capabilities(能力):服务器支持的功能特性
MCP Discovery 能做什么?
| 功能 | 说明 |
|---|---|
| 终端显示 | 直接在命令行输出 MCP Server 的详细信息 |
| 生成文件 | 创建 Markdown、HTML、纯文本格式的能力文档 |
| 更新文件 | 在已有文档中自动更新 MCP Server 能力区域 |
| 自定义模板 | 支持 Handlebars 模板引擎自定义输出格式 |
| CI/CD 集成 | 提供 GitHub Action 实现自动化文档维护 |
安装
# 具体安装方式请参考官方文档
# https://github.com/rust-mcp-stack/mcp-discovery
基本命令
子命令
| 命令 | 说明 |
|---|---|
print | 在终端显示 MCP Server 能力(默认) |
create | 创建包含能力信息的新文件 |
update | 更新已有文件中的能力区域 |
常用参数
| 参数 | 说明 |
|---|---|
-f, --filename <FILE> | 指定输出文件(用于 create/update) |
-t, --template <TEMPLATE> | 选择内置模板:md, md-plain, html, txt |
-p, --template-file <FILE> | 使用自定义 Handlebars 模板文件 |
-s, --template-string <STRING> | 直接传入 Handlebars 模板字符串 |
使用示例
1. 在终端显示 MCP Server 能力
mcp-discovery -- npx -y @modelcontextprotocol/server-everything
2. 生成 HTML 文档
mcp-discovery create -f capabilities.html -- npx -y @modelcontextprotocol/server-everything
3. 生成 Markdown 文档
mcp-discovery create -f capabilities.md -- npx -y @modelcontextprotocol/server-everything
4. 使用自定义模板
mcp-discovery create -f capabilities.md --template-file=custom_template.hbs -- npx -y @modelcontextprotocol/server-everything
内置模板
| 模板 | 说明 |
|---|---|
md | 表格格式的 Markdown,适合 README |
md-plain | 简洁纯文本 Markdown |
html | 带基础样式的 HTML |
txt | 无格式纯文本 |
💡 Tip: 如果不指定模板,MCP Discovery 会根据文件扩展名自动选择合适的内置模板。
文档标记(Markers)机制
update 命令通过标记注释来定位更新区域。运行命令后,标记之间的内容会被自动替换为最新的 MCP Server 能力信息。
Markdown 文件示例
# Server Info and Capabilities
<!-- mcp-discovery-render -->
(这里的内容会被自动替换)
<!-- mcp-discovery-render-end -->
指定模板
<!-- mcp-discovery-render template=md-plain -->
<!-- mcp-discovery-render-end -->
指定自定义模板文件
<!-- mcp-discovery-render template-file=my-custom-template.hbs -->
<!-- mcp-discovery-render-end -->
HTML 文件示例
<!DOCTYPE html>
<html lang="en">
<head>
<title>My MCP Server</title>
</head>
<body>
<h1>MCP Server Details</h1>
<div>
<!-- mcp-discovery-render -->
<!-- mcp-discovery-render-end -->
</div>
</body>
</html>
内联模板(Inline Template)
对于 HTML 文件,可以在标记内定义内联模板:
<h1>MCP Server Details</h1>
<div>
<!-- mcp-discovery-render -->
<!-- mcp-discovery-template
<b>Name: </b>{{name}}
<br/>
<b>Version: </b>{{version}}
<br/>
<b>Number of tools:</b> {{len tools}}
<h2>Summary:</h2>
{{> html-summary }}
mcp-discovery-template-end -->
<!-- mcp-discovery-render-end -->
</div>
GitHub Action 集成
MCP Discovery 提供官方 GitHub Action,可以在 CI/CD 流程中自动更新文档:
# .github/workflows/update-mcp-docs.yml
name: Update MCP Documentation
on:
push:
branches: [main]
workflow_dispatch:
jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update MCP capabilities
uses: rust-mcp-stack/mcp-discovery-action@v1
with:
file: README.md
command: "npx -y @modelcontextprotocol/server-everything"
- name: Commit changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git diff --staged --quiet || git commit -m "docs: update MCP capabilities"
git push
📓 Note: 具体配置请参考 mcp-discovery-action 官方文档。
应用场景
1. MCP Server 项目文档维护
为你开发的 MCP Server 自动生成和维护 README 中的能力说明:
# 每次发布新版本时运行
mcp-discovery update -f README.md -- node ./dist/server.js
2. 开发者门户/Wiki 集成
生成 HTML 格式的能力文档,集成到内部文档系统:
mcp-discovery create -f docs/capabilities.html -- npx @your-org/mcp-server
3. Agent 开发调试
快速查看 MCP Server 提供了哪些工具和资源:
# 终端快速预览
mcp-discovery -- npx -y @modelcontextprotocol/server-filesystem
# 保存为文件便于分析
mcp-discovery create -f debug-capabilities.json -t txt -- npx -y @modelcontextprotocol/server-filesystem
4. 多 MCP Server 统一文档
为团队使用的多个 MCP Server 生成统一格式的文档,便于 Agent 开发者查阅。
技术栈
- 语言:Rust
- MCP 交互:基于 rust-mcp-sdk
- 模板引擎:Handlebars
- 开源协议:MIT License
References
- MCP Discovery GitHub Repository. (n.d.). rust-mcp-stack. Retrieved January 26, 2026, from https://github.com/rust-mcp-stack/mcp-discovery
- MCP Discovery GitHub Action. (n.d.). rust-mcp-stack. Retrieved January 26, 2026, from https://github.com/rust-mcp-stack/mcp-discovery-action
- Model Context Protocol. (n.d.). Anthropic. Retrieved January 26, 2026, from https://modelcontextprotocol.io/