Mirror Frame Protocol — symmetric frame envelope for LLM agent communication
Project description
Mirror Frame Protocol (MFP)
Symmetric frame envelope for LLM agent communication
MFP is a protocol and runtime 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.
Features
- Symmetric design — no client/server distinction, all agents are peers
- End-to-end encryption — ChaCha20-Poly1305 AEAD with X25519 key exchange
- 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
def alice(channel_id, message):
print(f"Alice received: {message.decode()}")
return {"status": "ok"}
def bob(channel_id, message):
print(f"Bob received: {message.decode()}")
return {"status": "ok"}
# Bind agents to the runtime
alice_handle = bind(runtime, alice)
bob_handle = bind(runtime, bob)
# Establish a channel between them
alice_handle.establish_channel(bob_handle.agent_id, symmetric_key=None)
# Send a message from Alice to Bob
channels = mfp_channels(alice_handle)
channel_id = channels[0].channel_id
receipt = mfp_send(
alice_handle,
channel_id=channel_id,
plaintext=b"Hello from Alice!"
)
print(f"Message sent, receipt: {receipt.message_id.hex()[:16]}...")
# 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
- Quickstart Guide — step-by-step tutorial
- Production Guide — deployment and operations
- API Reference — library interface documentation
- Server Guide — standalone server configuration
- Architecture — design deep-dive
- Security Model — threat model and guarantees
- Contributing — development setup and guidelines
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: 0.4.0 (Production Ready)
All implementation phases complete including production hardening:
- ✅ P0: Critical Security
- ✅ P1: Operational Robustness (logging, health checks, metrics, limits)
- ✅ P2: Performance Optimization (Merkle tree, circuit breakers, timeouts, pooling)
- ✅ P3: Advanced Hardening (frame caching, key rotation, deduplication)
Test Coverage: 813 tests passing (591 unit, 191 integration, 27 E2E, 4 benchmark)
License
Apache License 2.0 — see LICENSE for details.
Credits
MFP — authored by Akil Abderrahim and Claude Sonnet 4.5
For protocol design documentation, see design/.
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-0.1.0.tar.gz.
File metadata
- Download URL: pymfp-0.1.0.tar.gz
- Upload date:
- Size: 92.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cff83739bbc70ae1c418c428e2d57115e504bcba9ba374715c4fce688a334e5
|
|
| MD5 |
92d59b1b6875c796d4ef87dd750871ba
|
|
| BLAKE2b-256 |
ea960c128ef4516ca02f43b6b488f8bdeb48ab1ce446b9ddd63184ce9161a807
|
File details
Details for the file pymfp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pymfp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 79.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
076bc23a82257aba3c44d7390f809f0f274991c5e22ad7c2447bf8ea4e4f7bba
|
|
| MD5 |
f3ab0b286dfa97ff5ab7682bbc2b4427
|
|
| BLAKE2b-256 |
c61c1563abd20e23cb18d6e701bc73131efa3a4fdd6d9c9597b9647a3fc29922
|