使用说明
Wireshark MCP服务器
通过 模型上下文协议 (MCP)。
适用于 任何stdio MCP主机:游标、克劳德桌面、克劳德代码、VS代码/复制副本、Windsurf、自定义代理和类似工具。没有供应商锁定——主机只需要启动:
python -m wireshark_mcp
版本0.2.2
| 文档(维基) | |
|---|---|
| 新手设置 | 安装TShark+此软件包 |
| MCP客户端 | 光标、克劳德、VS代码、通用 |
| 故障排除 | 离线服务器,PATH问题 |
| 安全 | 安全捕获规则 |
GitHub页面(可选):设置 设置→ 页面→ 来源=GitHub操作,然后 Pages 工作流发布 docs/ 作为HTML。
你得到了什么
- 通过MCP进行实时捕获和pcap/pcapng分析 工具
- 通过MCP引导工作流程 提示
- 初创公司 预检:如果缺少TShark,则进程退出,因此您的主机将显示服务器脱机/错误,而不是损坏的工具列表
setup/doctorCLIs使新用户可以配置路径而无需猜测
需求
快速启动(5分钟)
git clone https://github.com/A-G-U-P-T-A/wireshark-mcp
cd wireshark-mcp
python -m venv .venv
# Windows: .venv\Scripts\activate
# Unix: source .venv/bin/activate
python -m pip install -e .
python -m wireshark_mcp doctor
python -m wireshark_mcp setup
setup 检测TShark(或询问其路径)并写入或打印标准 mcpServers JSON块。将主机指向该配置,然后 重新加载/重新启动 主持人。
Windows Wireshark安装:
winget install --id WiresharkFoundation.Wireshark -e
MCP配置(任何主机)
{
"mcpServers": {
"wireshark": {
"command": "/absolute/path/to/.venv/bin/python",
"args": ["-m", "wireshark_mcp"],
"env": {
"TSHARK_PATH": "/absolute/path/to/tshark"
}
}
}
}
Windows示例路径:
- python
C:\\Users\\YOU\\...\\wireshark-mcp\\.venv\\Scripts\\python.exe - TShark:
C:\\Program Files\\Wireshark\\tshark.exe
现成模板: examples/mcpServers.wireshark.json
客户端特定的文件位置: docs/Clients.md
命令行界面
| 命令 | 目的 |
|---|---|
python -m wireshark_mcp |
运行MCP服务器(stdio) |
python -m wireshark_mcp doctor |
JSON依赖关系报告(退出0/1) |
python -m wireshark_mcp setup |
交互式TShark+主机配置 |
python -m wireshark_mcp setup --client print |
仅打印JSON |
项目布局
src/wireshark_mcp/ # MCP server package (tools, prompts, preflight)
examples/ # Sample mcpServers JSON
docs/ # Setup wiki for novices
tests/ # pytest (no live capture by default)
.cursor/skills/ # Optional Cursor agent skill
pyshark_mcp.py # Thin legacy shim
工具(已选择)
| 区域 | 工具 |
|---|---|
| 安装程序 | check_environment, configure_tshark |
| 捕获 | list_interfaces, quick_capture, capture_live_packets, save_capture_to_file |
| 分析 | read_pcap_file, analyze_traffic, deep_packet_analysis, quick_traffic_analysis |
| 应用程序协议 | analyze_dns_traffic, analyze_http_traffic, analyze_http_traffic_tabular |
| 诊断 | protocol_hierarchy_statistics, expert_information, filtered_packet_display |
提示和资源
提示: packet_capture_help, investigate_live_traffic, analyze_pcap_file, security_traffic_review, safe_capture_rules
资源: pyshark://version, pyshark://config (allow_simulation 总是 false)
安全
- 从分配的接口
tshark -D;外壳元字符被拒绝 - 子进程使用argv+
shell=False - 失败返回错误-- 无模拟数据包
细节: docs/Security.md
测试和CI
python -m pip install -e ".[dev]"
pytest -q -m "not live"
GitHub Actions在Ubuntu上安装TShark并运行非实时套件。
许可证
麻省理工学院
