PCAP MCP Server
Enables Wireshark-like PCAP analysis through tshark, providing tools for filtering packets, extracting protocol fields, drilling down into frames, session tracking, and timeline analysis for troubleshooting 5G, IMS/SIP, and network protocol issues.
README
pcap-mcp
基于 tshark/Wireshark dissector 的 PCAP 分析 MCP Server。
它把 Wireshark 常用的工作流(Display Filter 检索、字段抽取/时间线、按帧下钻、会话跟踪、导出 Packet List)封装为一组结构化 MCP tools,方便智能体/脚本按“像 Wireshark 一样”的方式自动化排障。
适用场景
- 5G 核心网/无线侧信令排障:NGAP/NAS-5GS/PFCP/GTPv2/GTP
- IMS/SIP 呼叫问题排查:SIP + Rx(Diameter) + SBI(HTTP2)
- QoS/策略问题:Rx AAR/AAA、PCF /npcf*、SMF 下发 packet filter 与 UE reject 的因果链
依赖
- Python:
>=3.10 - 系统工具:
tshark(必须)、capinfos(建议,通常随 wireshark 安装)
安装
pip install -r requirements.txt
如需以本地源码方式使用:
pip install -e .
启动
python3 -m pcap_mcp
或使用脚本入口:
pcap-mcp
配置
默认会尝试读取仓库根目录的 pcap_mcp_config.json。也可以通过环境变量指定:
PCAP_MCP_CONFIG_JSON=/abs/path/to/pcap_mcp_config.json
常用配置项(见 pcap_mcp_config.json):
allowed_pcap_dirs: 允许分析的 PCAP 目录白名单allow_any_pcap_path: 是否允许任意绝对路径 PCAP(默认 false,建议保持关闭)global_decode_as: 全局tshark -d规则(例如把某端口按 http2 解码)profiles: 常用 display filter / decode-as 组合packet_list_columns: Packet List 导出列模板(用于 Diameter/HTTP2/SIP 跟踪字段)
MCP Tools(已实现)
pcap_config_get- 获取当前加载的配置快照(profiles、packet_list_columns 等)
pcap_config_reload- 重新加载配置文件(无需重启 server)
pcap_list_fields- 字段发现:等价
tshark -G fields的可搜索封装
- 字段发现:等价
pcap_info- 抓包摘要:包数/时间范围/sha256/tshark 版本/是否包含常见协议等
pcap_frames_by_filter- 输入 display filter,返回匹配的 frame.number 列表(分页)
pcap_timeline- 输入 display filter + fields,返回“时间线表格”(分页)
pcap_frame_detail- 指定帧下钻:
restrict_layers=true+layers=[...]:只输出指定协议树(更像“只看关心层”)restrict_layers=false:输出完整协议树(等价 Wireshark 全量下钻)verbosity=full:额外输出十六进制(tshark -x)max_bytes:截断保护
- 指定帧下钻:
pcap_text_search- 在过滤后的帧集合里做文本搜索(内部会抓 detail 形成 snippet)
pcap_follow- 会话跟踪:从指定帧提取并生成 follow filter(例如 HTTP2 streamid / Diameter Session-Id / SIP Call-ID)
pcap_packet_list- 导出类似 Wireshark Packet List 的 TSV 文件,并返回预览行
推荐工作流(Wireshark-like)
pcap_info:确认抓包概况、协议是否齐全pcap_packet_list:先导出一个“全局 Packet List”,观察主要协议与时间窗pcap_frames_by_filter:对关键协议/错误码做一次定位(例如sip.Status-Code==580、diameter.cmd.code==265、http2.headers.path contains "npcf")pcap_frame_detail:对关键帧下钻(必要时restrict_layers=false+verbosity=full)pcap_follow:用 SIP Call-ID / Diameter Session-Id / HTTP2 streamid 串起完整会话pcap_timeline:抽关键字段形成“可读的时间线”并对齐多协议因果关系
示例(以工具调用参数为主)
1)按 SIP 580 定位并下钻
pcap_frames_by_filter
{
"pcap_path": "/home/ailink/code/mcp/test_iphone_call_jx-1230.pcap",
"display_filter": "sip && sip.Status-Code==580",
"limit": 50,
"offset": 0
}
pcap_frame_detail(全量下钻)
{
"pcap_path": "/home/ailink/code/mcp/test_iphone_call_jx-1230.pcap",
"frame_numbers": [3470],
"restrict_layers": false,
"verbosity": "full",
"max_bytes": 400000
}
2)查看 Rx AAR(cmd.code==265)里下发的 Flow-Description
{
"pcap_path": "/home/ailink/code/mcp/test_iphone_call_jx-1230.pcap",
"display_filter": "diameter && diameter.cmd.code==265",
"columns_profile": "rx_compact",
"preview_rows": 50
}
3)查询 PCF Npcf 信令
{
"pcap_path": "/home/ailink/code/mcp/test_iphone_call_jx-1230.pcap",
"display_filter": "http2 && http2.headers.path contains \"npcf\"",
"limit": 200,
"offset": 0
}
输出文件
- Packet List 导出默认写到:
pcap_mcp_config.json的output_dir - 文件名形如:
<pcap_stem>.packet_list.<UTC_TIMESTAMP>.tsv
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.