Back to MCP directory
publicPublicdnsLocal runtime

mcp-server-code-runner

Code Runner MCP Server是一个支持多语言代码片段执行的MCP服务,可在VS Code等应用中直接运行代码并显示结果。

article

README

🚀 代码运行器 MCP 服务器

代码运行器 MCP 服务器为用户提供便捷的代码运行环境,支持多种安装方式,还能自定义服务器,满足不同用户的使用需求。

🚀 快速开始

在使用代码运行器 MCP 服务器前,需完成安装步骤,并确保设置好想要运行语言的解释器或编译器,且将其添加到 PATH 环境变量中。

📦 安装指南

使用 npx 安装

  • 在 Windows 上的注意事项:若使用 npx 连接 MCP 服务器时遇到问题,可尝试以下两种解决方法:
    • 安装 Bun 并使用 bunx
      1. 安装 Bun
      2. 在配置中将 npx 替换为 bunx
    • 使用命令提示符 (cmd)
{
  "mcp": {
    "inputs": [],
    "servers": {
      "mcp-server-code-runner": {
        "command": "cmd",
        "args": [
          "/c",
          "npx",
          "-y",
          "mcp-server-code-runner@latest"
        ]
      }
    }
  }
}

使用 Docker 安装

  • 通过 Smithery 安装
npx -y @smithery/cli install @formulahendry/mcp-server-code-runner --client claude

💻 使用示例

基础用法

在使用代码运行器 MCP 服务器之前,请确保设置好您想要运行的语言的解释器或编译器,并将其添加到 PATH 环境变量中。您可以尝试以下提示语句:

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

使用确认

结果展示

📚 详细文档

自定义 MCP 服务器

若您想要构建自己的 MCP 服务器,可尝试使用 Yeoman 生成器 来创建您的 MCP 服务器项目!

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client