F
Fofa MCP
作者 @nn0nkey
MCP server by nn0nkey
创建于 10/6/2025
更新于 2 months ago
README
Repository documentation and setup instructions
FOFA MCP Server
作者: nn0nkey
基于 MCP (Model Context Protocol) 的 FOFA 和 Shodan 搜索引擎服务器实现,用于快速发现互联网上暴露的主机。
✨ 功能特点
- 🔍 支持 FOFA 和 Shodan 搜索引擎
- 🎯 多种结果格式输出 (ip:port, host, ip, port)
- 🤖 与 AI 助手自然交互(支持 Cherry Studio 等 MCP 客户端)
- 🔄 支持结果数量限制
- 🛡️ 自动重试机制
- 🌐 完全兼容 MCP 协议
📦 安装
- 克隆项目
git clone https://github.com/yourusername/Fofa-MCP.git
cd Fofa-MCP
- 安装依赖
pip install -r requirements.txt
- 配置 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(可选): 限制结果数量,默认 100field(可选): 返回字段格式ip:port(默认): 返回 "IP:端口" 格式host: 返回主机名ip: 返回 IP 地址port: 返回端口号
🔑 API 密钥获取
Shodan
- 访问 Shodan 官网
- 注册账户
- 在账户设置中获取 API 密钥
FOFA
- 访问 FOFA 官网
- 注册账户
- 在个人中心获取 API 密钥(Email 和 Key)
🛠️ 技术栈
- Python 3.7+
- MCP Python SDK
- Requests
- asyncio
📄 文件说明
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 密钥
🐛 故障排除
常见问题
-
"未设置 API 密钥"错误
- 检查环境变量是否正确设置
- 确认 API 密钥有效
-
"搜索错误"
- 检查网络连接
- 验证查询语句格式
- 确认 API 配额未超限
-
MCP 连接错误
- 确认使用最新版本的
fofa_mcp.py - 检查 Python 版本 >= 3.7
- 确认所有依赖已正确安装
- 确认使用最新版本的
📜 许可证
本项目采用 MIT 许可证
👤 作者
nn0nkey
基于 projectdiscovery/uncover 项目,使用 Python 重新实现
🙏 致谢
🔗 相关链接
如果这个项目对你有帮助,欢迎 ⭐ Star!
快速设置
此服务器的安装指南
安装包 (如果需要)
uvx fofa-mcp
Cursor 配置 (mcp.json)
{
"mcpServers": {
"nn0nkey-fofa-mcp": {
"command": "uvx",
"args": [
"fofa-mcp"
]
}
}
}