Skip to main content

๐Ÿฆ˜ Clangaroo - MCP server that helps Claude jump around C++ codebases via clangd

Project description

Clangaroo Banner

๐Ÿฆ˜ Clangaroo: Fast C++ code intelligence for LLMs via MCP

MIT License Python 3.10+ clangd 16+ Buy Me A Coffee

โœจ About

NOTE (January 2026): Claude Code now has built-in support for LSPs, making this unnecessary. Since it may still be useful in other agentic harnesses I'll leave the project here for now.

Clangaroo enables Claude Code, Gemini CLI, and other coding agents to jump around your C++ codebase with ease. Clangaroo provides fast, direct lookup of C/C++ symbols, functions, definitions, call hierarchies, type hierarchies, and more by your bestest LLM pals.

Clangaroo combines the speed of Tree-sitter parsing with the accuracy of clangd LSP, optionally enhanced by Google Gemini Flash AI for deeper insights. Let your AI buddies spend more time coding and less time stumbling around.

But WHY did you make this? I โค๏ธ using Claude Code, but every time it auto-compacts and then starts grepping around for the function we've been working on for forever, I die a little bit inside. But aren't there already a few MCPs that do this - why do we need another? I spent some time searching and found both MCP-language-server and Serena, which both look perfectly nice! Unfortunately, neither worked for me ๐Ÿ˜ญ

Clangaroo is meant to be super simple and is intended to 'just work'.

๐Ÿ“š Table of Contents

๐Ÿš€ Quick Start

1. Install Clangaroo

git clone https://github.com/jasondk/clangaroo
cd clangaroo
pip install -e .

2. Special compilation step for your C++ project

The clang LSP needs you to do this once:

# For Makefile-based projects
make clean
compiledb make

# (Some people prefer using ๐Ÿป)
bear -- make
# For CMake projects
cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cp build/compile_commands.json .

This will create a special compile_commands.json file in your project root.

3. Configure Claude Desktop or other MCP client

Did you know you can now add MCP servers to LM Studio?

๐ŸŽฏ Recommended configuration with AI:

N.B.: Use of --ai-enabled will use Google Gemini and will incur a small cost via your Gemini API key, if provided. This is usually very minor as long as you use Gemini Flash or Flash Lite.

Note: Please replace 'command' and 'project' with correct paths for your system, and replace your-google-ai-api-key with your API key (if using one). If you don't wish to use the AI enhanced services, simply leave out all the --ai options and the API key.

{
  "mcpServers": {
    "clangaroo": {
      "command": "/usr/local/bin/clangaroo",
      "args": [
        "--project", "/path/to/your/cpp/project",
        "--warmup",
        "--warmup-limit", "10",
        "--log-level", "info",
        "--ai-enabled",
        "--ai-provider", "gemini-2.5-flash",
        "--ai-cache-days", "14",
        "--ai-cost-limit", "15.0",
        "--call-hierarchy-depth", "10",
        "--ai-analysis-level", "summary",
        "--ai-context-level", "minimal"
      ],
      "env": {
        "CLANGAROO_AI_API_KEY": "your-google-ai-api-key"
      }
    }
  }
}
๐Ÿ“ Claude Desktop config file locations
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Default depth of AI analysis (--ai-analysis-level, default: summary).

  • summary: Quick overview with key points
  • detailed: Comprehensive analysis with examples and context

Default depth of context (`--ai-context-level`, default: `minimal`).
- `minimal`: Just the symbol and immediate documentation
- `local`: Include surrounding code in the same file
- `full`: Include dependencies and related files

4. Restart Claude Desktop

Quit and restart Claude. You're ready to explore your C++ code! ๐ŸŽ‰

5. Add MCP server to Claude Code

claude mcp add-from-claude-desktop (and make sure clangaroo is checked)

OR

claude mcp add /usr/local/bin/clangaroo --project /path/to/your/cpp/project --warmup --warmup-limit 10 --log-level info --ai-enabled --ai-provider gemini-2.5-flash --ai-cache-days 14 --ai-cost-limit 15.0 --call-hierarchy-depth 10 --ai-analysis-level summary --ai-context-level minimal --name clangaroo --env CLANGAROO_AI_API_KEY=your-google-ai-api-key

๐ŸŽฏ Features

  • โšก Ultra-Fast Navigation: Fast response times for code structure queries
  • ๐Ÿ” Smart Symbol Search: Hybrid Tree-sitter + clangd search with automatic fallback
  • ๐Ÿ“Š Deep Code Analysis: Call hierarchies, type hierarchies, and reference tracking
  • ๐Ÿค– AI-Powered Insights: Documentation summarization, pattern detection, and architectural analysis
  • ๐Ÿ’ช Robust: Works even with compilation errors thanks to Tree-sitter fallback
  • ๐Ÿš€ Zero Configuration: Just point to a project with compile_commands.json

๐Ÿ’ฌ Usage Examples

This is really meant for coding agents like Claude Code more than you, but if you want to use it, you can just talk to your LLM naturally about your code once the MCP server is hooked up:

