Python wrapper for the mlld CLI
Project description
mlld Python SDK
Python wrapper for mlld using a persistent NDJSON RPC transport over mlld live --stdio.
Installation
pip install mlld-sdk
Development
For local SDK work, use an editable install so changes in mlld.py apply immediately:
uv pip install -e /path/to/mlld/sdk/python
If you are already in the repo root, uv pip install -e ./sdk/python works too.
Requirements
- Python 3.10+
- Node.js runtime
- mlld CLI available by command path
Quick Start
from mlld import Client
client = Client()
# Optional command override (local repo build example)
# client = Client(command='node', command_args=['./dist/cli.cjs'])
output = client.process('show "Hello World"')
print(output)
result = client.execute(
'./agent.mld',
{'text': 'hello'},
state={'count': 0},
dynamic_modules={
'@config': {'mode': 'demo'}
},
timeout=10,
)
print(result.output)
client.close()
MCP Server Injection
Pass per-execution MCP server commands so each parallel call gets its own server instance:
result = client.execute(
'./agent.mld',
payload,
mcp_servers={
'tools': f'uv run python3 mcp_server.py {config_b64}'
},
)
In the mlld script, import tools from mcp "tools" as @mcp resolves "tools" to the command provided by the SDK. Each execute() call gets an independent server lifecycle.
Filesystem Integrity
from mlld import Client
client = Client()
signed = client.sign("docs/note.txt", identity="user:alice")
verified = client.verify("docs/note.txt")
content_sig = client.sign_content(
"runtime payload",
"user:alice",
signature_id="payload-1",
metadata={"channel": "sdk"},
)
handle = client.execute_async("./agent.mld", state={"exit": False})
file_sig = handle.write_file("out.txt", "hello from sdk")
handle.update_state("exit", True)
handle.result()
client.sign_content() stores signatures under .sig/content/. ExecuteHandle.write_file() writes relative to the executing script and auto-signs the output as agent:{script} with provenance metadata from the live request.
In-Flight State Updates
handle = client.process_async(
'loop(99999, 50ms) until @state.exit [\n continue\n]\nshow "done"',
state={'exit': False},
mode='strict',
timeout=10,
)
time.sleep(0.12)
handle.update_state('exit', True)
print(handle.result())
API
Client
Client(command='mlld', command_args=None, timeout=30.0, working_dir=None)process(script, *, file_path=None, payload=None, state=None, dynamic_modules=None, dynamic_module_source=None, mode=None, allow_absolute_paths=None, timeout=None, mcp_servers=None)process_async(...) -> ProcessHandleexecute(filepath, payload=None, *, state=None, dynamic_modules=None, dynamic_module_source=None, allow_absolute_paths=None, mode=None, timeout=None, mcp_servers=None)execute_async(...) -> ExecuteHandleanalyze(filepath)sign(path, *, identity=None, metadata=None, base_path=None, timeout=None) -> FileVerifyResultverify(path, *, base_path=None, timeout=None) -> FileVerifyResultsign_content(content, identity, *, metadata=None, signature_id=None, base_path=None, timeout=None) -> ContentSignaturefs_status(glob=None, *, base_path=None, timeout=None) -> list[FilesystemStatus]close()
Handle Methods
ProcessHandle and ExecuteHandle both provide:
request_idcancel()update_state(path, value, *, timeout=None)next_event(timeout=None) -> HandleEvent | Nonewait()result()
ExecuteHandle also provides:
write_file(path, content, *, timeout=None) -> FileVerifyResult
Module-level Convenience Functions
mlld.process(...)mlld.process_async(...)mlld.execute(...)mlld.execute_async(...)mlld.analyze(...)mlld.sign(...)mlld.verify(...)mlld.sign_content(...)mlld.fs_status(...)
Notes
- Each
Clientkeeps one live RPC subprocess for repeated calls. ExecuteResult.state_writesmerges final-result writes and streamedstate:writeevents.ExecuteResult.denialscollects structured guard/policy label-flow denials seen during execution.handle.next_event()can yieldguard_denialbefore completion, alongsidestate_writeandcomplete.- Sync methods remain as wrappers around async handle methods.
Project details
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 mlld_sdk-2.0.5.tar.gz.
File metadata
- Download URL: mlld_sdk-2.0.5.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74c80fbec5c7adb01f538c6733c1c5825768d90b080fc9f31dee864e3a251be5
|
|
| MD5 |
0c5d842c7649ee7ec60f311931d5e6f4
|
|
| BLAKE2b-256 |
d71b493526eca4483f7dbac8ac02cdc8c891d67ab76d5ef526e02b017ddf2f3e
|
Provenance
The following attestation bundles were made for mlld_sdk-2.0.5.tar.gz:
Publisher:
publish.yml on mlld-lang/mlld
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mlld_sdk-2.0.5.tar.gz -
Subject digest:
74c80fbec5c7adb01f538c6733c1c5825768d90b080fc9f31dee864e3a251be5 - Sigstore transparency entry: 1170715989
- Sigstore integration time:
-
Permalink:
mlld-lang/mlld@0b670124522f3aa6842c2af91db050f0f98536d6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mlld-lang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0b670124522f3aa6842c2af91db050f0f98536d6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mlld_sdk-2.0.5-py3-none-any.whl.
File metadata
- Download URL: mlld_sdk-2.0.5-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6f48f13196caf1368aeee28886991f2948b9cb31dde29b6f8ad10712e6a3c1e
|
|
| MD5 |
a802b01e2563931df4ceff54d5a951ab
|
|
| BLAKE2b-256 |
486eeb1fcb67caac8a45bcc107030a9c6de7082b00a9a6ff742c17cc94b7a981
|
Provenance
The following attestation bundles were made for mlld_sdk-2.0.5-py3-none-any.whl:
Publisher:
publish.yml on mlld-lang/mlld
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mlld_sdk-2.0.5-py3-none-any.whl -
Subject digest:
d6f48f13196caf1368aeee28886991f2948b9cb31dde29b6f8ad10712e6a3c1e - Sigstore transparency entry: 1170716028
- Sigstore integration time:
-
Permalink:
mlld-lang/mlld@0b670124522f3aa6842c2af91db050f0f98536d6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mlld-lang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0b670124522f3aa6842c2af91db050f0f98536d6 -
Trigger Event:
push
-
Statement type: