Generic codebase knowledge graph engine for Python projects.
Project description
codebaseGraph
codebaseGraph is alocal knowledge graph for AI coding agents. It builds a graph from Python source code, Markdown, and MDX files into a LadyBugDB-backed graph, then exposes search, compact context, schema, query
helpers, and read-only MCP tools.
Using codebaseGraph helps agents orient and reason faster, reduce guesswork, keep prompts focused, and make changes with better
impact awareness. Because the graph stores local source, documentation, spans, and relationships together, it gives
AI agents a compact evidence layer for safer edits, architecture review, dependency tracing, and onboarding while reducing token consumption and tool calling.
Requires Python 3.10+
Quick start
python -m pip install cbasegraph
codebase-graph setup --repo-root .
codebase-graph graph-search SampleService --repo-root . --no-refresh
Setup creates:
.codebaseGraph/
config.json
manifest.json
<repositoryName>_graph.ldb
For a repository named my-service, the database path is .codebaseGraph/my-service_graph.ldb.
The setup command materializes the graph, writes or updates one marked codebaseGraph block in AGENTS.md or
CLAUDE.md, and installs a Codex MCP client entry unless skipped.
Useful setup options:
codebase-graph setup --repo-root /path/to/repo
codebase-graph setup --mcp-client claude
codebase-graph setup --mcp-client lmstudio
codebase-graph setup --skip-mcp-config
codebase-graph setup --instructions-target claude
codebase-graph setup --dry-run --pretty
MCP install
codebase-graph mcp install --client codex
Supported clients are codex, claude, claude-project, lmstudio, hermes, openclaw, and generic.
Server naming:
codebase-graph setupinstalls the default MCP server ascodebase_graph.- Standalone
codebase-graph mcp installdefaults tocodebase_graph_<repo>. - Use
--name codebase_graphto override the standalone installer name.
The installer builds the server descriptor from .codebaseGraph/config.json, uses a supported native client CLI when
available, and falls back to writing the client config file directly. Use --dry-run --json to inspect the emitted
command or config patch before writing, and --verify to run a stdio smoke test after installation.
codebase-graph mcp install --client claude --scope user
codebase-graph mcp install --client claude-project
codebase-graph mcp install --client all --dry-run --json
codebase-graph mcp install --config-path /path/to/.codebaseGraph/config.json
codebase-graph mcp install --verify
MCP usage
Stdio is the default transport for local MCP clients:
codebase-graph mcp serve --config .codebaseGraph/config.json
codebase-graph-mcp --config .codebaseGraph/config.json
HTTP is available for local endpoint clients:
codebase-graph mcp http --config .codebaseGraph/config.json --host 127.0.0.1 --port 8765
Keep HTTP bound to 127.0.0.1 for normal use. Remote binding requires --allow-remote and a bearer token, but does not
provide TLS, rate limiting, authorization scopes, or a multi-user security model. HTTP clients must initialize first and
send the returned Mcp-Session-Id header on later requests.
Available MCP tools:
graph_healthgraph_searchgraph_contextgraph_schemagraph_query_helpersgraph_architecture_queriesgraph_querywith write-like statements blocked
graph_query returns at most 1,000 rows per call. Add a narrower MATCH pattern or a query-side LIMIT for broader
graph exploration.
CLI workflow
The CLI mirrors the MCP tools for clients that do not surface MCP directly:
codebase-graph graph-health --repo-root .
codebase-graph graph-context SampleService --repo-root . --profile definitions
codebase-graph graph-query "MATCH (n) RETURN count(n) AS total_nodes LIMIT 1" --repo-root .
Retrieval commands emit block format by default for agent-facing output. Use --json --pretty or --format json for structured inspection. MCP callers can request the typed payload with include_structured_content: true.
Retrieval commands also support --detail standard|slim; slim drops score diagnostics and duplicate or empty summary fields.
For coding-task architecture orientation, call graph_architecture_queries first, then run selected statements with
graph_query.
Development
python -m pip install -e .[dev]
python -m pytest
ruff check .
Release and security
CI runs pytest across Linux, macOS, and Windows for Python 3.10 through 3.14, plus ruff, package-build checks, supply-chain validation, and smoke tests. See docs/release.md for the full release process and conda-forge checklist.
Report suspected vulnerabilities privately. See SECURITY.md for supported versions, reporting expectations, and the local-first MCP security boundary.
Troubleshooting
- Missing LadyBugDB: install a package build that includes
real_ladybug; setup fails before creating.codebaseGraphif the runtime cannot open a graph database. - Stale graph: rerun
codebase-graph setup --repo-root .after material source or documentation changes. - Broken client config: rerun
codebase-graph mcp install --client <client> --verify. - PATH or executable issues: run setup from the virtual environment that contains
codebase-graph; the descriptor prefers that absolute executable path. - Unsupported files: binary, vendor, cache, virtualenv, build, dist,
.codebase_graph, and.codebaseGraphpaths are skipped. - Lock errors: stop other graph materialization or setup processes using the same
.codebaseGraph/<repositoryName>_graph.ldb. Stale locks with dead writer PIDs are removed automatically; if the error remains, inspect the.ldb.lockfile before removing it manually. - Diagnostics: set
CODEBASE_GRAPH_LOG_LEVEL=INFOto include setup start/completion events on stderr.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cbasegraph-0.2.4.tar.gz.
File metadata
- Download URL: cbasegraph-0.2.4.tar.gz
- Upload date:
- Size: 146.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ed650d160656f4c6a5ef760f0b8c00663d2c7964f90d12d848d1e7380f376e9
|
|
| MD5 |
d271ea6239bd7bf01cd92832e1c96e6b
|
|
| BLAKE2b-256 |
a181c6471088562ed839f37a362e73889a1a636e16166a8623003f5b367bcdea
|
Provenance
The following attestation bundles were made for cbasegraph-0.2.4.tar.gz:
Publisher:
release.yml on rabii-chaarani/codebaseGraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cbasegraph-0.2.4.tar.gz -
Subject digest:
2ed650d160656f4c6a5ef760f0b8c00663d2c7964f90d12d848d1e7380f376e9 - Sigstore transparency entry: 1775566582
- Sigstore integration time:
-
Permalink:
rabii-chaarani/codebaseGraph@4a23a51b1e5060991d2a1ab0f8ab812b646380ac -
Branch / Tag:
refs/heads/main - Owner: https://github.com/rabii-chaarani
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4a23a51b1e5060991d2a1ab0f8ab812b646380ac -
Trigger Event:
push
-
Statement type:
File details
Details for the file cbasegraph-0.2.4-py3-none-any.whl.
File metadata
- Download URL: cbasegraph-0.2.4-py3-none-any.whl
- Upload date:
- Size: 121.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2134dda1088d150609d695909ca7204a395fc2251bfdd255d5d893bdf00a5948
|
|
| MD5 |
e9fb339a00e149fab2ac9a51dfdac9e7
|
|
| BLAKE2b-256 |
b98db0624484b897c122418dfe4f351520ba9528f85bd2ba7d9dcd87e0665b34
|
Provenance
The following attestation bundles were made for cbasegraph-0.2.4-py3-none-any.whl:
Publisher:
release.yml on rabii-chaarani/codebaseGraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cbasegraph-0.2.4-py3-none-any.whl -
Subject digest:
2134dda1088d150609d695909ca7204a395fc2251bfdd255d5d893bdf00a5948 - Sigstore transparency entry: 1775567049
- Sigstore integration time:
-
Permalink:
rabii-chaarani/codebaseGraph@4a23a51b1e5060991d2a1ab0f8ab812b646380ac -
Branch / Tag:
refs/heads/main - Owner: https://github.com/rabii-chaarani
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4a23a51b1e5060991d2a1ab0f8ab812b646380ac -
Trigger Event:
push
-
Statement type: