Skip to main content

Mirror Frame Protocol — symmetric frame envelope for LLM agent communication

Project description

MFP — Python Implementation

Production-ready Python implementation of the Mirror Frame Protocol

This is the reference Python implementation of MFP, a protocol for secure, peer-to-peer communication between autonomous agents. It provides end-to-end encrypted channels, federated message transport, and a minimal API for agent lifecycle management.

Protocol Specification: For the complete MFP protocol design and specification, see mfp-spec

Features

  • Symmetric design — no client/server distinction, all agents are peers
  • End-to-end encryption — AES-256-GCM AEAD with HMAC-SHA-256 key derivation
  • Federation-ready — bilateral channels, recovery protocols, TCP transport
  • Production hardening — circuit breakers, timeouts, health checks, metrics
  • High performance — Merkle tree for O(log N) global state updates
  • Library-first — runtime embeds in any Python process
  • Standalone server — YAML-configured process for managing agents
  • Type-safe — full type annotations with py.typed marker

Installation

pip install pymfp

Or install from source:

git clone https://github.com/Madahub-dev/MFP.git
cd MFP
pip install -e .

Quickstart

5-minute hello world between two agents:

from mfp import Runtime, RuntimeConfig, bind, mfp_send, mfp_channels

# Create a runtime
config = RuntimeConfig()
runtime = Runtime(config)

# Define two simple agent callables
# Each receives a DeliveredMessage and returns None
def alice(msg):
    print(f"Alice received: {msg.payload.decode()}")

def bob(msg):
    print(f"Bob received: {msg.payload.decode()}")

# Bind agents to the runtime
alice_handle = bind(runtime, alice)
bob_handle = bind(runtime, bob)

# Establish a channel between them (Layer 2 / admin operation)
channel_id = runtime.establish_channel(alice_handle.agent_id, bob_handle.agent_id)

# Send a message from Alice to Bob
receipt = mfp_send(
    alice_handle,
    channel_id=channel_id,
    payload=b"Hello from Alice!",
)

print(f"Message sent, receipt step: {receipt.step}")

# Shutdown
runtime.shutdown()

Run this script to see agents communicate through MFP channels.

Architecture

┌─────────────────────────────────────────────────────────────┐
│                        Application                          │
└─────────────────────────────────────────────────────────────┘
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│  Public API: Runtime, bind/unbind, mfp_send/channels/status │
└─────────────────────────────────────────────────────────────┘
                            │
        ┌───────────────────┼───────────────────┐
        ▼                   ▼                   ▼
   ┌─────────┐         ┌─────────┐        ┌──────────┐
   │ Runtime │◄────────┤  Agent  │◄───────┤ Storage  │
   │ Pipeline│         │Lifecycle│        │  Engine  │
   └─────────┘         └─────────┘        └──────────┘
        │                                       │
        ▼                                       ▼
   ┌─────────┐                            ┌──────────┐
   │  Core:  │                            │Federation│
   │ Crypto, │                            │Transport │
   │ Frames  │                            └──────────┘
   └─────────┘

Layers:

  • Core — cryptographic primitives, frame construction/validation
  • Runtime — agent callable pipeline, hooks, error handling
  • Agent — lifecycle management (bind/unbind), tool interface
  • Storage — persistent state, message queues, channel records
  • Federation — bilateral channels, recovery, wire protocol, TCP server

Documentation

Python Implementation:

Protocol Specification:

CLI Usage

Launch the standalone server:

mfp-server --config runtime.yaml

Or using Python module syntax:

python -m mfp --config runtime.yaml

Development

Set up development environment:

# Clone and install with dev dependencies
git clone https://github.com/Madahub-dev/MFP.git
cd MFP
pip install -e ".[dev]"

# Run tests
pytest

# Run tests with coverage
pytest --cov=mfp --cov-report=term-missing

Project Status

Version: 1.0.0 (Stable)

All 7 implementation phases complete. Full single-runtime pipeline, persistence (SQLite), federation (TCP bilateral channels), async support, per-channel message ordering, audit events with redaction, and sliding window rate limiting. See IMPLEMENTATION.md for the full changelog.

Test Coverage: 813 tests passing (591 unit, 191 integration, 27 E2E, 4 benchmark)

License

Apache License 2.0 — see LICENSE for details.

Related Repositories

  • mfp-spec — MFP protocol specification and design documentation

Credits

MFP Python Implementation — authored by Akil Abderrahim and Claude Sonnet 4.5

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

pymfp-1.0.0.tar.gz (106.4 kB view details)

Uploaded Source

Built Distribution

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

pymfp-1.0.0-py3-none-any.whl (90.7 kB view details)

Uploaded Python 3

File details

Details for the file pymfp-1.0.0.tar.gz.

File metadata

  • Download URL: pymfp-1.0.0.tar.gz
  • Upload date:
  • Size: 106.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymfp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c5002cd999d1d910d703788d7b6ba4a2ba3616268bb088f28f9f3d8abcc4f743
MD5 718713177d820a2d0f06e653095bbf40
BLAKE2b-256 cede381c72a73dd95892138b654fedf64bff9697acc48077334af13bb3ef586a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymfp-1.0.0.tar.gz:

Publisher: publish.yml on Madahub-dev/MFP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymfp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pymfp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 90.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymfp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d080c3ed378701dafcce553a694a0a99248260190c2d6f3d965fa7578ca2e30
MD5 86c40c73f5eee530a5d4854627ba2504
BLAKE2b-256 adc551c96980e9c831131aa0f4a918e2c976deccb86cd550e24f52129617d621

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymfp-1.0.0-py3-none-any.whl:

Publisher: publish.yml on Madahub-dev/MFP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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