Implementation:0xKoda WireMCP summary derivation
| Knowledge Sources | |
|---|---|
| Domains | Networking, Packet_Analysis, Data_Transformation |
| Last Updated | 2026-10-28 00:00 GMT |
Overview
Concrete tool for deriving summary views (unique IPs, HTTP URLs, protocol stacks) from parsed packet JSON, implemented as a pattern within the `analyze_pcap` tool handler.
Description
The summary derivation pattern transforms the parsed JSON packet array (from tshark `-T json`) into three summary views:
- Unique IPs: `flatMap` over both `ip.src` and `ip.dst` fields, filtered and deduplicated via `Set`
- HTTP URLs: `filter` for packets with both `http.host` and `http.request.uri`, then `map` to `http://${host}${uri}`
- Protocols: `map` to `frame.protocols`, deduplicated via `Set` and filtered for truthiness
This is a user-defined pattern (not a library API) that provides the high-level forensic overview an LLM needs before drilling into the full packet JSON.
Usage
Use this pattern when you have parsed packet JSON and need to produce human/LLM-readable summary views of the network activity.
Code Reference
Source Location
- Repository: WireMCP
- File: index.js
- Lines: L324-336
Signature
// Unique IPs (src + dst)
const ips = [...new Set(packets.flatMap(p => [
p._source?.layers['ip.src']?.[0],
p._source?.layers['ip.dst']?.[0]
]).filter(ip => ip))];
// HTTP URLs
const urls = packets
.filter(p => p._source?.layers['http.host'] && p._source?.layers['http.request.uri'])
.map(p => `http://${p._source.layers['http.host'][0]}${p._source.layers['http.request.uri'][0]}`);
// Protocol stacks
const protocols = [...new Set(
packets.map(p => p._source?.layers['frame.protocols']?.[0])
)].filter(p => p);
Import
// No import needed — Array.prototype methods and Set are built-in
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| packets | Array<Object> | Yes | Parsed tshark JSON packets (each with `_source.layers`) |
Outputs
| Name | Type | Description |
|---|---|---|
| ips | string[] | Unique source and destination IPs |
| urls | string[] | Fully-qualified HTTP URLs |
| protocols | string[] | Unique protocol stacks (from `frame.protocols`) |
Usage Examples
Derive Summary Views from Parsed Packets
const packets = JSON.parse(stdout); // tshark -T json output
// Unique IPs
const ips = [...new Set(packets.flatMap(p => [
p._source?.layers['ip.src']?.[0],
p._source?.layers['ip.dst']?.[0]
]).filter(ip => ip))];
// HTTP URLs (only packets with both host and URI)
const urls = packets
.filter(p => p._source?.layers['http.host'] && p._source?.layers['http.request.uri'])
.map(p => `http://${p._source.layers['http.host'][0]}${p._source.layers['http.request.uri'][0]}`);
// Protocol stacks
const protocols = [...new Set(
packets.map(p => p._source?.layers['frame.protocols']?.[0])
)].filter(p => p);
console.error(`Found ${ips.length} unique IPs, ${urls.length} URLs`);