A Model Context Protocol (MCP) server that provides efficient access to Compiler Explorer (godbolt.org) compilation and execution services.
- Token-efficient responses - Minimized output while preserving essential information
- Use-case driven tools - Specific functions for common compilation scenarios
- Smart filtering - Context-aware output filtering based on the task
- Comprehensive language support - C++, C, Rust, Go, Python, and more
- Claude Code integration - Automated setup for Claude Code workflows
If you're using Claude Code, simply run:
git clone https://github.com/compiler-explorer/ce-mcp
cd ce-mcp
./setup-claude-code.sh
This will automatically install and configure everything. That's it!
- Python 3.10+ - Required for running the MCP server
- UV - Fast Python package manager (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
Or on macOS with Homebrew:
brew install uv
# Clone the repository
git clone https://github.com/compiler-explorer/ce-mcp
cd ce-mcp
# Option A: Quick setup (Linux/macOS)
./setup.sh
# Option B: Manual setup
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e ".[dev]"
# Run unit tests
.venv/bin/pytest tests/ -m "not integration"
# Run integration tests (requires internet)
.venv/bin/pytest tests/ -m integration
# Run all tests
.venv/bin/pytest tests/
# Basic usage
ce-mcp
# With custom configuration
ce-mcp --config ~/.config/ce-mcp/config.yaml
# With verbose logging
ce-mcp --verbose
The server provides 12 specialized MCP tools for compilation, analysis, and sharing. See docs/available_tools.md
for detailed documentation of each tool.
Core Tools:
compile_check_tool
- Syntax validationcompile_and_run_tool
- Compile and executecompile_with_diagnostics_tool
- Error analysis
Analysis Tools:
analyze_optimization_tool
- Assembly optimization analysiscompare_compilers_tool
- Compiler comparisonlookup_instruction_tool
- Assembly instruction documentation
Discovery & Sharing:
generate_share_url_tool
- Create Compiler Explorer URLsfind_compilers_tool
- Find compilers with filteringget_libraries_tool
- List available librariesget_library_details_tool
- Library informationget_languages_tool
- List supported languagesdownload_shortlink_tool
- Download shared code
Create a configuration file at ~/.config/compiler_explorer_mcp/config.yaml
:
compiler_explorer_mcp:
api:
endpoint: "https://godbolt.org/api"
timeout: 30
defaults:
language: "c++"
compiler: "g132"
output_limits:
max_stdout_lines: 100
max_stderr_lines: 50
# Install with development dependencies
uv pip install -e ".[dev]"
# Run tests
.venv/bin/pytest tests/
# Run integration tests (requires internet)
.venv/bin/pytest tests/ -m integration
# Format code
black .
isort .
# Type checking
mypy ce_mcp/
# Code quality checks
uv run black ce_mcp/ tests/
isort ce_mcp/ tests/
If you prefer using pip instead of UV:
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -e ".[dev]"
# Run the server
python -m ce_mcp.cli
"command not found: ce-mcp"
- Make sure your virtual environment is activated
- Try running directly:
python -m ce_mcp.cli
"ModuleNotFoundError: No module named 'packaging'"
- Install missing dependency:
uv pip install packaging
- Or reinstall with all dependencies:
uv pip install -e .
"ModuleNotFoundError: No module named 'ce_mcp'"
- Install in development mode:
uv pip install -e .
- Check your virtual environment is activated
Integration tests failing
- Tests require internet access to godbolt.org
- Some tests may be skipped if the API is temporarily unavailable
- Run unit tests only:
pytest tests/ -m "not integration"
"uv not found"
- Install UV:
curl -LsSf https://astral.sh/uv/install.sh | sh
- Or use pip:
pip install -e ".[dev]"
Create ~/.config/ce-mcp/config.yaml
for custom settings:
compiler_explorer_mcp:
api:
timeout: 30
defaults:
language: "c++"
compiler: "g132"
output_limits:
max_stdout_lines: 50
BSD-2-Clause