SharkMCP
SharkMCP
一个 MCP 服务器,将 sharkd(Wireshark 的程序化接口)作为一组工具暴露给 LLM。加载 PCAP/PCAPNG 文件并使用自然语言进行分析。
要求
Python 3.10+
Wireshark (提供
sharkd)
Related MCP server: Wireshark MCP
安装
git clone https://github.com/weirdmachine64/sharkmcp.git
cd sharkmcp
pip install -e .或者直接从仓库运行而不安装:
uvx --from git+https://github.com/weirdmachine64/sharkmcp sharkmcp配置
添加到你的 .mcp.json 中:
{
"mcpServers": {
"sharkmcp": {
"command": "uvx",
"args": ["--from", "git+https://github.com/weirdmachine64/sharkmcp", "sharkmcp"],
"env": {
"SHARKMCP_TIMEOUT": "300"
}
}
}
}环境变量 | 默认值 | 描述 |
|
| sharkd 二进制文件的路径 |
|
| 每个请求的超时时间(秒) |
工具
每个加载的 PCAP 都有一个专用的 sharkd 子进程。来自昂贵扫描(会话、专家信息、导出对象)的结果会被缓存在内存中,因此分页的后续调用无需重新扫描即可提供服务。
会话
工具 | 描述 |
| 加载 PCAP/PCAPNG 文件 |
| 列出所有已加载的 PCAP |
| 终止会话并释放内存 |
概览
工具 | 描述 |
| 帧计数、持续时间、文件大小、已识别协议 |
| 所有可用的 tap 类型、跟踪协议、字段类型 |
数据包检查
工具 | 描述 |
| 带有显示过滤器的分页帧列表 |
| 单个帧的完整协议树 |
| 将每个数据包的任意字段提取为表格 |
实用工具
工具 | 描述 |
| 验证显示过滤器和/或字段名称 |
| 按前缀自动补全字段或首选项名称 |
| 读取解析器首选项 |
| 为此会话设置解析器首选项 |
| 注释帧(会话范围) |
流量结构
工具 | 描述 |
| 带有帧/字节计数的嵌套协议树 |
| 每个时间间隔的帧和字节计数 |
| 多线流量图;支持 |
| 重组流 ( |
会话与拓扑
工具 | 描述 |
| 会话表 — 每个对等点对的字节/帧数 |
| 端点表 — 每个主机的发送/接收量 |
两者支持的层类型包括:tcp, udp, ip, ipv6, eth, sctp, dccp, mptcp, wifi, bluetooth, zigbee, fc, fddi, usb 等。
协议统计
工具 | 描述 |
| 逐帧异常检测 — 错误、警告、注释、聊天 |
|
|
|
|
|
|
|
|
媒体与 VoIP
工具 | 描述 |
| 带有状态和参与者的 SIP/H.323 通话列表 |
| RTP 流清单;传入 |
| UDP 多播流统计信息 |
导出与对象
工具 | 描述 |
| 列出可提取的对象 ( |
| 以 base64 格式下载对象、TLS 会话密钥 ( |
逃生舱
工具 | 描述 |
| 直接运行任何 sharkd tap — 在一次 PCAP 扫描中最多支持 16 个规范。使用 |
示例
> load_pcap("/captures/traffic.pcap", alias="traffic")
> protocol_hierarchy("traffic")
> expert_info("traffic", limit=20)
> conversations("traffic", type="tcp", sort_by="bytes")
> extract_fields("traffic", ["dns.qry.name", "dns.a"], filter="dns")
> follow_stream("traffic", "http", "tcp.stream eq 0")
> export_objects("traffic", type="http")
> download_object("traffic", "eo:http_0")架构
LLM
│ MCP (stdio)
▼
SharkMCP server
│ JSON-RPC 2.0 (stdin/stdout)
├─ sharkd [pcap-1]
├─ sharkd [pcap-2]
└─ sharkd [pcap-N]每个加载的 PCAP 对应一个 sharkd 子进程。会话是隔离的 — 不同别名上的并发查询永远不会相互阻塞。
Available Tools
30 toolscompleteA
Autocomplete field names or preference names by prefix.
field — field prefix, e.g. "tcp." → all tcp.* dissector fields.
pref — preference prefix, e.g. "tcp." → all tcp.* preferences.
At least one of field or pref must be provided.
Dense protocols (e.g. "opcua.") can return thousands of entries;
limit caps the list (0 = no cap).
Inputs: alias (required), field, pref, limit.
conversationsB
Conversation table for a given layer. Sums frames/bytes per peer pair.
Results are sorted by sort_by (descending) and paged with skip/limit.
The PCAP is scanned only on the first call for a given filter; all
subsequent pages are served from an in-memory cache. Set limit=0 for all.
Inputs: alias (required), type, display_filter, sort_by, +2 more.
download_objectA
Download the raw content of an exportable object, TLS secrets, or RTP audio.
Tokens come from:
export_objects → "eo:http_0", "eo:imf_0", etc.
TLS session keys → "ssl-secrets" (NSS Key Log format, if embedded)
RTP audio stream → "rtp:<src_ip>_<src_port>_<dst_ip>_<dst_port>_<ssrc>"
Content is returned base64-encoded under the data key along with
the MIME type and original filename where available.
Inputs: alias (required), token (required).
endpointsA
Endpoint table for a given layer. Sums tx/rx frames and bytes per host.
Results are sorted by sort_by (descending) and paged with skip/limit.
The PCAP is scanned only on the first call for a given filter; all
subsequent pages are served from an in-memory cache. Set limit=0 for all.
Inputs: alias (required), type, display_filter, sort_by, +2 more.
expert_infoC
Per-frame expert diagnostics — errors, warnings, notes, and chats.
Returns Wireshark's built-in anomaly detection results: TCP retransmissions,
malformed packets, unusual sequences, and protocol violations.
Each entry contains frame number (f), severity (s), protocol (p),
and message (m). Results are cached after the first scan.
Inputs: alias (required), display_filter, skip, limit.
export_objectsA
List exportable objects of the given type found in the capture.
Each returned object includes a _download token that can be passed to
download_object to retrieve the raw content. Supported types:
http, dicom, smb, tftp, imf, ftp-data.
The PCAP is scanned only on the first call for a given type; subsequent pages are served from cache.
Inputs: alias (required), type, skip, limit.
extract_fieldsC
Extract arbitrary fields per packet, e.g.
["ip.src", "tcp.dstport", "http.host"]. Returns rows of dicts keyed
by field name.
Inputs: alias (required), fields (required), display_filter, skip, +1 more.
follow_streamB
Reassemble a stream. display_filter selects it (e.g. tcp.stream eq 3).
Returns client/server addrs and base64 payload chunks with direction.
Long-lived streams can produce huge payload lists; max_payloads caps
how many chunks are returned. Set to 0 for no cap.
Inputs: alias (required), protocol (required), display_filter (required), max_payloads.
get_preferenceA
Read one or all sharkd dissector preferences.
Pass a dotted preference name (e.g. "tcp.check_checksum") to read a
single value, or omit to dump all preferences. Useful for checking
whether a dissector is enabled or what port a protocol is bound to.
Inputs: alias (required), preference.
iographA
Per-interval traffic graph for up to 8 simultaneous lines.
Each entry in graphs must be one of:
"packets" | "bytes" | "bits" — basic counters
"sum:" | "avg:" — aggregate a numeric field per interval
"min:" | "max:" — min/max of a numeric field per interval
"load:" | "frames:" — bit-rate or frame count for a field
filters — optional per-graph display filters (parallel list to graphs);
enables multi-line graphs of different protocol streams.
Results are paged with skip/limit (default 300 buckets ≈ 5 min at 1 s).
Inputs: alias (required), graphs (required), interval_ms, filters, +2 more.
io_statsA
Per-interval frame and byte counts. interval_ms is the bucket size.
Results are in chronological order and paged with skip/limit.
The PCAP is scanned only on the first call for a given (interval, filter)
combination; subsequent pages are served from cache.
Default limit is 300 intervals (~5 min at 1 s buckets). Set limit=0 for all.
Inputs: alias (required), interval_ms, display_filter, skip, +1 more.
list_packetsC
Page through packets via sharkd frames.
display_filter accepts Wireshark display-filter syntax.
columns overrides the default column set with arbitrary field names
(e.g. ["frame.number", "ip.src", "tcp.dstport"]).
refs is a list of reference frame numbers for delta-time calculations.
Inputs: alias (required), display_filter, skip, limit, +2 more.
list_pcapsA
List every loaded PCAP with its current sharkd status.
Inputs: no named parameters. Returns: result
load_pcapA
Load a PCAP/PCAPNG file into a fresh sharkd session.
alias defaults to the basename. Each loaded PCAP keeps a dedicated
sharkd subprocess warm so subsequent queries are interactive.
Returns the alias and basic status (frame count, duration, file size).
Inputs: path (required), alias.
multicast_streamsB
UDP multicast stream statistics.
Returns per-stream packet counts, byte rates, and burst statistics for all UDP multicast flows in the capture.
Inputs: alias (required), display_filter.
packet_detailA
Full protocol tree for one frame.
include_bytes — add raw bytes (base64) per layer.
include_hidden — include hidden protocol tree fields.
ref_frame — reference frame number for delta-time display.
prev_frame — previous frame number for delta-time display.
Inputs: alias (required), frame_number (required), include_bytes, include_hidden, +2 more.
pcap_summaryC
Combined status + analyse: filename, size, frame count, duration,
protocols seen, first/last timestamps.
Inputs: alias (required).
protocol_hierarchyC
Protocol hierarchy stats — nested tree of frame/byte counts per protocol.
Inputs: alias (required), display_filter.
protocol_statsC
Protocol-level aggregate statistics.
protocol options: dns — query/response counts by type and return code http — HTTP request/response packet counters http_requests — requests grouped by URI http_server — load distribution across servers http_seq — HTTP request sequences http2 — HTTP/2 stream statistics rtsp — RTSP packet counters sip — SIP response code counters dhcp — DHCP message type distribution h225 — H.225 message and response status
Inputs: alias (required), protocol (required), display_filter.
response_time_delayC
Response time delay statistics for signalling protocols.
Measures per-transaction round-trip delay: h225_ras — H.225 RAS registration/admission delays megaco — MEGACO/H.248 gateway control delays mgcp — MGCP gateway control delays radius — RADIUS authentication/accounting delays
Inputs: alias (required), protocol (required), display_filter.
rtp_streamsB
RTP stream inventory and per-stream quality analysis.
Without stream_spec — returns all RTP streams with SSRC, codec,
packet count, and timing.
With stream_spec — returns jitter, packet loss, and sequence error
statistics for one stream. Format:
<src_ip>_<src_port>_<dst_ip>_<dst_port>_<ssrc>
e.g. 200.57.7.195_9762_200.57.7.196_26946_0xd2bd4e3e
Inputs: alias (required), stream_spec, display_filter.
sequence_diagramB
Flow sequence diagram data for visualising packet exchanges.
Returns time-ordered node and flow entries suitable for rendering a sequence diagram (equivalent to Wireshark's Flow Graph window). any — all flows tcp — TCP flows (handshakes, data, teardowns) icmp — ICMP echo request/reply flows icmpv6 — ICMPv6 flows
Inputs: alias (required), type, display_filter.
server_infoA
List all types available in this sharkd session: tap identifiers, follow protocols, column fields, and stats tree entries.
Useful for discovering valid values before calling conversations, endpoints, follow_stream, or protocol_hierarchy.
Inputs: alias (required).
service_response_timeC
Service response time statistics — min/max/avg latency per request type.
Measures the elapsed time between a protocol request and its response. Useful for detecting slow servers, network congestion, or anomalous response-time patterns in application protocols.
Inputs: alias (required), protocol (required), display_filter.
set_frame_commentA
Set a comment on a frame for the duration of this session (non-persistent).
Pass an empty string to clear an existing comment. Useful for annotating frames during forensic analysis.
Inputs: alias (required), frame_number (required), comment.
set_preferenceA
Set a sharkd dissector preference for this session.
Changes are session-scoped and do not persist after the server restarts.
Common uses: forcing a non-standard port to decode as a specific protocol
(e.g. name="http.tcp.port", value="8080"), or enabling/disabling a
dissector option.
Inputs: alias (required), name (required), value (required).
tapA
Run one or more sharkd statistics taps in a single PCAP scan.
specs — tap identifiers from server_info, e.g.
["expert", "conv:TCP", "stat:dns", "srt:smb"]
filter — global display filter applied to all taps (sharkd supports
only one filter per tap call; per-tap filters are iograph-only)
skip / limit — pagination applied to each tap's flat list result
Up to 16 specs per call (sharkd limit). Results are cached after the
first scan; paginated follow-up calls are served from memory.
Use server_info to discover all valid tap identifiers.
Inputs: alias (required), specs (required), filter, skip, +1 more.
unload_pcapB
Terminate the sharkd session for alias and free its memory.
Inputs: alias (required).
validateA
Validate a display-filter expression and/or a field name.
filter — Wireshark display filter (e.g. tcp.port == 443).
field — fully qualified field name (e.g. http.request.method).
Returns {"status":"OK"} on success or an error object.
At least one of filter or field must be provided.
Inputs: alias (required), filter, field.
voip_callsC
VoIP call list with state, duration, and participant addresses.
Detects SIP, H.323, MGCP, and SKINNY calls in the capture and reconstructs the call flow from signalling messages.
Inputs: alias (required), display_filter.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 30 tools
Each tool targets a distinct operation on packet capture data, such as loading, listing, extracting fields, following streams, or computing statistics. Overlaps like io_stats and iograph are clarified by descriptions (one simple counts, the other multi-line graphs). No two tools appear to do the same thing.
Tool names mix verb_noun patterns (list_pcaps, load_pcap, set_preference) with noun-only names (protocol_hierarchy, voip_calls, rtp_streams). While the naming is readable and uses snake_case consistently, the lack of a uniform verb prefix creates inconsistency.
30 tools cover a broad range of PCAP analysis features (loading, filtering, statistics, protocol details, export). This is slightly above the typical 15-20 but justified given the extensive functionality of Wireshark/sharkd. No obvious bloat.
The tool surface is comprehensive for analyzing packet captures: it covers file management, packet listing, field extraction, stream reassembly, export objects, multiple statistics taps, protocol-specific analysis, preferences, and validation. Missing features like live capture or saving are outside the server's stated purpose.
Maintenance
Related MCP Connectors
Use your Mac, Windows or Linux computer from ChatGPT, Claude or Codex: files, commands, documents.
File tools for your AI chat: PDF tables to Excel, merge PDFs, images to PDF, fill PDF forms.
File uploads for AI agents. Upload, list, and manage files. No signup required.
Open, inspect, filter, edit and convert xlsx and csv files from your AI chat. Processing is local.
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables LLMs to perform automated network forensics, threat hunting, and traffic analysis using Wireshark/TShark.344MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to analyze network traffic using Wireshark/tshark, providing packet statistics, protocol analysis, and anomaly detection through natural language interaction.75MIT
- FlicenseCqualityDmaintenanceEnables LLMs to capture, analyze, and summarize network traffic using Wireshark CLI tools, supporting live capture, pcap analysis, and LLM-oriented summaries.76-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with tshark and related command-line tools for live packet capture, PCAP analysis, filtering, stream following, and capture file merging.1MIT