MCP code execution

MCP code execution: let AI agents run and test code in a sandbox

OnlineCompiler.io's MCP server gives an AI agent three tools: list_compilers, run_code and run_tests. The code the agent writes runs on our servers, in a fresh sandbox with no network, in any of 45 languages, instead of on your machine. Add one URL to Claude Code, Claude Desktop, Cursor or VS Code; it's free up to 100,000 runs a month.

By the OnlineCompiler.io team. Updated . We make OnlineCompiler.io, so we're one of the options here. Every competitor figure links to the vendor's own page, and we say where our API falls short.

Add it to your agent

Get an API key by signing in, then add the server. It speaks streamable HTTP at https://api.onlinecompiler.io/mcp and takes the key as a Bearer token (the bare key works too). It's the same API key the REST API takes.

Claude Code

Terminal
claude mcp add onlinecompiler https://api.onlinecompiler.io/mcp \
  --transport http \
  --header "Authorization: Bearer YOUR_API_KEY"

Cursor and VS Code

In .cursor/mcp.json or .vscode/mcp.json:

mcp.json
{
  "servers": {
    "onlinecompiler": {
      "url": "https://api.onlinecompiler.io/mcp",
      "headers": { "Authorization": "Bearer YOUR_API_KEY" }
    }
  }
}

Claude Desktop

In claude_desktop_config.json:

claude_desktop_config.json
{
  "mcpServers": {
    "onlinecompiler": {
      "url": "https://api.onlinecompiler.io/mcp",
      "headers": { "Authorization": "Bearer YOUR_API_KEY" }
    }
  }
}

Clients that read the official MCP Registry can also find it by name: io.onlinecompiler/compiler.

The three tools

ToolTakesReturns
list_compilersNothingThe 45 compiler ids and names, such as python-3.14 and rust-1.93
run_codecode, compiler, optional input (stdin) and time_limit (up to 30 s)Output, errors, status, exit code, run time, memory and whether output was cut
run_testscode, compiler, up to 10 tests of input and expected_output, optional time_limit per test (2 s by default) and checker (trim, exact, tokens or float)An overall verdict, a score from 0 to 100, and a verdict for each test, such as accepted, wrong_answer or time_limit_exceeded

This is what an agent sends to run_tests to check a function it just wrote, including a large input that catches a slow solution:

run_tests arguments
{
  "compiler": "python-3.14",
  "code": "n = int(input())\nprint(n * (n + 1) // 2)",
  "tests": [
    {"input": "3", "expected_output": "6"},
    {"input": "10", "expected_output": "55"},
    {"input": "100000", "expected_output": "5000050000"}
  ],
  "time_limit": 1
}

The tool result says which tests passed and, for each failure, what the program printed, so the agent can fix the code and call it again. run_tests runs every test unless the code fails to compile or the call runs out of time, so the agent sees every failure at once. The same judging is available over REST as the run tests API, with hidden tests and weighted scoring.

What agents use it for

  • Checking code before suggesting it: run the snippet and read the real output instead of guessing it.
  • Test-driven fixes: write a function, run it against test cases, and repeat until every verdict is accepted.
  • Languages you haven't installed: Haskell, COBOL, Zig, OCaml or Prolog run the same way as Python, with no toolchain on your machine.
  • Evaluating generated code: the HumanEval benchmark's own README warns against running model-written code outside a sandbox; here every run gets one.

Limits and safety

Each call starts a fresh container under gVisor, as a non-root user on a read-only image, with no network, 512 MB of memory, 2 CPUs, 16 processes and at most 30 seconds. Nothing survives the call, so a misbehaving program can't leave anything behind for the next one. Give each agent its own key with a monthly limit, so a loop that calls the tool thousands of times stops at a number you chose. The security page has the details.

MCP code execution compared with agent sandboxes

Agent sandboxes rent the agent a whole machine for a session. This server runs one program per call. Which you want depends on what the agent does between steps:

ServiceWhat a call getsLanguages out of the boxState between callsPricing
OnlineCompiler.io MCPOne run in a fresh gVisor sandbox, up to 30 s, no network45, compiled and interpretedNone100,000 runs a month free, then from $10 a month for 150,000 runs, with no per-minute billing
E2BA Firecracker microVM session, up to 1 hour (Hobby) or 24 hours (Pro)Python and JavaScript, plus packages you installFiles and memory persist when paused$100 one-time credit, then Pro at $150 a month plus usage
Claude code execution toolA container in Anthropic's APIPython and BashContainers live 30 days$0.05 per container-hour after 1,550 free hours a month, 5-minute minimum
OpenAI code interpreterA container session in OpenAI's APIPythonKept for the sessionFrom $0.03 per 20-minute 1 GB session, 5-minute minimum

Choose a VM sandbox when the agent needs packages it installs, files that persist, network access or runs longer than 30 seconds; E2B also runs MCP servers inside its sandboxes. Choose this server when the agent needs quick runs and test verdicts in many languages, counted in runs rather than billed by the minute.

Frequently asked questions

What is MCP code execution?

An MCP server that exposes running code as a tool. The AI agent calls the tool with the code, the server runs it in its own sandbox, and the output or errors come back as the tool result, so generated code never runs on your machine.

Which MCP clients does it work with?

Claude Code, Claude Desktop, Cursor, VS Code and any client that connects to a remote server over streamable HTTP with a header. The server is https://api.onlinecompiler.io/mcp, and it is listed in the official MCP Registry as io.onlinecompiler/compiler.

Is this MCP code execution server free?

Yes, up to 100,000 runs a month, commercial use included, with no credit card. Each run_code call is one run and each test in a run_tests call is one run; list_compilers is free.

Can the agent install packages or use the internet?

No. Every run starts from a fresh sandbox with the language's standard library and no network access, and nothing is kept between calls. For agents that need installed packages, files that persist or network access, use a VM sandbox such as E2B.

How do I stop a runaway agent from using all my runs?

Give each agent its own API key with a monthly limit. When the key reaches it, calls fail with a clear error until the next month, and the account emails you at 80% and 100% of the allowance.

Which languages can the agent run?

All 45: Python, C, C++, Java, C#, F#, Go, Rust, PHP, Ruby, Haskell, TypeScript, JavaScript, SQL, Bash, Fortran, Visual Basic, Kotlin, R, Swift, COBOL, Perl, Julia, Pascal, Octave, Assembly, Lua, OCaml, Common Lisp, Erlang, Elixir, Prolog, D, FreeBASIC, Dart, Clojure, Groovy, Scala, Zig, Nim, Crystal, Ada, PowerShell, Racket, Objective-C. The list_compilers tool returns the compiler ids the agent should use.