
tshark-mcp
io.github.Kx96xx由 GitHub 账号 Kx96xx 发布v0.2.0更新于 Nov 5, 2026
Read-only packet capture analysis with tshark: Diameter, GTP, SIP, RTP, SIGTRAN, DNS, TCP and TLS.
概览
只读的 MCP 服务器,用 tshark 分析本机抓包文件,让助手带帧号解释失败的通话、附着和会话。
- 可以做什么
- 对未知抓包做总体研判:排序后的发现、抓包质量与元数据检查,以及工作与故障抓包的对比
- 查看数据包:按显示过滤器取字段、单帧完整解析、专家告警、会话统计、字段与过滤器查询
- 分析电信信令:Diameter、GTP、PFCP、SIP、SIGTRAN/MAP、NAS 与 IMS 注册、短信投递、原因码查询
- 检查语音与媒体:SIP 对话、通话 KPI 与话段、SDP 与实际 RTP 对照、抖动与 MOS、DTMF
- 诊断 IP 传输:TCP 健康与连接、DNS、TLS/QUIC 握手、HTTP 时延、ICMP 错误、隧道
- 跨协议追踪单个用户,在抓包目录中查找标识,并可选地把过滤后的子集导出为新的 pcapng
- 适用场景
- 当你手上有移动核心网、IMS 或 IP 网络的 pcap 文件,想让助手回答附着为何失败、为何单向音频、数据会话为何变慢等问题,又不想给它 shell 和原始 tshark 时适用。
- 运行要求
- 以 stdio 方式在本机运行 PyPI 包 tshark-mcp-server,可用 uvx 或 pipx;需要 Python 3.10+ 和 tshark 4.0 或更新版本(在 PATH 中或由 TSHARK_MCP_TSHARK 指定)。必须设置 TSHARK_MCP_ALLOW_DIRS(或 --allow-dir)指明可读取的抓包目录。也提供 Docker 镜像。
安装
在 SourceWeft 中
- 打开 控制台中的 tshark-mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
tshark-mcp
[CI] [PyPI] [Downloads] [Python 3.10 to 3.13] [Licence MIT]
Ask your AI assistant why a call, an attach or a session failed, and get the answer from
your own pcap, with frame numbers. tshark-mcp is a read-only MCP server: it runs
tshark -r on captures in directories you allow, pairs requests with answers across Diameter,
GTP, SIP/RTP, SIGTRAN, DNS, TCP and TLS, and names the cause codes.
(needs uv and tshark; other clients below)
[A real MCP client session: sip_dialogs and media_path_check on the one-way audio example]
A live session, not a mock-up: an MCP client starts the PyPI package over stdio and calls two tools on examples/sip_one_way_audio.pcap. Recorded with vhs from docs/media/demo.tape.
Why
- Telecom captures need correlation, not grep. A failed attach, a dropped bearer or one-way audio spans Diameter, GTP, SIP, RTP and MAP. The tools pair requests with answers, name the result codes (Diameter 5420, GTP cause 78, Q.850 cause 16) and say what never got a reply.
- An agent with a shell and tshark is a liability. This server can only run
tshark -r <file>on files inside directories you allow, under hard caps on size, packets, output and time. It cannot capture, resolve names or load code, and it writes nothing unless the operator turns onexport_subsetwith--export-dir. - It tells you when the capture itself cannot be trusted: duplicate packets from a SPAN session, bytes the capture missed, cut-short frames, checksum offload, clocks that run backwards.
Install and connect
-
Install tshark (it comes with Wireshark):
brew install --cask wireshark,apt-get install tsharkordnf install wireshark-cli. -
Run the server from PyPI with uv (nothing to install; Python 3.10 or newer):
Or install it once and use the
tshark-mcpcommand:uv tool install tshark-mcp-serverorpipx install tshark-mcp-server.Requirements: Python 3.10+, tshark 4.0 or newer (tested with 4.2 and 4.6); the
mcp(2.1+) andpydantic(2.12+) packages are installed automatically. The package is published astshark-mcp-server(the PyPI nametshark-mcpbelongs to an unrelated project); the command staystshark-mcp. From a clone:uv tool install .orpipx install ..Or build the container (tshark included, non-root, captures mounted read-only):
docker build -t tshark-mcp ., then usedocker run --rm -i --read-only --tmpfs /tmp --cap-drop ALL --network none -v /path/to/pcaps:/captures:ro tshark-mcpas the server command. -
Connect a client, naming the directory that holds your captures.
Claude Code:
Or as a Claude Code plugin (the server plus seven investigation skills; needs
uv), which asks for the capture directory and redaction when enabled:Claude Desktop as an extension:
python mcpb/build.py && npx -y @anthropic-ai/[email protected] pack build/mcpb build/tshark-mcp.mcpb, then openbuild/tshark-mcp.mcpband pick the capture directories.Claude Desktop (
claude_desktop_config.json), Cursor, or any client that starts stdio servers:With
uv tool installorpipx, use"command": "tshark-mcp"and drop the first three args.MCP Registry clients (VS Code and the directories that index the registry) find it as
io.github.Kx96xx/tshark-mcp: they run the PyPI package withuvxand ask forTSHARK_MCP_ALLOW_DIRS, the one required setting. Each GitHub release publishes the new version there (server.json).To run it by hand:
tshark-mcp --allow-dir /path/to/pcaps [--allow-dir /more] [--log-file ~/tshark-mcp.jsonl].TSHARK_MCP_ALLOW_DIRS(colon-separated) works instead of the flag. Three small synthetic captures to start with are in examples/.
Found a bug or a wrong answer?
- A wrong or misleading answer: open a Wrong answer issue with the tool call, the output excerpt, what you expected and the plain tshark command that shows it.
- A crash or error: open a Bug issue with the tool call, the error, and your tshark, Python and OS versions.
- A security problem: report it privately through GitHub private vulnerability reporting (SECURITY.md), not in an issue.
- Questions: Discussions.
Never attach a capture with real subscriber data (IMSI, MSISDN, IMEI, IP addresses) to a public
issue. Share the tool call and its output, and if a capture is needed, a minimal synthetic or
anonymised one (--redact ids+ips masks identifiers in the output, not in the file).
What you can ask it
Start with "What is wrong in this capture?": the assistant calls incident_summary, which runs
every check the capture's protocols allow and returns ranked findings with frame numbers and the
next call to make, plus the protocols it has no check for. Then ask the specific question:
- "Which capture in this directory mentions IMSI 001010123456789, and when?"
- "Why did this subscriber's attach fail?" (Diameter result codes and the AVPs behind them)
- "Was the GTP session created? What cause came back, and which PAA?"
- "What is our ASR to this destination, and did post-dial delay go up?"
- "Why is there one-way audio on this call?"
- "What was the call quality: loss, jitter, MOS?"
- "Why can't this UE register on IMS?" and "Where did the SMS go?"
- "Is this a purge storm? How often is the MME looping?"
- "Where does the failing capture first differ from the working one?"
- "Which DNS resolver is failing, and for which names?"
- "Is the upload slow because of the network, the server or the receiver?"
- "Can I trust the loss numbers in this file at all?"
- "What does Experimental-Result 5420 mean, and which spec section do I quote?"
One real answer, trimmed. The capture is
examples/sip_one_way_audio.pcap: a SIP call where the
called side never sends media. The agent finds the Call-ID with sip_dialogs, then calls:
The caller's RTP arrived exactly where the SDP answer asked for it and nothing came back,
so the fault is behind the media gateway, not the caller's NAT or codec. Every row carries
frame numbers (first_frame: 6), so packet_detail can show the packet behind any claim.
More worked examples, one per tool, are in docs/TOOLS.md; a full
investigation of a failed attach is in docs/EXAMPLE.md.
Safety model
- Read-only by construction. The only program started is tshark, from an argv list with
-nand-r, never a shell. Capture, write, export and extension flags are refused before a process exists. tshark gets an empty profile, so no personal Lua script, plugin or extcap loads, and at most two tshark processes run at once. - One write tool, off by default.
export_subsetwrites a filtered subset of a capture to a NEW pcapng file, only when the server was started with--export-dir DIR(a directory outside every--allow-dir), never overwrites, never writes elsewhere and is capped by--export-max-mb(50). Without the flag it refuses every call. - Allowlist and caps. Every path must resolve inside an
--allow-dir. File size (500 MB), packets dissected per call (500), frames read per run (200 000), JSON per call (30 KB) and run time (60 s) are capped; the numbers are configurable, none can be switched off. - Packet text is data, not instructions. Strings copied from packets are cleaned, capped
and named in
untrusted_text_fields. Optional redaction (--redact ids) replaces IMSIs, MSISDNs, IMEIs, SIP users and UE addresses with stable tokens before anything leaves the server.
Transport is stdio only; --transport streamable-http is for local experiments and has no
authentication. Details, the full caps table and the redaction rules: docs/SAFETY.md.
How to report a vulnerability: SECURITY.md.
Tools
Fifty-five tools. Every one returns JSON with a typed `outputSchema`, pages with `limit`and offset, takes start/end to read one time window of a capture (ISO 8601, epoch seconds, "+120s" after the capture start, "-30s" before its end), and returns failures as {"error": {...}} with isError: true and a fix hint. The tool list is
compact by default (less than half the size of the full list); each tool's full schema is the resource schema://tools/<name>, and
--schema-profile full publishes them all. Only the default toolset (33 tools, about 60% of the
list: incident_summary, the capture overview, the most used TCP/IP and telecom tools) is listed
unless you add --toolsets mobile,voice,network (or all); see
AGENTS.md. Full arguments, fields and examples: docs/TOOLS.md.
Every tool with limit also takes output="summary" (the summary plus three rows, under 8 KB),
columns (row keys to keep) and max_output_kb (a lower cap for one call); every result says
what it cost in tokens_estimate.
Prompts
Six MCP prompts turn the common investigations into guided workflows: the tool calls in
order, what to cite, when to stop and the shape of the answer. Claude Code shows them as
/mcp__tshark-mcp__<name>. The path arguments complete to capture files under the allowed
directories (at most 50 names per answer, never outside the allowlist).
Redaction
Telecom captures carry IMSIs, MSISDNs, IMEIs, SIP users and UE addresses. Start the server
with --redact ids (or TSHARK_MCP_REDACT=ids), or pass redact="ids" on a call, and those
values come back as stable keyed tokens such as imsi:3f2a9c1b0d that still join across
tools and work as arguments in later calls. ids+ips hides every IP address too. A call can
raise the server's level, never lower it. What is found, what is not, and how the pre-scan
works: docs/SAFETY.md.
Limitations
- No live capture, by design. The server reads files that already exist and nothing else.
- No decryption: IPsec, TLS and ciphered NAS are reported as tshark sees them.
tls_handshakesreads only the clear part of the handshake; after a TLS 1.3 ServerHello its outcome is inferred from the record pattern and says so. - Large captures are slow. tshark reads the whole file for every call; a 500 MB capture with a selective filter takes tens of seconds, so prefer pre-sliced captures.
- Pairing follows what is in the file. A request whose answer was captured on another
interface is
unanswered; one the capture stopped too soon to answer is alsonear_capture_end. How GTP responses are matched across NATs and proxies is in docs/TOOLS.md. - MAP decoding relies on tshark's dissectors; a segmented XUDT whose other segments are missing is reported as segmented, not guessed.
Roadmap
- 5G core: HTTP/2 SBI (Nnrf, Nausf, Nsmf).
- Streaming per-call progress so a long tshark run can be cancelled from the client.
- Optional S1AP/NGAP and NAS summaries with EMM/ESM cause names.
Development
The suite runs in about a minute; CI runs it on Python 3.10 to 3.13 with
the tshark that Ubuntu 24.04 ships (4.2). Every capture the tests use is synthetic, built by
tests/pcapgen.py at run time with documentation addresses and test identities, and the three
captures under examples/ come from the same generator, so nothing in the repository contains
traffic from a real network (the list of scenarios is in docs/TOOLS.md).
Sixteen task-success scenarios (docs/EVALS.md) check that the right tool answers an
operator's question with the right facts; a model-driven mode is there and off by default.
Conventions for contributors and for agents: CONTRIBUTING.md, AGENTS.md.
Licence
MIT, Copyright (c) 2026 Karl Hulse.
来源:README.md,提交 a2ec027
工具
0版本历史
1- v0.2.0最新Nov 5, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分