Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Command-Line Interface

Eryx includes a CLI for running Python code in a sandbox directly from the terminal. It supports an interactive REPL, script execution, inline code, and stdin.

Installation

The CLI is included with the Python package:

pip install pyeryx

Or run without installing using uvx:

uvx --with pyeryx eryx

Usage Modes

Interactive REPL

Start an interactive session with persistent state:

python -m eryx
Eryx 0.3.1 (sandbox REPL)
Type "exit()" or Ctrl-D to quit.
>>> x = 42
>>> print(x * 2)
84
>>> exit()

The REPL uses a Session under the hood, so variables, functions, and classes persist between inputs. Multi-line blocks (functions, classes, loops) are detected automatically.

Execute a Script File

python -m eryx script.py

Execute Inline Code

python -m eryx -c 'print("Hello from the sandbox!")'

Read from Stdin

echo 'print(1 + 1)' | python -m eryx -

Or pipe without the - flag:

echo 'import sys; print(sys.version)' | python -m eryx

Flags

Resource Limits

FlagDescriptionDefault
--timeout MSExecution timeout in milliseconds30000
--max-memory BYTESMaximum memory in bytes128MB
python -m eryx --timeout 5000 -c 'print("quick")'
python -m eryx --max-memory 67108864 script.py   # 64MB limit

Runtime

FlagDescription
-s, --precompiled PATHRun in the precompiled Python runtime (.cwasm) at PATH instead of the built-in one

Build one with packages baked in using eryx-precompile, then run code in it. Only use files you trust: a precompiled runtime is native code.

eryx-precompile compile -o numpy.cwasm \
  --preinit --stdlib ./python-stdlib \
  --package numpy-2.2.3-wasi.tar.gz --import numpy

python -m eryx --precompiled numpy.cwasm -c 'import numpy; print(numpy.array([1, 2, 3]).sum())'

Networking

FlagDescription
--netAllow access to any public host
--allow-host PATTERNAllow access only to hosts matching pattern (repeatable, implies --net)

Either way, localhost and private networks stay blocked (the default NetConfig blocks).

python -m eryx --net -c 'import urllib.request; ...'
python -m eryx --allow-host '*.example.com' -c '...'

Filesystem

FlagDescription
-v SRC:DST[:ro]Mount host directory SRC at sandbox path DST
# Mount current directory read-write
python -m eryx -v $(pwd):/mnt/data script.py

# Mount read-only
python -m eryx -v /path/to/files:/input:ro -c 'print(open("/input/data.txt").read())'

MCP (Model Context Protocol)

FlagDescription
--mcpEnable MCP server integration (auto-discovers from user-wide IDE configs)
--mcp-projectAlso read MCP configs in the current directory (implies --mcp)
--mcp-config PATHPath to MCP config file (implies --mcp, can be repeated)
# Auto-discover MCP servers from user-wide Claude, Cursor, Zed, Windsurf, Codex, Gemini configs
python -m eryx --mcp -c 'r = await mcp["github"].search_repos(query="test"); print(r)'

# Also use .mcp.json, .vscode/mcp.json, ... in the current (trusted) directory
python -m eryx --mcp-project -c '...'

# Use a specific config file
python -m eryx --mcp-config .mcp.json -c '...'

See MCP Integration for details on config discovery and supported IDEs.

Other

FlagDescription
--versionPrint version and exit
-h, --helpShow help message

Subcommands

eryx serve

Start an MCP server that exposes the sandbox as a run_python tool:

eryx serve                              # basic sandbox server
eryx serve --timeout 60000 --net        # with options
eryx serve --mcp                        # with inner MCP tools

The serve subcommand accepts all the same sandbox flags listed above. See MCP Server for full documentation.

Examples

# Quick one-liner
uvx --with pyeryx eryx -c 'import sys; print(f"Python {sys.version}")'

# Run a script with timeout
uvx --with pyeryx eryx --timeout 5000 script.py

# Network-enabled execution
uvx --with pyeryx eryx --allow-host 'httpbin.org' -c '
import urllib.request
resp = urllib.request.urlopen("https://httpbin.org/get")
print(resp.read().decode())
'

# Mount a local directory (read-only)
uvx --with pyeryx eryx -v ./data:/data:ro -c '
import os
print(os.listdir("/data"))
'

Next Steps