loading…
Search for a command to run...
loading…
An MCP server that enables users to compile C++ code and retrieve assembly output through the Compiler Explorer (godbolt.org) API. It supports standard tool cal
An 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.
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.
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) for streaming compilation status and results./capabilities endpoint for clients to discover available tools and their schemas./message endpoint for general client-to-server communication.Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Install dependencies:
pip install "mcp-server[fastmcp]" uvicorn requests pydantic
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.
The server exposes several endpoints compliant with the Model Context Protocol.
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
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
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"}
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"}
npx @modelcontextprotocol/inspector
{
"servers": {
"my-mcp-server-4620e938": {
"url": "http://localhost:8000/sse",
"type": "http"
}
},
"inputs": []
}
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"cppcon-mcp-server": {
"command": "npx",
"args": []
}
}
}