"Uncover the cryptic lair where the `UserManager` class is conjured from the void."  
"Reveal every shadowy corner that invokes the dreaded `summonSoulPayment()` ritual."  
"Expose the unholy powers inherited by the `DatabaseConnection` class from its ancient ancestors."  
"Dissect the twisted call hierarchy of `unleashChaos()` and narrate the program's descent into madness."
#YMMV

๐Ÿ› ๏ธ Available Tools

Tool Category Tools Description
๐Ÿ” Discovery cpp_list_files
cpp_search_symbols
Find files and symbols in your codebase
๐Ÿ“ Navigation cpp_definition
cpp_references
cpp_hover
Jump to definitions, find references, get type info
๐Ÿ“ž Call Analysis cpp_incoming_calls
cpp_outgoing_calls
Trace function relationships
๐Ÿ—๏ธ Type Hierarchy cpp_prepare_type_hierarchy
cpp_supertypes
cpp_subtypes
Analyze inheritance
โšก Structure cpp_list_functions
cpp_list_classes
cpp_get_outline
cpp_extract_signatures
Fast structural analysis

๐Ÿค– AI Features (Optional)

Setup

  1. Get your API key from Google AI Studio
  2. Add to your environment (bash):
    export CLANGAROO_AI_API_KEY="your-api-key"
    

What You Get

  • ๐Ÿ“š Smart Documentation: Complex C++ docs explained clearly
  • ๐Ÿ” Pattern Analysis: Understand why and how functions are called
  • ๐Ÿ›๏ธ Architecture Insights: Identify design patterns automatically
  • ๐Ÿ’ก Refactoring Tips: Get improvement recommendations
  • ๐Ÿ’ฐ Cost Effective: $3-7/month typical usage with smart caching

โš™๏ธ Configuration Reference

View all configuration options

Basic Options

  • --project PATH - Path to C++ project root (required)
  • --log-level LEVEL - Logging verbosity: debug, info, warning, error
  • --timeout SECONDS - LSP request timeout (default: 5.0)

Performance Options

  • --warmup - Pre-warm the index by opening key files
  • --warmup-limit N - Number of files to warm up (default: 10)
  • --wait-for-index - Wait for clangd indexing to complete
  • --index-timeout SECONDS - Timeout for index wait (default: 300)
  • --index-path PATH - Custom clangd index location

AI Options

  • --ai-enabled - Enable AI features
  • --ai-provider PROVIDER - AI provider: gemini-2.5-flash or gemini-2.5-flash-lite
  • --ai-api-key KEY - Google AI API key
  • --ai-cache-days DAYS - Cache AI summaries for N days (default: 7)
  • --ai-cost-limit AMOUNT - Monthly cost limit in USD (default: 10.0)
  • --ai-analysis-level LEVEL - Default analysis depth: summary or detailed
  • --ai-context-level LEVEL - Code context depth: minimal, local, or full

Call Hierarchy Options

  • --call-hierarchy-depth DEPTH - Maximum depth (1-10, default: 3)
  • --call-hierarchy-max-calls NUM - Total call limit (default: 100)
  • --call-hierarchy-per-level NUM - Calls per depth level (default: 25)

๐Ÿ“‹ Requirements

  • Python 3.10+
  • clangd 16+ (brew install llvm or apt install clangd)
  • C++ project with compile_commands.json
  • (Optional) Google AI API key for AI features

๐Ÿ”ง Troubleshooting

Claude doesn't see the tools
  1. Check the config file location and JSON syntax
  2. Use absolute paths in the configuration
  3. Restart Claude Desktop completely
  4. Check logs with --log-level debug
No results from queries
  1. Verify compile_commands.json includes the files
  2. Wait for indexing: add --wait-for-index flag
  3. Test clangd directly: clangd --check=file.cpp
Performance issues
  • Enable warmup: --warmup --warmup-limit 30
  • Use shared index: --index-path /shared/clangd-index
  • Reduce call hierarchy depth for large codebases

๐Ÿ“„ License

MIT License - see the file for details.

๐Ÿ™ Acknowledgments


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_jasondk_clangaroo-0.2.0.tar.gz (67.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_jasondk_clangaroo-0.2.0-py3-none-any.whl (77.8 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_jasondk_clangaroo-0.2.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_jasondk_clangaroo-0.2.0.tar.gz
  • Upload date:
  • Size: 67.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_jasondk_clangaroo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 51c6100922f1d15ecb9eb4c8e50bf3a7659266343aa27fcb1dac91fc764ae11e
MD5 05412382b652c96855ec23e7b1ae4e30
BLAKE2b-256 0ce5cf80331556b411c96e47a3558d293960f6b3e5f51f87a36b799a8196e455

See more details on using hashes here.

File details

Details for the file iflow_mcp_jasondk_clangaroo-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_jasondk_clangaroo-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 77.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_jasondk_clangaroo-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d35a5dcfe786dc17abbf4c366bd9a578be6892e5c9bdacedda79439cb2569615
MD5 301e724c0c0d93a54c7d9609d6f0d602
BLAKE2b-256 30a1821652a29322c55f5d8429b270c78cfa54f16dc8df34d8b887689fe4855f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page