Skip to main content
Glama
FOFA MCP Server

FOFA MCP Server

by nn0nkey

FOFA MCP Server

作者: nn0nkey

基于 MCP (Model Context Protocol) 的 FOFA 和 Shodan 搜索引擎服务器实现,用于快速发现互联网上暴露的主机。

✨ 功能特点

  • 🔍 支持 FOFA 和 Shodan 搜索引擎

  • 🎯 多种结果格式输出 (ip:port, host, ip, port)

  • 🤖 与 AI 助手自然交互(支持 Cherry Studio 等 MCP 客户端)

  • 🔄 支持结果数量限制

  • 🛡️ 自动重试机制

  • 🌐 完全兼容 MCP 协议

Related MCP server: mcp-shodan

📦 安装

  1. 克隆项目

git clone https://github.com/yourusername/Fofa-MCP.git
cd Fofa-MCP
  1. 安装依赖

pip install -r requirements.txt
  1. 配置 API 密钥

设置以下环境变量(至少需要设置一个搜索引擎的API密钥):

# Windows
set SHODAN_API_KEY=your_shodan_api_key_here
set FOFA_EMAIL=your_fofa_email_here
set FOFA_KEY=your_fofa_key_here

# Linux/Mac
export SHODAN_API_KEY=your_shodan_api_key_here
export FOFA_EMAIL=your_fofa_email_here
export FOFA_KEY=your_fofa_key_here

🚀 使用方法

在 Cherry Studio 中使用

在 Cherry Studio 的 MCP 配置中添加:

{
    "mcpServers": {
        "fofa-mcp": {
            "command": "python",
            "args": ["fofa_mcp.py"],
            "cwd": "/path/to/Fofa-MCP",
            "env": {
                "SHODAN_API_KEY": "your_shodan_api_key_here",
                "FOFA_EMAIL": "your_fofa_email_here",
                "FOFA_KEY": "your_fofa_key_here"
            }
        }
    }
}

直接运行

# Windows
start_server.bat

# Linux/Mac
./start_server.sh

# 或直接运行
python fofa_mcp.py

📝 使用示例

我想查询百度的10个ip

工具参数

  • query (必需): 搜索查询语句

  • limit (可选): 限制结果数量,默认 100

  • field (可选): 返回字段格式

    • ip:port (默认): 返回 "IP:端口" 格式

    • host: 返回主机名

    • ip: 返回 IP 地址

    • port: 返回端口号

🔑 API 密钥获取

Shodan

  1. 访问 Shodan 官网

  2. 注册账户

  3. 在账户设置中获取 API 密钥

FOFA

  1. 访问 FOFA 官网

  2. 注册账户

  3. 在个人中心获取 API 密钥(Email 和 Key)

🛠️ 技术栈

📄 文件说明

  • fofa_mcp.py - MCP 服务器主程序

  • requirements.txt - Python 依赖

  • config.json.example - Cherry Studio 配置示例

  • start_server.bat - Windows 启动脚本

  • start_server.sh - Linux/Mac 启动脚本

  • CHERRY_STUDIO_SETUP.md - Cherry Studio 详细配置说明

⚠️ 注意事项

  • 本工具仅供安全研究和合法用途使用

  • 请遵守相关法律法规和搜索引擎的使用条款

  • 建议合理使用 API 配额,避免频繁请求

  • 某些搜索结果可能需要付费 API 密钥

🐛 故障排除

常见问题

  1. "未设置 API 密钥"错误

    • 检查环境变量是否正确设置

    • 确认 API 密钥有效

  2. "搜索错误"

    • 检查网络连接

    • 验证查询语句格式

    • 确认 API 配额未超限

  3. MCP 连接错误

    • 确认使用最新版本的 fofa_mcp.py

    • 检查 Python 版本 >= 3.7

    • 确认所有依赖已正确安装

📜 许可证

本项目采用 MIT 许可证

👤 作者

nn0nkey

基于 projectdiscovery/uncover 项目,使用 Python 重新实现

🙏 致谢

🔗 相关链接


如果这个项目对你有帮助,欢迎 ⭐ Star!

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      A
      maintenance
      Gives AI agents access to Shodan's API and CVEDB for internet reconnaissance, DNS intelligence, and vulnerability analysis. Enables host and device lookups, search queries with facets, DNS resolution, and CVE/CPE intelligence with CVSS, EPSS, and KEV data.
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to perform internet reconnaissance against the Shodan API and CVEDB, covering host and port lookups, device searches with facets, DNS and subdomain queries, and CVE/CPE vulnerability intelligence with EPSS and KEV data. Also exposes plan and credit information so agents can stay aware of query costs.
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to perform internet reconnaissance through the Shodan API: looking up IP addresses and domains for open ports, banners, TLS certificates, DNS records, and searching or counting internet-connected devices with facets. It also delivers CVE/CPE vulnerability intelligence, including CVSS scores, EPSS estimates, and KEV status.
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to query the Shodan API and CVEDB for internet-connected device reconnaissance, returning open ports, banners, TLS certificates, cloud and location details, plus DNS records and subdomains. Also delivers vulnerability intelligence such as CVSS, EPSS, and KEV status for CVEs, products, and CPEs.
      MIT