Skip to main content

scapy-mcp

MCP server that wraps scapy for packet crafting, dissection, pcap staging, and live capture. Tools operate on a worker that holds a scapy_mcp.config.settings.ScapySettings instance and respects a four-stage transmit policy before any frame leaves the host.

Tools

Group Tool Purpose
craft craft_packet Build a Packet from a LayerSpec discriminated union.
dissect dissect_bytes Parse raw bytes into layers + summary text.
pcap read_pcap Read a pcap from pcap_write_dir with offset/limit.
pcap write_pcap Stage a pcap into pcap_write_dir (paths outside the dir refused).
capture capture_start Start a BPF-filtered capture (optional feed).
capture capture_stop Stop the in-progress capture.
capture capture_read Read a range of captured frames.
transmit transmit_packet Send a single packet after every transmit control passes.
transmit probe_packet One-shot emit at a small BPF, used to confirm the surface works.

Four transmit controls

Every transmit_packet call is checked against:

  1. Master kill-switch (transmit_enabled: bool, default false). The default refuses every frame — you must set SCAPY_MCP_TRANSMIT_ENABLED=true to permit emission at all.
  2. L3 CIDR allow-list (transmit_allow_l3_cidrs: list[str]). Set to ["0.0.0.0/0"] for unrestricted L3; production deployments pin the specific CIDRs the worker is allowed to reach.
  3. L2 destination allow-flag (transmit_allow_l2: bool, default false). Pure ARP / ND / RAW frames require this flag; L3 packets do not.
  4. Broadcast opt-in (transmit_allow_broadcast: bool, default false). Even after the L2/L3 allow-list, broadcasts refuse unless this is true.

A fifth control caps probe-target count: transmit_max_probe_targets: int (default 16).

A refusal emits an EmissionRefusedError with the failing control name and a human-readable reason. The wrapper logs a scapy-write-would-refuse / scapy-transmit-refused warning so the refusal is visible without polluting the caller's error stream.

BPF probe (capture)

Capture is OPTIONAL. When /dev/bpf* is missing the function refuses with CapabilityUnavailableError and the capture feed is marked unavailable. /readyz stays 200 because capture is not a required feed.

Deterministic fixtures

Tests do not open raw sockets. All packet construction is exercised against in-memory fixtures under tests/fixtures/. Each fixture includes a hand-crafted bytes() body that round-trips through craft_packetrdpcap/wrpcapdissect_bytes. No real network frames in the suite.

Regenerate via:

python -m scripts.gen_pcap_fixtures

Default = closed-by-default transmit

The shipped defaults cannot emit a frame:

transmit_enabled = false
transmit_allow_l3_cidrs = []
transmit_allow_l2 = false
transmit_allow_broadcast = false

A worker installs only what its operator explicitly approves. See scapy_mcp/config/settings.py for the full settings surface.

License

BSD-3-Clause.

Download files

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

Source Distribution

scapy_mcp-0.1.1.tar.gz (226.5 kB view details)

Uploaded Source

Built Distribution

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

scapy_mcp-0.1.1-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file scapy_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: scapy_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 226.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for scapy_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d56f8f22a875f4675c2549ef8499a5afc71662252dea5a721a19f67486a907be
MD5 402a47758e46d87a3f3b11eae58f71e0
BLAKE2b-256 eac36c08ab601955689d36b4553fb650e1466dd346633c2006b8d9f673ba2edd

See more details on using hashes here.

File details

Details for the file scapy_mcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: scapy_mcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for scapy_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed251cd36c9abefb29ece72ff37b5662386495f0e1bf855627e6307fa2588551
MD5 21f047ff2d07fae830540726e6b2341c
BLAKE2b-256 c36e67266396e8f0c33b1fb47a50383c7d68d6706dd1441c569a69ce2ab7affc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page