CodeGraph安装及在idea的claude code插件中使用

介绍

CodeGraph 是一个本地优先的代码智能系统,它将你的代码库转化为可查询的知识图谱------包含符号、关系、调用路径和文件结构------然后通过模型上下文协议(MCP)将其暴露给 AI 编程 Agent。当 Agent 面临结构化问题时,无需再生成开销昂贵的 Explore 子 Agent 去执行 grep 和读取大量文件,CodeGraph 允许它以亚毫秒级的读取速度查询预索引的 SQLite 图谱。结果便是:Agent 会话成本降低约 25%,工具调用减少约 62%,且答案通常无需读取任何文件------这一切均在你的本机 100% 本地运行,无需 API 密钥或外部服务。

项目地址

https://github.com/colbymchenry/codegraph/tree/b026e64b413bb4dca1bc7326d7de0837afe0a899

安装

我采用的node方式进行安装的 要求的是node版本20+

bash 复制代码
npm i -g @colbymchenry/codegraph

自动检测安装

bash 复制代码
codegraph install --yes 

也可以选择其他安装模式(选择其一安装就行)

bash 复制代码
codegraph install                                    #交互式安装
codegraph install --yes                              # 自动检测,接受默认值
codegraph install --target=cursor,claude --yes       # 显式指定目标
codegraph install --target=auto --location=local     # 检测到的 Agent,项目本地配置
codegraph install --print-config codex               # 打印 MCP 代码片段,不写入文件

在项目根目录下执行用于构建初始知识图谱

bash 复制代码
codegraph init -i

查看状态

bash 复制代码
codegraph status

卸载

bash 复制代码
codegraph uninstall          # 从所有已配置的 Agent 中移除 MCP 配置
codegraph uninit             # 从当前项目中移除 .codegraph/

集成到idea中的claude code插件

查看node位置

bash 复制代码
npm config get prefix

找到目录下的 codegraph.cmd

我这里的claude code插件用的是CC GUI

重启下我们的idea编辑器

然后修改claude code 的mcp,路径替换一下

bash 复制代码
{
  "mcpServers": {
    "codegraph": {
      "type": "stdio",
      "command": "D:\\Tools\\work\\NVM\\v22.12.0\\codegraph.cmd",
      "args": [
        "serve",
        "--mcp"
      ]
    }
  }
}

测试

bash 复制代码
@codegraph 统计 Java 类总数
相关推荐
zzipeng1 小时前
Linux 并发与竞争
java·linux·运维
27669582921 小时前
京东随机变速滑块拼图验证码识别(京东E卡)
java·服务器·前端·python·京东滑块·京东变速滑块·京东e卡绑卡
未若君雅裁1 小时前
ArrayList 源码全解析:动态扩容、数组互转与底层原理
java
wbc103155581 小时前
基于 VSCode + Icarus 的 Verilog 编译和仿真
ide·vscode·编辑器
Java程序员-小白1 小时前
Spring Boot整合Sa-Token框架(入门篇)
java·spring boot·后端·sa-token
NE_STOP1 小时前
Docker--初识Dockerfile
java
码哥字节2 小时前
升到 Spring Boot 4.1,虚拟线程开了,HikariCP 连接池却崩了
java·springboot·claude code
devilnumber2 小时前
java自定义事件处理器极简版:「外卖点餐」场景
java·开发语言