fofa-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
fofa-mcp
FOFA 网络空间搜索引擎的 MCP 服务,Node.js 实现(TypeScript),移植自 keyblues/fofa-skills。内置 SQLite 缓存、F 点预算守卫、1 req/s 限流与审计日志,支持 stdio 与 Streamable HTTP 两种传输。
使用预构建镜像
docker pull ghcr.io/fb0sh/fofa-mcp:latest多架构(linux/amd64、linux/arm64),标签:latest(main 分支)、main、v*(打 tag 时同时生成 1.0.0 / 1.0)。
从源码构建:
docker build -t fofa-mcp:local .Related MCP server: SecOps-MCP-Server
方式一:stdio(Claude Desktop / Cursor 等本地 MCP 客户端)
{
"mcpServers": {
"fofa": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "FOFA_KEY=你的32位KEY",
"-e", "FOFA_BASE_URL=https://fofa.info/api/v1",
"-v", "fofa-data:/data",
"ghcr.io/fb0sh/fofa-mcp:latest"
]
}
}
}MCP_TRANSPORT默认就是stdio,无需额外参数。-v fofa-data:/data让 SQLite 缓存在容器重建后仍然保留;不挂载则每次--rm都会丢缓存。用目录 bind mount 时,容器以 uid 1000(
node)运行,宿主机目录需对该 uid 可写;不想处理权限就用上面的命名卷。
方式二:Streamable HTTP
docker run -d --name fofa-mcp \
-p 8080:8080 \
-e MCP_TRANSPORT=http \
-e FOFA_KEY=你的32位KEY \
-e MCP_AUTH_TOKEN=换成一个随机token \
-v fofa-data:/data \
ghcr.io/fb0sh/fofa-mcp:latestMCP 端点:
http://127.0.0.1:8080/mcp,健康检查:http://127.0.0.1:8080/healthz客户端配置(支持 HTTP 的 MCP 客户端):
{
"mcpServers": {
"fofa": {
"type": "http",
"url": "http://127.0.0.1:8080/mcp",
"headers": { "Authorization": "Bearer 换成一个随机token" }
}
}
}设置了
MCP_AUTH_TOKEN后,未携带正确Authorization: Bearer <token>的请求返回 401。MCP_TRANSPORT=both可在同一进程里同时提供 stdio 和 HTTP。HTTP 模式默认绑定
0.0.0.0(容器内需要),暴露到公网前请务必设置MCP_AUTH_TOKEN并在反向代理上启用 TLS。绑定非 localhost 时不自动做 Host 头校验;需要 DNS rebinding 防护就设置
MCP_ALLOWED_HOSTS(例如MCP_ALLOWED_HOSTS=mcp.example.com,127.0.0.1),不在白名单的 Host 返回 403。
环境变量
变量 | 默认 | 说明 |
| 空 | FOFA API Key(32 位 hex);仅用缓存工具可不填 |
|
| API 基地址 |
|
|
|
|
| HTTP 监听地址 |
|
| HTTP 监听端口(兼容 |
|
| HTTP 上的 MCP 路径 |
| 空 | HTTP 静态 Bearer Token;为空则不校验 |
| 空 | HTTP Host 头白名单(逗号分隔);为空不限制 |
|
| SQLite 缓存路径 |
|
| F 点预算持久化状态 |
| 空 | 会话 F 点预算;设置后翻页按累计估算消耗放行 |
|
| 全局放开翻页限制(仍会消耗 F 点) |
工具(14 个)
工具 | 免费 | 说明 |
| ✓ | 账号信息(邮箱、VIP、F 点余额),缓存 5 分钟 |
| page=1 免费 | 搜索资产,返回总数 + 前 20 条预览,整页落库 |
| ✓ | 按字段聚合统计,用于评估查询规模 |
| ✓ | 单个 IP/域名的资产详情( |
| ✓ | 按 |
| ✓ | 列出缓存查询(找回 hash,避免重复付费搜索) |
| ✓ | 给已缓存查询补打/清除 tag |
| ✓ | 删除单个缓存查询 |
| ✓ | 清理 N 天前的缓存 |
| ✓ | 缓存行数统计 |
| ✓ | 多查询按字段去重/交集,输出重叠矩阵 |
| ✓ | 汇总暴露面报告(端口/国家/协议分布、高危端口、后台面板) |
| ✓ | 查看审计日志 |
| ✓ | 清理 N 天前的审计日志 |
F 点预算守卫
默认只允许
page=1(零 F 点消耗)。page>1默认硬阻断(错误码 2001);只有以下任一条件才放行:调用方显式传
allow_fpoints=true(应在用户明确授权预计消耗后);进程环境设置
FOFA_ALLOW_FPOINTS=true;设置了
FOFA_FPOINTS_BUDGET=N,按累计估算消耗校验。
预算模式会把已消耗量持久化到
FOFA_FPOINTS_STATE,请求失败自动退回预留额度。
缓存与一致性
缓存键:
SHA-256(query|fields|full|page|size),只做精确匹配(与 Python 版一致)。TTL:
full=false24 小时,full=true7 天;cache_read对过期数据仍返回并置cache_expired=true。数据库表结构与 Python 版相同(
query_cache/query_result/info_cache/host_cache/audit_log),可直接复用旧库文件。
发布
推送
main或打v*tag 会触发.github/workflows/docker.yml:先跑npm run build+ stdio/HTTP 离线 smoke,再构建 linux/amd64 + linux/arm64 并推送到 GHCR。仓库为 Public,因此 GHCR 包可直接匿名拉取;若改为 Private,需在 GitHub 包设置里调整可见性并
docker login ghcr.io。
本地开发与验证
npm ci
npm run build
npm run smoke # stdio 全流程(离线 mock FOFA,无需真实 KEY)
npm run smoke:http # Streamable HTTP 全流程要求 Node.js 24+(使用内置 node:sqlite)。
本地运行:
FOFA_KEY=xxx npm start # stdio
MCP_TRANSPORT=http MCP_PORT=8080 FOFA_KEY=xxx npm start与 Python 版的差异
以 MCP 工具替代 CLI 子命令,参数语义保持一致(
fields/page/size/full/allow_fpoints/tag)。输出为 JSON(
content.text,同时提供structuredContent);不再输出__fofa__标记。不自动读取
.env文件,请通过进程环境或docker run --env-file注入。数据库使用 Node 内置
node:sqlite,无需原生编译依赖。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Guarded MCP server for agent-readable business truth, provenance, readiness, and discovery.
ZEN SecDB MCP server for CVE intelligence, CVSS/EPSS scoring, advisories, SSVC, and package audits.
A paid remote MCP for CLI tool MCP, built to return verdicts, receipts, usage logs, and audit-ready
Related MCP Servers
- AlicenseAqualityDmaintenanceA production-ready foundation for building secure, observable MCP servers with built-in authentication, rate limiting, and reference tools like database-query and semantic-search.15MIT
- FlicenseNot gradedqualityDmaintenanceEnterprise MCP server for Google SecOps (Chronicle) SIEM/SOAR, enabling alert triage, UDM telemetry search, YARA-L detection rule management, log ingestion, and parser administration via Streamable HTTP.-
- AlicenseNot gradedqualityAmaintenanceEnables authorized penetration testers to run reconnaissance, scanning, brute-force, exploitation, traffic capture, wordlist generation, and client-report workflows through MCP clients, with stdio/HTTP/SSE transport and OIDC bearer authentication.157 npmGPL 3.0
- AlicenseNot gradedqualityAmaintenanceEnables professional penetration testers to run reconnaissance, exploitation, brute-force, traffic-capture, and reporting workflows through MCP tools over STDIO/HTTP/SSE transports with bearer/OIDC authentication and Dockerized host tooling.157 npmGPL 3.0