MCP LLMS-TXT文档服务器
概述
llms.txt 是LLM的网站索引,提供背景信息、指导和详细标记文件的链接。可以使用Cursor和Windsurf等IDE或Claude Code/Desk等应用程序 llms.txt 检索任务的上下文。然而,这些应用程序使用不同的内置工具来读取和处理文件,如 llms.txt检索过程可能是不透明的,并且并不总是有办法审计工具调用或返回的上下文。
llms txt
您可以在此处找到langgraph和langchain的llms.txt文件:
| 库 | llms.txt |
|---|---|
| Python语言图 | |
| LangGraph JS | |
| 语言链Python | https://python.langchain.com/llms.txt |
| 朗链JS | https://js.langchain.com/llms.txt |
快速启动
安装uv
- 请看 官方紫外线文件 其他安装方式
uv.
curl -LsSf https://astral.sh/uv/install.sh | sh选择一个 llms.txt 要使用的文件。
- 例如, 这是 LangGraph
llms.txt文件。
注意:安全和域访问控制 出于安全原因,mcpdoc实施了严格的域访问控制: 1. 远程llms.txt文件:当您指定远程llms.txt URL时(例如。,https://langchain-ai.github.io/langgraph/llms.txt),mcpdoc仅自动添加该特定域(langchain-ai.github.io)到允许的域列表。这意味着该工具只能从该域上的URL获取文档。 1. 本地llms.txt文件:使用本地文件时,没有域会自动添加到允许列表中。您必须明确指定允许使用的域--allowed-domains参数。 1. 添加其他域:要允许从自动包含的域之外的域中获取数据,请执行以下操作: - 使用--allowed-domains domain1.com domain2.com添加特定域 - 使用--allowed-domains '*'允许所有域(谨慎使用) 此安全措施可防止对未经用户明确批准的域进行未经授权的访问,确保只能从可信来源检索文档。
(可选)使用您的 llms.txt 所选文件:
uvx --from mcpdoc mcpdoc \
--urls "LangGraph:https://langchain-ai.github.io/langgraph/llms.txt" "LangChain:https://python.langchain.com/llms.txt" \
--transport sse \
--port 8082 \
--host localhost- 这应该在以下时间运行:http://localhost:8082
- 跑 MCP检查员 并连接到正在运行的服务器:
npx @modelcontextprotocol/inspector- 在这里,您可以测试
tool电话。
连接到光标
- 打开
Cursor Settings和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 LangChain:https://python.langchain.com/llms.txt",
"--transport",
"stdio"
]
}
}
}- 确认服务器正在您的
Cursor Settings/MCP选项卡。 - 最佳做法是更新游标全局(用户)规则。
- 打开的游标
Settings/Rules并更新User Rules具有以下内容(或类似内容):
for ANY question about LangGraph, use the langgraph-docs-mcp server to help answer --
+ call list_doc_sources tool to get the available llms.txt file
+ call fetch_docs tool to read it
+ reflect on the urls in llms.txt
+ reflect on the input question
+ call fetch_docs on any urls relevant to the question
+ use this to answer the questionCMD+L(在Mac上)打开聊天。- 确保
agent被选中。
然后,尝试一个示例提示,例如:
what are types of memory in LangGraph?连接到Windsurf
- 打开Cascade
CMD+L(在Mac上)。 - 点击
Configure MCP要打开配置文件,~/.codeium/windsurf/mcp_config.json. - 更新为
langgraph-docs-mcp如上所述。
- 更新
Windsurf Rules/Global rules具有以下内容(或类似内容):
for ANY question about LangGraph, use the langgraph-docs-mcp server to help answer --
+ call list_doc_sources tool to get the available llms.txt file
+ call fetch_docs tool to read it
+ reflect on the urls in llms.txt
+ reflect on the input question
+ call fetch_docs on any urls relevant to the question然后,尝试示例提示:
- 它将执行您的工具调用。
连接到克劳德桌面
- 打开
Settings/Developer更新~/Library/Application\ Support/Claude/claude_desktop_config.json. - 更新为
langgraph-docs-mcp如上所述。 - 重新启动Claude Desktop应用程序。
\[!注意\] 如果在尝试将MCPDoc工具添加到Claude Desktop时遇到Python版本不兼容的问题,可以显式指定文件路径python可执行于uvx命令。 Example configuration ``{ "mcpServers": { "langgraph-docs-mcp": { "command": "uvx", "args": [ "--python", "/path/to/python", "--from", "mcpdoc", "mcpdoc", "--urls", "LangGraph:https://langchain-ai.github.io/langgraph/llms.txt", "--transport", "stdio" ] } } }``
\[!注意\] 目前(3/21/25),Claude Desktop似乎不支持 rules 对于全局规则,请在提示后附加以下内容。
for ANY question about LangGraph, use the langgraph-docs-mcp server to help answer --
+ call list_doc_sources tool to get the available llms.txt file
+ call fetch_docs tool to read it
+ reflect on the urls in llms.txt
+ reflect on the input question
+ call fetch_docs on any urls relevant to the question
- 您将在聊天输入的右下角看到您的工具。
然后,尝试示例提示:
- 它将在处理您的请求时请求批准工具调用。
连接到克劳德代码
- 安装后在终端中 克劳德代码,运行此命令将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", "LangChain:https://python.langchain.com/llms.txt"]}' -s local- 你会看到
~/.claude.json更新。 - 通过启动Claude Code并运行以查看您的工具进行测试:
$ Claude
$ /mcp \[!注意\] 目前(3/21/25),Claude Code似乎不支持 rules 对于全局规则,请在提示后附加以下内容。
for ANY question about LangGraph, use the langgraph-docs-mcp server to help answer --
+ call list_doc_sources tool to get the available llms.txt file
+ call fetch_docs tool to read it
+ reflect on the urls in llms.txt
+ reflect on the input question
+ call fetch_docs on any urls relevant to the question
然后,尝试示例提示:
- 它将请求批准工具调用。
命令行界面
这 mcpdoc 命令提供了一个用于启动文档服务器的简单CLI。
您可以通过三种方式指定文档源,这些方式可以组合使用:
- 使用YAML配置文件:
- 这将从以下位置加载LangGraph Python文档
sample_config.yaml此仓库中的文件。
mcpdoc --yaml sample_config.yaml- 使用JSON配置文件:
- 这将从以下位置加载LangGraph Python文档
sample_config.json此仓库中的文件。
mcpdoc --json sample_config.json- 直接指定带有可选名称的llms.txt URL:
- URL可以指定为纯URL,也可以使用以下格式指定可选名称
name:url. - 您可以使用以下命令指定多个URL
--urls参数多次。 - 我们就是这样装载的
llms.txt对于上面的MCP服务器。
mcpdoc --urls LangGraph:https://langchain-ai.github.io/langgraph/llms.txt --urls LangChain:https://python.langchain.com/llms.txt您还可以组合这些方法来合并文档源:
mcpdoc --yaml sample_config.yaml --json sample_config.json --urls LangGraph:https://langchain-ai.github.io/langgraph/llms.txt --urls LangChain:https://python.langchain.com/llms.txt附加选项
--follow-redirects:遵循HTTP重定向(默认为False)--timeout SECONDS:HTTP请求超时(秒)(默认值为10.0)
附加选项示例:
mcpdoc --yaml sample_config.yaml --follow-redirects --timeout 15这将加载具有15秒超时的LangGraph Python文档,并在必要时遵循任何HTTP重定向。
配置格式
YAML和JSON配置文件都应该包含文档源列表。
每个来源必须包括 llms_txt URL,并且可以选择性地包含 name:
YAML配置示例(sample_config.YAML)
# Sample configuration for mcp-mcpdoc server
# Each entry must have a llms_txt URL and optionally a name
- name: LangGraph Python
llms_txt: https://langchain-ai.github.io/langgraph/llms.txtJSON配置示例(sample_config.JSON)
[
{
"name": "LangGraph Python",
"llms_txt": "https://langchain-ai.github.io/langgraph/llms.txt"
}
]程序化使用
from mcpdoc.main import create_server
# Create a server with documentation sources
server = create_server(
[
{
"name": "LangGraph Python",
"llms_txt": "https://langchain-ai.github.io/langgraph/llms.txt",
},
# You can add multiple documentation sources
# {
# "name": "Another Documentation",
# "llms_txt": "https://example.com/llms.txt",
# },
],
follow_redirects=True,
timeout=15.0,
)
# Run the server
server.run(transport="stdio")