Installing and updating cg
cg is a Python package (Python 3.11+). The PyPI name is cg-code-graph; the commands are cg and cg-mcp. It installs as a user-level tool. No checkout and no sudo.
New here? Quick start indexes a sample app and runs the first queries in a few minutes.
Install
Recommended.
uv tool install cg-code-graph
If you already use pipx.
pipx install cg-code-graph
The install script picks uv or pipx.
curl -fsSL https://raw.githubusercontent.com/cyberchronos00/code-graph/main/install.sh | sh
Run this in PowerShell.
irm https://raw.githubusercontent.com/cyberchronos00/code-graph/main/install.ps1 | iex
Latest commit or a tag. pipx install takes the same git URL.
uv tool install git+https://github.com/cyberchronos00/code-graph
uv tool install git+https://github.com/cyberchronos00/code-graph@vX.Y.Z
install.sh --version vX.Y.Z
Virtual environment
Inside a venv, pip works too.
pip install cg-code-graph
cg doctor
cg doctor
It lists the tools it found, whether extractor dependencies are installed, and for each language whether indexing is exact or heuristic. Pass a project path to check that project. The MCP doctor tool prints the same report.
One MCP server for many graphs
cg install --host cursor registers one project graph. In a project it also writes a short "use cg first" rule for agents: a marked section in AGENTS.md and .cursor/rules/cg.mdc (--no-rules skips both; see Install into a host). When several repos would each add their own cg-* server, register them once and run a single cg-mcp:
cg install --global --registry --host cursor
cg install --global --migrate --host cursor # dry run
cg install --global --migrate --apply --host cursor # write ~/.config/cg/graphs.toml and the host config
--registry writes one cg entry with no --db. The server reads ~/.config/cg/graphs.toml (CG_GRAPHS overrides the path). --migrate folds existing per-repo cg-* entries into that file. It prints the plan and writes nothing until --apply, which also saves a .bak of each config it changes. Details: MCP server.
JavaScript runtime
TypeScript / JavaScript indexing needs Node.js 20+ or Bun (tested with Bun 1.4.2).
Lookup order: CG_NODE, then node, then bun on PATH.
Extractor dependencies install with npm ci, or bun install when npm is missing.
A Bun-only container (oven/bun) needs nothing else.
cg doctor names the runtime it found.
Update and uninstall
Update.
uv tool upgrade cg-code-graph
Uninstall.
uv tool uninstall cg-code-graph
Update.
pipx upgrade cg-code-graph
Uninstall.
pipx uninstall cg-code-graph
Update, shell then PowerShell.
install.sh --update
install.ps1 -Update
Uninstall, shell then PowerShell.
install.sh --uninstall
install.ps1 -Uninstall
The old package name codegraph (through v0.9.0) is removed by the install scripts. By hand: uninstall codegraph, then install cg-code-graph.
Upgrading to 0.17
0.17 renames the import package to cg_code_graph. Two other PyPI projects (codegraph and codegraph-py) already ship a top-level codegraph package, and another project uses the older environment prefix, so this project no longer uses either.
- Environment variables are
CG_*(CG_JOBS,CG_CACHE, …). TheCODEGRAPH_*names were removed in 0.19.0: renameCODEGRAPH_<NAME>toCG_<NAME>, and renameCODEGRAPH_CACHEandCODEGRAPH_CACHE_DIRtoCG_CACHE. - The cache root is
~/.cache/cg(%LOCALAPPDATA%\cgon Windows, or$XDG_CACHE_HOME/cg). The first command that uses the default root moves~/.cache/codegraphthere and dropsswift-build/(SwiftPM build directories embed absolute paths, so the next Swift index rebuilds). Extractor installs, SCIP output and fact caches move with it. SetCG_CACHEto keep a cache where it is. python -m cg_code_graph.clireplacespython -m codegraph.cli.python -m cg_code_graphworks the same way. Thecgandcg-mcpcommands are unchanged. MCP entries thatcg installwrote with an absolutecg-mcpkeep working. An entry that still runspython -m codegraph.mcp_serveris reported bycg doctor; re-runcg install.- Git hooks that still run
python -m codegraph.clistop refreshing until you re-runcg hooks install.cg hooks statusandcg doctorname an outdated hook.
Elsewhere
- Extractors install on the first index that needs them, or with
cg setup. Cache and prune:cg setup -hand clean. - Exact mode for Rust, C / C++, Kotlin and Swift needs optional indexers: Rust, C and C++, Kotlin, Swift. Java heuristic mode needs no JDK;
cg setup java/install.sh --with javaprint the JDK 17+ hint for scip-java (Java). - What the install scripts do:
install.sh --help. Working on a checkout of cg: Contributing.
Generated, copied and vendored files
cg keeps generated files out of the graph by default and lists them in cg coverage. A copy points back at the file you edit.
Java
What .java adds beyond Install, CLI specs, and Graph schema: the heuristic syntax layer and the ids those pages do not spell out. Toolchain fit: cg doctor. Why a file stayed heuristic: cg coverage.