Skip to main content

A modular Python MCP Server for analyzing PCAP files

Project description

mcpcap

mcpcap logo

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

  1. Start the MCP Server:

    mcpcap --pcap-path /path/to/pcap/files
    
  2. Connect your LLM client to the MCP server

  3. 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

Local Directory:

mcpcap --pcap-path /local/path/to/pcaps

Remote HTTP Server:

mcpcap --pcap-url http://example.com/pcaps/

Module Selection

mcpcap --modules dns --pcap-path /path/to/files

Example

An example PCAP file (example.pcap) containing DNS traffic is included with the project to help you get started.

Architecture

mcpcap's modular design makes it easy to extend support for new protocols:

  1. Core Engine: Handles PCAP file loading and basic packet processing
  2. Protocol Modules: Individual modules for specific protocols (DNS, etc.)
  3. MCP Interface: Translates between LLM queries and packet analysis results
  4. Output Formatter: Converts analysis results to structured JSON

Adding New Modules

New protocol modules can be added by:

  1. Implementing the module interface
  2. Defining scapy display filters for the protocol
  3. Creating analysis functions specific to the protocol
  4. 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 without authentication. 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
  • MCP server dependencies (automatically installed)

Support

For questions, issues, or feature requests, please open an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcpcap-0.2.1.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcpcap-0.2.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file mcpcap-0.2.1.tar.gz.

File metadata

  • Download URL: mcpcap-0.2.1.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for mcpcap-0.2.1.tar.gz
Algorithm Hash digest
SHA256 cdcb8a8de43ffd32bf4daaa68d3cbbe19448ab58f82b411bc993b33bd7961906
MD5 99f738bd52d89f87d90e76a9bd812f3d
BLAKE2b-256 52533572ce89c8e1150272ad24a1757dd51a673966828e2660b4664d7152f0c1

See more details on using hashes here.

File details

Details for the file mcpcap-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: mcpcap-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for mcpcap-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7c8eb8b247eddc74a56ac18e0892d9680c8f78a687d1849f7214660d4215a3b0
MD5 fbedf8c2a0181ee5492d21a08abab15c
BLAKE2b-256 70f06bfe8a47fcea770d5d6544944e007be417df68aeac2df25b7c3f5dadcd1a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page