cpp-analysis-mcp
cpp-analysis-mcp
C++コードを読むだけでなく、実際にテストできるようにするAIコーディングエージェント向けのMCPサーバーです。
問題
C++のバグの中には、ソースコード上では見えないものがあります。これは問題なさそうに見えます:
void deposit(int amt) {
balance += amt; // no lock
}100スレッドから実行すると、更新が失われます。このバグはテキストではなくタイミングに存在するため、ファイルを読むだけのAIはこれを問題なしと判断します。
これらのバグを検出するツールはすでに存在し、優れています。ただ、それらはAIアシスタントに接続されていないコマンドラインプログラムにすぎません。このプロジェクトは、その接続を実現するものです。
Related MCP server: cpp-semantic-graph
機能
8つのツール、3つの問い:
問い | ツール | コスト |
何かおかしいところはあるか? | static_check_file / _snippet | 秒 |
実際に間違っているか? | sanitize_file / _project / _snippet | 分 |
どこが遅いか? | profile_file / _project | 分 |
エージェントは低コストから始め、必要な場合にのみ段階を上げます。8番目のツールであるcapabilitiesは、このマシンで実際に実行できることを報告します。
内部では、データ競合にはThreadSanitizer、メモリ破壊にはAddressSanitizer、リークにはLeakSanitizer、未定義動作にはUBSan、コンパイル時にはclang-tidyと-Wthread-safety、プロファイリングにはperfを使用しています。
プラットフォーム対応
Linux | macOS | Windows | |
ASan、UBSan、静的チェック | 対応 | 対応 | 対応 |
TSan、LSan | 対応 | 対応 | 対応(WSL経由) |
プロファイラー(perf) | 対応 | 未対応 | 対応(WSL経由) |
Windowsでは、サーバーがWSLディストリビューションを自動的に見つけ、Linux専用ツールをその経由で実行します。通常のC:\パスを渡し続けるだけで済みます。実行できないものがある場合、サーバーはそれを明確に伝え、修正するためのコマンドを提示します。
セットアップ
Python 3.11以上、uv、およびC++コンパイラ(clangまたはgcc)が必要です。
git clone https://github.com/GusDawn123/cpp-analysis-mcp
cd cpp-analysis-mcp
uv sync次に、エージェントに登録します。Claude Codeの場合:
claude mcp add cpp-analysis -- uv run --directory <path-to-repo> cpp-analysis-mcp他のMCPクライアントの場合は、同じコマンドを設定ファイルに追加します:
{ "mcpServers": { "cpp-analysis": {
"command": "uv",
"args": ["run", "--directory", "<path-to-repo>", "cpp-analysis-mcp"]
}}}初回起動には1分かかります。サーバーは各解析について小さなバグを含むプログラムをコンパイルして実行し、ツールが実際にマシン上で動作することを確認した上で、結果をキャッシュします。
空の結果を信頼できる理由
サーバーはツールの言葉をそのまま信じることはありません。起動時に実際のバグ(データ競合、リーク、オーバーフロー)を仕込み、各検出器がそれを検出することを要求します。既知のバグに対して沈黙する検出器は、理由と修正するためのインストールコマンドとともに「利用不可」として報告されます。
つまり、空のレポートは、ここで動作することが証明されている検出器が何も見つけなかったことを意味します。この違いは重要です。なぜなら、静かに壊れたツールはクリーンなコードとまったく同じに見えるからです。
アーキテクチャ
your AI agent (Claude Code, Cursor, anything that speaks MCP)
|
server.py eight tools, no logic of its own
|
pipelines/ the recipes: check, sanitize, profile
|
+----------+-------------+
| | |
build/ process.py parsers/
compiles runs tools raw tool output in,
the code safely, with clean findings out
| timeouts
|
+-- platforms/ what Linux, macOS, and Windows each need
+-- toolchains/ what clang and gcc each need
+-- wsl.py Windows borrowing Linux for what it lacksレイヤー規則はソースツリーを解析するテストによって強制されるため、腐敗することはありません。server.pyは制御フローを持たず、process.pyだけがサブプロセスを起動でき、パーサーはファイルに触れることがなく、このマシンが何であるかを問い合わせることができるモジュールは正確に1つだけです。
テスト
507のユニットテストはコンパイラ不要でどこでも実行できます。統合テストはバグを仕込んだフィクスチャをコンパイルして実行し、Linux、macOS、Windowsで取得したゴールデン出力がすべてのパーサーの正確性を保証します。
make testライセンス
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
AI-native git hosting — repos, PRs, issues, CI gates, and AI code review over MCP (60 tools).
MCP server for building and testing AI agents with multi-model experimentation and insights.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Voice-powered bug reporting with 13 MCP tools. Record bugs by talking; let AI find and fix them.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that exposes LLDB debugging capabilities, enabling AI-assisted interactive debugging of C/C++ applications through 40 specialized tools.39 PyPI4MIT
- FlicenseNot gradedqualityBmaintenanceBuilds a semantic knowledge graph of C++ code and exposes 9 MCP tools for AI assistants to search classes, functions, inheritance, callers, callees, overrides, and more.3-
- FlicenseNot gradedqualityDmaintenanceEnables AI coding assistants to manage persistent memory, search project context, generate tests, review architecture, and orchestrate workflows through 15 MCP tools, enhancing context-aware code generation.-
- FlicenseBqualityCmaintenanceEnables AI agents to perform comprehensive, zero-infrastructure codebase analysis through 24 MCP tools, covering security, quality, architecture, type safety, git history, and dead code detection with high precision and local privacy.45-