Skip to content

MCP tool reference

The svm-mcp server exposes these tools over MCP (stdio). Every tool takes the sandbox id, so the server keeps no state. Set it up in MCP server.

Create a sandbox from a template (default ‘code-interpreter’) and return its id. It ends on its own after timeout_seconds.

Parameter Type Required Default
template str no "code-interpreter"
timeout_seconds int no 0

Returns dict[str, Any]

List your sandboxes, one page at a time (page_size 1 to 200, 0 for the default). The answer has sandboxes and next_page_token: when next_page_token is not empty there are more, so call again with it as page_token.

Parameter Type Required Default
page_token str no ""
page_size int no 0

Returns dict[str, Any]

Kill a sandbox and discard everything in it.

Parameter Type Required Default
sandbox_id str yes

Returns str

Run code in a sandbox and return its value, printed output, rich results (as formats, PNG as base64) and any error. Variables persist between calls for the same language.

Parameter Type Required Default
sandbox_id str yes
code str yes
language str no "python"
timeout_seconds int no 0

Returns dict[str, Any]

Run a shell command in a sandbox. text starts with the exit code and what a test runner or compiler reported (summary, failed tests, error locations, and what was fixed or newly broken since the last run of the same command), then the output cut to budget tokens (0 for the default, 1500) keeping the end of the log and the lines that report errors. raw=true returns stdout and stderr instead. pure=true says the output depends only on the files under cwd (a test run or a build check: no network, clock or randomness); the answer is then reused while those files are unchanged, also on forks of the sandbox, and cached says so.

Parameter Type Required Default
sandbox_id str yes
command str yes
cwd str no ""
timeout_seconds int no 0
pure bool no false
budget int no 0
raw bool no false

Returns dict[str, Any]

Read a text file from a sandbox (up to 256 KiB).

Parameter Type Required Default
sandbox_id str yes
path str yes

Returns str

Write a text file in a sandbox (up to 1 MiB), replacing any existing file.

Parameter Type Required Default
sandbox_id str yes
path str yes
content str yes

Returns str

List a directory in a sandbox.

Parameter Type Required Default
sandbox_id str yes
path str no "/home/user"

Returns list[dict[str, Any]]

Show a numbered window of a text file (lines start..start+lines-1, default 100) with how many lines lie above and below, or list a directory. budget caps the answer in tokens (0 for the default); relative paths start at cwd (default: the sandbox’s working directory). cache=true reuses an earlier identical call’s answer while no file under cwd has changed, also across forks of the sandbox.

Parameter Type Required Default
sandbox_id str yes
path str yes
start int no 1
lines int no 100
budget int no 0
cwd str no ""
cache bool no false

Returns str

Search files with ripgrep (a regex, or a literal with fixed_strings): matches grouped by file with line numbers, at most max_matches, with the totals. glob filters files, e.g. ‘*.py’. budget caps the answer in tokens (0 for the default); relative paths start at cwd (default: the sandbox’s working directory). cache=true reuses an earlier identical call’s answer while no file under cwd has changed, also across forks of the sandbox.

Parameter Type Required Default
sandbox_id str yes
pattern str yes
path str no "."
glob str no ""
fixed_strings bool no false
context int no 0
max_matches int no 50
budget int no 0
cwd str no ""
cache bool no false

Returns str

Map a repository: its most referenced classes and functions, one source line each with its line number, ranked by how much the rest of the code uses them. focus (files you are working on) and mentions (names) steer the ranking. budget caps the answer in tokens (0 for the default); relative paths start at cwd (default: the sandbox’s working directory). cache=true reuses an earlier identical call’s answer while no file under cwd has changed, also across forks of the sandbox.

Parameter Type Required Default
sandbox_id str yes
path str no "."
focus list[str] | None no null
mentions list[str] | None no null
budget int no 0
cwd str no ""
cache bool no false

Returns str

Change files with a unified diff (patch) or edits ([{path, old, new}] replaces text that occurs once; {path, content} creates a file; {path, delete: true} removes one). All or nothing: on a conflict nothing changes and the error shows the closest text in the file. diagnostics=true runs the language server on the changed files. verify (a test or build command, e.g. ‘pytest -q’) then runs in cwd and its failures are appended, so an edit and its check are one call; the patch stays applied whatever it reports. budget caps the answer in tokens (0 for the default); relative paths start at cwd (default: the sandbox’s working directory).

Parameter Type Required Default
sandbox_id str yes
patch str no ""
edits list[dict[str, Any]] | None no null
dry_run bool no false
diagnostics bool no false
budget int no 0
cwd str no ""
verify str no ""

Returns str

Errors and warnings for one file from a language server (python, javascript, typescript, go or java, guessed from the extension). The server must be installed in the sandbox. budget caps the answer in tokens (0 for the default); relative paths start at cwd (default: the sandbox’s working directory). cache=true reuses an earlier identical call’s answer while no file under cwd has changed, also across forks of the sandbox.

Parameter Type Required Default
sandbox_id str yes
path str yes
language str no ""
budget int no 0
cwd str no ""
cache bool no false

Returns str

Copy a running sandbox (memory, disk and processes) into count children (1 to 16) and return their ids. Each child goes on from the same state on its own, so you can try different changes side by side without redoing the setup.

Parameter Type Required Default
sandbox_id str yes
count int no 1
timeout_seconds int no 0

Returns dict[str, Any]

Try one script in count branches of a sandbox at once (2 to 16 forks) and keep the best. The script runs with /bin/sh in each branch; $SVM_BRANCH_INDEX (0 to count-1) tells it which branch it is, e.g. to pick one of several candidate fixes. A branch scores 1 when the script exits 0, or, with success_pattern (RE2), when its stdout matches. keep: best (default) keeps the best branch running, passed every branch that scored 1, none none. Branches come back best first, each with its exit code, reward and the end of its output; continue in a kept branch by its sandbox_id.

Parameter Type Required Default
sandbox_id str yes
script str yes
count int no 4
success_pattern str no ""
keep str no "best"
cwd str no ""
timeout_seconds int no 0

Returns dict[str, Any]

Start a command in the background (a dev server, a watcher, a long build) and return at once with a process_id. Its output goes to a log; use wait_for to wait for it.

Parameter Type Required Default
sandbox_id str yes
command str yes
cwd str no ""

Returns dict[str, Any]

Wait in one call for a process from start_process: until port listens, or pattern (an extended regex) appears in its log, or it exits, or timeout_seconds (default 60, at most 1800) pass. Without port and pattern it waits for the exit. Returns met (port, pattern, exit or timeout), exit_code once it has exited, and the end of its log. Use it instead of polling with sleep.

Parameter Type Required Default
sandbox_id str yes
process_id str yes
port int no 0
pattern str no ""
timeout_seconds int no 0

Returns dict[str, Any]

Drive the browser in a sandbox made with create_sandbox(template=‘browser’) through the page’s accessibility tree, which costs far fewer tokens than a screenshot. action: navigate (url), snapshot, click (ref), type (ref, text, submit), press (key, e.g. Enter), back, wait_for (text). navigate, click and type answer with the page’s new snapshot; each control in it has a ref to pass to click or type. max_chars caps the answer (0 for the default).

Parameter Type Required Default
sandbox_id str yes
action str yes
url str no ""
ref str no ""
text str no ""
submit bool no false
key str no ""
max_chars int no 0

Returns str