网站抓取器MCP服务器
这是一个MCP(模型上下文协议)服务器,提供对网站抓取器API的访问。它使AI代理和LLM能够通过标准化工具从网站中提取干净的文本内容。
特性
- 🔧 MCP协议:基于模型上下文协议构建,实现无缝的人工智能集成
- 🌐 网页内容提取:从HTML页面中提取可读文本和元数据
- 🐳 Docker支持:使用Docker和Docker Compose轻松部署
- ⚡ 异步操作:内置FastMCP,实现高效异步处理
API文档
- 网站爬虫网站: https://pypi.org/project/beautifulsoup4/
- API文档: https://www.crummy.com/software/BeautifulSoup/bs4/doc/
可用工具
此服务器提供以下工具:
scrape_website:从任何网站URL中提取干净的文本内容scrape_website_custom_headers:使用自定义User-Agent和Referer标头抓取网站get_scraper_info:获取有关刮板机服务能力的信息
安装
使用Docker(推荐)
- 克隆此存储库:
git clone https://github.com/Traia-IO/website-scraper-mcp-server.git
cd website-scraper-mcp-server- 使用Docker运行:
./run_local_docker.sh使用Docker Compose
- 创建一个
.env使用您的配置文件:
PORT=8000- 启动服务器:
docker-compose up手动安装
- 使用安装依赖项
uv:
uv pip install -e .- 运行服务器:
uv run python -m server用法
健康检查
测试服务器是否正在运行:
python mcp_health_check.py使用CrewAI
from traia_iatp.mcp.traia_mcp_adapter import create_mcp_adapter
# Connect to the MCP server
with create_mcp_adapter(
url="http://localhost:8000/mcp/"
) as tools:
# Use the tools
for tool in tools:
print(f"Available tool: {tool.name}")
# Basic website scraping
result = await tools.scrape_website(website_url="https://example.com")
print(f"Title: {result['title']}")
print(f"Content: {result['content'][:200]}...")
# Scraping with custom headers
result = await tools.scrape_website_custom_headers(
website_url="https://example.com",
user_agent="Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15",
referer="https://www.google.com/"
)
print(f"Custom headers result: {result['title']}")
# Get service information
info = await tools.get_scraper_info()
print(f"Service: {info['service_name']}")
print(f"Features: {info['features']}")发展
测试服务器
- 在本地启动服务器
- 运行健康检查:
python mcp_health_check.py - 使用CrewAI适配器测试单个工具
添加新工具
要添加新工具,请编辑 server.py 以及:
- 为网站抓取器端点创建API客户端函数
- 添加
@mcp.tool()装饰功能 - 使用新工具更新此README
- 更新
deployment_params.json工具名称位于功能数组中
部署
部署配置
这 deployment_params.json 文件包含此MCP服务器的部署配置:
{
"github_url": "https://github.com/Traia-IO/website-scraper-mcp-server",
"mcp_server": {
"name": "website-scraper-mcp",
"description": "Web scraping service for extracting clean text content from websites. provides tools for basic scraping, custom headers support, and content metadata extraction. useful for gathering information from web pages for analysis or data collection.",
"server_type": "streamable-http",
"requires_api_key": false,
"payment_protocol": "402",
"capabilities": [
"scrape_website",
"scrape_website_custom_headers",
"get_scraper_info"
]
},
"deployment_method": "cloud_run",
"gcp_project_id": "traia-mcp-servers",
"gcp_region": "us-central1",
"tags": ["website scraper", "web scraping", "content extraction", "text extraction", "api", "mcp", "d402", "payment-protocol", "http-402"],
"ref": "main"
}重要:始终更新 capabilities 添加或删除工具时使用数组!
谷歌云运行
此服务器旨在部署在Google Cloud Run上。部署将:
- 从Dockerfile构建一个容器
- 使用指定配置部署到Cloud Run
- 暴露
/mcp客户端连接的端点
环境变量
PORT:服务器端口(默认值:8000)STAGE:环境阶段(默认:MAINNET,选项:MAINNET、TESTNET)LOG_LEVEL:日志记录级别(默认值:INFO)SERVER_ADDRESS:付款地址(IATP钱包合约)MCP_OPERATOR_PRIVATE_KEY:支付协议的操作员签名密钥MCP_OPERATOR_ADDRESS:结算验证操作员公共地址D402_TESTING_MODE:跳过测试主持人(默认值:false)D402_FACILITATOR_URL:支付服务商URL(如果启用了测试模式,则可选)D402_FACILITATOR_API_KEY:主持人API密钥(可选)DEFAULT_SETTLEMENT_TOKEN:默认结算令牌地址DEFAULT_SETTLEMENT_NETWORK:默认结算网络NETWORK:区块链网络(默认:sepolia)
故障排除
- 服务器未启动:使用以下命令检查Docker日志
docker logs - 连接错误:确保服务器在预期端口上运行
- 工具错误:检查服务器日志以获取详细的错误消息
贡献
- 分叉存储库
- 创建要素分支
- 实施新工具或改进
- 更新README和deployment_params.json
- 提交拉取请求
