Local-first knowledge graph repo memory for coding agents.
Adaptive KG-RAG indexes a workspace into a typed code knowledge graph, then lets coding agents query compact repo context through MCP instead of reading large parts of the repository into the prompt.
What It Does
- Indexes files, symbols, imports, calls, tests, docs, and repo-memory facts
across Python, JavaScript/TypeScript, Java, and C/C++ (functions,
structs/unions/enums, typedefs, macros,
#includeedges). - Shows graph status, node/edge counts, storage footprint, and export tokens in a VS Code sidebar.
- Provides a graph explorer for inspecting files, symbols, and relationships.
- Configures MCP for Codex, Claude Code, Cursor, Antigravity, and Kimi.
- Lets agents query
adaptive_kg_status,adaptive_kg_query, and related MCP tools before falling back to direct source reads. Graph retrieval is hybrid (vector + lexical scoring, then graph expansion) and falls back to flat vector chunk RAG when the graph is sparse. - Uses offline Hash/KG mode by default (private, no API). Optional local
semantic embeddings (
sentence-transformers) or API providers are selectable via theadaptiveKg.embeddingProvidersetting.
Important Beta Note
This extension is currently a lightweight VS Code wrapper around the local Adaptive KG Python package. For best results, install the Python package from the project repository first:
git clone https://github.com/YijunSun/KG-RAG-CodeKG
cd KG-RAG-CodeKG
python -m pip install -e .[dev]
If you are developing from source, set adaptiveKg.sourceRoot to the repository
root when VS Code cannot discover src/adaptive_kg automatically.
Quick Use
- Open a repository in VS Code.
- Open the Adaptive KG activity bar icon.
- Run
Index WorkspaceorRebuild Graph. - Run
Configure Agent MCPand choose Codex, Claude Code, Cursor, Antigravity, or Kimi. - Restart the selected agent or open a fresh agent session.
MCP Targets
| Agent | MCP Config | Managed Instruction File |
|---|---|---|
| Codex | ~/.codex/config.toml |
AGENTS.md |
| Claude Code | .mcp.json |
CLAUDE.md |
| Cursor | ~/.cursor/mcp.json |
.cursor/rules/adaptive-kg-rag.mdc |
| Antigravity | ~/.gemini/antigravity/mcp_config.json |
GEMINI.md |
| Kimi CLI | ~/.kimi/mcp.json |
— |
| Kimi Code | ~/.kimi-code/mcp.json |
— |
Use Adaptive KG: Uninstall Agent MCP to remove the managed MCP entry and
managed instruction block from one target or all configured targets.
Commands
Adaptive KG: Index WorkspaceAdaptive KG: Rebuild Workspace GraphAdaptive KG: Query Workspace GraphAdaptive KG: Configure Agent MCPAdaptive KG: Uninstall Agent MCPAdaptive KG: Show Graph StatusAdaptive KG: Open Graph ExplorerAdaptive KG: Prepare LLM Graph AuditAdaptive KG: Open Agent ProtocolAdaptive KG: Review Pending UpdatesAdaptive KG: Start Local API ServerAdaptive KG: Evaluate Local Model
Embeddings
Set adaptiveKg.embeddingProvider:
hashing(default) — offline deterministic, zero dependencies, fully private.sentence-transformers— local semantic embeddings (MiniLM); free and private, needs theembedextra installed, and falls back tohashingif the model isn't available.openai/gemini/openrouter/custom— API embeddings. These send code snippets to a third party and are subject to its rate limits.
For code retrieval the graph's edge structure (who-calls-whom, imports, includes) does most of the work, so the local providers are recommended; API embeddings mainly help fuzzy natural-language queries.
Privacy
Default indexing and querying are fully local — hashing and
sentence-transformers never send your code off the machine. Only the API
embedding providers transmit code, and only when you explicitly select one. MCP
mode does not ask Adaptive KG for your model API key; the host agent keeps using
its own account and model session.
Project
Source, documentation, benchmarks, and release notes: