Skip to content

Getting Started

Connect an LLM

Route model tool calls into an mvm sandbox with explicit boundaries.

An LLM should not execute generated code directly on the host. Route tool calls through a sandbox, validate the request, apply a timeout, and redact output before returning it to the model.

model tool call
-> app validates request
-> mvm sandbox command
-> app redacts stdout/stderr
-> model receives bounded result
import json
import subprocess
def run_code(code: str) -> dict:
if len(code) > 20_000:
raise ValueError("tool input too large")
proc = subprocess.run(
["mvmctl", "run", "--timeout", "10", "--", "python", "-c", code],
check=False,
text=True,
capture_output=True,
)
return {
"exit_code": proc.returncode,
"stdout": proc.stdout[-8000:],
"stderr": proc.stderr[-8000:],
}
print(json.dumps(run_code("print(2 + 2)")))

For repeated calls, build and boot a named sandbox instead:

Terminal window
mvmctl init ./llm-tool --preset python
mvmctl machine build --flake ./llm-tool
mvmctl machine run --flake ./llm-tool --name llm-tool -d
mvmctl machine exec llm-tool -- python /work/tool.py
  • Validate the tool schema before invoking mvmctl.
  • Set a timeout.
  • Default to no network access unless the tool needs a named endpoint.
  • Do not pass secrets through command-line args.
  • Treat stdout and stderr as untrusted model-visible data.
  • Store receipts or audit identifiers with the model trace when available.