Run code snippets in 35 languages (JS, Python, Go, Ruby, etc.) via mcp-server-code-runner (npx)
Common agent task: you need to run a quick code snippet — compute a value, test a function, generate output — without setting up a full project or shell pipeline. mcp-server-code-runner provides a single run-code tool that accepts code and a language ID, writes to a temp file, executes with the system's installed runtime, and returns stdout. Supports 35 languages. Credential-free, runs via npx.
Recipe: Run code snippets in 35 languages via mcp-server-code-runner (npx)
Server: [email protected] · npm · stdio Launch: npx -y mcp-server-code-runner Auth: none Tools (1):
run-code— acceptscode(string) andlanguageId(enum of 35 languages), writes to a temp file, executes with the system's installed runtime, returns stdout.
Supported languages (35): javascript, typescript, python, ruby, go, rust, php, perl, perl6, lua, groovy, powershell, bat, shellscript, fsharp, csharp, vbscript, coffeescript, scala, swift, julia, crystal, ocaml, r, applescript, clojure, racket, scheme, ahk, autoit, dart, haskell, nim, lisp, kit, v, sass, scss
Prerequisite: The target language's runtime must be installed on the host machine (e.g. node for JavaScript, python3 for Python, go for Go).
Trace: JavaScript — compute first 10 primes and their sum
// REQUEST
{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"run-code","arguments":{"code":"const primes = []; for (let n = 2; primes.length < 10; n++) { if ([...Array(n).keys()].slice(2).every(i => n % i)) primes.push(n); } console.log(\"First 10 primes:\", primes); console.log(\"Sum:\", primes.reduce((a,b) => a+b, 0));","languageId":"javascript"}}}
// RESPONSE
{"result":{"content":[{"type":"text","text":"First 10 primes: [\n 2, 3, 5, 7, 11,\n 13, 17, 19, 23, 29\n]\nSum: 129\n"}]},"jsonrpc":"2.0","id":2}How it works internally
- Writes code to a temp file (e.g.
/tmp/tmp.js) - Executes via the language's CLI (e.g.
node "/tmp/tmp.js") - Returns stdout as a text content block
Notes
- Server logs execution commands to stdout (before the JSON-RPC response), e.g.
Temporary file created at: /tmp/tmp.jsandExecuting command: node "/tmp/tmp.js"— these are informational, not part of the MCP response. - No sandboxing — code runs with the same permissions as the npx process. For untrusted code, run inside a container.
- Execution time depends on the snippet and runtime startup; JavaScript is near-instant, compiled languages (Go, Rust) include compile time.
- Python execution may need extra wait time due to runtime startup.
- The server supports
tools.listChangedcapability, suggesting it can dynamically update its tool list.
{ "server": "[email protected]", "transport": "stdio", "launch": "npx -y mcp-server-code-runner", "tools": ["run-code"], "supported_languages": 35, "traces": [ { "tool": "run-code", "args": { "code": "const primes = []; for (let n = 2; primes.length < 10; n++) { if ([...Array(n).keys()].slice(2).every(i => n % i)) primes.push(n); } console.log('First 10 primes:', primes); console.log('Sum:', primes.reduce((a,b) => a+b, 0));", "languageId": "javascript" }, "result": "First 10 primes: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] Sum: 129", "execution_method": "node /tmp/tmp.js" } ], "probed_at": "2026-06-11T08:12:00Z" }