Code Runner MCP Server,支持运行 39 种编程语言!

175 天前
 formulahendry

大家好,我是 Code Runner for VS Code 的作者。

最近,MCP (Model Context Protocol) 非常火🔥,于是,我就在想,如果把 Code Runner 的代码运行功能,做成一个 MCP Server ,那么是不是会很强大!

于是,前天晚上,说干就干!

构思、设计、开发、调试、测试、发布,一气呵成!

我发布了 Code Runner MCP Server: https://www.npmjs.com/package/mcp-server-code-runner

发布不到一天时间,已有 221 个下载量了!

因为可以运行多种编程语言,你甚至可以通过 Python/JS 等主流语言,把 Code Runner MCP Server 作为灵活又强大的 Computer Use ! 这个 Computer Use tool 可以干任何事!

比如,查询当前 OS 的 CPU 信息:

比如,给当前窗口截图,并保存图片到本地:

在上面的例子中,当遇到 pip 包没有安装时,GH Copilot Agent 甚至能帮忙自动安装,最终完成截图任务!

你可以在任何支持 MCP 协议的客户端中使用 Code Runner MCP Server:VS Code 、Cursor 、Windsurf 、Claude Desktop 等等。(注:VS Code 需要用最新的 Insider 版本。)

支持的编程语言: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

目前 Code Runner MCP Server 还只支持 stdio 。未来支持 SSE 之后,甚至还能在 remote 跑!

项目完全开源,欢迎来围观:

https://github.com/formulahendry/mcp-server-code-runner

4928 次点击
所在节点    分享创造
25 条回复
yimity
175 天前
你这并发一下,就把别人的结果返回了。
kaichen
175 天前
没有沙盒隔离的话,是不是 llm 产生有破坏性的 code 出来会炸?
formulahendry
175 天前
@yimity 目前 Code Runner MCP Server 只支持 stido ,只能运行在用户的本地环境里面哈,所以暂时没有这个问题
formulahendry
175 天前
@kaichen 要看 MCP Host 怎么调用了~
目前蛮多编辑器在运行 MCP Server tool 之前,都会让用户确认的:
https://raw.githubusercontent.com/formulahendry/mcp-server-code-runner/refs/heads/main/images/usage-confirm.png
kaichen
175 天前
@formulahendry #4 那个确认蛮烦的,客户端有选项开自动,另外是如果不一行行盯着看,不好说能否检查出💥问题
huluhulu
175 天前
@formulahendry 本地环境也很危险啊,万一我说删除所有问题,它可能就去执行了。。。
coefu
175 天前
@kaichen 在中间加一个审计的过滤器咯。
coefu
175 天前
@huluhulu 就像 DBA 审计 sql 语句一样的过滤器不知道有没有搞头。
azertim
175 天前
是韩老师不
formulahendry
175 天前
@azertim 😀
formulahendry
175 天前
@kaichen Auto-Approve 是把双刃剑
formulahendry
175 天前
@huluhulu 一般集成 MCP 的 AI 客户端都有确认选项的。
x4gz
174 天前
用 chatwise 试了下 没成功 说找不到 python = =
formulahendry
174 天前
@x4gz 本地需要安装相应语言的编译器或者解释器哈~
https://github.com/formulahendry/mcp-server-code-runner?tab=readme-ov-file#usage
x4gz
174 天前
@formulahendry #14 连 Mac 自带的 zsh 和 python 都不能运行 是还需要其他设置吗
formulahendry
174 天前
@x4gz error message 是什么样的呢?
如果在 terminal 里,可以直接运行 python xxx.py 吗?
欢迎提 issue 哈: https://github.com/formulahendry/mcp-server-code-runner/issues
x4gz
174 天前




formulahendry
174 天前
@x4gz 看起来,你 python 解释器的路径,没有设置在 $PATH 环境变量里面,你可以参考下面的文档来设置下:
https://mac.install.guide/python/command-not-found-python
x4gz
174 天前
@formulahendry #18 我用 homebrew 安装的 还需要特别设置吗 而且 bash zsh 也没反应啊 = =
formulahendry
173 天前
@x4gz 是的,这个 issue 里面,也有位 macOS 用户,和你遇到类似的问题,他加了 $PATH 环境变量就解决了: https://github.com/formulahendry/mcp-server-code-runner/issues/1#issuecomment-2745329953

bash zsh 的话,是因为 LanguageId 用的是 `shellscript`: https://github.com/formulahendry/mcp-server-code-runner/blob/main/src/constants.ts#L13 ,没有 mapping 上,之后我会优化下~

另外, 你的 mac 如果已经装了 node.js 或者其他语言,并且已经设置在 $PATH 环境变量的话,也可以直接试试:用 javascript

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1120022

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX