使用说明
LLMs.txt生成器
一个功能强大的MCP(模型上下文协议)服务器,可以自动生成 llms.txt 和 llms-full.txt 任何网站的文件,遵循 llmstxt.org规范.
🚀 快速入门-在Cursor中安装
选项1:一键安装(推荐)
备注:一键安装要求您在本地克隆存储库。克隆后,您可以创建自己的深度链接。
-
克隆存储库:
git clone https://github.com/damionrashford/llms-txt-generator-mcp.git cd llms-txt-generator-mcp -
创建您的深度链接:
替换
/path/to/your/llms-txt-generator-mcp使用此配置中的实际路径:{ "llms-txt-generator": { "command": "python3", "args": ["/path/to/your/llms-txt-generator-mcp/server.py"], "env": { "PYTHONPATH": "/path/to/your/llms-txt-generator-mcp", "LOG_LEVEL": "INFO" }, "timeout": 60000, "initTimeout": 15000, "stderr": "inherit" } } -
生成深度链接:
- 复制上面的JSON配置
- 替换
/path/to/your/llms-txt-generator-mcp与你的实际路径 - Base64编码JSON
- 创建深度链接:
cursor://anysphere.cursor-deeplink/mcp/install?name=llms-txt-generator&config=YOUR_BASE64_CONFIG
-
点击深度链接 在Cursor中安装
选项2:手动安装
-
克隆存储库:
git clone https://github.com/damionrashford/llms-txt-generator-mcp.git cd llms-txt-generator-mcp -
设置环境:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -e . -
添加到Cursor的MCP配置:
打开
~/.cursor/mcp.json(如果不存在则创建)并添加:{ "mcpServers": { "llms-txt-generator": { "command": "python3", "args": ["/path/to/your/llms-txt-generator-mcp/server.py"], "env": { "PYTHONPATH": "/path/to/your/llms-txt-generator-mcp", "LOG_LEVEL": "INFO" }, "timeout": 60000, "initTimeout": 15000, "stderr": "inherit" } } } -
重新启动游标 加载新的MCP服务器。
🛠️ 用法
安装后,您可以使用 generate_llms_txt 光标中的工具:
支持的URL格式:
https://example.com@https://example.com(带@前缀)example.com(自动添加https://)- 本地文件路径
示例用法:
Generate LLMs.txt for https://gofastmcp.com/clients/roots
该工具将生成:
llms.txt:干净、结构化的文件llms-full.txt:包含HTML的完整内容documentation_data.json:供程序使用的结构化数据
📋 特性
- ✅ 自动页面发现:抓取网站以查找相关页面
- ✅ 灵活的URL支持:处理各种URL格式和本地文件
- ✅ 结构化输出:生成人类可读和机器可读的格式
- ✅ MCP集成:与Cursor和其他MCP客户端无缝集成
- ✅ 错误处理:强大的错误处理和详细的反馈
- ✅ 速率限制:内置速率限制,以尊重服务器
🏗️ 建筑
核心组件
server.py:使用官方MCP Python SDK的主MCP服务器src/core/generator.py:核心LLMs.txt生成逻辑src/config/config.py:配置管理src/utils/:用于内容处理和站点地图提取的实用模块
MCP服务器功能
- 单一工具:
generate_llms_txt-为任何网站生成文档 - 结构化输出:返回成功状态、页数、文件内容和输出位置
- 灵活输入:接受各种格式的URL,并自动规范化
- 临时处理:使用临时目录生成干净文件
🔧 发展
先决条件
- Python 3.8+
- pip或uv
安装
-
克隆和设置:
git clone https://github.com/damionrashford/llms-txt-generator-mcp.git cd llms-txt-generator-mcp python -m venv venv source venv/bin/activate pip install -e . -
运行服务器:
python server.py -
使用CLI进行测试:
python generate_llms_txt.py https://example.com
项目结构
llms-txt-generator-mcp/
├── server.py # Main MCP server
├── generate_llms_txt.py # Standalone CLI tool
├── generate_deeplink.py # Helper script for creating deeplinks
├── pyproject.toml # Project configuration
├── Makefile # Development commands
├── src/
│ ├── core/
│ │ └── generator.py # Core generation logic
│ ├── config/
│ │ └── config.py # Configuration management
│ └── utils/ # Utility modules
└── README.md
📦 分布
对于其他用户
为了使其他用户可以使用此功能,他们可以:
- 使用一键安装链接 (推荐)
- 手动克隆和设置 按照上面的安装说明进行操作
- 创建自己的深度链接 使用MCP配置格式
MCP配置格式
{
"llms-txt-generator": {
"command": "python3",
"args": ["/path/to/server.py"],
"env": {
"PYTHONPATH": "/path/to/project",
"LOG_LEVEL": "INFO"
},
"timeout": 60000,
"initTimeout": 15000,
"stderr": "inherit"
}
}
创建深度链接
-
准备配置:
# Create the JSON config (replace with your path) echo '{"llms-txt-generator":{"command":"python3","args":["/path/to/your/llms-txt-generator-mcp/server.py"],"env":{"PYTHONPATH":"/path/to/your/llms-txt-generator-mcp","LOG_LEVEL":"INFO"},"timeout":60000,"initTimeout":15000,"stderr":"inherit"}}' > config.json -
Base64编码:
cat config.json | base64 -
创建深度链接:
cursor://anysphere.cursor-deeplink/mcp/install?name=llms-txt-generator&config=YOUR_BASE64_OUTPUT
🙏 致谢
- llmstxt.org 对于规范
- MCP Python SDK 用于协议实现
- 光标 用于MCP客户端集成
准备好为任何网站生成LLMs.txt文件了吗?安装MCP服务器并开始记录! 🚀
