这是一个从 llm.txt 文件中提取并提供上下文的模型上下文协议(MCP)服务器,使AI模型能够理解开发环境中的文件结构、依赖关系和代码关系。此服务器提供了对 LLM.txt 目录 的全面访问,支持文件列表、内容检索以及高级多查询搜索功能。
%LOCALAPPDATA%\llm-txt-mcp~/Library/Caches/llm-txt-mcp~/.cache/llm-txt-mcp最简单的安装方式是使用 MCP Get,它会自动在 Claude Desktop 中配置服务器:
npx @michaellatman/mcp-get@latest install @mcp-get-community/server-llm-txt
或者,您可以在您的 Claude Desktop 配置中手动配置服务器,通过在 claude_desktop_config.json 中添加以下内容:
{
"mcpServers": {
"llm-txt": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-llm-txt"
]
}
}
}
列出目录中所有可用的 LLM.txt 文件。结果会在本地缓存24小时。
示例响应:
[
{
"id": 1,
"url": "https://docs.squared.ai/llms.txt",
"name": "AI Squared",
"description": "AI Squared 提供一个数据和AI集成平台,帮助所有人获取智能洞察。"
}
]
通过ID(从 list_llm_txt 获取)获取 LLM.txt 文件的内容。
参数:
id: LLM.txt 文件的数字ID示例响应:
{
"id": 1,
"url": "https://docs.squared.ai/llms.txt",
"name": "AI Squared",
"description": "AI Squared 提供一个数据和AI集成平台,帮助所有人获取智能洞察。",
"content": "# AI Squared\n\n## 文档\n\n- [创建目录](https://docs.squared.ai/api-reference/catalogs/create_catalog)\n- [更新目录](https://docs.squared.ai/api-reference/catalogs/update_catalog)\n..."
}
在 LLM.txt 文件中搜索多个子字符串。
参数:
id: LLM.txt 文件的数字IDqueries: 要搜索的字符串数组(不区分大小写)context_lines(可选): 匹配前后显示的行数(默认值:2)示例响应:
{
"id": 1,
"url": "https://docs.squared.ai/llms.txt",
"name": "AI Squared",
"matches": [
{
"lineNumber": 42,
"snippet": "- [PostgreSQL](https://docs.squared.ai/guides/data-integration/destinations/database/postgresql): PostgreSQL\n popularly known as Postgres, 是一个强大的开源对象关系数据库系统,结合了许多特性,安全地存储和扩展数据工作负载。\n- [null](https://docs.squared.ai/guides/data-integration/destinations/e-commerce/facebook-product-catalog)",
"matchedLine": "- [PostgreSQL](https://docs.squared.ai/guides/data-integration/destinations/database/postgresql): PostgreSQL\n popularly known as Postgres, 是一个强大的开源对象关系数据库系统,结合了许多特性,安全地存储和扩展数据工作负载。",
"matchedQueries": ["postgresql", "database"]
}
]
}
虽然上面的例子为了清晰展示使用了字符串ID,但实际实现使用的是数字ID。我们发现,当使用字符串ID(如域名或slug)时,语言模型更容易产生看起来合理但实际上不存在的 LLM.txt 文件。使用不透明的数字ID鼓励模型首先检查可用文件列表,而不是猜测可能的ID。
要在开发模式下运行并自动重新编译:
npm install
npm run watch
MIT