Code context for AI dev tools — graph-grounded, pack-scoped retrieval over MCP. 60% fewer tokens, audit-grade citations.
Project description
karst
Code context for AI dev tools. karst sits between your repo and any AI
tool — Cursor, Claude Desktop, a custom agent — and feeds it the right slice
of the codebase: graph-grounded, pack-scoped, and cited to file:line. The
result is ~60% fewer input tokens per question, answers you can verify, and a
blast-radius check before you change anything.
It runs locally, returns context (not answers) over MCP, and never calls an LLM itself — so you don't give karst an API key. Your IDE already has the model; karst just makes what it reads sharp and cheap.
uv tool install karst # recommended — fast, and puts `karst` on PATH for you
# or
pipx install karst # isolated install, also handles PATH
# or
pip install karst # if `karst` isn't found after, use `python -m karst …`
uvandpipxare the cleanest because they put thekarstcommand on your PATH automatically. With plainpip --user(notably Microsoft Store Python) the command may not be on PATH — in that casepython -m karst …always works, no PATH setup required.
Why
Most "chat with your codebase" tools dump tens of thousands of vaguely-related tokens into the model on every question. You can't see what was loaded, you can't scope it, and the bill arrives at the end of the month. karst inverts that:
- Scopes — pack-filtered retrieval reads ~200 chunks, not 5,000.
- Cites — every chunk carries an exact
file:line. Verify, don't trust. - Predicts — a real call/import graph answers "what else breaks if I change this?" — which embeddings alone can't.
Measured on a real 246-file NestJS + Next.js repo: 906 chunks indexed, re-index 343s → 2.3s incremental, ~$0.019 per question on Sonnet 4.6 (shown before the call), 60% fewer tokens with packs attached.
Quickstart (CLI)
# 1. index a repo (incremental + cached after the first run)
karst index ./my-repo
# 2. build the call/import graph (enables impact analysis)
karst graph-index ./my-repo
# 3. auto-suggest context packs and tag the index
karst packs --storage ~/.karst/indexes/my-repo \
suggest ./my-repo --apply --retag
# 4. ask — retrieval is pack-scoped and the token cost is printed
karst ask "How does checkout charge the user?" \
--storage ~/.karst/indexes/my-repo
# what breaks if I change a function?
karst impact --target checkout \
--graph-path ~/.karst/indexes/my-repo/graph.pkl
# review a diff with severity-tagged, cited findings
karst review --staged --storage ~/.karst/indexes/my-repo
karst ask needs an LLM key (ANTHROPIC_API_KEY or OPENAI_API_KEY), or pass
--no-llm to get the raw cited chunks. The MCP server below needs no key —
your IDE supplies the model.
Use it from your IDE (MCP)
karst ships an MCP server (karst-mcp) exposing five tools — search_code,
find_impact, list_packs, index_status, index_repository — over stdio.
Claude Desktop (claude_desktop_config.json) or Cursor
(.cursor/mcp.json) — pick whichever launcher you have:
{
"mcpServers": {
"karst": { "command": "uvx", "args": ["--from", "karst", "karst-mcp"] }
}
}
uvx needs nothing pre-installed — it fetches and runs karst on demand. Already
installed it? { "command": "karst-mcp" } works too. No PATH at all? Use
{ "command": "python", "args": ["-m", "karst.mcp_server"] }.
Restart the host, then ask normally — it calls karst's tools when useful and gets back scoped, cited context. Full setup is in docs/MCP.md.
How it works
- Index — tree-sitter splits every function, class and method into an AST-aware chunk (Python, JS, TS, Go, Rust, Java); chunks are embedded into a local Qdrant store. Incremental: a SHA manifest + embedding cache skip unchanged files.
- Graph — a NetworkX knowledge graph of
CALLS/IMPORTS/CONTAINSedges powers impact analysis ("what depends on this?"). - Pack — related files become named, attachable context packs (
auth,billing). A query loads only its pack. - Serve — the MCP server returns ranked,
file:line-cited chunks; your host's model reasons over them.
Everything is local and offline-capable (FastEmbed/ONNX embeddings, Qdrant local mode, sqlite caches — no Docker, no daemon).
Status
Live: AST chunking (6 languages), call/import graph + impact analysis, pack-scoped retrieval, token + cost meter, incremental indexing + embedding cache, diff code review, and the MCP server. Coming next: hosted indexing, team-shared pack libraries, a GitHub PR review bot.
License
Apache-2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
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 karst-0.1.2.tar.gz.
File metadata
- Download URL: karst-0.1.2.tar.gz
- Upload date:
- Size: 80.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c3f7f549a7c5871ec7b578dce55005e7608018a1f253d646b793a150559fcce
|
|
| MD5 |
3c62b0ca0ccf742ecb96433a3d7f3799
|
|
| BLAKE2b-256 |
b9f93cecf1fa51fe72cf7eb6aab902481e4b9dd237cf04c110e247b4ed5acb92
|
Provenance
The following attestation bundles were made for karst-0.1.2.tar.gz:
Publisher:
publish.yml on Moin105/upgraded-garbanzo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
karst-0.1.2.tar.gz -
Subject digest:
7c3f7f549a7c5871ec7b578dce55005e7608018a1f253d646b793a150559fcce - Sigstore transparency entry: 1886108809
- Sigstore integration time:
-
Permalink:
Moin105/upgraded-garbanzo@0725689ba7145b5ba4e0ed97e9df950c9840294e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Moin105
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0725689ba7145b5ba4e0ed97e9df950c9840294e -
Trigger Event:
release
-
Statement type:
File details
Details for the file karst-0.1.2-py3-none-any.whl.
File metadata
- Download URL: karst-0.1.2-py3-none-any.whl
- Upload date:
- Size: 84.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99ffafaaa455656cffd34e867190aecf62b164656e71aa8c3b66b203f3e33315
|
|
| MD5 |
b4e9861a4db83b70edc708ed46a8efb4
|
|
| BLAKE2b-256 |
09699d9f46462a259143a5719b8555679a07a153a5c77a6f1d8d3bfac35247e6
|
Provenance
The following attestation bundles were made for karst-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on Moin105/upgraded-garbanzo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
karst-0.1.2-py3-none-any.whl -
Subject digest:
99ffafaaa455656cffd34e867190aecf62b164656e71aa8c3b66b203f3e33315 - Sigstore transparency entry: 1886108853
- Sigstore integration time:
-
Permalink:
Moin105/upgraded-garbanzo@0725689ba7145b5ba4e0ed97e9df950c9840294e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Moin105
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0725689ba7145b5ba4e0ed97e9df950c9840294e -
Trigger Event:
release
-
Statement type: