MCP.tools Actor–将任何网站变成人工智能工具
   
使用MCP(模型上下文协议)工具将任何网站转换为AI工具。此Apify Actor自动从网页中提取交互式元素,并生成可与Cursor、Claude和其他AI助手一起使用的MCP兼容的工具定义。
🚀 特性
- 🎯 交互式元素提取:自动查找按钮、输入、下拉菜单和链接
- 🍪 Cookie横幅删除:删除OneTrust、Cookiebot和其他常见的cookie横幅
- 🔧 MCP工具生成:创建具有安全名称和描述的MCP兼容工具定义
- 📸 视觉预览:使用一键集成按钮生成漂亮的预览页面
- 🛡️ 错误处理:自动截图和错误记录
- 📊 结构化输出:干净的JSON格式已准备好进行MCP集成
📋 示例输入
{
"url": "https://example.com",
"cookies": [
{"name": "session_id", "value": "abc123"}
],
"removeBanners": true,
"maxActions": 50
}输入参数
- 网址 (必填):要处理的网站URL
- 饼干 (可选):为经过身份验证的页面设置的Cookie列表
- 移除横幅 (默认值:
true):自动删除cookie同意横幅 - 最大动作 (默认值:
50,分钟:5,最大值:200):要提取的交互元素的最大数量
📤 示例输出
actor生成三个输出:
1.MCP工具JSON(mcp-{id}.json)
{
"tools": [
{
"name": "button_submit_form",
"description": "Click the Submit Form button",
"input_schema": {
"type": "object",
"properties": {
"selector": {
"type": "string",
"description": "CSS selector for the Submit Form button",
"default": "#submit-btn"
}
},
"required": ["selector"]
}
},
{
"name": "input_username",
"description": "Enter text in the Enter username input field",
"input_schema": {
"type": "object",
"properties": {
"selector": {
"type": "string",
"description": "CSS selector for the Enter username input field",
"default": "#username"
}
},
"required": ["selector"]
}
}
]
}2.数据集记录
{
"mcpJsonUrl": "https://api.apify.com/v2/key-value-stores/.../records/mcp-abc123.json",
"previewUrl": "https://api.apify.com/v2/key-value-stores/.../records/preview-abc123.html",
"screenshotUrl": "https://api.apify.com/v2/key-value-stores/.../records/screenshot-abc123.png",
"toolCount": 12,
"url": "https://example.com",
"runId": "abc123",
"actionsCount": 12
}3.预览HTML页面
一个漂亮的预览页面,包括:
- 📊 统计仪表板(工具计数、操作计数、运行ID)
- 🚀 用于Cursor和Claude集成的一键按钮
- 📋 显示所有提取元素的视觉动作卡
- 🔧 打印精美的MCP JSON,便于检查
💰 定价
每次0.03美元 -将网站转化为人工智能工具的实惠定价。
🛠️ 安装
本地开发
- 克隆存储库:
git clone
cd mcp-website-tool- 安装依赖项:
pip install -e ".[dev]"- 安装Playwright浏览器:
playwright install chromium运行测试
pytest📖 用法
通过Apify平台
- 首选 Apify控制台
- 查找 MCP.tools演员
- 使用目标URL配置输入
- 运行并获取您的MCP工具JSON!
通过API
curl -X POST "https://api.apify.com/v2/acts/YOUR_ACTOR_ID/run-sync" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"maxActions": 50
}'🏗️ 项目结构
├── src/
│ ├── main.py # Main Actor entry point
│ ├── types.py # Pydantic models for validation
│ ├── browser.py # Playwright browser management
│ ├── extractor.py # Interactive element extraction
│ ├── mcp_generator.py # MCP tools generation
│ └── utils.py # Utility functions
├── tests/ # Comprehensive test suite
├── input_schema.json # Apify input schema
├── apify.json # Apify actor configuration
└── README.md # This file🔧 发展
代码质量
black src tests
ruff check src tests
mypy src
pytest测试驱动开发
本项目遵循TDD原则:
- 编写失败的测试(红色)
- 实现最小代码(绿色)
- 在保持测试通过的同时进行重构
📦 依赖项
- 芹菜:为actor开发指定SDK
- 剧作家:浏览器自动化框架
- 皮丹提克:使用Python类型注释进行数据验证
- 结构日志:结构化日志记录
📝 许可证
MIT许可证-有关详细信息,请参阅许可证文件
🤝 贡献
欢迎投稿!请按照以下步骤操作:
- 复刻仓库
- 创建要素分支
- 先写测试(TDD)
- 实现该功能
- 确保所有测试通过
- 提交拉取请求
📞 支持
有关问题和疑问,请在存储库上打开一个问题。
______________________________________________________________________
由...制作❤️ 对于AI社区
