Language Machine Protocol (LMP) 🚀
LMP (Language Machine Protocol) is the open standard designed to bridge higher-level AI logic (like LLMs and Agent frameworks) with low-level, sandboxed execution environments.
Think of it like LSP (Language Server Protocol), but instead of connecting your code editor to a language analyzer, it connects your AI Agent to a Stateful Sandbox Engine.
✨ Key Features
- 🧠 Stateful Execution: Variables, functions, and memory persist between code executions. You no longer have to pass giant state strings back and forth.
- 🔒 Capability-Based Security: (Coming soon) Strict bounds on CPU, memory, and filesystem access to run untrusted agent code safely.
- 🛠️ JSON-RPC 2.0: Completely standard, language-agnostic message protocol over standard input/output (
stdio). - 🤖 Agent Framework Ready: Drop-in adapters for LangChain out-of-the-box.
📦 Installation
Installing LMP is incredibly simple. You can install it globally via pip:
pip install lmp-protocol
💻 The LMP CLI (Inspector)
LMP comes with a built-in CLI to help you start servers or debug your execution engine interactively.
To launch the LMP Inspector (an interactive terminal where you can type code and inspect memory), run:
lmp repl
Example Session:
Welcome to the LMP Inspector (REPL)!
lmp> x = [1, 2, 3, 4]
lmp> sum_x = sum(x)
lmp> inspect()
--- Variables ---
x (list): [1, 2, 3, 4]
sum_x (int): 10
-----------------
To start a standalone headless daemon process:
lmp start
🐍 Python SDK Usage
If you are building custom tools, you can use the LMPClient to manage background sandboxes effortlessly.
from lmp.client.client import LMPClient
# The context manager automatically boots and terminates the daemon process
with LMPClient() as client:
# 1. Execute Code
client.execute("a = 10\nb = 20")
# 2. Stateful Memory persists!
res = client.execute("print(a + b)")
print(res["result"]["pipes"]["stdout"]) # Outputs: 30
# 3. Inspect Memory dynamically
memory = client.inspect()
print(memory["result"]["variables"]["a"]["value"]) # Outputs: 10
🦜🔗 LangChain Integration
If you are building an AI Agent using LangChain, giving it a secure, stateful Python environment is just one line of code.
from lmp.adapters.langchain import LMPTool
from langchain.agents import initialize_agent, AgentType
from langchain.llms import OpenAI
# Initialize the stateful LMP tool
python_tool = LMPTool()
llm = OpenAI(temperature=0)
agent = initialize_agent(
tools=[python_tool],
llm=llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True
)
agent.run("Calculate the first 10 numbers of the Fibonacci sequence and print them.")
📖 Specifications
The core protocol relies on the following core JSON-RPC methods:
lmp.initialize: Establish a sandboxed session.lmp.execute: Run raw text or AST JSON payloads.lmp.inspect: Introspect memory structures without triggering side effects.lmp.terminate: Destroy the environment safely.
For deep architectural details, please see the Full Protocol Specification.
Metadata
Release files for lmp-protocol 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lmp_protocol-0.3.0.tar.gz | 14.4 kB | Without provenance | Details for lmp_protocol-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lmp_protocol-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for lmp_protocol-0.3.0-py3-none-any.whl |
Total release size: 28.2 kB
Release files / lmp_protocol-0.3.0.tar.gz
| Download URL | lmp_protocol-0.3.0.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04eca762c29521bb5fc254c7283d1f2aeded19f407a4e730b7c3abc62a8c8ee8
|
|
BLAKE2b-256 checksum How to use checksums |
481489264d59a3391e490b713e894ff8bd3bffd122a86a69df06a8f4f24871f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / lmp_protocol-0.3.0-py3-none-any.whl
| Download URL | lmp_protocol-0.3.0-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73b0684acbfcdf62b161af271e432fb3e86fd16eed095da6b93e22ae300b88e3
|
|
BLAKE2b-256 checksum How to use checksums |
80897c528e72892a8fd2253e665d8d5c645805ba9c6aede85131459f10e8d354
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for lmp-protocol 0.3.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.