Skip to main content

Generic codebase knowledge graph engine for Python projects.

Project description

codebaseGraph

codebaseGraph builds a repo-local knowledge graph for coding agents. It materializes Python source, AGENTS.md, CLAUDE.md, 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 --format block

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 setup installs the default MCP server as codebase_graph.
  • Standalone codebase-graph mcp install defaults to codebase_graph_<repo>.
  • Use --name codebase_graph to 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_health
  • graph_search
  • graph_context
  • graph_schema
  • graph_query_helpers
  • graph_architecture_queries
  • graph_query with 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 --format block
codebase-graph graph-query "MATCH (n) RETURN count(n) AS total_nodes LIMIT 1" --repo-root .

Use --format block for agent-facing output and --json --pretty for structured inspection. 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 .codebaseGraph if 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 .codebaseGraph paths 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.lock file before removing it manually.
  • Diagnostics: set CODEBASE_GRAPH_LOG_LEVEL=INFO to 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

cbasegraph-0.2.1.tar.gz (125.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cbasegraph-0.2.1-py3-none-any.whl (94.1 kB view details)

Uploaded Python 3

File details

Details for the file cbasegraph-0.2.1.tar.gz.

File metadata

  • Download URL: cbasegraph-0.2.1.tar.gz
  • Upload date:
  • Size: 125.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cbasegraph-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2e58610601b57785e74b83758f2928cedd7ed5b8cd3c3203935524b09c9123be
MD5 d95e676d91ba2324eb5b5c7da70eff49
BLAKE2b-256 7503619205975ee3efd7cd0bba1424ada76fc34d57eda4ffa1785012f24027c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbasegraph-0.2.1.tar.gz:

Publisher: release.yml on rabii-chaarani/codebaseGraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cbasegraph-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cbasegraph-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 94.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cbasegraph-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bfe0dc40dbc12e3f312fadfc50264e9ebf09d1a7cf2fcfb084b5f7b776e0434c
MD5 a81af2ecc5fda467834d7c1fed7ab940
BLAKE2b-256 6c8c17270b3486e0abedac4bbf217cca2151d17dc286d8b3f04472ed758c528b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbasegraph-0.2.1-py3-none-any.whl:

Publisher: release.yml on rabii-chaarani/codebaseGraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page