内容
# 火爬虫多密钥MCP服务器
一款内置支持多API密钥的火爬虫MCP服务器。它向OpenCode和其他MCP客户端公开火爬虫的网页搜索、抓取、爬取、提取、浏览器交互、监控和研究工具。
此分支在需要单个本地火爬虫MCP服务器跨多个API密钥轮换时非常有用,而不是配置多个单独的MCP服务器条目。
## 亮点
- 默认本地`stdio`MCP服务器
- 可选的流式HTTP传输,用于托管或本地HTTP使用
- 使用`FIRECRAWL_API_KEYS`进行多密钥轮换
- 使用`FIRECRAWL_API_KEY`进行单密钥备用
- 进程本地轮询密钥选择
- 在重试的火爬虫错误中,跨池密钥重试/故障转移
- 支持火爬虫云和自托管API
- 使用`tsup`捆绑TypeScript源代码
## 要求
- Node.js 22或更高版本
- pnpm
- 一个或多个火爬虫API密钥
- OpenCode或其他兼容MCP的客户端
## 安装
```bash
git clone https://github.com/AdvaitR7/firecrawl-mcp-multiple-keys.git
cd firecrawl-mcp-multiple-keys
pnpm install
pnpm run build
```
构建过程创建`dist/index.js`。MCP客户端应使用Node.js运行该文件。
## 配置API密钥
对于多个密钥,设置`FIRECRAWL_API_KEYS`为逗号分隔或空格分隔的列表:
```bash
FIRECRAWL_API_KEYS=firecrawl_key_1,firecrawl_key_2
```
对于单个密钥,设置`FIRECRAWL_API_KEY`:
```bash
FIRECRAWL_API_KEY=firecrawl_key_1
```
`FIRECRAWL_API_KEYS`优先于`FIRECRAWL_API_KEY`,除非设置了`FIRECRAWL_OAUTH_TOKEN`。
## 密钥轮换行为
在启动时,服务器将`FIRECRAWL_API_KEYS`加载到进程本地密钥池中。使用该池的每个请求都从序列中的下一个密钥开始。
```text
请求 1 -> 密钥 1
请求 2 -> 密钥 2
请求 3 -> 密钥 1
请求 4 -> 密钥 2
```
对于可重试的失败,例如`429`、`5xx`、超时或网络错误,支持的读取样式操作可以尝试在当前循环中剩余的密钥。变异操作更为保守,以避免重复作业。
头部凭证和`FIRECRAWL_OAUTH_TOKEN`绕过环境密钥池。
## OpenCode设置
首先构建项目:
```bash
pnpm install
pnpm run build
```
在OpenCode配置中添加本地MCP条目。使用到`dist/index.js`的绝对路径。
多密钥配置:
```json
{
"mcp": {
"firecrawl": {
"type": "local",
"command": ["node", "/absolute/path/to/firecrawl-mcp-multiple-keys/dist/index.js"],
"enabled": true,
"timeout": 30000,
"environment": {
"FIRECRAWL_API_KEYS": "firecrawl_key_1,firecrawl_key_2"
}
}
}
}
```
单密钥配置:
```json
{
"mcp": {
"firecrawl": {
"type": "local",
"command": ["node", "/absolute/path/to/firecrawl-mcp-multiple-keys/dist/index.js"],
"enabled": true,
"timeout": 30000,
"environment": {
"FIRECRAWL_API_KEY": "firecrawl_key_1"
}
}
}
}
```
在更改MCP配置后重启OpenCode。
## 环境变量
| 变量 | 是否必需 | 描述 |
| --- | --- | --- |
| `FIRECRAWL_API_KEYS` | 否 | 用于轮询轮换的逗号或空格分隔的API密钥 |
| `FIRECRAWL_API_KEY` | 否 | 单个火爬虫API密钥备用 |
| `FIRECRAWL_OAUTH_TOKEN` | 否 | 用于stdio使用的静态火爬虫OAuth访问令牌 |
| `FIRECRAWL_API_URL` | 否 | 自托管实例的自定义火爬虫API URL |
| `HTTP_STREAMABLE_SERVER` | 否 | 设置为`true`以使用流式HTTP传输 |
| `SSE_LOCAL` | 否 | 设置为`true`以使用本地HTTP流行为 |
| `CLOUD_SERVICE` | 否 | 设置为`true`以实现托管云服务行为 |
| `PORT` | 否 | HTTP传输端口,默认为`3000` |
| `HOST` | 否 | HTTP传输主机,默认为云模式以外的`localhost` |
## 传输模式
默认情况下,服务器在stdio上启动:
```bash
FIRECRAWL_API_KEYS=firecrawl_key_1,firecrawl_key_2 node dist/index.js
```
用于本地流式HTTP传输:
```bash
HTTP_STREAMABLE_SERVER=true FIRECRAWL_API_KEY=firecrawl_key_1 node dist/index.js
```
stdio服务器的直接终端执行将等待MCP协议输入。对于正常使用,请通过OpenCode或其他MCP客户端运行它。
## 工具
### 核心火爬虫工具
| 工具 | 描述 |
| --- | --- |
| `firecrawl_scrape` | 使用markdown、JSON、HTML、截图或其他格式抓取单个URL |
| `firecrawl_map` | 在网站上发现URL |
| `firecrawl_search` | 搜索网页、新闻、图片、GitHub、研究或PDF |
| `firecrawl_search_feedback` | 发送以前的火爬虫搜索结果的反馈 |
| `firecrawl_feedback` | 为抓取、解析、映射或搜索作业发送通用端点反馈 |
| `firecrawl_crawl` | 从站点或部分抓取多个页面 |
| `firecrawl_check_crawl_status` | 检查现有抓取作业状态 |
| `firecrawl_extract` | 从一个或多个URL中提取结构化数据 |
| `firecrawl_agent` | 启动自主网页研究代理作业 |
| `firecrawl_agent_status` | 轮询代理作业直到完成 |
| `firecrawl_interact` | 在浏览器会话中与网页交互 |
| `firecrawl_interact_stop` | 停止交互会话 |
| `firecrawl_parse` | 解析上传或本地文档,包括PDF |
### 监控工具
| 工具 | 描述 |
| --- | --- |
| `firecrawl_monitor_create` | 为页面或搜索创建循环监控 |
| `firecrawl_monitor_list` | 列出监控 |
| `firecrawl_monitor_get` | 通过ID获取监控 |
| `firecrawl_monitor_update` | 更新监控设置 |
| `firecrawl_monitor_delete` | 删除监控 |
| `firecrawl_monitor_run` | 立即触发监控检查 |
| `firecrawl_monitor_checks` | 列出历史监控检查 |
| `firecrawl_monitor_check` | 检查一次监控检查及其页面差异 |
### 研究工具
| 工具 | 描述 |
| --- | --- |
| `firecrawl_research_search_papers` | 按主题搜索研究论文 |
| `firecrawl_research_inspect_paper` | 获取论文的元数据 |
| `firecrawl_research_related_papers` | 通过引用图相似性从种子论文扩展 |
| `firecrawl_research_read_paper` | 为一篇论文读取相关的全文段落 |
| `firecrawl_research_search_github` | 搜索GitHub问题、拉取请求和自述文件 |
## 开发
安装依赖项:
```bash
pnpm install
```
构建:
```bash
pnpm run build
```
测试:
```bash
pnpm test
```
检查代码:
```bash
pnpm run lint
```
格式化:
```bash
pnpm run format
```
运行编译后的stdio服务器:
```bash
FIRECRAWL_API_KEYS=firecrawl_key_1,firecrawl_key_2 pnpm start
```
## 安全
永远不要在源文件、自述文件示例、截图、问题或提交中放置真实的火爬虫API密钥。将密钥保存在MCP客户端环境配置、shell环境或本地`.env`文件中,不要提交。
如果密钥被泄露,请在火爬虫中吊销它并创建一个替换密钥。
## 许可证
MIT