Skip to main content

Language Machine Protocol (LMP) 🚀

PyPI version Python 3.11+ License: MIT

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lmp_protocol-0.3.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lmp_protocol-0.3.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file lmp_protocol-0.3.0.tar.gz.

File metadata

  • Download URL: lmp_protocol-0.3.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for lmp_protocol-0.3.0.tar.gz
Algorithm Hash digest
SHA256 04eca762c29521bb5fc254c7283d1f2aeded19f407a4e730b7c3abc62a8c8ee8
MD5 951d7dcb5bc511bb759035a5a9a6bebf
BLAKE2b-256 481489264d59a3391e490b713e894ff8bd3bffd122a86a69df06a8f4f24871f3

See more details on using hashes here.

File details

Details for the file lmp_protocol-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: lmp_protocol-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for lmp_protocol-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73b0684acbfcdf62b161af271e432fb3e86fd16eed095da6b93e22ae300b88e3
MD5 51be83a5f09989e41832dd2d3c560e50
BLAKE2b-256 80897c528e72892a8fd2253e665d8d5c645805ba9c6aede85131459f10e8d354

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page