返回市场
代码运行器服务器

代码运行器服务器

作者:formulahendry231 星标更新:2025-09-22

项目介绍

Code Runner MCP Server

NPM 下载量 smithery 徽章 Docker 拉取次数

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

它支持多种编程语言:JavaScript、PHP、Python、Perl、Perl 6、Ruby、Go、Lua、Groovy、PowerShell、BAT/CMD、BASH/SH、F# 脚本、C# 脚本、VBScript、TypeScript、CoffeeScript、Scala、Swift、Julia、Crystal、OCaml 脚本、R、AppleScript、Elixir、Clojure、Racket、Scheme、AutoHotkey、AutoIt、Kotlin 脚本、Dart、Haskell、Ni、Lisp、Kit、V、SCSS、Sass。完整的列表可以在 constants.ts 中查看。

<a href="https://glama.ai/mcp/servers/d3mluq4vy9"> <img width="380" height="200" src="https://gips2.baidu.com/it/u=1378948258,1812652707&fm=3081&app=3081&f=PNG?w=760&h=400" alt="mcp-server-code-runner MCP 服务器" /> </a>

安装

使用 npx 在 VS Code 中安装

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

在 VS Code 中安装 MCP 服务器 (npx) 在 VS Code Insiders 中安装 MCP 服务器 (npx)

或者,您可以在 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 为例。通过以下按钮在 VS Code 中安装 Code Runner MCP 服务器:

在 VS Code 中安装 MCP 服务器 (Docker) 在 VS Code Insiders 中安装 MCP 服务器 (Docker)

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

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

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"
        ],
      }
    }
  }
}

使用 Streamable HTTP 传输运行

npm install -g mcp-server-code-runner@latest
mcp-server-code-runner --transport http

使用说明

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

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

  • 运行 JavaScript 代码:console.log(5+6)
  • 我的操作系统中的临时文件夹在哪里?使用 run-code 工具
  • 我机器上有多少个 CPU?使用 run-code 工具

构建自己的 MCP 服务器

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