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.typedmarker
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:
- Quickstart Guide — step-by-step tutorial
- Production Guide — deployment and operations
- API Reference — library interface documentation
- Server Guide — standalone server configuration
- Architecture — implementation design deep-dive
- Security Model — threat model and guarantees
- Contributing — development setup and guidelines
Protocol Specification:
- MFP Spec Repository — complete protocol design and 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5002cd999d1d910d703788d7b6ba4a2ba3616268bb088f28f9f3d8abcc4f743
|
|
| MD5 |
718713177d820a2d0f06e653095bbf40
|
|
| BLAKE2b-256 |
cede381c72a73dd95892138b654fedf64bff9697acc48077334af13bb3ef586a
|
Provenance
The following attestation bundles were made for pymfp-1.0.0.tar.gz:
Publisher:
publish.yml on Madahub-dev/MFP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymfp-1.0.0.tar.gz -
Subject digest:
c5002cd999d1d910d703788d7b6ba4a2ba3616268bb088f28f9f3d8abcc4f743 - Sigstore transparency entry: 1181703069
- Sigstore integration time:
-
Permalink:
Madahub-dev/MFP@e694ea204442e781800671cb8d1defd9bdf14db3 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Madahub-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e694ea204442e781800671cb8d1defd9bdf14db3 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d080c3ed378701dafcce553a694a0a99248260190c2d6f3d965fa7578ca2e30
|
|
| MD5 |
86c40c73f5eee530a5d4854627ba2504
|
|
| BLAKE2b-256 |
adc551c96980e9c831131aa0f4a918e2c976deccb86cd550e24f52129617d621
|
Provenance
The following attestation bundles were made for pymfp-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on Madahub-dev/MFP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymfp-1.0.0-py3-none-any.whl -
Subject digest:
2d080c3ed378701dafcce553a694a0a99248260190c2d6f3d965fa7578ca2e30 - Sigstore transparency entry: 1181703074
- Sigstore integration time:
-
Permalink:
Madahub-dev/MFP@e694ea204442e781800671cb8d1defd9bdf14db3 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Madahub-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e694ea204442e781800671cb8d1defd9bdf14db3 -
Trigger Event:
release
-
Statement type: