Ask questions about your network.
mcpcap
A modular Python MCP (Model Context Protocol) Server for analyzing PCAP files. mcpcap enables LLMs to read and analyze network packet captures from local or remote sources, providing structured JSON responses about network traffic.
Overview
mcpcap uses a modular architecture to analyze different network protocols found in PCAP files. Each module focuses on a specific protocol, allowing for targeted analysis and easy extensibility. The server leverages the powerful scapy library for packet parsing and analysis.
Key Features
- Modular Architecture: Easily extensible to support new protocols
- Local & Remote PCAP Support: Read files from local directories or HTTP servers
- Scapy Integration: Leverages scapy's comprehensive packet parsing capabilities
- MCP Server: Integrates seamlessly with LLM clients via Model Context Protocol
- JSON Responses: Structured data format for easy LLM consumption
Installation
mcpcap requires Python 3.10 or greater.
Using pip
pip install mcpcap
Using uv
uv add mcpcap
Using uvx (for one-time usage)
uvx mcpcap
Quick Start
-
Start the MCP Server:
Local PCAP file:
mcpcap --pcap-path /path/to/specific/file.pcap
Local PCAP directory:
mcpcap --pcap-path /path/to/pcap/files
Remote PCAP file:
mcpcap --pcap-url https://example.com/sample.pcap
With advanced options:
mcpcap --pcap-path /path/to/pcaps --max-packets 100 --protocols dns
-
Connect your LLM client to the MCP server
-
Ask questions about your network traffic:
- "What domain was queried the most in the DNS traffic?"
- "Show me all DNS queries for example.com"
- "What are the top 5 queried domains?"
Modules
DNS Module
The DNS module analyzes Domain Name System packets in PCAP files.
Capabilities:
- Extract DNS queries and responses
- Identify queried domains and subdomains
- Analyze query types (A, AAAA, MX, etc.)
- Track query frequency and patterns
- Identify DNS servers used
Example Usage:
# LLM can ask: "What domains were queried in this PCAP?"
# mcpcap will return structured JSON with DNS query information
Configuration
PCAP Sources
mcpcap supports multiple ways to specify PCAP data sources:
Local PCAP File:
mcpcap --pcap-path /local/path/to/specific.pcap
Local Directory:
mcpcap --pcap-path /local/path/to/pcaps
Remote PCAP File (Direct Link):
mcpcap --pcap-url https://wiki.wireshark.org/uploads/dns.cap
Remote Directory Listing:
mcpcap --pcap-url http://example.com/pcaps/
Analysis Options
Module Selection:
mcpcap --modules dns --pcap-path /path/to/files
Protocol Filtering:
mcpcap --protocols dns --pcap-path /path/to/files
Packet Limiting (for large files):
mcpcap --max-packets 1000 --pcap-path /path/to/files
Combined Options:
mcpcap --pcap-path /data/capture.pcap --max-packets 500 --protocols dns
CLI Reference
mcpcap [--pcap-path PATH | --pcap-url URL] [OPTIONS]
Source Options (choose one):
--pcap-path PATH
: Local PCAP file or directory--pcap-url URL
: Remote PCAP file URL or directory listing
Analysis Options:
--modules MODULES
: Comma-separated modules to load (default: dns)--protocols PROTOCOLS
: Comma-separated protocols to analyze (default: dns)--max-packets N
: Maximum packets to analyze per file (default: unlimited)
Examples:
# Analyze specific file
mcpcap --pcap-path ./capture.pcap
# Remote file with packet limit
mcpcap --pcap-url https://example.com/dns.cap --max-packets 100
# Directory with protocol filter
mcpcap --pcap-path /captures --protocols dns --modules dns
Example
An example PCAP file (dns.pcap
) containing DNS traffic is included in the examples/
directory to help you get started.
Architecture
mcpcap's modular design makes it easy to extend support for new protocols:
- Core Engine: Handles PCAP file loading and basic packet processing
- Protocol Modules: Individual modules for specific protocols (DNS, etc.)
- MCP Interface: Translates between LLM queries and packet analysis results
- Output Formatter: Converts analysis results to structured JSON
Adding New Modules
New protocol modules can be added by:
- Implementing the module interface
- Defining scapy display filters for the protocol
- Creating analysis functions specific to the protocol
- Registering the module with the core engine
Future modules might include:
- BGP (Border Gateway Protocol)
- HTTP/HTTPS traffic analysis
- TCP connection tracking
- And more!
Remote Access
mcpcap supports reading PCAP files from remote HTTP servers in two modes:
Direct File Access: Point directly to a PCAP file URL
mcpcap --pcap-url https://wiki.wireshark.org/uploads/__moin_import__/attachments/SampleCaptures/dns.cap
Directory Listing: Parse HTML directory listings to find PCAP files
mcpcap --pcap-url http://server.com/pcap-files/
Supported File Types: .pcap
, .pcapng
, .cap
Current Limitations:
- HTTP/HTTPS only (no authentication)
- Directory listings require standard HTML format
- Files are downloaded temporarily for analysis
Future versions may include support for Basic Authentication and other security mechanisms.
Contributing
Contributions are welcome! Whether you want to:
- Add support for new protocols
- Improve existing modules
- Enhance the MCP interface
- Add new features
Please feel free to open issues and submit pull requests.
License
MIT
Requirements
- Python 3.10+
- scapy (packet parsing and analysis)
- requests (HTTP remote file access)
- fastmcp (MCP server framework)
- All dependencies are automatically installed via pip
Support
For questions, issues, or feature requests, please open an issue on GitHub.