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, Ruby, Go, Lua, Groovy, PowerShell, BASH, F# Script, C# Script, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, R, Elixir, Clojure, Racket, Scheme, AutoHotkey, Kotlin Script, Dart, Haskell, Lisp, and more.

Setup

npx for VS Code

Add the following to your settings.json:

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

npx for Claude Desktop

Add the following to your claude_desktop_config.json:

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

Docker

If using Docker, add the following to your settings.json:

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

Installing via Smithery

To install Code Runner MCP Server for Claude Desktop automatically via Smithery:

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

npx Issues on Windows

On Windows, MCP servers may fail to connect with npx. Consider the following workarounds:

Using bunx

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

Using cmd

Below is an example configuration for VS Code:

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

Usage

Ensure the interpreter or compiler of the programming language you want to run is set in your PATH environment variable.

You can try the following prompts in the application configured with the Code Runner MCP Server:

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

Build Your Own MCP Server

To build your own MCP Server, try the Yeoman Generator for MCP Server.