5-Minute Quickstart¶
By the end of this page you'll have used ms-enclave to run a snippet of Python inside a Docker sandbox.
Prerequisites: installation done, Docker daemon running.
Minimal example¶
Save the following as hello_sandbox.py:
import asyncio
from ms_enclave.sandbox.boxes import SandboxFactory
from ms_enclave.sandbox.model import DockerSandboxConfig, SandboxType
async def main():
# 1) Configure: pick an image, enable python_executor
config = DockerSandboxConfig(
image='python:3.11-slim',
tools_config={'python_executor': {}},
)
# 2) async with auto-manages lifecycle (start → use → destroy container)
async with SandboxFactory.create_sandbox(SandboxType.DOCKER, config) as sandbox:
result = await sandbox.execute_tool('python_executor', {
'code': 'print("hello from ms-enclave")'
})
print(result.output.strip())
asyncio.run(main())
Run:
Expected output (first run will pull python:3.11-slim):
Key points¶
tools_configmust declare each tool — undeclared tools won't be registered and calls will fail.execute_tool(tool_name, parameters): the first arg maps to a key intools_config; the second is tool-specific (python_executortakescode).async with: on exit, the container is automatically stopped and removed — no leaks.
Next¶
- Understand the
Sandbox/Manager/Toolabstractions → Core Concepts - See all available entry points → Usage Guides Overview
- Manage many sandboxes in one app → Local Manager
- Let an LLM choose the tools → LLM Agent integration