karst

io.github.Moin105由 GitHub 帳號 Moin105 發布v0.2.9更新於 Oct 26, 2026

Code context for AI dev tools: pack-scoped, cited code retrieval over MCP.

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

本機 MCP 伺服器,為程式碼庫建立索引,讓 AI 編碼工具取得附引用的程式碼檢索與呼叫/匯入圖影響範圍分析。

可以做什麼
  • 檢索已索引的程式碼,回傳附精確 file:line 引用的排序片段
  • 沿呼叫、匯入與繼承圖計算變更的影響範圍
  • 列出情境包並查看儲存庫索引狀態
  • 由助理觸發儲存庫的增量索引或重建索引
  • 全部在本機執行:嵌入、向量庫與圖都留在本機
適用情境
適合讓助理回答關於某個特定儲存庫的問題,或在修改函式、類別、介面前先了解還有哪些地方會受影響。也適合不希望把原始碼交給雲端索引服務的團隊。
執行需求
以本機 stdio 程序執行,通常用 uvx 從 karst 的 PyPI 套件啟動,因此需要 Python 以及 uv(或 pipx)。MCP 伺服器本身不需要 API 金鑰,推理由宿主自帶的模型完成。首次解析某語言會下載 tree-sitter 解析器(約 18-21 MB),首次索引會下載嵌入模型(約 65 MB),兩者都會快取到磁碟。
安裝前請注意
工具結果(包含檢索到的程式碼片段與影響分析結果)會回傳給 MCP 用戶端,用戶端通常再轉送給它自己的模型供應商。首次執行的下載會連線 GitHub 與 huggingface.co,且解析器下載發生在原生程式碼中,Python 層的網路鉤子看不到。可選的 HTTP 模式缺少 KARST_MCP_TOKEN 時會拒絕啟動,且只讀取 KARST_MCP_ROOTS 下的儲存庫,但把 KARST_MCP_HOST 設為 0.0.0.0 會讓它暴露到網路。CLI 的 ask 與 review 指令在 shell 中已有金鑰時,會把程式碼傳送給 Anthropic 或 OpenAI。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 karst,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

karst

Know what your change breaks — without your code leaving your machine. karst gives any AI coding tool — Cursor, Claude Desktop, a custom agent — a local map of your codebase. It answers questions with exact file:line citations and walks a real call / import / inheritance graph to compute the blast radius of a change — "what else breaks if I touch this?" — the question plain search and agentic grep can't answer.

It runs locally, speaks MCP (so it drops into any agent), and has no telemetry: the CLI sends nothing anywhere by itself. Indexing, search and impact analysis never call an LLM. Only karst ask and karst review do, and only when you have configured one. What leaves your machine lists every case. As a bonus, pack-scoped retrieval cuts ~60% of the input tokens per question.

Regulated, air-gapped, or IP-sensitive team? karst is built for the environments cloud coding tools structurally can't enter — fully offline, no telemetry, source you can audit. Start with What leaves your machine and the Compliance & Air-Gap Pack (attestation, network-egress table, pre-filled security questionnaire, offline install).

bash
uv tool install karst      # recommended — fast, and puts `karst` on PATH for you# orpipx install karst         # isolated install, also handles PATH# orpip install karst          # if `karst` isn't found after, use `python -m karst …`

uv and pipx are the cleanest because they put the karst command on your PATH automatically. With plain pip --user (notably Microsoft Store Python) the command may not be on PATH — in that case python -m karst … always works, no PATH setup required.

First run: what gets downloaded

karst's own code makes no network requests, but two of its dependencies fetch files the first time they are needed. Both are cached on disk, so each happens once.

  1. Tree-sitter parsers (tree-sitter-language-pack). Its wheel contains no grammars: on first use of a language it downloads a parser bundle and unpacks that language's library. To fetch the six languages karst parses now, run this once with the Python environment karst is installed in:

    bash
    python -c "from tree_sitter_language_pack import get_parser; [get_parser(n) for n in ('python', 'javascript', 'typescript', 'go', 'rust', 'java')]"

    .tsx files are parsed with the typescript grammar, so there is no separate tsx entry. The cache is per user and per tree-sitter-language-pack version, not per virtual environment, so any Python with the same version installed fills it. That helps for uv tool and pipx installs, where karst lives in a private environment.

  2. Embedding model (BAAI/bge-small-en-v1.5, about 65 MB, from huggingface.co) on the first index, quickstart, ask, review or MCP search_code. Run karst quickstart once on any small repo to fetch it, then set KARST_OFFLINE=1 to forbid further model downloads.

Parser download details, for tree-sitter-language-pack 1.9.1 (the version pinned in pyproject.toml):

