About Crawl4ai Middleware
Crawl4ai Middleware connects crawl4ai web-scraping tasks to MCP-compatible applications. It provides tools to launch crawls, retrieve results, and manage saved result files.
Key features
- 01Create web-crawl tasks
- 02Retrieve results by task ID
- 03Save crawl results locally
- 04List and read saved result files
Use cases
- 01Fetching a webpage through an MCP-compatible app
- 02Reviewing full crawl output from locally saved files
MCP support
The MCP server exposes crawl task creation, result retrieval, and saved-file management as tools for MCP clients.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMECrawl4AI MCP 服务器
这是一个MCP(模型上下文协议)服务器,用于将crawl4ai的网页抓取功能集成到支持MCP的应用程序中,如Cursor IDE。
功能
该服务器提供以下工具:
create_crawl_task- 创建网页抓取任务并获取任务IDget_crawl_result- 根据任务ID获取抓取结果并保存到本地文件list_saved_results- 列出已保存的抓取结果文件read_saved_result- 读取已保存的抓取结果文件内容。
文件存储
所有抓取的网页内容会保存在服务器脚本同级目录下的 url 文件夹中,文件命名格式为:
extracted_域名_任务ID_时间戳.txt
这样可以避免因内容过大导致的显示问题,并可随时查看完整抓取结果。
安装依赖
pip install mcp[cli] httpx python-dotenv
配置
默认配置
服务器默认配置为:
- API地址:http://192.168.31.12:11235/
- API密钥:sk-3180623
环境变量配置
你可以通过以下两种方式配置环境变量:
-
创建.env文件
在与
crawl4ai_server.py同一目录下创建一个名为.env的文件,内容如下:CRAWL4AI_API_BASE=http://192.168.31.12:11235 CRAWL4AI_API_KEY=sk-3180623 OUTPUT_DIR= LOG_LEVEL=INFO注意:确保.env文件使用UTF-8编码保存,不要包含BOM头。
-
设置系统环境变量
你也可以直接在操作系统中设置以下环境变量:
CRAWL4AI_API_BASE- API服务器地址CRAWL4AI_API_KEY- API密钥OUTPUT_DIR- 自定义输出目录(可选)LOG_LEVEL- 日志级别(可选,默认INFO)
在Cursor中使用
-
确保已安装所需依赖项
-
修改Cursor的配置文件,路径通常为:
- Windows:
%APPDATA%\Cursor\User\settings.json
- Windows:
-
在配置文件中添加以下内容:
{
"mcpServers": {
"crawl4ai": {
"command": "python",
"args": [
"E:/APP/craw14ai-middleware/crawl4ai_server.py"
]
}
}
}
- 重启Cursor以加载MCP服务器
使用示例
在Cursor中,你可以让AI助手使用这些工具:
- "请帮我抓取网页 https://example.com"
- "请获取任务ID为 abc123 的抓取结果"
- "请列出已保存的抓取结果文件"
- "请读取文件 extracted_example_com_abc123.txt 的内容"
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.