onlinecompiler.io

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

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

Add it to your agent

The server speaks streamable HTTP at https://api.onlinecompiler.io/mcp. claude.ai, Claude Desktop, the Claude mobile apps, ChatGPT, Claude Code and Codex sign you in to OnlineCompiler.io (with Google or an email link) and ask you to approve the connection; there is no key to copy. The app then appears as a key named after it, for example "Claude (connected app)", on your API Keys page. Disable that key and the app is disconnected. Cursor and VS Code take an API key instead, and so does any client you would rather give one.

claude.ai, Claude Desktop and mobile

In claude.ai or Claude Desktop, open Customize, then Connectors, then Add custom connector. Paste https://api.onlinecompiler.io/mcp, then sign in to OnlineCompiler.io when asked and approve. The connector belongs to your Claude account, so the same sign-in works in claude.ai, Claude Desktop and the Claude mobile apps.

ChatGPT

Turn on developer mode in ChatGPT's settings, add a custom connector with the same URL, https://api.onlinecompiler.io/mcp, and sign in when asked.

Claude Code

Terminal
claude mcp add --transport http onlinecompiler https://api.onlinecompiler.io/mcp

Then run /mcp inside Claude Code, pick onlinecompiler and sign in. To use an API key instead, send it as a header:

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

Or install it as a Claude Code plugin from our GitHub repository, which does the same as the first command:

Claude Code
/plugin marketplace add onlinecompiler-io/onlinecompiler-mcp
/plugin install onlinecompiler@onlinecompiler

Codex

Terminal
codex mcp add onlinecompiler --url https://api.onlinecompiler.io/mcp
codex mcp login onlinecompiler

To use an API key instead, skip the login and put the key in an environment variable that bearer_token_env_var names, in ~/.codex/config.toml:

config.toml
[mcp_servers.onlinecompiler]
url = "https://api.onlinecompiler.io/mcp"
bearer_token_env_var = "ONLINECOMPILER_API_KEY"

Gemini CLI

Terminal
gemini extensions install https://github.com/onlinecompiler-io/onlinecompiler-mcp

The extension adds the server and a short note telling Gemini when to use the tools. Gemini CLI signs you in to OnlineCompiler.io the first time it connects. To use an API key instead, the repository's README shows the settings.json entry.

Cursor and VS Code

Sign up and copy the key made for you on your dashboard (more under API Keys). It's the same key the REST API takes, sent as a Bearer token (the bare key works too). In .cursor/mcp.json or .vscode/mcp.json:

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

Smithery

The server is listed on Smithery as onlinecompiler/compiler.

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

The four tools

ToolTakesReturns
list_compilersNothingThe 46 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, float, rows, table or table_ordered)An overall verdict, a score from 0 to 100, and a verdict for each test, such as accepted, wrong_answer or time_limit_exceeded
judge_problemproblem (the id or slug of one of your stored problems), compiler, code, and optional mode (all by default, or samples for the visible tests only)A verdict, a score, a summary sentence, a verdict for each test (a hidden test has its verdict and nothing else), the submission id, a signed receipt, and the problem id and version

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.

judge_problem judges code against a stored problem of your account, whose tests, checker and limits live on the server. It waits for the result and returns it, with the problem id and version it was judged against, and the same signed receipt a REST submission has. It uses your problem's own scoring rather than run_tests' percent. A call that finds no such problem, or an archived one or one with no published version, comes back as an error, never as an invented result. This is what an agent sends to judge a candidate's visible tests against the problem sum:

judge_problem arguments
{
  "problem": "sum",
  "compiler": "python-3.14",
  "code": "def solve(a, b):\n    return a + b",
  "mode": "samples"
}

Let your own backend, not the model, decide when a candidate's code is judged for the record; an AI interviewer can call judge_problem with samples to try code and leave the final judging to your server.

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 network46, compiled and interpreted; Python has a fixed data science stack, no installsNone100,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 install; internet on by defaultFiles 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 Bash; pandas, numpy, scipy, scikit-learn, statsmodels, matplotlib and seaborn preinstalled, no internetContainers 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

For data analysis, the code interpreter API page covers what Python ships with, how CSV files go in and PNG charts come back, and what a run costs.

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. The stateless API or stateful sandbox page compares E2B, Northflank, Daytona, Modal and Vercel Sandbox in more detail.

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.ai, Claude Desktop, the Claude mobile apps, ChatGPT, Claude Code and Codex, where you add the URL and sign in, and Cursor and VS Code, which use an API key. Any client that connects to a remote server over streamable HTTP works. 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, each test in a run_tests call is one run and each test judge_problem runs is one run; list_compilers is free.

Can the agent install packages or use the internet?

No installs and no network. Every run starts from a fresh sandbox and nothing is kept between calls. Python comes with numpy, pandas, scipy, scikit-learn, matplotlib, seaborn, statsmodels, sympy, openpyxl, pillow, duckdb, wordcloud, polars, pgmpy, nltk already installed at published versions, and the agent can pass up to 20 input files and get charts and other files back. Other languages have only their standard library. For agents that need packages of their own choosing, 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 46: Python, C, C++, Java, C#, F#, Go, Rust, PHP, Ruby, Haskell, TypeScript, JavaScript, SQL, DuckDB, 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.