使用说明
MCP LLMS-TXT文档服务器
概述
llms.txt 是LLM的网站索引,提供背景信息、指导和详细标记文件的链接。可以使用Cursor和Windsurf等IDE或Claude Code/Desk等应用程序 llms.txt 检索任务的上下文。然而,这些应用程序使用不同的内置工具来读取和处理文件,如 llms.txt检索过程可能是不透明的,并且并不总是有办法审计工具调用或返回的上下文。
主控程序 为开发人员提供了一种方法 完全控制 这些应用程序使用的工具。在这里,我们创建 开源MCP服务器 为MCP主机应用程序(如Cursor、Windsurf、Claude Code/Desk)提供(1)用户定义的列表 llms.txt 文件和(2)简单 fetch_docs 工具读取任何提供的URL llms.txt 文件夹。这允许用户审核每个工具调用以及返回的上下文。
快速启动
安装uv
- 请看 官方紫外线文件 其他安装方式
uv.
curl -LsSf https://astral.sh/uv/install.sh | sh
选择一个 llms.txt 要使用的文件。
- 例如, 这是 LangGraph
llms.txt文件。
(可选)使用您的 llms.txt 选择的文件:
uvx --from mcpdoc mcpdoc \
--urls LangGraph:https://langchain-ai.github.io/langgraph/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",
"--transport",
"stdio",
"--port",
"8081",
"--host",
"localhost"
]
}
}
}
- 确认服务器正在您的
Cursor Settings/MCP选项卡。 CMD+L(在Mac上)打开聊天。- 确保
agent被选中。
然后,尝试一个示例提示,例如:
use the langgraph-docs-mcp server to answer any LangGraph questions --
+ 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 question
what are types of memory in LangGraph?
连接到Windsurf
- 打开Cascade
CMD+L(在Mac上)。 - 点击
Configure MCP要打开配置文件,~/.codeium/windsurf/mcp_config.json. - 更新为
langgraph-docs-mcp如上所述。
CMD+L(在Mac上)打开Cascade并刷新MCP服务器。- 将列出可用的MCP服务器,显示
langgraph-docs-mcp连接。
然后,尝试示例提示:
- 它将执行您的工具调用。
连接到克劳德桌面
- 打开
Settings/Developer更新~/Library/Application\ Support/Claude/claude_desktop_config.json. - 更新为
langgraph-docs-mcp如上所述。 - 重新启动Claude Desktop应用程序。
- 您将在聊天输入的右下角看到您的工具。
然后,尝试示例提示:
- 它将在处理您的请求时请求批准工具调用。
连接到克劳德代码
- 安装后在终端中 克劳德代码,运行此命令将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
$ /mcp
然后,尝试示例提示:
- 它将请求批准工具调用。
命令行界面
这 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. - 我们就是这样装载的
llms.txt对于上面的MCP服务器。
mcpdoc --urls LangGraph:https://langchain-ai.github.io/langgraph/llms.txt
您还可以组合这些方法来合并文档源:
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)
附加选项示例:
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.txt
JSON配置示例(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")