CPPCon MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
pip install "mcp-server[fastmcp]" uvicorn requests pydantic
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add cpp-compiler-explorer -- node "<FULL_PATH_TO_MCP_COMPILER_EXPLORER>/dist/index.js"

Replace <FULL_PATH_TO_MCP_COMPILER_EXPLORER>/dist/index.js with the actual folder you prepared in step 1.

README.md

Compile C++ code and retrieve assembly output via Compiler Explorer API

CPPCon MCP Server

This project implements a Model Context Protocol (MCP) server that provides a tool to compile C++ code using the Compiler Explorer (godbolt.org) API. It allows clients to request the assembly output for given C++ code and compiler options, supporting both standard tool invocation and Server-Sent Events (SSE) for streaming results.

Features

  • MCP Compliant: Built using mcp-server[fastmcp], ensuring adherence to the Model Context Protocol.
  • get_assembly Tool: Exposes a tool that compiles C++ code using MSVC (via godbolt.org) and returns the generated assembly.
  • SSE Support: Provides a Server-Sent Events endpoint (/sse) for streaming compilation status and results.
  • Tool Discovery: Exposes a /capabilities endpoint for clients to discover available tools and their schemas.
  • Client Messaging: Supports a /message endpoint for general client-to-server communication.

Setup

Prerequisites

  • Python 3.11 or higher

Installation

  1. Create a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    
  2. Install dependencies:

    pip install "mcp-server[fastmcp]" uvicorn requests pydantic
    

Running the Server

To start the MCP server, execute the server.py script:

python server.py

The server will run on http://127.0.0.1:8000 by default.

Usage

The server exposes several endpoints compliant with the Model Context Protocol.

1. Get Server Capabilities

Clients can discover the server's capabilities, including available tools, by sending a GET request to the /capabilities endpoint.

curl http://127.0.0.1:8000/capabilities

2. Invoke `get_assembly` Tool (Standard POST)

To get the assembly output for C++ code in a single request/response cycle, send a POST request to the /tool/get_assembly endpoint.

Example Request:

curl -X POST 
     -H "Content-Type: application/json" 
     -d '{"code": "int main() { return 0; }", "options": "/O2"}' 
     http://127.0.0.1:8000/tool/get_assembly

3. Stream `get_assembly` Results (Server-Sent Events)

For streaming compilation status and results, connect to the /sse endpoint using GET. The code and options for compilation are passed as URL query parameters. An optional sessionId can also be provided for client tracking.

Example Request:

curl -N "http://127.0.0.1:8000/sse?code=int%20main()%20%7B%20return%200%3B%20%7D&options=/O2&sessionId=my_compiler_session_123"

The server will stream events in the following format:

event: message
data: {"status": "starting_compilation", "sessionId": "my_compiler_session_123"}

event: result
data: {"type": "text", "text": "; Assembly output here..."}

event: message
data: {"status": "compilation_complete", "sessionId": "my_compiler_session_123"}

In case of an error, an event: error will be sent:

event: error
data: {"type": "server_error", "text": "Error details here...", "sessionId": "my_compiler_session_123"}

4. Send Client Messages

Clients can send general messages to the server via a POST request to the /message endpoint. These messages can be used for various client-initiated communications.

Example Request:

curl -X POST 
     -H "Content-Type: application/json" 
     -d '{"type": "client_ping", "sessionId": "my_compiler_session_123", "data": "Are you alive?"}' 
     http://127.0.0.1:8000/message

The server will respond with:

{"status": "message_received", "sessionId": "my_compiler_session_123"}

5. Test Server Using modelcontextprotocol/inspector

npx @modelcontextprotocol/inspector

6. Configure using VSCode http MCP server command create mcp.json and start tool

{
    "servers": {
        "my-mcp-server-4620e938": {
            "url": "http://localhost:8000/sse",
            "type": "http"
        }
    },
    "inputs": []
}

7. Chat with Copilot, when context need assembly, it will invoke

Tools (1)

get_assemblyCompiles C++ code using MSVC via godbolt.org and returns the generated assembly.

Configuration

claude_desktop_config.json
{"servers": {"my-mcp-server-4620e938": {"url": "http://localhost:8000/sse", "type": "http"}}}

Try it

Compile this C++ code and show me the assembly output: int main() { return 0; }
Get the assembly for the following C++ snippet using /O2 optimization: #include <iostream> int main() { std::cout << "Hello World"; return 0; }
What does the assembly look like for this C++ function when compiled with MSVC?

Frequently Asked Questions

What are the key features of CPPCon MCP Server?

MCP compliant server built with fastmcp. Provides get_assembly tool for C++ compilation. Supports Server-Sent Events (SSE) for streaming compilation results. Exposes capabilities and message endpoints for client communication.

What can I use CPPCon MCP Server for?

Analyzing assembly output for C++ performance optimization. Verifying compiler behavior for specific C++ code snippets. Integrating C++ compilation feedback directly into AI-assisted coding workflows.

How do I install CPPCon MCP Server?

Install CPPCon MCP Server by running: pip install "mcp-server[fastmcp]" uvicorn requests pydantic

What MCP clients work with CPPCon MCP Server?

CPPCon MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep CPPCon MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare