Compiler Explorer
Compile code with thousands of compilers, inspect the assembly, and share godbolt.org links
我该使用它吗
质量与安全性
发现(2)
- LOW在 lookup_asm_instruction 中
- LOW在 generate_short_url 中
基于对工具定义和协议合规性的自动分析。
上下文开销
这是每次将服务器的工具加载到模型上下文窗口时所消耗的大致 token 数。数值越高,可用于其他任务的注意力就越少。
安装
一键安装
将以下内容添加到你的 `claude_desktop_config.json` 文件中:
{
"mcpServers": {
"compiler-explorer": {
"url": "https://godbolt.org/mcp"
}
}
}远程端点
https://godbolt.org/mcpstreamable-http它能做什么
工具清单
工具(7)
🟢compile(source, language, compiler, options, execute, ...)
Compile source code and return assembly output, stdout, and stderr
输入模式
{
"type": "object",
"properties": {
"source": {
"type": "string",
"description": "Source code to compile"
},
"language": {
"type": "string",
"description": "Language ID (e.g. \"c++\", \"c\", \"rust\", \"python\")"
},
"compiler": {
"description": "Compiler ID from list_compilers (e.g. \"g161\"). If omitted, uses the language's `defaultCompiler` from list_languages.",
"type": "string"
},
"options": {
"description": "Compiler flags (e.g. \"-O2 -std=c++20 -Wall\")",
"type": "string"
},
"execute": {
"description": "Run the program instead of returning assembly. `asm` becomes empty; runtime output goes to top-level `stdout`/`stderr`; compile diagnostics move to `buildResult.stdout`/`stderr`.",
"type": "boolean"
},
"stdin": {
"description": "Standard input for execution (requires execute=true)",
"type": "string"
},
"filters": {
"description": "Output filters",
"type": "object",
"properties": {
"intel": {
"description": "Use Intel assembly syntax (default: true)",
"type": "boolean"
},
"demangle": {
"description": "Demangle symbol names (default: true)",
"type": "boolean"
},
"directives": {
"description": "Filter assembler directives (default: true)",
"type": "boolean"
},
"commentOnly": {
"description": "Filter comment-only lines (default: true)",
"type": "boolean"
},
"labels": {
"description": "Filter unused labels (default: true)",
"type": "boolean"
},
"libraryCode": {
"description": "Filter library code (default: false)",
"type": "boolean"
},
"trim": {
"description": "Trim whitespace (default: false)",
"type": "boolean"
}
}
},
"libraries": {
"description": "Libraries to link.",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Library ID from list_libraries (e.g. \"boost\")."
},
"version": {
"type": "string",
"description": "Version id (\"188\") OR human form (\"1.88.0\") — both accepted."
}
},
"required": [
"id",
"version"
]
}
},
"maxAsmLines": {
"description": "Cap asm output (default 500 lines).",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
"maxStdoutLines": {
"description": "Cap each stdout stream — compile and execute separately (default 100).",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
"maxStderrLines": {
"description": "Cap each stderr stream — compile and execute separately (default 100).",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"source",
"language"
],
"$schema": "http://json-schema.org/draft-07/schema#"
}🟢list_compilers(language, instructionSet, match, maxResults, lean, ...)
List available compilers, optionally filtered by language
输入模式
{
"type": "object",
"properties": {
"language": {
"description": "Language ID to filter by (e.g. \"c++\", \"rust\", \"python\")",
"type": "string"
},
"instructionSet": {
"description": "Target architecture filter. Combine with `latestPerMajor: true` for \"newest X for arch Y\" (e.g. `{language:\"c++\", instructionSet:\"amd64\", latestPerMajor:true}`).",
"type": "string",
"enum": [
"6502",
"aarch64",
"amd64",
"x86",
"arm32",
"avr",
"beam",
"c6x",
"dex",
"ebpf",
"evm",
"eravm",
"ez80",
"hook",
"hppa",
"core",
"java",
"kvx",
"llvm",
"loongarch",
"m68k",
"mips",
"mos6502",
"mpy",
"mrisc32",
"msp430",
"perl",
"powerpc",
"ptx",
"python",
"amd_cdna1",
"amd_cdna2",
"amd_cdna3",
"amd_cdna4",
"amd_cdna5",
"amd_rdna1",
"amd_rdna2",
"amd_rdna3",
"amd_rdna3_5",
"amd_rdna4",
"riscv32",
"riscv64",
"s390x",
"sass",
"sh",
"sparc",
"spirv",
"vax",
"wasm32",
"wasm64",
"wdc65c816",
"xtensa",
"z180",
"z80"
]
},
"match": {
"description": "Case-insensitive AND-of-tokens filter on id and name. Punctuation splits tokens; numeric tokens match whole-word (\"gcc 14.1\" matches \"14.1.0\" not \"14.10\"); alphanumeric tokens substring-match (\"g14\" matches \"g142\"). Literal text only — for \"newest version\" use `latestPerMajor`; for \"newest X on arch Y\" prefer `instructionSet` + `latestPerMajor`.",
"type": "string"
},
"maxResults": {
"description": "Cap full-detail entries (default 25). Beyond the cap, degrades to lean (id+name only) with a refinement hint.",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
"lean": {
"description": "Force id+name only, regardless of count. Useful to browse the catalog before drilling in.",
"type": "boolean"
},
"latestPerMajor": {
"description": "\"Newest X\" filter. By release track (stable/nightly/prerelease/experimental): newest stable per (language, instructionSet, semver major); all nightly + prerelease; experimental skipped unless `includeExperimental: true`.",
"type": "boolean"
},
"includeExperimental": {
"description": "With `latestPerMajor: true`, also include experimental compilers (c++ proposal forks, llvm-mos platform variants). Off by default — bloats \"newest X\" answers.",
"type": "boolean"
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}🟢list_languages
List supported languages. Each entry has `defaultCompiler` and `compilerCount`.
输入模式
{
"type": "object",
"properties": {}
}🟢list_libraries(language, match, maxResults, lean)
List available libraries for a given programming language
输入模式
{
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "Language ID (e.g. \"c++\", \"rust\")"
},
"match": {
"description": "Case-insensitive AND-of-tokens filter on id, name, and version strings (so \"boost 1.88\" finds Boost when one of its versions matches 1.88.x). Numeric tokens match version-prefix; alphanumeric substring.",
"type": "string"
},
"maxResults": {
"description": "Cap full-detail entries (default 25). Beyond the cap, degrades to lean (id+name only) with a refinement hint.",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
"lean": {
"description": "Force id+name only, regardless of count. Useful to browse the catalog before drilling in.",
"type": "boolean"
}
},
"required": [
"language"
],
"$schema": "http://json-schema.org/draft-07/schema#"
}🟢lookup_asm_instruction(instruction_set, opcode)
Look up documentation for an assembly instruction
输入模式
{
"type": "object",
"properties": {
"instruction_set": {
"type": "string",
"enum": [
"6502",
"aarch64",
"amd64",
"amd_cdna1",
"amd_cdna2",
"amd_cdna3",
"amd_cdna4",
"amd_cdna5",
"amd_rdna1",
"amd_rdna2",
"amd_rdna3",
"amd_rdna3_5",
"amd_rdna4",
"arm32",
"avr",
"evm",
"java",
"llvm",
"perl",
"powerpc",
"ptx",
"python",
"riscv64",
"sass",
"wdc65c816"
],
"description": "Instruction set architecture (no default — must match the asm dialect being looked up)."
},
"opcode": {
"type": "string",
"description": "Assembly instruction mnemonic (e.g. \"MOV\", \"ADD\", \"JMP\")"
}
},
"required": [
"instruction_set",
"opcode"
],
"$schema": "http://json-schema.org/draft-07/schema#"
}🟡generate_short_url(source, language, compiler, options, libraries)
Create a Compiler Explorer short URL for sharing code with compiler settings
输入模式
{
"type": "object",
"properties": {
"source": {
"type": "string",
"description": "Source code"
},
"language": {
"type": "string",
"description": "Language ID (e.g. \"c++\", \"c\", \"rust\")"
},
"compiler": {
"type": "string",
"description": "Compiler ID from list_compilers (e.g. \"g161\", \"clang_trunk\")"
},
"options": {
"description": "Compiler flags (e.g. \"-O2 -std=c++20\")",
"type": "string"
},
"libraries": {
"description": "Libraries to include.",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Library ID from list_libraries."
},
"version": {
"type": "string",
"description": "Version id (\"188\") OR human form (\"1.88.0\")."
}
},
"required": [
"id",
"version"
]
}
}
},
"required": [
"source",
"language",
"compiler"
],
"$schema": "http://json-schema.org/draft-07/schema#"
}🟢get_shortlink_info(id)
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.
输入模式
{
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Short link ID or full URL (e.g. \"G38YP7eW4\" or \"https://godbolt.org/z/G38YP7eW4\")"
}
},
"required": [
"id"
],
"$schema": "http://json-schema.org/draft-07/schema#"
}社区
证据