MCP.so
登录

Compiler Explorer MCP Server

@Compiler Explorer

基本信息

传输方式

streamable-http

认证方式

请查阅提供方文档

分类

开发工具

作者

Compiler Explorer

关于 Compiler Explorer MCP Server

Compiler Explorer(godbolt.org)内置了一个 MCP 服务器,AI 客户端可以通过它列出语言、编译器和库,编译或运行源代码并查看汇编输出,查询汇编指令文档,以及创建或解析短链接。它可免费使用,无需认证。

#compiler#assembly#godbolt#c++#developer-tools

连接信息

https://compiler-explorer.com/mcp

接入方式

claude mcp add compiler-explorer --transport http https://compiler-explorer.com/mcp

Compiler Explorer MCP Server 工具

7

Compile source code and return assembly output, stdout, and stderr

List available compilers, optionally filtered by language

List supported languages. Each entry has `defaultCompiler` and `compilerCount`.

List available libraries for a given programming language

Look up documentation for an assembly instruction

Create a Compiler Explorer short URL for sharing code with compiler settings

Retrieve source and compiler config from a CE short URL. Compiler entries are returned in the `compile` tool's shape ({compiler, options, libraries:[{id, version}]}). Multi-pane shortlinks (executors, conformance views, CMake trees, per-compiler filters/tools) are flattened — only the basic compile inputs survive.

概览

什么是 Compiler Explorer MCP Server?

Compiler Explorer MCP Server 是 Compiler Explorer(godbolt.org)内置的、无需认证的 MCP 端点。AI 助手可以通过它列出编译器、编译或运行代码、查看生成的汇编,并把结果分享为 Compiler Explorer 短链接。

Compiler Explorer 是一个网页工具,用来查看编译器在多种语言、编译器和版本下把代码编译成了什么。它的 MCP 服务器让 LLM 客户端可以像网页界面一样操作它。Compiler Explorer 文档给出的地址是 https://godbolt.org/mcp;本页使用的地址 https://compiler-explorer.com/mcp 是同一个公共部署在 Compiler Explorer 另一个域名下的入口,返回的工具相同。该服务器也已收录在官方 MCP Registry 中,名称为 io.github.compiler-explorer/compiler-explorer。

如何使用 Compiler Explorer MCP Server?

无需安装,也不需要 API 密钥。该端点是无状态的 Streamable HTTP:每次工具调用都是一个 JSON-RPC POST 请求,没有会话 ID。在浏览器中打开该地址(GET 请求)会返回 405 Method Not Allowed,这是正常现象。

Claude Code

claude mcp add --transport http compiler-explorer https://compiler-explorer.com/mcp

文档中的同一命令使用 https://godbolt.org/mcp,两个地址都可以。

Claude Desktop 和 claude.ai

进入 Settings → Connectors → Add custom connector,粘贴 https://compiler-explorer.com/mcp。无需登录。

Cursor

在 ~/.cursor/mcp.json 中添加:

{
  "mcpServers": {
    "compiler-explorer": {
      "url": "https://compiler-explorer.com/mcp"
    }
  }
}

VS Code

在 .vscode/mcp.json 中添加:

{
  "servers": {
    "compiler-explorer": {
      "type": "http",
      "url": "https://compiler-explorer.com/mcp"
    }
  }
}

自托管的 Compiler Explorer 实例会在 <your-ce-host>/mcp 提供相同的端点。

Compiler Explorer MCP Server 的主要功能

  • 官方出品,内置于每个 Compiler Explorer 部署中,与公共 REST API 并列。
  • 无需认证,无需本地安装。
  • 无状态的 Streamable HTTP,任何支持远程 MCP 服务器的客户端都能使用。
  • 可使用 Compiler Explorer 的语言、编译器和库进行编译,并可选择在其临时沙箱中执行程序。
  • 提供 amd64、arm64、riscv 等指令集的汇编指令文档。
  • 支持 https://godbolt.org/z/... 短链接的双向转换:智能体可以打开别人分享的链接、重新编译,或生成新的链接。
  • 每个工具都带有 MCP 注解(只读或幂等提示)。

Compiler Explorer MCP Server 工具

