Code Runner MCP Server
The `mcp-server-code-runner` package provides a server designed to execute code snippets across a vast array of programming languages, including JavaScript, Python, PHP, Go, Ruby, TypeScript, and many others, then display their results. It acts as an MCP (Model Context Protocol) server, integrating with compatible AI clients and development environments like VS Code or Claude Desktop to offer real-time code execution capabilities. While the current version 0.1.8 suggests an early-stage or pre-1.0 development phase, it is actively maintained and serves as a powerful utility for agents requiring quick, sandboxed code execution. Its key differentiators include extensive language support (over 30 languages) and flexible deployment options via `npx` or Docker, making it highly adaptable for various AI-driven development and testing workflows.
Common errors
-
failed to start command: exec: "npx": executable file not found in $PATH
cause The `npx` command-line tool is not installed or not accessible in the system's PATH environment variable.fixInstall Node.js (which includes npm and npx) version 18 or later. Verify installation with `node -v` and `npx -v`. Ensure Node.js's installation directory is in your system's PATH. -
Error: spawn npx ENOENT
cause The MCP client cannot correctly find the `npx` command in your system's PATH, often due to how child processes inherit environment variables, especially on Windows or with Node.js version managers like fnm.fixEnsure `npx` is installed and the Node.js executable path is fully discoverable by the environment starting the MCP server. On Windows, try explicitly setting the `command` in your MCP server configuration to `cmd.exe` and passing `/c` before `npx` (e.g., `"command": "cmd.exe", "args": ["/c", "npx", "-y", "mcp-server-code-runner@latest"]`). -
Cannot run program "C:\Program Files\nodejs\npx": CreateProcess error=193, %1 is not a valid Win32 application
cause This error can occur on Windows when the environment tries to execute `npx` in an incompatible mode (e.g., x86 on an x64 machine) or if the `npx` executable itself is corrupted or incorrectly linked.fixEnsure your Node.js installation is correct for your system's architecture. Reinstall Node.js if necessary. Verify that no other Node.js tasks are interfering. Consider the `cmd.exe /c npx` workaround as described for 'spawn npx ENOENT' to ensure correct shell context.
Warnings
- gotcha When running `mcp-server-code-runner` via `npx` on Windows, users may encounter issues related to PowerShell execution policies or `npx` not being found in the PATH, especially with Node.js version managers like nvm, fnm, or volta.
- gotcha The server executes code locally on your machine. While powerful, this means executed code has potential access to your files or system resources. Running untrusted code without proper sandboxing can pose security risks, especially with AI agents.
- gotcha To execute code in various programming languages, ensure that the respective language interpreter or compiler (e.g., Node.js for JavaScript, Python executable for Python) is installed and correctly configured in your system's PATH environment variable. The server relies on these external tools.
Install
-
npm install mcp-server-code-runner -
yarn add mcp-server-code-runner -
pnpm add mcp-server-code-runner
Imports
- npx Command Invocation
mcp-server-code-runner
npx -y mcp-server-code-runner@latest
- VS Code MCP Server Configuration
{ "mcp-server-code-runner": { "command": "npx" } }{ "mcp": { "inputs": [], "servers": { "mcp-server-code-runner": { "command": "npx", "args": [ "-y", "mcp-server-code-runner@latest" ] } } } } - Docker Invocation
docker run formulahendry/mcp-server-code-runner
docker run --rm -i formulahendry/mcp-server-code-runner
Quickstart
{
"mcp": {
"inputs": [],
"servers": {
"mcp-server-code-runner": {
"command": "npx",
"args": [
"-y",
"mcp-server-code-runner@latest"
]
}
}
}
}