代码运行服务

一个支持多种编程语言的代码片段运行服务,适用于开发调试和教学场景。

作者 By formulahendry
混合部署 代码运行 多语言支持
GitHub

代码运行程序MCP服务器

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。完整列表可在此处查看 警察.

mcp-server-code-runner MCP server

设置

npx代表VS代码

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

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

JSON``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14{ “mcp”: { “inputs”: [], “servers”: { “mcp-server-code-runner”: { “command”: “npx”, “args”: [ “-y”, “mcp-server-code-runner@latest” ], } } } }


### 适用于Claude Desktop的npx


配置在 `claude_desktop_config.json`:


JSON```
1
2
3
4
5
6
7
8
9
10
11{
  "mcpServers": {
    "mcp-server-code-runner": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-server-code-runner@latest"
      ],
    }
  }
}

码头工人

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

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

JSON``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16{ “mcp”: { “inputs”: [], “servers”: { “mcp-server-code-runner”: { “command”: “docker”, “args”: [ “run”, “—rm”, “-i”, “formulahendry/mcp-server-code-runner” ] } } } }


### Widnows上的npx问题


在Windows上, [MCP服务器可能无法连接到 `npx`](https://github.com/modelcontextprotocol/servers/issues/40).


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


#### 使用bunx


1. 安装 [包子](https://bun.sh/docs/installation).
2. 在配置中,更改 `npx` 随着 `bunx`.


#### 使用cmd


以下是VS代码配置 `settings.json`:


JSON```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16{
  "mcp": {
    "inputs": [],
    "servers": {
      "mcp-server-code-runner": {
        "command": "cmd",
        "args": [
          "/c",
          "npx",
          "-y",
          "mcp-server-code-runner@latest"
        ],
      }
    }
  }
}

与一起跑步 可流式HTTP传输

SHELL``` 1 2npm install -g mcp-server-code-runner@latest mcp-server-code-runner —transport http


## 用法


在使用Code Runner MCP Server之前,请确保在中设置了要运行的编程语言的解释器或编译器 `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服务器吗?尝试 [MCP服务器用约曼发电机](https://www.npmjs.com/package/generator-mcp) 创建您的MCP服务器项目!