探测返回了七个工具,分为三组:

  • 发现:list_languages 返回每种语言及其 defaultCompiler 和 compilerCount。list_compilers 可按语言、指令集或自由文本筛选,latestPerMajor 参数只保留每个主版本最新的稳定编译器(lean: true 只返回 ID 和名称)。list_libraries 列出某种语言可用的库。
  • 编译:compile 接收源代码、编译器 ID、选项和库,返回汇编、stdout 和 stderr;设置 execute: true 时还会运行程序。输出默认限制为 500 行汇编以及 stdout、stderr 各 100 行,可通过 maxAsmLines、maxStdoutLines、maxStderrLines 调高。lookup_asm_instruction 用于解释汇编助记符。
  • 分享:generate_short_url 将源代码和编译器设置保存为短链接,相同内容的重复调用返回同一个 URL。get_shortlink_info 把短链接还原为源代码和编译器配置,格式与 compile 的输入一致。

Compiler Explorer MCP Server 的使用场景

  • 检查优化:“用 GCC 和 Clang 以 -O2 编译这个循环,告诉我它有没有被向量化。”
  • 学习汇编:“vpermq 在 amd64 上做什么?”
  • 比较版本:“这段 C++23 代码能在最新的 Clang 和 GCC 上编译通过吗?”
  • 运行小程序:“编译并执行这个 Rust 函数,给我看输出。”
  • 提交 bug:“生成一个能复现这个错误编译问题的 godbolt 短链接。”
  • 查看分享的链接:“打开 https://godbolt.org/z/... 并解释两个编译器输出的差异。”

Compiler Explorer MCP Server 常见问题排查

  • 在浏览器中打开地址显示“Method Not Allowed”:该端点只接受 POST(以及用于 CORS 的 OPTIONS),请通过 MCP 客户端使用。
  • 输出被截断:compile 默认限制输出行数,请调高 maxAsmLines、maxStdoutLines 或 maxStderrLines。
  • 错误以纯文本返回:调用失败时会设置 isError: true,并附带可读信息,例如 Compilation error: ... 或 Short link "abc" not found。
  • 分享链接丢失了执行器或 CMake 面板:get_shortlink_info 会把多面板链接简化为基本的编译输入。

常见问题

1

Compiler Explorer MCP Server 是官方的吗?

是的。它属于开源的 Compiler Explorer 项目,在其 `docs/MCP.md` 中有说明,并已收录在官方 MCP Registry 中。

2

需要 API 密钥或账号吗?

不需要。该端点无需认证,与 Compiler Explorer 的公共 REST API 并列提供。

3

应该用 godbolt.org/mcp 还是 compiler-explorer.com/mcp?

两者访问的是同一个公共 Compiler Explorer 服务。文档使用 `https://godbolt.org/mcp`,短链接也以 `godbolt.org/z/...` 的形式返回。

4

它能运行我的代码,而不仅仅是编译吗?

可以。给 `compile` 传入 `execute: true`,程序会在 Compiler Explorer 的临时沙箱中运行,影响不会超出本次调用。

5

它支持 Claude Code、Cursor 和 VS Code 吗?

支持。它是标准的无状态 Streamable HTTP 服务器,任何支持远程 MCP 服务器的客户端都可以按上面的配置使用。

6

可以连接我自己的 Compiler Explorer 实例吗?

可以。自托管部署会在 `<your-ce-host>/mcp` 提供相同的端点。

7

Compiler Explorer 远程 MCP 服务器是什么?

Compiler Explorer 的远程 MCP 服务器是一个托管的 Model Context Protocol 端点,地址是 https://compiler-explorer.com/mcp,AI 助手无需在本地安装或运行任何东西即可连接。

8

怎么连接 Compiler Explorer 的 MCP 服务器?

把端点 https://compiler-explorer.com/mcp 添加到任意支持 MCP 的客户端,比如 Claude Code、Cursor 或 VS Code。本页的接入代码块可以一步配置好每个客户端。

9

Compiler Explorer 的 MCP 服务器需要认证吗?

此收录尚未确认 Compiler Explorer 的认证要求。连接前请查阅提供方文档。

10

Compiler Explorer 的 MCP 服务器用的是哪种传输方式?

Compiler Explorer 暴露的是 streamable-http 端点,这是远程 MCP 服务器普遍使用、主流客户端都支持的传输方式。

评论