Graph Hub
Local-first code intelligence for AI agents. Transform your codebase into a queryable knowledge graph. 85% token savings for Claude Code, Cursor, and MCP-compatible tools.
Ask AI about Graph Hub
Powered by Claude Β· Grounded in docs
I know everything about Graph Hub. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
The Problem
AI coding assistants lose context between sessions. They re-read the same files, re-learn your codebase, and burn tokens on questions they've already answered.
| Approach | Tokens Used | What Happens |
|---|---|---|
| Traditional | 9,216 | grep β read 5 files β hope for the best |
| GraphHub | 507 | get_context("functionName") β done β |
94% fewer tokens. Same answer. Every time.
β‘ Quick Start
npm install graphhub
One command. GraphHub auto-detects every AI agent on your machine and writes to their global configs β no per-project setup, ever.
All setup options
npx graphhub setup # auto-detect + install present clients
npx graphhub setup --force # install for all 5 clients regardless
npx graphhub setup --client claude-code,kilo-cli # pick specific clients
npx graphhub setup --dry-run # preview what would be installed
npx graphhub setup --list # list all supported clients
npx graphhub uninstall-all # remove from all clients
Clone & run locally
git clone https://github.com/slnquangtran/Graph-Hub.git
cd Graph-Hub && npm install
npm run index -- /path/to/your/project
npm run setup -- /path/to/your/project
π§ How It Works
Your Source Code
β
βΌ
βββββββββββββββββββ ββββββββββββββββββββ
β Tree-sitter ββββββΆβ KuzuDB Graph DB β
β AST Parser β β β
β TS Β· JS Β· PY β β File ββCONTAINSββΆ Symbol
βββββββββββββββββββ β Symbol ββCALLSβββΆ Symbol
β β File ββIMPORTSβββΆ File
βΌ β Symbol ββINHERITSβΆ Symbol
βββββββββββββββββββ ββββββββββ¬ββββββββββ
β Local Embeddingsβ β
β (MiniLM-L6-v2) β ββββββββΌβββββββββββ
β No API needed β β MCP Server β
βββββββββββββββββββ β REST API :9000 β
β Dashboard :5173β
βββββββββββββββββββ
Supported AI Agents
| Agent | Global Config | Status |
|---|---|---|
~/.claude/settings.json | β Full support | |
~/.config/opencode/opencode.json | β Full support | |
~/.gemini/settings.json | β Full support | |
~/.antigravity/mcp.json | β Full support | |
~/.config/kilo/kilo.json | β Full support |
π Token Savings
Real measurements on GraphHub's own codebase β not synthetic benchmarks.
| Task | Without GraphHub | With GraphHub | Savings |
|---|---|---|---|
| Find function callers | 9,216 | 507 | π’ 94% |
| Impact analysis | 7,281 | 673 | π’ 91% |
| List file symbols | 2,745 | 322 | π’ 88% |
| Search code logic | 2,115 | 759 | π‘ 64% |
| Codebase overview | 2,381 | 1,389 | π‘ 42% |
| Total | 23,738 | 3,650 | π 85% |
Result: 5Γ more tasks in the same context window.
π MCP Tools
GraphHub registers 27 MCP tools across 7 categories. Click each to expand.
π Search & Discovery
// Natural language β code
semantic_search({ query: "authentication validation", mode: "hybrid" })
// Exact or fuzzy symbol name
search_by_name({ name: "validateToken" })
// Results grouped by file
search_grouped({ query: "error handling middleware" })
// Cosine-similar symbols
find_similar({ name: "parseRequest", top_k: 5 })
// Explain which strategy was chosen
explain_search({ query: "jwt token refresh" })
πΈ Graph & Impact
// Callers + callees of a symbol
get_context({ name: "validateToken" })
// Full blast radius before you edit
impact_analysis({ name: "handleRequest" })
// Callers/callees for many symbols at once
batch_context({ names: ["validateToken", "handleRequest", "parseBody"] })
// Symbols in git-changed files + risk buckets
changed_symbols({ diff: "staged" })
// Raw Cypher for power users
query_graph({ cypher: "MATCH (s:Symbol)-[:CALLS]->(t) RETURN s.name, t.name LIMIT 20" })
// All symbols in a file
get_file_symbols({ path: "src/services/auth/token.ts" })
π One-Shot Debugging
// RAG search + context + impact + next steps in one call
debug_trace({ query: "null pointer in auth middleware", top_k: 3 })
π§Ή Code Health
// Find functions/classes nobody calls β safe to delete?
find_dead_code({ kinds: ["function", "method"] })
// Find near-duplicate implementations (uses stored embeddings, no API cost)
find_duplicates({ name: "validateToken", min_similarity: 0.85, cross_file_only: true })
// Detect circular import chains and mutual-recursion call cycles
find_cycles({ type: "both", max_length: 3 })
π§ Session Memory
// Save a learning
remember({ content: "Auth uses JWT with 15m TTL", type: "learning", project: "myapp" })
// Retrieve by similarity
recall({ query: "how does auth work?" })
// Chronological view
timeline({ limit: 20, project: "myapp" })
// Update or delete
update_observation({ id: "abc-123", content: "Updated: now uses refresh tokens" })
forget({ project: "myapp", type: "learning" })
// Linked to specific symbols
related_observations({ symbol: "validateToken" })
π Pattern Memory β Bug Fixes & Skills
// Store a bug fix pattern
remember_bugfix({
symptom: "TypeError: Cannot read property user of undefined",
root_cause: "req.session was null on the /guest route",
fix: "Added session guard at middleware entry",
})
// Recall by symptom similarity β even next week
recall_bugfix({ symptom: "undefined user property on guest route" })
// Cache which skill worked for a task
remember_skill_choice({
task_description: "rename a function safely across the repo",
skill_path: ".claude/skills/refactoring/SKILL.md",
outcome: "success",
})
// Route future similar tasks to the same skill
recall_skill_choice({ task_description: "rename a symbol in multiple files" })
β¨ Features
π§© Core Intelligence
|
π Developer Experience
|
π Language Support
| Language | Support | Parser |
|---|---|---|
| TypeScript / TSX | β Full | Tree-sitter AST |
| JavaScript / JSX | β Full | Tree-sitter AST |
| Python | β Full | Tree-sitter AST |
| Go Β· Rust Β· Java | β‘ Partial | Text chunker |
| Markdown Β· Shell | β Full | Text chunker |
βοΈ Configuration
Global install (recommended)
npx graphhub setup
Auto-detects and writes to each agent's global config β no per-project setup needed.
| Client | Global Config File |
|---|---|
| Claude Code | ~/.claude/settings.json |
| OpenCode | ~/.config/opencode/opencode.json |
| Gemini CLI | ~/.gemini/settings.json |
| Antigravity | ~/.antigravity/mcp.json |
| Kilo CLI | ~/.config/kilo/kilo.json |
Existing keys are preserved β only the graphhub entry is added or updated. Use --force to install for agents that aren't yet present. A postinstall hook runs automatically after npm install graphhub; opt out with GRAPHHUB_NO_INSTALL=1, CI=1, or npm_config_global=true.
Claude Code hooks + CLAUDE.md (legacy)
npm run install-claude
Adds PreToolUse/PostToolUse hooks and updates CLAUDE.md. The setup command above covers MCP config only.
Manual JSON config
{
"mcpServers": {
"graphhub": {
"command": "npx",
"args": ["tsx", "src/index.ts", "serve"],
"cwd": "/path/to/graphhub"
}
}
}
π Commands
| Command | Description |
|---|---|
npm run index -- <dir> | Index a directory into the knowledge graph |
npm run serve | Start MCP server (stdio) |
npm run serve-api | Start REST API on port 9000 |
npm run dashboard | Start API + React dashboard |
npm run report | Generate GRAPH_REPORT.md |
npm run visualize | Export graph to Mermaid format |
npm run setup | Configure all supported MCP clients |
npm run uninstall-all | Remove GraphHub from all clients |
npm run install-claude | Configure Claude Code hooks + CLAUDE.md (legacy) |
npm test | Run 77-test suite |
π Tech Stack
| Component | Technology |
|---|---|
| Parser | web-tree-sitter (WASM) |
| Database | KuzuDB (embedded graph) |
| Embeddings | @xenova/transformers Β· all-MiniLM-L6-v2 |
| MCP | @modelcontextprotocol/sdk |
| API | Express.js |
| Dashboard | React + Vite + React Flow |
| Tests | Vitest Β· 77 tests |
πΊ Roadmap
Completed β
- Session memory (remember / recall / forget)
- Always-on PreToolUse hooks
- PostToolUse auto-reindex
- Graph report generation
- Verified 85% token reduction
- Class hierarchy edges (INHERITS, IMPLEMENTS)
- One-shot
debug_traceand bulkbatch_context - Pattern memory for bug fixes and skill routing
- One-command multi-client setup (Claude Code, OpenCode, Gemini CLI, Antigravity, Kilo CLI)
- Global install β writes to home-dir configs so all projects benefit without per-project setup
-
.gitignoresupport (cross-platform, including Windows path normalization) - Proper database lifecycle β
close()releases the file lock on MCP server, watch mode, and CLI exit
Coming next:
- Dead code detection (
find_dead_code) - Duplicate function detection (
find_duplicates) - Circular dependency / call cycle detection (
find_cycles) - Worker thread indexing for large repos
- Native Go / Rust / Java Tree-sitter grammars
- Community detection (Leiden algorithm)
π Changelog
v1.4.0 β Code Health Tools
find_dead_codeβ Find functions, methods, and classes with zero callers. Common entry-point patterns (main,init,onX,handleXβ¦) are filtered automatically; passinclude_entry_points: trueto see everything.find_duplicatesβ Find near-duplicate implementations of any symbol using stored cosine embeddings. No API cost β works offline. Supportsmin_similaritythreshold andcross_file_onlyfilter.find_cyclesβ Detect circular import chains and mutual-recursion call cycles up to length 3. Reports each cycle as an ordered list of file paths (import) or symbol names (call).- 14 new tests β Full coverage of entry-point filtering, cycle detection, similarity threshold, and cross-file filtering.
v1.3.1 β Global Install + Kilo CLI
- Global install β All adapters now write to home-dir global configs (
~/.claude/,~/.gemini/, etc.) so onenpx graphhub setup --forcecovers every project without per-project setup - Kilo CLI support β New adapter for Kilo CLI (
~/.config/kilo/kilo.json) graphhubDirfix βnpx graphhub setupnow correctly resolves the package location fromimport.meta.urlinstead ofprocess.cwd()(which pointed to the user's project, causing broken MCP server paths)- Gemini CLI fix β Was writing to
<project>/.gemini/instead of~/.gemini/; fixed to use home dir - Windows path fix β MCP server entry paths now always use forward slashes in JSON configs
v1.3.0 β Stability & Python
- DB lifecycle fix β MCP server, watch mode, and all CLI commands now properly release the KuzuDB file lock on exit
.gitignoresupport β cross-platform path normalization (fixes Windows\vs/mismatch)- Python parser β upgraded to full Tree-sitter AST extraction (functions, classes, calls, inheritance)
- Import alias resolution β
import { foo as bar }now storesfooas the specifier, fixing cross-file call graph edges - Fuzzy symbol search β case-insensitive (
toLower(s.name) CONTAINS query) forget()safety β requires at least one filter; no longer silently deletes all observations- MCP
get_file_symbolsβ fixed: was returning an empty object (raw DB cursor) - Error resilience β per-file parse errors no longer abort the entire indexing run
- BigInt coercion β KuzuDB
count()results coerced toNumber;JSON.stringifyno longer throws on stats
π€ Contributing
Contributions are welcome! Feel free to open an issue or submit a PR.
git clone https://github.com/slnquangtran/Graph-Hub.git
cd Graph-Hub && npm install
npm test # run 77 tests
npm run index -- ./src # index GraphHub itself
π Privacy
| 100% Local | All data stays in .graphhub/ in your project β nothing leaves your machine |
| No External APIs | Embeddings are generated locally with @xenova/transformers |
| No Telemetry | Zero network calls during indexing or querying |
π License
ISC Β© 2024
If GraphHub saves you tokens, a β star helps others find it.
