RainyMCP
A network analysis MCP server providing 23 tools for packet capture, protocol analysis, and cryptographic inspection, including TLS handshake, certificate extraction, and SM2/SM3/SM4 support.
README
Rainy MCP Server
一个真正支持 AI IDE(暂不支持Antigravity)的 Rainy MCP 服务器,实现了符合 MCP (Model Context Protocol) 规范的 SSE 传输层。(由 RainyMarks 开发)
特性
- 真正的 SSE 实现:完整实现 MCP SSE 传输规范,支持 EventSource 长连接
- 会话管理:自动管理客户端会话生命周期,支持超时清理
- 异步工具调用:工具执行不阻塞主线程,结果通过 SSE 推送
- 23 个强大工具:覆盖网络抓包、TLS/SSL分析、IPSec/ISAKMP、数字证书解析等场景
- 期末考试专用:支持 SM2/SM3/SM4 国密分析,TLS握手分析,证书公钥提取等
- 零外部 MCP 依赖:完全自包含实现,无需安装
mcp包
架构
┌─────────────────┐ GET /sse ┌──────────────────┐
│ Cursor IDE │ ◄───────────────► │ SSE MCP Server │
│ (MCP Client) │ │ │
│ │ POST /messages │ - SessionMgr │
│ │ ────────────────► │ - ToolRegistry │
│ │ │ - RainyMCP │
└─────────────────┘ └──────────────────┘
│
▼
┌──────────────┐
│ tshark │
│ (Wireshark) │
└──────────────┘
前置要求
- Python 3.8+
- Wireshark (需要
tshark命令行工具)
安装 Wireshark
Windows:
- 下载安装 Wireshark
- 确保安装时勾选 "TShark" 组件
- 将 Wireshark 安装目录添加到系统 PATH(如
C:\Program Files\Wireshark)
macOS:
brew install wireshark
Linux (Ubuntu/Debian):
sudo apt install tshark
安装
# 克隆项目
git clone <repository-url>
cd Rainy_mcp
# 安装依赖
pip install -r requirements.txt
使用方法
1. 启动服务器
python rainy_mcp.py
可选参数:
python rainy_mcp.py --host 127.0.0.1 --port 3000 --tshark-path /path/to/tshark
启动成功后会显示:
服务器地址: http://127.0.0.1:3000
SSE 端点: http://127.0.0.1:3000/sse
消息端点: http://127.0.0.1:3000/messages
已注册 8 个 Rainy 工具
2. 配置 Cursor IDE
在项目根目录创建 mcp.json(或 .cursor/mcp.json):
{
"mcpServers": {
"rainy": {
"url": "http://127.0.0.1:3000/sse"
}
}
}
3. 在 Cursor 中使用
重启 Cursor 或刷新 MCP 连接后,可以直接使用 Rainy 工具:
"帮我分析这个 pcap 文件中的 HTTP 流量"
"列出所有可用的网络接口"
"提取流量包中的所有 IP 地址"
可用工具 (23个)
基础工具 (8个)
| 工具名称 | 描述 |
|---|---|
list_interfaces |
列出所有可用的网络接口 |
capture_live |
实时抓包分析,支持过滤器 |
analyze_pcap |
分析 pcap/pcapng 文件内容 |
get_protocols |
获取 tshark 支持的协议列表 |
get_packet_statistics |
获取数据包统计信息(I/O、会话、端点) |
extract_fields |
提取数据包中的特定字段 |
analyze_protocols |
分析特定协议(HTTP、TCP、DNS 等) |
analyze_errors |
分析网络错误(重传、丢包等) |
🎓 期末考试专用工具 (15个)
TLS/SSL 分析
| 工具名称 | 描述 | 考试用途 |
|---|---|---|
analyze_tls_handshake |
TLS 握手完整分析 | 🔥 提取 random 随机数、cipher_suites |
extract_certificates |
提取 TLS 证书 | 🔥 获取签名证书和加密证书 |
get_cipher_suites |
获取加密套件列表 | 🔥 找出四个 cipher suite |
IPSec/ISAKMP 分析
| 工具名称 | 描述 | 考试用途 |
|---|---|---|
analyze_ipsec |
分析 ESP/AH 协议 | IPSec 协议分析 |
analyze_isakmp |
IKE/ISAKMP 分析 | 🔥 主模式前四个包、DH公钥、证书 |
数字证书解析
| 工具名称 | 描述 | 考试用途 |
|---|---|---|
parse_certificate |
X.509 证书深度解析 | 🔥 序列号、公钥、签名值、SM3摘要 |
extract_public_key |
提取公钥 | 🔥 RSA/SM2(512bit)/ECC 公钥 |
get_signature_value |
获取签名值 | 🔥 ServerKeyExchange签名、SM2签名 |
流重组与协议分析
| 工具名称 | 描述 |
|---|---|
follow_tcp_stream |
TCP 流追踪重组 |
follow_udp_stream |
UDP 流追踪重组 |
extract_http_objects |
HTTP 对象提取 |
analyze_dns_detail |
DNS 深度分析 |
安全检测与智能摘要
| 工具名称 | 描述 |
|---|---|
detect_anomalies |
异常检测(端口扫描、可疑流量) |
generate_traffic_summary |
智能流量摘要报告 |
get_conversation_graph |
IP 通信图谱数据 |
输出控制:证书/签名相关工具(如
analyze_tls_handshake、extract_certificates、parse_certificate、extract_public_key、get_signature_value)新增参数full_output(默认 false),开启后不再截断长字段;流重组工具follow_tcp_stream/follow_udp_stream新增max_lines(默认 2000,<=0 表示不截断)。
工具详细说明
list_interfaces
列出系统上所有可用的网络接口。
// 无需参数
{}
capture_live
实时抓包分析。需要管理员/root 权限。
{
"interface": "eth0", // 必需:网络接口名称
"duration": 10, // 可选:抓包时长(秒),默认 10
"filter": "tcp port 80", // 可选:BPF 过滤器
"max_packets": 100 // 可选:最大数据包数,默认 100
}
analyze_pcap
分析已保存的 pcap 文件。
{
"file_path": "capture.pcap", // 必需:文件路径
"filter": "http", // 可选:显示过滤器
"max_packets": 100 // 可选:最大数据包数
}
extract_fields
提取特定字段并统计。
{
"file_path": "capture.pcap",
"fields": ["ip.src", "ip.dst"], // 必需:字段列表
"filter": "", // 可选:显示过滤器
"max_packets": 5000 // 可选:最大数据包数
}
analyze_errors
分析网络传输错误。
{
"file_path": "capture.pcap",
"error_type": "all", // 可选:all/malformed/tcp/retransmission/duplicate_ack/lost_segment
"max_packets": 5000
}
🎓 期末考试场景示例
第八章:TLS 分析
> "分析这个pcap中的TLS握手,找出random随机数和cipher_suites"
> "提取第一个包的随机数和第二个包选中的加密套件"
第八章:ISAKMP 分析
> "分析ISAKMP流量,找出主模式的前四个包"
> "提取IKE密钥交换中的DH公钥和证书"
第九章:数字证书分析
> "解析流量中的证书,提取公钥和签名值"
> "根据证书序列号找到对应的公钥"
第七章:SM2 签名验签
> "提取SM2签名值(r,s)和公钥,准备验签"
> "找出签名报文和签名原文"
第六章:SM3 摘要
> "从证书中提取国密SM3摘要值"
端点说明
| 端点 | 方法 | 描述 |
|---|---|---|
/ |
GET | 状态页面 |
/status |
GET | 状态页面 |
/sse |
GET | SSE 长连接端点,返回 text/event-stream |
/messages |
POST | JSON-RPC 消息接收端点 |
SSE 协议流程
1. Client ──GET /sse──────────────────────────► Server
2. Client ◄──event: endpoint, data: /messages?session_id=xxx── Server
3. Client ──POST /messages?session_id=xxx────► Server
(JSON-RPC: initialize)
4. Client ◄──event: message, data: {result}─── Server
5. Client ──POST /messages (tools/list)──────► Server
6. Client ◄──event: message, data: {tools}─── Server
7. Client ──POST /messages (tools/call)──────► Server
8. Client ◄──event: message, data: {content}─ Server
常见问题
Q: 为什么看不到网络接口?
A: 列出网络接口需要管理员权限。请以管理员身份运行 PowerShell/终端后启动服务器。
Q: Cursor 连接失败怎么办?
- 确认服务器已启动且在 3000 端口运行
- 检查
mcp.json配置是否正确(使用url而非serverUrl) - 访问 http://127.0.0.1:3000/status 确认服务器状态
- 重启 Cursor 刷新 MCP 连接
Q: tshark 命令找不到?
确保 Wireshark 已安装且 tshark 在系统 PATH 中。可以通过 --tshark-path 参数指定完整路径:
python rainy_mcp.py --tshark-path "C:\Program Files\Wireshark\tshark.exe"
技术栈
- Web 框架: Starlette (ASGI)
- 服务器: Uvicorn
- 协议: MCP over SSE (Server-Sent Events)
- 后端工具: tshark (Wireshark CLI)
许可证
MIT License
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.