
Mcpdoc
将 llms-txt 暴露给 IDE 进行开发
概述
MCP LLMS-TXT 文档服务
概览
llms.txt 是一个用于大型语言模型(LLMs)的网站索引,提供背景信息、指导以及链接到详细的 Markdown 文件。IDE 如 Cursor 和 Windsurf 或应用程序如 Claude Code/Desktop 可以使用 llms.txt
来获取任务上下文。然而,这些应用程序使用不同的内置工具来读取和处理像 llms.txt
这样的文件。检索过程可能不透明,不一定总有办法审计工具调用或返回的上下文。
MCP 为开发人员提供了对这些应用使用的工具的 完全控制。在这里,我们创建了一个开源 MCP 服务器来为 MCP 托管应用(例如,Cursor、Windsurf、Claude Code/Desktop)提供 (1) 用户自定义的 llms.txt
文件列表和 (2) 一个简单的 fetch_docs
工具,用于读取任何提供文件中的 URL。这使得用户可以审计每个工具调用以及返回的上下文。
快速入门
安装 uv
- 请参考 官方 uv 文档 了解其他安装
uv
的方法。
bash
curl -LsSf https://astral.sh/uv/install.sh | sh
选择要使用的 llms.txt
文件
- 例如,这里是 LangGraph 的
llms.txt
文件。
(可选)使用你的选择的 llms.txt
文件,在本地测试 MCP 服务器:
bash
uvx --from mcpdoc mcpdoc \
--urls LangGraph:https://langchain-ai.github.io/langgraph/llms.txt \
--transport sse \
--port 8082 \
--host localhost
- 该服务器应该运行在: http://localhost:8082
- 运行 MCP 检查器 并连接到正在运行的服务器:
bash
npx @modelcontextprotocol/inspector
- 在这里,你可以测试工具调用。
连接到 Cursor
- 打开 Cursor 设置 和 MCP 选项卡。
- 这将打开
~/.cursor/mcp.json
文件。
- 将以下内容粘贴到文件中(我们使用了名称
langgraph-docs-mcp
并链接到 LangGraph 的 llms.txt)。
{
"mcpServers": {
"langgraph-docs-mcp": {
"command": "uvx",
"args": [
"--from",
"mcpdoc",
"mcpdoc",
"--urls",
"LangGraph:https://langchain-ai.github.io/langgraph/llms.txt",
"--transport",
"stdio",
"--port",
"8081",
"--host",
"localhost"
]
}
}
}
- 确认服务器在你的 Cursor 设置/MCP 标签下正在运行。
- 使用
CMD+L
(在 MacOS 上)打开聊天窗口。 - 确保选择了机器人助手。
然后,尝试以下示例提示语:
使用 llmg-docs-mcp 服务器回答与 LangGraph 相关的问题 ——
+ 调用 list_doc_sources 工具以获取可用的 llms.txt 文件
+ 调用 fetch_docs 工具进行阅读
+ 反思 llms.txt 文件中的 url
+ 反思输入问题
+ 对与问题相关的 url 调用 fetch_docs 工具
+ 使用所得结果作答
LangGraph 中的内存类型有哪些?
连接到 Windsurf
- 按下
CMD+L
(Mac)打开 Cascade。 - 点击 Configure MCP 打开心配置文件
~/.codeium/windsurf/mcp_config.json
。 - 根据上面所注明更新
langgraph-docs-mcp
配置。
CMD + L
(在Mac上)打开Cascade,并刷新MCP服务器。- 显示可连的 MCP 服务器,显示连接的
langgraph - docs - mcp
。
然后,尝试下列问题示例:
- 这将执行你的工具调用。
连接到 Claude Desktop
- 打开设置/开发者部分更新
~/Library/Application\ Support /Claude/claude_desktop_config.json
。 - 按照以上所列更新
langgraph - docs - mcp
。 - 重启 Claude Desktop 应用程序。
- 你会在聊天窗口底部右侧看到你的工具选项。
然后,尝试示例提示语:
- 执行请求时会要求你批准工具调用。
连接到 Claude Code
- 在安装完成后,Claude Code 终端中运行以下命令,将 MCP 服务器添加到你的项目中:
claude mcp add-json langgraph-docs '{"type":"stdio","command":"uvx" ,"args":["--from", "mcpdoc", "mcpdoc", "--urls", "langgraph:https://langchain-ai.github.io/langgraph/llms.txt"]}' -s local
- 你会看到更新的
~/.claude.json
文件内容。 - 测试:通过启动 Claude Code 查看工具:
Claude
/mpc
然后,尝试示例提示语:
- 这将要求你批准工具调用。
命令行界面
mcpdoc
命令提供了用于启动文档服务器的简单命令行界面(CLI)。
您可以以三种方式指定文档资源,这些方式可以组合使用:
- 使用 YAML 配置文件:
- 这将以示例
sample_config.yaml
中的 LangGraph Python 数据开始。
bash
mcpdoc --yaml sample_config.yaml
- 使用 JSON 配置文件:
- 这将以示例
sample_config.json
配置文中的 LangGraph 数据开始。
bash
mcpdoc --json sample_config.json
- 直接指定 llms.txt 的 URL 和可选名称:
- URL 可以以普通 URL 或命名的方式指定,格式为
name:url
。 - 该方法是上方的 MCP 服务器加载 llms.txt 的方式。
bash
mcpdoc --urls LangGraph:https://langchain-ai.github.io/langgraph/llms.txt
您还可以结合这些方法来合并文档来源数据:
bash
mcpdoc --yaml sample_config.yaml --json sample_config.json --urls https://langchain-ai.github.io/langgraph/llms.txt
额外选项
--follow-redirects
:跟随HTTP 重定向(默认设置为 False)-timeout SECONDS
:以秒为单位设置HTTP 请求超时时间(默认值为 10.0)
带有额外选项的例子:
bash
mcpdoc --yaml sample_config.yaml --follow-redirects --timeout 15
该指令将以 15 秒超时加载 LangGraph Python 文档,并根据需要遵循任何 HTTP 重定向。
配置格式
YAML 和 JSON 配置文件应包含文档来源列表。
每个来源必须包括 llms_txt
参数 URL,而 name
则为可选的附加参数:
YAML 配置示例 (sample_config.xml
)
yaml
# Sample configuration for mcp-mcpdoc server
# 每个条目都必须有一个 llms_txt URL,并且可以包含一个 name
- name: Langraph Python
llms_txt: https://langchain-ai.github.io/langraph/llms.txt
JSON 配置示例 (sample_config.xml
)
json
[
{
"name": "Langgraf Python",
"llms_txt": "https://langchain-ai.github.io/langraph/llms.txt"
}
]
编程使用
python
from mcpdoc.main import create_server
# 通过数据创建服务器
server = create_server(
[
{
"name": "LangGraph Python",
"llms_txt": "https://langchain-ai.github.io/langgraph/llms.txt",
},
# 可以添加多个文档来源
# {
# "name": "Another Documentation",
# "llms_txt": "https://example.com/llms.txt",
# },
],
follow_redirects=True,
timeout=15.0,
)
# 执行服务器
server.run(transport="stdio")

Ai Cursor Scraping Assistant
一个强大的工具,利用 Cursor AI 和 MCP(模型上下文协议)轻松为各种类型的网站生成网络爬虫。
Ai Customer Support Bot Mcp Server
一个模型上下文协议(MCP)服务器,使用Cursor AI和Glama.ai集成提供由AI驱动的客户服务。
All In One Model Context Protocol
🚀 集成 AI 搜索、RAG 和多服务集成(GitLab/Jira/Confluence/YouTube)的一体化 MCP 服务器,用于增强开发工作流程
Arxiv Search Mcp
一个提供从 arXiv.org 搜索和获取论文工具的 MCP 服务器。