Compiler Explorer MCP
Connects LLMs to the Compiler Explorer API, enabling code compilation, exploring compiler features, analyzing optimizations, and comparing assembly output across different compilers, optimization levels, and programming languages.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Compiler Explorer MCP compare the assembly output of a virtual function call vs a normal function call in GCC 13"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Compiler Explorer MCP
A Model Context Protocol (MCP) server that connects LLMs to the Compiler Explorer API, enabling them to compile code, explore compiler features, and analyze optimizations across different compilers and languages.
Example Questions
Here are some interesting questions you can ask your LLM using this MCP:
Compiler Feature Exploration
"What is the earliest version of GCC that supports the
#embeddirective?""Show me how different versions of Clang handle C++20 modules"
"What optimization flags are available in Clang 12 that weren't in Clang 11?"
"Can you demonstrate how MSVC and GCC handle C++20 coroutines differently?"
Optimization Analysis
"What's the assembly difference between
-O2and-O3for a simple recursive Fibonacci function in GCC 13?""How does Clang's vectorization compare to GCC's for a basic matrix multiplication?"
"Show me how different optimization levels affect tail-call optimization in this recursive function"
"What's the impact of
-ffast-mathon this floating-point heavy computation?"
Language Feature Support
"Which C++20 features are supported in the latest versions of GCC, Clang, and MSVC?"
"Show me how different compilers implement std::optional's memory layout"
"Compare how GCC and Clang handle C++20's constexpr virtual functions"
"Demonstrate the differences in how Intel and GCC compilers auto-vectorize SIMD operations"
Assembly Deep Dives
"What's the most efficient way to implement a population count in x86 assembly across different CPU architectures?"
"Show me how different compilers optimize a simple string reverse function at -O3"
"Compare the assembly output of a virtual function call vs a normal function call"
"How do different compilers implement std::variant's type switching in assembly?"
Cross-Language Comparison
"Compare the generated assembly for the same algorithm in C++, Rust, and Go"
"How do exception handling mechanisms differ between C++ and Rust in terms of generated code?"
"Show me the overhead of Rust's bounds checking compared to unchecked C++ array access"
"Compare how C++ and D implement RAII in terms of generated assembly"
Performance Investigation
"What's the assembly-level difference between using std::sort and a hand-written quicksort?"
"Show me how different string concatenation methods compare in terms of generated instructions"
"Compare the efficiency of std::map vs std::unordered_map operations in assembly"
"How do different smart pointer implementations affect inlining and code size?"
Available Tools
5 toolscompile_codeA
Compile source code using specified compiler and options.
Args:
source: Source code to compile
language: Programming language of the source code
compiler: Compiler name or ID to use
ctx: MCP context for logging and error reporting
options: Compiler flags and options
filters: Configuration for filtering compiler output
libraries: List of library dependencies
Returns:
Dictionary containing compilation results with keys:
- code: Exit code of the compilation
- stdout: Standard output from the compiler
- stderr: Standard error from the compiler
- asm: Generated assembly (if applicable)
Raises:
HTTPException: If compilation fails, compiler not found, or API request fails
Example:
>>> result = await compile_code(
... source="int main() { return 0; }",
... language="cpp",
... compiler="gcc",
... ctx=ctx
... )
Inputs: source (required), language (required), compiler (required), options, +2 more.
get_opcode_documentationB
Get documentation for a specific opcode in a given instruction set. If a user asks about an opcode, but you don't have the instruction set, you can query list_compiler_versions for a specific compiler and it will tell you the instruction set. You are not an expert on opcodes, so if a user asks about an opcode, you should always use this tool!
Args:
instruction_set: Instruction set to search for opcode documentation
opcode: Opcode to search for documentation
Example:
>>> await get_opcode_documentation("amd64", "lea")Inputs: instruction_set (required), opcode (required).
list_compilers_for_languageA
Get available compilers for a specific programming language.
Args:
language: Programming language to get compilers for (e.g., 'cpp', 'rust')
Returns:
List of unversioned compiler names available for the language
Raises:
HTTPException: If the API request fails
Example:
>>> await list_compilers_for_language("cpp")
["gcc", "clang", "msvc"]
Inputs: language (required).
list_compiler_versionsA
Get available compiler versions matching a compiler name regex.
NOTE: This may return a lot of results! Choose a specific regex to narrow down the results and not overflow the MCP client.
Args:
compiler_regex: Regular expression to match compiler names (case-insensitive)
Returns:
List of dictionaries containing matching compiler information, each with keys:
- id: Unique identifier for the compiler
- name: Display name of the compiler
- semver: Version string of the compiler
Raises:
HTTPException: If the API request fails
Example:
>>> await list_compiler_versions("gcc")
[{"id": "gcc-12.2", "name": "GCC 12.2"}, {"id": "gcc-11.3", "name": "GCC 11.3"}]
>>> await list_compiler_versions("clang.*trunk")
[..., {"id": "irclangtrunk", "name": "clang (trunk)", "lang": "llvm", "compilerType": "", "semver": "(trunk)", "instructionSet": "amd64"}, ...]
Inputs: compiler_regex (required).
list_languagesA
Get a list of supported programming languages.
Returns:
List of dictionaries containing language information, each with keys:
- id: Unique identifier for the language
- name: Display name of the language
- extensions: List of file extensions associated with the language
Raises:
HTTPException: If the API request fails
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a distinct, non-overlapping purpose: compile_code handles compilation, get_opcode_documentation provides opcode docs, list_compilers_for_language lists compilers by language, list_compiler_versions lists compiler versions, and list_languages lists supported languages. There is no ambiguity in tool selection.
Tools follow a consistent verb_noun pattern (compile_code, get_opcode_documentation, list_compilers_for_language, list_compiler_versions, list_languages), all using snake_case. The minor deviation is that get_opcode_documentation uses 'get' while others use 'list' or 'compile', but this is appropriate for its action and doesn't break consistency.
With 5 tools, this is well-scoped for a compiler exploration server. Each tool serves a clear purpose in the workflow (listing languages/compilers, compiling code, getting documentation), and none feel redundant or missing given the domain.
The toolset covers core compiler exploration tasks: listing languages and compilers, compiling code, and accessing opcode documentation. A minor gap is the lack of tools for managing compilation sessions or saving/loading code snippets, but the provided tools enable basic compilation and exploration workflows without dead ends.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
The OpenRouter MCP server plugs OpenRouter into the AI tools you already use. Once connected, your assistant can pull live OpenRouter data (models, prices, your credits, rankings, and docs) and send quick test messages, all without leaving your editor.
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables LLMs to read, search, and analyze code files with advanced caching and real-time file watching capabilities.640MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables Large Language Models to interact with Binary Ninja for reverse engineering tasks like viewing assembly code, decompiled code, renaming functions, and adding comments.3MIT
- FlicenseAqualityNot gradedmaintenanceA Model Context Protocol server that allows LLMs to interact with Python environments, enabling code execution, file operations, package management, and development workflows.9-
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables users to compile C++ code and retrieve assembly output through the Compiler Explorer (godbolt.org) API. It supports standard tool calls and Server-Sent Events for streaming compilation status and results.-