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.1.1.tar.gz (12.1 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.1.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lmp_protocol-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 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.1.1.tar.gz
Algorithm Hash digest
SHA256 9af65dfbdb8bc0ab6513e4569bfa20fcc8d7165420a07fe315f32b32765846e6
MD5 ba2e2a0d67c9f3282631deb484b11472
BLAKE2b-256 e7edd00233166d6c9478aca78dafc0ecaf0e9e25498455abfba5f1578dad6170

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lmp_protocol-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 71679b5361a1a1426d68c4e0ecb9e7ca345d924245e89c72176f9e870c47f708
MD5 29e63884cfa536af6f44fcfad0dbf30b
BLAKE2b-256 10ec3093a14e244f0769661d6011279d3d2c48d8680bfa1d38ae0ca21f840e45

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