代码运行器

@formulahendry/mcp-server-code-runner
4 Stars 974 次浏览 formulahendry 更新于 2026-08-23

用于运行代码片段并显示结果的MCP服务器。

该服务暂未提供标准配置,请参考 README 手动接入

可用工具 (1 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

run-code 2 个参数 需填 2 项

Run code snippet and return the result.

必填参数:code、languageId

服务介绍

Code Runner MCP Server

NPM Downloads smithery badge Docker Pulls

用于运行代码片段并显示结果的MCP服务器。

它支持运行多种编程语言: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。完整的列表可以在constants.ts中查看。

设置

使用 npx 在 VS Code 中安装

使用以下按钮在VS Code中安装Code Runner MCP服务器:

Install in VS Code Insiders

或者,您可以在settings.json中添加配置:

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

使用 npx 在 Claude Desktop 上安装

claude_desktop_config.json中的配置:

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

使用 Docker 安装

以VS Code为例。在settings.json中的配置:

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

通过 Smithery 安装

注意: 这将使Code Runner MCP服务器在一个由Smithery托管的远程容器环境中运行。

要通过Smithery自动为Claude Desktop安装Code Runner MCP服务器:

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

Windows上的npx问题

在Windows上,MCP服务器可能无法通过npx连接

您可以尝试以下两种解决方法:

使用 bunx

  1. 安装Bun
  2. 在配置中,将npx替换为bunx

使用 cmd

以下是VS Code在settings.json中的配置示例:

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

使用

在使用Code Runner MCP服务器之前,请确保您希望运行的编程语言的解释器或编译器已设置在PATH环境变量中。

在已配置了Code Runner MCP服务器的应用程序中尝试以下指令:

  • 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

构建自己的MCP服务器

想要构建自己的MCP服务器?试试Yeoman Generator for MCP Server来创建您的MCP服务器项目!

相关 MCP 服务