mcp-server-code-runner

MCP.Pizza Chef: formulahendry

The mcp-server-code-runner is an MCP server that executes code snippets across a wide range of programming languages including JavaScript, Python, Ruby, Go, and many more. It provides real-time code execution results, enabling developers and applications to run and test code dynamically within an MCP-enabled environment. This server supports over 30 languages, making it versatile for diverse development and automation workflows.

Use This MCP server To

Execute code snippets in various programming languages on demand Test and validate code dynamically within an MCP environment Integrate real-time code execution into developer tools and IDEs Run scripts for automation tasks across multiple languages Provide instant feedback for code examples in documentation or tutorials Enable multi-language code evaluation in AI-assisted coding workflows Support polyglot programming environments with unified execution Automate code testing and debugging in continuous integration pipelines

README

Code Runner MCP Server

NPM Downloads smithery badge Docker Pulls

MCP Server for running code snippet and show the result.

It supports running multiple programming languages: JavaScript, PHP, Python, Perl, Perl 6, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F# Script, C# Script, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml Script, R, AppleScript, Elixir, Clojure, Racket, Scheme, AutoHotkey, AutoIt, Kotlin Script, Dart, Haskell, Ni, Lisp, Kit, V, SCSS, Sass. Full list could be seen here in constants.ts.

mcp-server-code-runner MCP server

Setup

npx for VS Code

Install the Code Runner MCP server in VS Code using below buttons:

Install in VS Code Install in VS Code Insiders

Alternatively, you can add configuration in settings.json:

{
  "mcp": {
    "inputs": [],
    "servers": {
      "mcp-server-code-runner": {
        "command": "npx",
        "args": [
          "-y",
          "mcp-server-code-runner@latest"
        ],
      }
    }
  }
}

npx for Claude Desktop

Configuration in claude_desktop_config.json:

{
  "mcpServers": {
    "mcp-server-code-runner": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-server-code-runner@latest"
      ],
    }
  }
}

Docker

Use VS Code as example. Install the Code Runner MCP server in VS Code using below buttons:

Install in VS Code Install in VS Code Insiders

Alternatively, you can add configuration in settings.json:

{
  "mcp": {
    "inputs": [],
    "servers": {
      "mcp-server-code-runner": {
        "command": "docker",
        "args": [
          "run",
          "--rm",
          "-i",
          "formulahendry/mcp-server-code-runner"
        ]
      }
    }
  }
}

npx issue on Widnows

On Windows, MCP servers may fail to connect with npx.

You could try below two workarounds:

use bunx

  1. Install Bun.
  2. In configuration, change npx with bunx.

use cmd

Below is VS Code configuration in settings.json:

{
  "mcp": {
    "inputs": [],
    "servers": {
      "mcp-server-code-runner": {
        "command": "cmd",
        "args": [
          "/c",
          "npx",
          "-y",
          "mcp-server-code-runner@latest"
        ],
      }
    }
  }
}
npm install -g mcp-server-code-runner@latest
mcp-server-code-runner --transport http

Usage

Before using Code Runner MCP Server, please make sure interpreter or compiler of the programming language you want to run is set in PATH environment variable.

Try below prompts in the application which has configured Code Runner MCP Server:

  • Run the JavaScript Code: console.log(5+6)
  • Where is temporary folder in my OS? Use run-code tool
  • How many CPUs do I have in my machine? Use run-code tool

Build your own MCP Server

Want to build your own MCP Server? Try Yeoman Generator for MCP Server to create your MCP Server project!

mcp-server-code-runner FAQ

How do I add support for a new programming language?
You can extend the server by modifying its configuration and adding the language runtime, following the patterns in constants.ts.
Is the code execution sandboxed for security?
Yes, the server runs code snippets in isolated environments to prevent unauthorized access and ensure safe execution.
Can this server handle asynchronous code execution?
It supports asynchronous execution depending on the language runtime capabilities and server configuration.
How do I integrate this server with an MCP client?
Connect the client to the server's API endpoint and use the MCP protocol to send code snippets and receive execution results.
What languages are supported by default?
It supports over 30 languages including JavaScript, Python, Ruby, Go, PHP, PowerShell, Bash, TypeScript, and more.
Can I run code snippets that require external libraries?
Support for external libraries depends on the server environment setup; you may need to pre-install required dependencies.
Does the server provide execution time limits?
Yes, to prevent resource abuse, the server enforces execution timeouts configurable by the administrator.
Is there Docker support for easy deployment?
Yes, the server is available as a Docker image for straightforward deployment and scaling.