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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| csegraph-2.0.1.tar.gz | 96.7 kB | With provenance | Details for csegraph-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| csegraph-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for csegraph-2.0.1-py3-none-any.whl |
Total release size: 216.4 kB
Release files / csegraph-2.0.1.tar.gz
| Download URL | csegraph-2.0.1.tar.gz |
|---|---|
| Size | 96.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25d39147087c3c12266d36c86cfdf58929bf7643d32ca9d3a715fe0121e9698b
|
|
BLAKE2b-256 checksum How to use checksums |
8ed305f93c81328ed5bb5dd44449bbab20fcddfe86e8c3d1ea4eeab9d638ddd4
|
| 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 14, 2026.
Transparency logRelease files / csegraph-2.0.1-py3-none-any.whl
| Download URL | csegraph-2.0.1-py3-none-any.whl |
|---|---|
| Size | 119.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d933959e57056dc004bfff9dd0784716fa27f9c86c1bdd89c2a2465a4846b62
|
|
BLAKE2b-256 checksum How to use checksums |
38e24e2379f035bb66ea7c997fccb3fb657326c22001979c212b1adf80b2e1f0
|
| 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 14, 2026.
Transparency logSecurity for csegraph 2.0.1
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.
Attestation for csegraph-2.0.1.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 14, 2026.
Transparency logA 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.