{"id":14698,"library":"mcp-server-code-runner","title":"Code Runner MCP Server","description":"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.","status":"active","version":"0.1.8","language":"javascript","source_language":"en","source_url":"https://github.com/formulahendry/mcp-server-code-runner","tags":["javascript","mcp","code-runner","server","typescript"],"install":[{"cmd":"npm install mcp-server-code-runner","lang":"bash","label":"npm"},{"cmd":"yarn add mcp-server-code-runner","lang":"bash","label":"yarn"},{"cmd":"pnpm add mcp-server-code-runner","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is a server application, not a library meant for direct JS import. This entry describes the common command-line invocation pattern to run the server via npx. The `-y` flag is for automatic confirmation.","wrong":"mcp-server-code-runner","symbol":"npx Command Invocation","correct":"npx -y mcp-server-code-runner@latest"},{"note":"This JSON snippet illustrates how to configure the Code Runner MCP server within VS Code's `settings.json` to enable an AI agent to use it. The full `mcp` object structure is crucial.","wrong":"{ \"mcp-server-code-runner\": { \"command\": \"npx\" } }","symbol":"VS Code MCP Server Configuration","correct":"{\n  \"mcp\": {\n    \"inputs\": [],\n    \"servers\": {\n      \"mcp-server-code-runner\": {\n        \"command\": \"npx\",\n        \"args\": [\n          \"-y\",\n          \"mcp-server-code-runner@latest\"\n        ]\n      }\n    }\n  }\n}"},{"note":"This command demonstrates running the MCP server using Docker. The `--rm` flag ensures the container is removed on exit, and `-i` keeps stdin open. This provides an isolated execution environment.","wrong":"docker run formulahendry/mcp-server-code-runner","symbol":"Docker Invocation","correct":"docker run --rm -i formulahendry/mcp-server-code-runner"}],"quickstart":{"code":"{\n  \"mcp\": {\n    \"inputs\": [],\n    \"servers\": {\n      \"mcp-server-code-runner\": {\n        \"command\": \"npx\",\n        \"args\": [\n          \"-y\",\n          \"mcp-server-code-runner@latest\"\n        ]\n      }\n    }\n  }\n}","lang":"json","description":"This quickstart demonstrates configuring the `mcp-server-code-runner` within VS Code's `settings.json` to enable code execution capabilities for AI agents. This JSON structure registers the server to be run via `npx` on demand."},"warnings":[{"fix":"Adjust PowerShell execution policies (e.g., `Set-ExecutionPolicy RemoteSigned -Scope CurrentUser`). Ensure Node.js and `npx` are correctly installed and added to your system's PATH. For some environments, explicitly calling `cmd.exe /c npx ...` in the MCP server configuration might be necessary to ensure proper shell handling.","message":"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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always use a reputable MCP client that prompts for explicit human confirmation before executing code. Consider running the server inside a Docker container for an isolated execution environment. Review the source code on GitHub for trusted servers.","message":"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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Verify that all necessary language runtimes are installed. Check your system's PATH environment variable to ensure the directories containing the interpreters/compilers are included. For Node.js, ensure version 18 or later is installed for optimal `npx` functionality.","message":"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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Install 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.","cause":"The `npx` command-line tool is not installed or not accessible in the system's PATH environment variable.","error":"failed to start command: exec: \"npx\": executable file not found in $PATH"},{"fix":"Ensure `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\"]`).","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.","error":"Error: spawn npx ENOENT"},{"fix":"Ensure 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.","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.","error":"Cannot run program \"C:\\Program Files\\nodejs\\npx\": CreateProcess error=193, %1 is not a valid Win32 application"}],"ecosystem":"npm"}