Skip to main content

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

Release files for pymfp 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymfp 1.0.0
File Size Uploaded
pymfp-1.0.0.tar.gz 106.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pymfp 1.0.0
File Interpreter ABI Platform
pymfp-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 197.2 kB

Release files / pymfp-1.0.0.tar.gz

Download URL pymfp-1.0.0.tar.gz
Size 106.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c5002cd999d1d910d703788d7b6ba4a2ba3616268bb088f28f9f3d8abcc4f743
BLAKE2b-256 checksum
How to use checksums
cede381c72a73dd95892138b654fedf64bff9697acc48077334af13bb3ef586a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 25, 2026.

Transparency log

Release files / pymfp-1.0.0-py3-none-any.whl

Download URL pymfp-1.0.0-py3-none-any.whl
Size 90.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d080c3ed378701dafcce553a694a0a99248260190c2d6f3d965fa7578ca2e30
BLAKE2b-256 checksum
How to use checksums
adc551c96980e9c831131aa0f4a918e2c976deccb86cd550e24f52129617d621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.0

2 release 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