HostGitHub release v1.9.1 of kreuzberg-dev/tree-sitter-language-pack: a manifest, parsers.json, and one archive per platform, parsers-<os>-<arch>.tar.zst (about 18-21 MB). GitHub redirects to xberg-io/tree-sitter-language-pack (the repo's new name) and serves the archive from release-assets.githubusercontent.com. HTTPS only; HTTPS_PROXY / ALL_PROXY are honored.
IntegrityThe archive's SHA-256 is compared with the value in the manifest. A mismatch raises ChecksumMismatchError and nothing is cached. The manifest and the archive come from the same release, so this catches corrupt or altered downloads, not a compromised release. There is no signature check, and the unpacked libraries (native code, loaded into the karst process) are not re-hashed on later runs.
CacheLinux ${XDG_CACHE_HOME:-~/.cache}/tree-sitter-language-pack/v1.9.1/libs, macOS ~/Library/Caches/tree-sitter-language-pack/v1.9.1/libs, Windows %LOCALAPPDATA%\tree-sitter-language-pack\v1.9.1\libs. python -c "import tree_sitter_language_pack as t; print(t.cache_dir())" prints it. (Microsoft Store Python keeps the Windows folder under its own LocalCache\Local directory instead.)
Mirror / offlineTREE_SITTER_LANGUAGE_PACK_MANIFEST_URL (an https:// or file:// URL) replaces the manifest URL. For an air-gapped machine, run the command above on a connected machine with the same OS and CPU and copy the libs folder to the same path.

After that command has run once, analyze, graph-index and impact make no network requests. When a language's library is in the cache, the pack loads it from disk and never contacts GitHub; with all six cached it works with no manifest and no network. This holds while the cache folder for that version is intact: a different tree-sitter-language-pack version uses a different cache folder and would download again.

Do not use the pack's own download([...]) for this. In 1.9.1 it returns without fetching anything for languages the pack already lists; calling get_parser, which is what karst does, is what fetches. KARST_OFFLINE=1 covers the embedding model only, not the parsers.

The parser download happens in the pack's native code, not in Python. A Python-level network hook (a socket.socket monkeypatch, or an audit hook on socket.connect) does not see it, so it cannot show whether karst went online. Check at the OS level instead: a firewall log, or strace -f -e trace=network on Linux.

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)

karst command not found? Your Python Scripts dir isn't on PATH (common with Microsoft Store Python). Everything below works the same with python -m karst … — no PATH setup. (Or install via uv/pipx, which put karst on PATH for you.)

bash
cd your-project
# one command: index + call/import graph + suggested packskarst quickstart                 #  or:  python -m karst quickstart
# ask questions about the code (defaults to this folder's index)karst ask "how does checkout charge the user?" --no-llm    # cited code, no API keykarst ask -i                     # interactive: ask many questions
# what breaks if I change a function? (run inside the project; it finds the graph itself)karst impact --target checkout
# review a diff with severity-tagged, cited findingskarst review --staged --storage ~/.karst/indexes/<your-project>-<hash>   # the path quickstart prints
karst examples                   # a copy-paste cheatsheet of everything

karst quickstart prints the exact follow-up commands with your index path filled in. karst ask writes an LLM answer when ANTHROPIC_API_KEY / OPENAI_API_KEY is set, which sends the retrieved code to that provider (see What leaves your machine); add --no-llm for cited chunks and no network call. The MCP server below needs no key either — 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:

json
{  "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.

Guides

New here? Start with whichever fits you:

  • Why karst? — what it is and what it's for, in plain language. Read this first if you're not sure what problem it solves.
  • Quickstart — zero to asking real questions in 5 minutes, no API key, with real output.
  • For vibe coders — use karst from Cursor / Claude Desktop with no CLI commands — you just chat.
  • Connect your AI tool — copy-paste MCP setup for every client: Claude Desktop, Claude Code, Cursor, Windsurf, VS Code, Zed, JetBrains, plus the web apps.
  • Self-hosted & air-gapped — run karst and the AI answers fully on your machine with a local model. For teams whose code can't go to the cloud.
  • Cookbook — real scenarios (onboarding, blast radius, cutting token cost, reviewing a diff) with copy-paste commands.
  • MCP setup — connect karst to any MCP client.

How it works

  1. 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.
  2. Graph — a NetworkX knowledge graph of CALLS / IMPORTS / CONTAINS / IMPLEMENTS edges powers impact analysis ("what depends on this?" — including which classes implement an interface or extend a base).
  3. Pack — related files become named, attachable context packs (auth, billing). A query loads only its pack.
  4. 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). The one-time downloads and every path that can reach the network are listed below.

What leaves your machine

The CLI has no telemetry, analytics, update check or phone-home, and karst's own code contains no HTTP client. Network traffic comes only from the rows below. Each one is either a one-time download that sends none of your data, or something you start or configure.

Command / flagWhat is sentWhereWhen
analyze, graph-index, impact, packs …, MCP find_impact / list_packs / index_statusNothing—Never. (analyze, graph-index and packs suggest parse code, so they need the parsers in the next row.)
First parse of a language (analyze, graph-index, index, quickstart, packs suggest, MCP index_repository)Nothing of yours. A plain download of the tree-sitter parser bundle, about 18-21 MB. GitHub sees your IP address, as with any download. It is made from native code, so a Python-level socket hook does not see it; watch for it at the OS level.github.com (redirects to release-assets.githubusercontent.com)Once per parser version, unless already cached. Pre-download it.
First embedding (index, quickstart, ask, review, MCP search_code / index_repository)Nothing of yours. A download of the embedding model, about 65 MB. Embedding itself runs locally.huggingface.co, through FastEmbed and huggingface_hubOnce, into ~/.karst/models. KARST_OFFLINE=1 blocks it.
ask without --no-llmYour question plus the retrieved chunks: the top 8 by default, each cut to 2,000 characters, plus up to 6 graph neighbors with --graph.Anthropic (api.anthropic.com), OpenAI (api.openai.com), or your local model serverEvery run, once a provider is configured. With none configured it stops with an error and sends nothing.
review --staged / --base / --diff / --prFor each changed file: its diff hunks, up to 3 containing chunks per hunk (each cut to 1,500 characters) and up to 3 similar chunks per hunk (each cut to 800; --no-neighbors drops these).Same provider rules as ask. review has no --no-llm, so it always needs an LLM.Every run.
review --pr NThe PR number and --repo. It reads the PR diff.GitHub, through your gh CLI, as the account gh is logged in toWhen you use --pr.
review --pr N --post-to-prA PR review with one inline comment per finding: severity, message, suggested fix.GitHub, through gh api, as your gh account. Visible to everyone on the PR.When you add the flag. There is no confirmation prompt.
karst-mcp (stdio or --http), any toolThe retrieved code chunks and impact results go back to your MCP client (Claude Desktop, Cursor, Claude Code, …). karst sends nothing outward itself.Your MCP client, which normally forwards tool results to its own model provider.Every tool call. What the client does next is governed by the client, not by karst.
karst-mcp --httpNothing outward. It serves your indexed code to clients that present the bearer token.Listens on 127.0.0.1:8080 by default. It refuses to start without KARST_MCP_TOKEN, and its tools only read repos under KARST_MCP_ROOTS (default: the working directory). KARST_MCP_HOST=0.0.0.0 (or --host) exposes it to your network.While it runs.

Which LLM ask and review use: --llm (ask only) or KARST_LLM_PROVIDER if set; otherwise a local server if KARST_LLM_BASE_URL is set; otherwise Anthropic if ANTHROPIC_API_KEY is set; otherwise OpenAI if OPENAI_API_KEY is set. An API key that is already in your shell for another tool is enough to make karst ask send code chunks to that provider. Use --no-llm for cited chunks and no call, or --llm local / KARST_LLM_PROVIDER=local for a local model; the local server URL defaults to http://localhost:11434/v1 (Ollama), and if you point KARST_LLM_BASE_URL at a remote host the prompt goes there. The Anthropic and OpenAI SDKs are optional extras (karst[anthropic], karst[openai], karst[llm]); a plain pip install karst cannot call either, and the local option uses the openai extra.

The vector store (Qdrant) runs in embedded local-file mode under ~/.karst/indexes/; there is no remote Qdrant option. Once the embedding model is cached, FastEmbed loads it from disk without a request, and KARST_OFFLINE=1 turns a missing model into an error instead of a download. The model download goes through Hugging Face's client library, which has its own usage-telemetry switch (HF_HUB_DISABLE_TELEMETRY=1); that setting belongs to that library, not to karst.

Status

Live: AST chunking (6 languages), call/import graph + impact analysis, pack-scoped retrieval, token + cost meter, incremental indexing + embedding cache, diff code review with inline PR posting (review --pr --post-to-pr), and the MCP server over both stdio and remote Streamable-HTTP (karst-mcp --http). Coming next: hosted indexing, team-shared pack libraries, an autonomous GitHub PR review bot, and OAuth for browser connectors (claude.ai / ChatGPT).

License

Apache-2.0. See LICENSE.

來源:README.md,提交 abd50e6

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.2.9最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分