Skip to main content

CseGraph

CseGraph is a local-first context system for coding agents. It indexes a repository into SQLite, retrieves the smallest useful code slices for a task, and exposes focused graph expansion only when structural evidence is needed.

CseGraph 2.0 is a hard compatibility cutoff:

  • the index schema is csegraph-sqlite-v12;
  • an index created by another schema must be rebuilt with csegraph index;
  • there is no schema migration path;
  • indexed source languages are Python, JavaScript, and TypeScript;
  • the public surface is nine CLI commands and six strict MCP tools.

Install

CseGraph requires Python 3.10 or newer.

python -m pip install csegraph

Create a fresh index:

csegraph index /path/to/repository

Retrieve task-specific context:

csegraph context "Fix stale cache invalidation" \
  --repo /path/to/repository \
  --target Cache.invalidate \
  --token-budget 800 \
  --format markdown

Register the MCP server for a supported coding client:

csegraph install /path/to/repository --platform codex

CLI

The CLI has exactly nine commands:

Command Purpose
csegraph index Build and atomically install a fresh v12 index.
csegraph refresh Apply changed and deleted files to an existing v12 index.
csegraph context Retrieve compact, budgeted task context.
csegraph graph Inspect a focused graph neighborhood.
csegraph path Find a focused dependency path.
csegraph status Report index health and freshness.
csegraph doctor Diagnose MCP client setup.
csegraph install Register CseGraph with an MCP client.
csegraph serve Start the MCP stdio server.

Run csegraph --help or csegraph <command> --help for accepted arguments.

Agent workflow

Call csegraph_context directly for ordinary coding tasks. Use csegraph_minimal only for explicit index-health or repository-orientation requests. Escalate to csegraph_graph or csegraph_path only when the compact response recommends that focused structural operation.

The MCP server exposes exactly six tools:

Tool Purpose
csegraph_index Build a fresh repository index.
csegraph_refresh Refresh changed and deleted files.
csegraph_minimal Return a small health or orientation summary.
csegraph_context Return compact task-specific code slices.
csegraph_graph Return a focused neighborhood.
csegraph_path Return a focused dependency path.

Every MCP input schema rejects unknown properties.

Compact context v5

csegraph_context accepts task, repo, target, task_kind, token_budget, source_mode, and diagnostic. The first two are required. diagnostic is a boolean and defaults to false.

The only context response contract is csegraph-context-v5:

{
  "schema_version": "csegraph-context-v5",
  "status": "ready",
  "slices": [
    {
      "path": "package/cache.py",
      "lines": [42, 61],
      "symbol": "Cache.invalidate",
      "role": "target",
      "code": "..."
    }
  ]
}

Depending on status and request, the response may also contain candidates, missing, next, warnings, or diagnostics. Diagnostics are included only when requested and remain inside the same whole-response token budget.

Every continuation has one shape:

{
  "tool": "csegraph_graph",
  "arguments": {"repo": "/path/to/repository", "node": "Cache.invalidate"},
  "reason": "Inspect direct dependents."
}

tool is required; arguments and reason are optional.

Index lifecycle

The repository index is stored at .csegraph/index.db. csegraph index builds and validates a new database beside the active database, then replaces the active database atomically. A failed build leaves the active database intact. Successful replacement leaves no backup or migration artifact.

Commands that encounter a missing or non-v12 index report index_required and direct the caller to csegraph_index or csegraph index.

Benchmarks

Benchmark runners are maintainer tools under tools/; benchmarking is not a product CLI or MCP operation. Benchmark evidence is tracked in benchmark_results/ and summarized in Benchmark Evidence.

Development

python -m pip install -e ".[test,dev]"
python -m pytest -q
python -m ruff check .
python -m ruff format --check .
python -m mypy

Local indexes, caches, build outputs, benchmark reports, cloned sandbox repositories, and editor dependencies are disposable. They are ignored by git and should be removed before sharing a clean checkout.

Privacy

Indexing, retrieval, refresh, and MCP operation run locally. CseGraph does not execute indexed code and normal operation requires no network request.

License

MIT

Metadata

Release files for csegraph 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csegraph 2.0.0
File Size Uploaded Provenance Actions
csegraph-2.0.0.tar.gz 96.6 kB With provenance Details for csegraph-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for csegraph 2.0.0
File Interpreter ABI Platform Actions
csegraph-2.0.0-py3-none-any.whl Python 3 none any Details for csegraph-2.0.0-py3-none-any.whl

Total release size: 216.4 kB

Release files / csegraph-2.0.0.tar.gz

Download URL csegraph-2.0.0.tar.gz
Size 96.6 kB
Tags Source
SHA-256 checksum
How to use checksums
02be286129eeb9c228a833035ea676057816cdf0aa4689fe9fde0c34e5759f29
BLAKE2b-256 checksum
How to use checksums
a6822d016e32c5874a2774e928c8bcd05c00adfec296a007694066531aec7b36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 12, 2026.

Transparency log

Release files / csegraph-2.0.0-py3-none-any.whl

Download URL csegraph-2.0.0-py3-none-any.whl
Size 119.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f027edc3b61093c784e185dde5b59390b1f324c3087e374ed2d186b0858c7cb
BLAKE2b-256 checksum
How to use checksums
559e8303d31bface414730178f4e071457aaac78a89dc7363cf471d5bb3a33fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 12, 2026.

Transparency log

Security for csegraph 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for csegraph-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page