Skip to main content
Glama
Mohamedaslam227

WiFi PCAP Analyzer MCP

README.md
# WiFi PCAP Analyzer MCP

A local MCP server for inspecting Wi-Fi PCAP and PCAPNG files through
PyShark, TShark, and Capinfos.

## Architecture

```text
MCP API tools
        ↓
application services
        ↓
domain contracts and models
        ↓
filesystem, repository, and TShark adapters
```

The code uses a standard `src` package layout:

```text
src/wifi_pcap_mcp/
├── server.py                 Composition and MCP runtime
├── api/                     MCP tools, responses, and the error boundary
├── application/services/    Capture, packet, analysis, and export workflows
├── domain/                  Models, repository contracts, typed errors
├── adapters/                Filesystem, repository, TShark, and Capinfos adapters
└── config/                  Shared configuration constants
```

Every registered tool passes through `api/error_boundary.py`. Expected
application failures receive stable error codes, while unexpected failures are
logged to stderr with an error ID and returned without a traceback. Successful
and failed calls share this envelope:

```json
{"ok": true, "data": {}, "error": null}
```

The repository stores capture metadata and keys, not live PyShark readers. A
fresh reader is created and closed for each analysis call.

For a full tool catalog, end-to-end prompts, useful Wireshark filters, and
structured error tests, see [MCP Server Testing Guide](docs/MCP_TESTING.md).

## Prerequisites

- VS Code with GitHub Copilot and GitHub Copilot Chat
- Python 3.13 for Windows
- Wireshark with TShark installed

On Windows, install Wireshark with **TShark** selected. Create the virtual
environment and install the project:

```powershell
& "$env:LOCALAPPDATA\Programs\Python\Python313\python.exe" -m venv .venv-windows
& ".\.venv-windows\Scripts\python.exe" -m pip install -e .
```

The server checks `PATH`, `TSHARK_PATH`, and the standard
`C:\Program Files\Wireshark\tshark.exe` location, so TShark does not have to be
on `PATH` when Wireshark is installed in its default directory.

## Connect to GitHub Copilot in VS Code

The parent workspace already contains `.vscode/mcp.json`. Open the `MCP` folder
(the parent of this directory) in VS Code, then:

1. Open the Command Palette with `Ctrl+Shift+P`.
2. Run **MCP: List Servers**.
3. Select **wifiPcapAnalyzer**, then select **Start**.
4. Review and accept VS Code's trust prompt.
5. Open Copilot Chat, select **Agent**, and use **Configure Tools** to confirm
   that `load_capture`, `get_summary`, `filter_packets`, and `dissect_packet`
   are enabled.

The workspace configuration launches
`.venv-windows\Scripts\python.exe` directly. It does not use WSL.

## Try it

Use an absolute Windows path so the server can find the capture reliably:

```text
Load the Wi-Fi capture at C:\captures\sample.pcap with capture ID sample-wifi,
summarize it, and identify the most useful Wireshark display filters for
investigating it.
```

Copilot should first call `load_capture`. That tool returns a `capture_id`.
Copilot can pass that ID to the other tools.

## Troubleshooting

- **Server does not start:** run **MCP: List Servers** >
  **wifiPcapAnalyzer** > **Show Output**.
- **`tshark` not found:** install Wireshark/TShark, or set `TSHARK_PATH` to the
  full path of `tshark.exe` before starting VS Code.
- **Python path changed:** recreate `.venv-windows`, then update `command` in
  `.vscode/mcp.json` if the workspace was moved.
- **Tools changed but Copilot shows the old list:** run **MCP: Reset Cached
  Tools**, then restart the server.

## Run without Copilot

From this directory, start the stdio server with either command:

```powershell
& ".\.venv-windows\Scripts\python.exe" server.py
& ".\.venv-windows\Scripts\wifi-pcap-mcp.exe"
```

The command appears to wait without printing anything; that is normal for a
stdio MCP server because it is waiting for an MCP client.

[![M8ven Score](https://m8ven.ai/badge/mcp/mohamedaslam227/pcap-mcp-server)](https://m8ven.ai/mcp/mohamedaslam227/pcap-mcp-server)

TDQS

A4.1/5.0

Scored across 23 tools

Disambiguation3/5

Most tools are clearly separated into lifecycle, metadata, and packet-retrieval roles, and the descriptions are detailed about input types. However, dissect_packet and get_packet_by_number are explicit aliases, and several TCP/DNS retrieval tools overlap enough to create misselection risk.

Naming Consistency5/5

All tool names follow a consistent snake_case verb_noun pattern with predictable prefixes like load_, get_, set_, and filter_. Singular/plural noun choices are consistent with the returned data, and even the redundant get_packet_by_number is name-consistent.

Tool Count3/5

At 23 tools, the server sits in the heavy 16-25 range and is borderline appropriate for a full PCAP analyzer. The count is defensible given the breadth of metadata, validation, and Wi-Fi-specific retrieval features, but the duplicate dissection tool and overlapping retrieval variants mean it could be trimmed without losing capability.

Completeness5/5

The server covers capture lifecycle, decryption-key configuration, export, metadata and statistics, validation, timeline analysis, generic filtering, per-frame dissection, and Wi-Fi-specific client/AP/transaction views. No major operational gap is apparent for file-based WiFi packet-capture analysis.

Maintenance

ActivityMaintained
ResponsivenessUnresponsive