MCP LLMS-TXT Documentation Server

MIT License
4
  • Apple
  • Linux

Integrations

  • Integrates with Windsurf (part of Codeium ecosystem) to provide access to llms.txt files and documentation retrieval tools.

  • Provides access to LangGraph documentation through llms.txt, allowing tools to retrieve information about LangGraph features and capabilities.

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。这允许用户审计每个工具调用以及返回的上下文。

快速入门

安装 uv

curl -LsSf https://astral.sh/uv/install.sh | sh

选择要使用的llms.txt文件。

  • 例如,这是LangGraph llms.txt文件。

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

uvx --from mcpdoc mcpdoc \ --urls LangGraph:https://langchain-ai.github.io/langgraph/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", "--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

  • 使用CMD+L打开 Cascade(在 Mac 上)。
  • 单击Configure MCP以打开配置文件~/.codeium/windsurf/mcp_config.json
  • 如上所述,使用langgraph-docs-mcp进行更新。

  • CMD+L (在 Mac 上)打开 Cascade 并刷新 MCP 服务器。
  • 可用的 MCP 服务器将被列出,并显示langgraph-docs-mcp已连接。

然后,尝试示例提示:

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

连接到 Claude 桌面

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

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

然后,尝试示例提示:

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

连接到克劳德代码

  • 安装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 $ /mcp

然后,尝试示例提示:

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

命令行界面

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格式的可选名称来指定。
  • 这就是我们为上面的 MCP 服务器加载llms.txt的方式。
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")
ID: 8jv6rzdsu9