MCP HubMCP Hub
formulahendry

mcp-server-code-runner

by: formulahendry

Code Runner MCP Server

112created 19/03/2025
Visit
Runner

📌Overview

Purpose: The Code Runner MCP Server is designed to execute code snippets across various programming languages and display their results.

Overview: This robust server supports an extensive range of programming languages, enabling users to run code snippets efficiently. It can be integrated with tools like Visual Studio Code, Claude Desktop, or executed via Docker, offering versatility for different environments.

Key Features:

  • Multi-Language Support: The server can run code snippets in numerous languages including JavaScript, Python, PHP, Ruby, and many others, making it suitable for diverse programming tasks.

  • Flexible Integration Options: Users can seamlessly integrate the server using npx, Docker, or through configurations in IDEs like VS Code, providing flexible deployment options tailored to user preferences.


Code Runner MCP Server

MCP Server for running code snippets and showing results.

It supports multiple programming languages including 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 in constants.ts.

Setup

npx for VS Code

Install the Code Runner MCP server in VS Code using the provided buttons.

Alternatively, add this configuration in settings.json:

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

npx for Claude Desktop

Configure 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 to install Code Runner MCP server.

Alternatively, add this configuration in settings.json:

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

Installing via Smithery

This will run Code Runner MCP Server in a remote container environment hosted by Smithery.

To install automatically for Claude Desktop via Smithery:

npx -y @smithery/cli install @formulahendry/mcp-server-code-runner --client claude

npx Issue on Windows

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

use bunx

  1. Install Bun.
  2. Change npx to bunx in configuration.

use cmd

VS Code configuration in settings.json:

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

Run with Streamable HTTP Transport

npm install
npm run build
npm run start:streamableHttp

Usage

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

Try these prompts:

  • 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!