代码运行程序MCP服务器
](https://www.npmjs.com/package/mcp-server-code-runner) ](https://smithery.ai/server/@formulahendry/mcp-server-code-runner) ](https://hub.docker.com/r/formulahendry/mcp-server-code-runner)
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。完整列表可在此处查看 警察.
设置
npx代表VS代码
使用以下按钮在VS Code中安装Code Runner MCP服务器:
或者,您可以在中添加配置 settings.json:
{
"mcp": {
"inputs": [],
"servers": {
"mcp-server-code-runner": {
"command": "npx",
"args": [
"-y",
"mcp-server-code-runner@latest"
],
}
}
}
}适用于Claude Desktop的npx
配置在 claude_desktop_config.json:
{
"mcpServers": {
"mcp-server-code-runner": {
"command": "npx",
"args": [
"-y",
"mcp-server-code-runner@latest"
],
}
}
}码头工人
以VS Code为例。使用以下按钮在VS Code中安装Code Runner MCP服务器:
或者,您可以在中添加配置 settings.json:
{
"mcp": {
"inputs": [],
"servers": {
"mcp-server-code-runner": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"formulahendry/mcp-server-code-runner"
]
}
}
}
}Widnows上的npx问题
在Windows上, MCP服务器可能无法连接到 npx.
您可以尝试以下两种解决方法:
使用bunx
- 安装 包子.
- 在配置中,更改
npx随着bunx.
使用cmd
以下是VS代码配置 settings.json:
{
"mcp": {
"inputs": [],
"servers": {
"mcp-server-code-runner": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"mcp-server-code-runner@latest"
],
}
}
}
}与一起跑步 可流式HTTP传输
npm 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 toolHow many CPUs do I have in my machine? Use run-code tool


构建自己的MCP服务器
想要构建自己的MCP服务器吗?尝试 MCP服务器用约曼发电机 创建您的MCP服务器项目!
