Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Provides precise C++ code semantic analysis for AI coding tools like Claude Code and Cursor by integrating clangd static analysis, enabling symbol definition lookup, reference tracking, and hover information.

README.md

MCP C++ Analyzer

项目背景

使用AI 编程工具(如 GitHub Copilot、Cursor)辅助C++大型项目开发面临诸多局限性:

依赖处理效率低下:为了解决单个用户的问题,现有AI编程工具常常会整体引入整个头文件,甚至包含无关的源代码片段,如果引入的源码文件很大,那么就会导致上下文窗口和Token资源被大量占用,信息冗余,且容易引发理解混乱和响应延迟。

上下文感知能力不足:现有工具受限于上下文窗口大小,当项目代码超出窗口限制时,会对历史聊天结论内容进行文本压缩或信息截断,导致先前的分析信息丢失。

静态分析工具集成不足:在需要获取符号信息时,往往采用简单的文件内容搜索方式,缺乏与clangd等专业静态分析工具的深度集成,导致效率低下和分析结果不够精准。

项目介绍

MCP-CPP-Analyzer 是一个专为C++开发设计的Model Context Protocol (MCP) 服务,通过深度整合clangd静态分析工具,为Claude Code、Cursor等支持MCP协议的AI编程工具提供精确的C++代码语义分析能力。该服务通过符号定义查找、引用追踪、悬停信息获取等功能,实现AI工具与专业C++分析工具的无缝集成,解决现有AI编程工具在大型C++项目中的应用局限。

安装

环境要求

  • Python >= 3.12

先git clone到本地,然后安装:

uv sync //安装相关依赖
pip install -e .

请确保执行 pip install 时使用的 Python 版本 >= 3.12。可通过 python --version 确认。

使用方法

前置要求

  1. 安装 clangd:请确保已安装 clangd 并将其添加到系统环境变量(PATH)中
  • 下载地址:https://releases.llvm.org/download.html
  1. CPP项目生成 compile_commands.json:确保项目根目录包含 compile_commands.json 文件
  • CMake项目(非visual studio项目):cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
  • visual studio项目:需要使用工具将sln文件转换成 compile_commands.json

CMAKE_EXPORT_COMPILE_COMMANDS — CMake 4.1.0-rc3 Documentation

MCP 客户端连接

Cursor 配置

在 C++ 项目下创建 .cursor/mcp.json

{
  "mcpServers": {
    "cpp-analyzer": {
      "command": "mcp-cpp-analyzer",
      "args": [
        "serve",
        "--transport", "stdio",
        "--compile-db-path", "<compile_commands.json所在目录>"
      ]
    }
  }
}

安装 Cursor Rule(可选,推荐)

将内置的 Cursor 规则文件安装到目标 C++ 项目中,引导 AI 优先使用 MCP 工具进行精确的符号分析:

# 安装到指定项目目录
mcp-cpp-analyzer install-rule /path/to/your/cpp-project

# 安装到当前目录
mcp-cpp-analyzer install-rule

规则文件会被复制到 <目标目录>/.cursor/rules/ 下,已存在的同名文件不会被覆盖。

当前已支持的能力

服务器提供以下 MCP 工具:

get_definition

查找符号定义位置

get_references

查找符号引用

get_hover

获取符号的悬停信息(类型、文档等)

diagnose_clangd

诊断 clangd 服务器状态和响应能力

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Developer Tools servers.