LLM友好内容获取服务

一个MCP服务器,用于获取LLM友好格式的网页内容,自动发现并使用llms.txt文件,支持Markdown版本和HTML到Markdown的转换。

  • by Crazytieguy
  • Rust
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 Crazytieguy/better-fetch-mcp

使用说明

llms-fetch-mcp 翻译为中文可以是“获取MCP(多控制平面/微服务配置提供程序等,具体含义根据上下文确定)的LLMS工具”或简化为“LLMS MCP获取工具”,其中LLMS可能代表某个特定的系统、服务或框架名称,而MCP的具体含义需要根据实际应用场景来确定

MCP服务器,以适合大型语言模型(LLM)的格式获取网页内容。自动发现并使用 llms.txt(文件名为“llms”的文本文件) 当文件可用时尝试使用Markdown版本,若不可行则回退到干净的HTML转Markdown转换。

快速入门

在您的MCP客户端配置中添加:

Claude Desktop / Claude Code(可译为“Claude桌面版 / Claude代码版”或根据具体语境简化为“Claude桌面 / Claude代码”,但为保持原名特色,直译保留)

{
  "mcpServers": {
    "llms-fetch": {
      "command": "npx",
      "args": ["-y", "llms-fetch-mcp"]
    }
  }
}

Cursor 集成开发环境(IDE)

{
  "mcp.servers": {
    "llms-fetch": {
      "command": "npx",
      "args": ["-y", "llms-fetch-mcp"]
    }
  }
}

它是如何工作的

当你获取一个URL时,服务器会并行尝试多个来源:

  1. https://example.com/llms-full.txt - 完整的大型语言模型(LLM)文档
  2. https://example.com/llms.txt - 简洁的大型语言模型(LLM)文档
  3. https://example.com.md - Markdown版本
  4. https://example.com/index.md - 目录 Markdown
  5. https://example.com - 原始URL(如有需要,将HTML转换为Markdown)

内容在本地缓存中 .llms-fetch-mcp/ 以便快速访问。服务器会自动为缓存文件生成目录,以帮助浏览大型文档。

配置

目录设置

服务器智能地生成一个目录表,选择标题级别以在预算范围内最大化细节:

  • --toc-budget - 最大ToC大小(以字节为单位)(默认:4000)
  • --toc-threshold - 生成目录(ToC)所需的最小文档大小(以字节为单位,默认值:8000)

使用 npx:

{
  "mcpServers": {
    "llms-fetch": {
      "command": "npx",
      "args": ["-y", "llms-fetch-mcp", "--toc-budget", "2000", "--toc-threshold", "4000"]
    }
  }
}

已安装二进制文件:

{
  "mcpServers": {
    "llms-fetch": {
      "command": "llms-fetch-mcp",
      "args": ["--toc-budget", "2000", "--toc-threshold", "4000"]
    }
  }
}

自定义缓存目录

使用 npx:

{
  "mcpServers": {
    "llms-fetch": {
      "command": "npx",
      "args": ["-y", "llms-fetch-mcp", "/path/to/custom/cache"]
    }
  }
}

已安装二进制文件:

{
  "mcpServers": {
    "llms-fetch": {
      "command": "llms-fetch-mcp",
      "args": ["/path/to/custom/cache"]
    }
  }
}

为什么是llms.txt?

llms.txt(文件名,可翻译为“大型语言模型文件.txt”或保持原样,因为文件名通常不直接翻译) 这是一个新兴标准,旨在让网站提供针对大型语言模型(LLM)优化的文档。像FastHTML、Anthropic Docs等网站正在采用这一标准。当这些文件可用时,该服务器会自动发现并使用它们,为您呈现比HTML抓取更干净、更简洁的内容。

安装

如果你更喜欢安装而不是使用 npx:

Shell(macOS/Linux)

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/Crazytieguy/llms-fetch-mcp/releases/latest/download/llms-fetch-mcp-installer.sh | sh

PowerShell(Windows)

irm https://github.com/Crazytieguy/llms-fetch-mcp/releases/latest/download/llms-fetch-mcp-installer.ps1 | iex

Homebrew(一种在Mac OS X上使用的软件包管理器)

brew install Crazytieguy/tap/llms-fetch-mcp

npm

npm install -g llms-fetch-mcp

货物

cargo install llms-fetch-mcp

许可证

麻省理工学院(MIT)