MCP LLMS-TXT Documentation Server

Official

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Integrates with Windsurf (by Codeium) to provide document context retrieval through the llms.txt protocol.

  • Provides access to LangGraph documentation through its llms.txt file, enabling contextual information retrieval for development tasks.

MCP LLMS-TXT文档服务器

概述

llms.txt是法学硕士 (LLM) 的网站索引,提供背景信息、指导以及详细 Markdown 文件的链接。像 Cursor 和 Windsurf 这样的 IDE,或者像 Claude Code/Desktop 这样的应用程序,可以使用llms.txt检索任务的上下文。然而,这些应用程序使用不同的内置工具来读取和处理像llms.txt这样的文件。检索过程可能不透明,并且并不总是有办法审计工具调用或返回的上下文。

MCP为开发者提供了一种完全控制这些应用程序所用工具的方法。我们创建了一个开源 MCP 服务器,为 MCP 宿主应用程序(例如 Cursor、Windsurf、Claude Code/Desktop)提供 (1) 用户定义的llms.txt文件列表,以及 (2) 一个简单的fetch_docs工具,用于读取任何提供的llms.txt文件中的 URL。这允许用户审计每个工具调用以及返回的上下文。

llms-txt

您可以在此处找到 langgraph 和 langchain 的 llms.txt 文件:

图书馆llms.txt
LangGraph Pythonhttps://langchain-ai.github.io/langgraph/llms.txt
LangGraph JShttps://langchain-ai.github.io/langgraphjs/llms.txt
LangChain Pythonhttps://python.langchain.com/llms.txt
LangChain JShttps://js.langchain.com/llms.txt

快速入门

安装 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 获取文档。
  2. 本地 llms.txt 文件:使用本地文件时,不会自动将任何域名添加到允许列表中。您必须使用--allowed-domains参数明确指定允许哪些域名。
  1. 添加其他域:为了允许从自动包含的域之外的域获取:
  • 使用--allowed-domains domain1.com domain2.com添加特定域
  • 使用--allowed-domains '*'允许所有域(谨慎使用)

此安全措施可防止未经授权访问用户未明确批准的域,确保只能从受信任的来源检索文档。

(可选)使用您选择的llms.txt文件在本地测试 MCP 服务器:

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

npx @modelcontextprotocol/inspector

  • 在这里,您可以测试tool调用。

连接到光标

  • 打开Cursor SettingsMCP选项卡。
  • 这将打开~/.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选项卡中运行。
  • 最佳做法是更新 Cursor Global(用户)规则。
  • 打开光标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 question
  • CMD+L (在 Mac 上)打开聊天。
  • 确保已选择agent

然后,尝试示例提示,例如:

what are types of memory in LangGraph?

连接到 Windsurf

  • 使用CMD+L打开 Cascade(在 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

然后,尝试示例提示:

  • 它将执行您的工具调用。

连接到 Claude 桌面

  • 打开Settings/Developer来更新~/Library/Application\ Support/Claude/claude_desktop_config.json
  • 如上所述,使用langgraph-docs-mcp进行更新。
  • 重新启动 Claude 桌面应用程序。

[!Note] 如果您在尝试将 MCPDoc 工具添加到 Claude Desktop 时遇到 Python 版本不兼容的问题,您可以在uvx命令中明确指定python可执行文件的文件路径。

{ "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" ] } } }

[!Note] 目前(2025 年 3 月 21 日)Claude Desktop 似乎不支持全局rules ,因此请将以下内容附加到您的提示中。

<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 </rules>

  • 您将在聊天输入的右下角看到您的工具。

然后,尝试示例提示:

  • 在处理您的请求时,它会要求批准工具调用。

连接到克劳德代码

  • 安装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", "--urls", "LangChain:https://python.langchain.com/llms.txt"]}' -s local
  • 您将看到~/.claude.json已更新。
  • 通过启动 Claude Code 并运行来查看您的工具进行测试:
$ Claude $ /mcp

[!Note] 目前(2025 年 3 月 21 日)看来,Claude Code 不支持全局rules ,因此请将以下内容附加到您的提示中。

<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 </rules>

然后,尝试示例提示:

  • 它将要求批准工具调用。

命令行界面

mcpdoc命令提供了一个简单的 CLI 来启动文档服务器。

您可以通过三种方式指定文档源,并且可以组合使用:

  1. 使用 YAML 配置文件:
  • 这将从此 repo 中的sample_config.yaml文件加载 LangGraph Python 文档。
mcpdoc --yaml sample_config.yaml
  1. 使用 JSON 配置文件:
  • 这将从此 repo 中的sample_config.json文件加载 LangGraph Python 文档。
mcpdoc --json sample_config.json
  1. 直接指定带有可选名称的 llms.txt URL:
  • URL 可以指定为纯 URL,也可以使用name:url格式的可选名称来指定。
  • 您可以多次使用--urls参数来指定多个 URL。
  • 这就是我们为上面的 MCP 服务器加载llms.txt的方式。
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.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")
ID: 655da7rcrv