Skip to main content

LUMEN — Python binding

Production-quality Python implementation of the LUMEN binary protocol for MCP (Model Context Protocol). Drop-in transports with automatic LUMEN negotiation and transparent JSON-RPC fallback.

Architecture

Mirrors the TypeScript @lumen/mcp-transport package exactly:

Module File Purpose
Hyb128 hyb128.py Hybrid length codec (4 modes: 00 / 01 / 10 / 11)
Dict dict.py 128-entry static + 127 session dictionary, O(1) lookup
Compress compress.py Compact binary payload codec (8 value tags)
Frame frame.py Frame builder/parser (12 frame types, 4 flags)
Frame Assembler frame_assembler.py Zero-allocation streaming reassembler
Negotiation negotiation.py LUMEN probe/ack handshake
Transport transport.py Stdio + WebSocket drop-in MCP transports
Cadencia cadencia.py Rust sidecar bridge client
Public API __init__.py Single import surface

Status

Component Status
Hyb128 codec 🟢 Done
Static dictionary 🟢 Done — 128 static + 127 session
Binary compressor 🟢 Done
Frame builder/parser 🟢 Done
Frame assembler 🟢 Done
Negotiation handshake 🟢 Done
Stdio transport 🟢 Done
WebSocket transport 🟢 Done
Cadencia bridge 🟢 Done
Test suite ✅ 94/94 passing

Quick start

from lumen import LumenStdioTransport, compress_value, decompress_value

# Standalone compress/decompress
payload = {"tool": "search", "arguments": {"query": "hello"}}
compressed = compress_value(payload)   # 47-55% smaller than JSON
restored = decompress_value(compressed)
assert restored == payload

# Use as MCP transport (drop-in replacement)
transport = LumenStdioTransport(command="python", args=["server.py"])
await transport.start()  # negotiates LUMEN, falls back to JSON-RPC

Installation

cd implementations/python
pip install -e .            # core only
pip install -e ".[test]"    # with pytest + pytest-asyncio
pip install -e ".[websocket,test]"  # full install

Running tests

cd implementations/python
python -m pytest tests/ -v

Package structure

implementations/python/
├── pyproject.toml
├── README.md
├── src/
│   └── lumen/
│       ├── __init__.py          # Public API surface
│       ├── hyb128.py            # Hyb128 length codec
│       ├── dict.py              # 128-entry static dictionary
│       ├── compress.py          # Binary payload compressor
│       ├── frame.py             # Frame builder & parser
│       ├── frame_assembler.py   # Streaming reassembler
│       ├── negotiation.py       # Probe/ack handshake
│       ├── transport.py         # Stdio + WebSocket transports
│       └── cadencia.py          # Rust sidecar bridge
└── tests/
    ├── __init__.py
    └── test_lumen.py            # Comprehensive test suite

Protocol

LUMEN v0.1.0. See ../../RFC_LUMEN.md for the formal RFC or ../../SPEC_DEV.md for the developer specification.

License

MIT

Metadata

Release files for lumen-mcp 0.1.0

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

Built distribution (wheel)

Table of built distributions (wheels) for lumen-mcp 0.1.0
File Interpreter ABI Platform Actions
lumen_mcp-0.1.0-py3-none-any.whl Python 3 none any Details for lumen_mcp-0.1.0-py3-none-any.whl

Release files / lumen_mcp-0.1.0-py3-none-any.whl

Download URL lumen_mcp-0.1.0-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65c86c887f996e12e7b4e030efab0f4f8e06394b71aaec8d7b384f2b3eed26af
BLAKE2b-256 checksum
How to use checksums
a29d89775b7253dc59be472faba94b20d16d3e58702b5aad7ea1eab456e3ac97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for lumen-mcp 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

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