mcpdoc v0.0.10 --- MCP LLMS-TXT Documentation Server
概述
mcpdoc 是一个 MCP 服务端,将 llms.txt 文档暴露为 MCP 工具,供 IDE(Cursor、Windsurf)或 AI 编码工具(Claude Code/Desktop、opencode)按需获取上下文。由 LangChain 维护。
两种工具
| 工具 | 说明 |
|---|---|
list_doc_sources |
列出所有已注册的文档源名称 |
fetch_docs |
读取指定文档源的完整内容 |
三种配置来源
可组合使用:
1. --urls 直接指定
支持 URL 或本地文件路径,格式 name:path:
bash
mcpdoc --urls "LangGraph:https://langchain-ai.github.io/langgraph/llms.txt"
mcpdoc --urls "RedisUtil:.opencode/docs/redis-util.md" --allowed-domains '*'
2. --yaml YAML 配置文件
yaml
- name: RedisUtil
llms_txt: .opencode/docs/redis-util.md
- name: IFileClient
llms_txt: .opencode/docs/ifile-client.md
3. --json JSON 配置文件
json
[
{
"name": "LangGraph Python",
"llms_txt": "https://langchain-ai.github.io/langgraph/llms.txt"
}
]
CLI 参数
| 参数 | 说明 |
|---|---|
--urls/-u |
URL 或本地文件路径列表,支持 name:path 格式 |
--yaml/-y |
YAML 配置文件路径 |
--json/-j |
JSON 配置文件路径 |
--allowed-domains |
允许 fetch 的域名白名单,* 表示全部放行 |
--follow-redirects |
是否跟随 HTTP 重定向 |
--timeout |
HTTP 请求超时(秒,默认 10.0) |
--transport |
传输协议:stdio(默认)或 sse |
--host |
SSE 模式下绑定地址(默认 127.0.0.1) |
--port |
SSE 模式下端口(默认 8000) |
--log-level |
日志级别(SSE 模式) |
安全机制
- 远程 URL:自动将该 URL 的域名加入允许白名单
- 本地文件:不自动添加域名,必须显式用
--allowed-domains指定 - 使用
--allowed-domains '*'可以放行所有域名(谨慎使用)
URL 安全约束
fetch_docs 工具只能拉取 list_doc_sources 列出的文档源中的链接,不能随意访问任意 URL。这确保大模型只能读取你明确授权的文档内容。
编程使用
python
from mcpdoc.main import create_server
server = create_server(
[
{
"name": "LangGraph Python",
"llms_txt": "https://langchain-ai.github.io/langgraph/llms.txt",
},
],
follow_redirects=True,
timeout=15.0,
)
server.run(transport="stdio")
典型用法(opencode 配置)
json
{
"mcp": {
"jz-common-docs": {
"type": "local",
"command": [
"uvx", "--from", "mcpdoc",
"mcpdoc",
"--yaml", ".opencode/mcp-config.yaml",
"--allowed-domains", "*"
],
"enabled": true
},
"agentscope-docs": {
"type": "local",
"command": [
"uvx", "--from", "mcpdoc",
"mcpdoc",
"--urls", "AgentScopeJava:https://java.agentscope.io/llms.txt"
],
"enabled": true
}
}
}
开源信息
- GitHub: https://github.com/langchain-ai/mcpdoc
- PyPI: mcpdoc
- 许可证: MIT
- 维护者: LangChain
- 当前版本: 0.0.10(2025-07-22)