code-runner — Claude Code MCP server: run code snippets in chat
An MCP server that executes a snippet and hands the output back to your agent. Handy for checking a calculation or a function's behaviour without leaving the conversation.
claude mcp add code-runner -- npx -y mcp-server-code-runnerWhat code-runner does
code-runner exposes a run-code tool. The agent passes source code in, the server runs it on your machine, and the result lands in the chat. JavaScript, Python, PHP, Ruby, Go, Lua, PowerShell, BAT/CMD, BASH/SH, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, R, Elixir, Clojure, Kotlin Script, Dart and Haskell are among the supported languages; the full set lives in constants.ts in the repo.
Two install routes: npx or a Docker container. Claude takes a single command, while Cursor and GitHub Copilot need a JSON block in their settings file. There is also a Streamable HTTP transport — install the package globally and start the server with --transport http.
The catch is PATH. Whatever interpreter or compiler you want to use has to be reachable there, otherwise the tool call fails with nothing to execute. Windows users hit a separate snag: npx sometimes refuses to connect an MCP server, and the README suggests switching to bunx or wrapping the call in cmd /c.
What it helps with
- check a Python calculation without opening a terminal
- run a short Go or Ruby snippet and read the output
- find the temp folder path or CPU count by executing code
- compare how a function behaves in two languages
- execute a PowerShell or BASH script from inside the agent
Example prompts for the agent
- Run the JavaScript code:
console.log(5+6) - Where is the temporary folder on my OS? Use the
run-codetool - How many CPUs does this machine have? Use
run-code
How to install code-runner
Platform CLI
claude mcp add code-runner -- npx -y mcp-server-code-runnerPlatform CLI
codex mcp add code-runner -- npx -y mcp-server-code-runnerConfig file
{
"mcpServers": {
"code-runner": {
"command": "npx",
"args": [
"-y",
"mcp-server-code-runner"
]
}
}
}Config file
{
"servers": {
"code-runner": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-server-code-runner"
]
}
}
}Platform CLI
gemini mcp add code-runner npx -y mcp-server-code-runnerStep by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about code-runner
How do I install code-runner in Claude Code?
Run claude mcp add code-runner -- npx -y mcp-server-code-runner. The server then shows up in your MCP list and the run-code tool becomes available.
What does code-runner do?
It runs a code snippet in one of the supported languages and returns the output to the conversation. Your agent can execute something and work from the result.
What does code-runner need to work?
The interpreter or compiler for the language you want must be on your PATH. Without it there is nothing to execute.