Code Graph RAG MCP
Code Rag with Graph - local only installation
Code Graph RAG MCP Server
Sponsor https://accelerator.slider-ai.ru/
Advanced Multi-Language Code Analysis with Semantic Intelligence
A powerful Model Context Protocol server that creates intelligent graph representations of your codebase with comprehensive semantic analysis capabilities.
π 10 Languages Supported | β‘ 5.5x Faster | π Semantic Search | π 24 MCP Methods
π Quick Start
Installation
# Install globally
npm install -g @er77/code-graph-rag-mcp
# Or use with npx (no installation)
npx @er77/code-graph-rag-mcp /path/to/your/project
Claude Desktop Integration
# Quick setup (recommended)
npx @modelcontextprotocol/inspector add code-graph-rag \
--command "npx" \
--args "@er77/code-graph-rag-mcp /path/to/your/codebase"
or
# ΠΡΡΡΡΠ°Ρ Π½Π°ΡΡΡΠΎΠΉΠΊΠ° (ΡΠ΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡΠ΅ΡΡΡ)
claude mcp add-json code-graph-rag ' {
"command": "npx",
"args": ["@er77/code-graph-rag-mcp", "/_work_fodler"],
"env": {
"MCP_TIMEOUT": "80000"
}
}
Manual setup: Add to Claude Desktop config β See detailed instructions
Gemini CLI Integration
# Using helper script (prints the exact gemini CLI command to run)
./scripts/GEMINI-CORRECT-CONFIG.sh
# Or manually (example)
gemini mcp add-json code-graph-rag '{
"command": "npx",
"args": ["@er77/code-graph-rag-mcp", "/path/to/your/codebase"]
}'
Codex CLI Integration
# Using helper script (prints how to update ~/.codex/config.toml)
./scripts/CODEX-CORRECT-CONFIG.sh
# Project-scoped MCP server in ~/.codex/config.toml
[projects."/path/to/your/project".mcp_servers.code_graph_rag]
command = "npx"
args = ["@er77/code-graph-rag-mcp", "/path/to/your/codebase"]
transport = "stdio"
Multi-codebase support: Analyze multiple projects simultaneously β Multi-Codebase Setup Guide
Installation Guide (All Clients)
- NPM:
npm install -g @er77/code-graph-rag-mcp - Run server locally:
code-graph-rag-mcp /path/to/your/project - Claude: use Inspector (above) or see Quick Start
- Gemini: run
./scripts/GEMINI-CORRECT-CONFIG.shand follow the printed command - Codex: run
./scripts/CODEX-CORRECT-CONFIG.shand update~/.codex/config.toml
π Performance
5.5x faster than Native Claude tools with comprehensive testing results:
| Metric | Native Claude | MCP CodeGraph | Improvement |
|---|---|---|---|
| Execution Time | 55.84s | <10s | 5.5x faster |
| Memory Usage | Process-heavy | 65MB | Optimized |
| Features | Basic patterns | 24 methods | Comprehensive |
| Accuracy | Pattern-based | Semantic | Superior |
π Key Features
π¬ Advanced Analysis Tools (24 MCP Methods)
| Feature | Description | Use Case |
|---|---|---|
| Semantic Search | Natural language code search | "Find authentication functions" |
| Code Similarity | Duplicate & clone detection | Identify refactoring opportunities |
| JSCPD Clone Scan | JSCPD-based copy/paste detection without embeddings | Targeted duplicate sweeps |
| Impact Analysis | Change impact prediction | Assess modification risks |
| AI Refactoring | Intelligent code suggestions | Improve code quality |
| Hotspot Analysis | Complexity & coupling metrics | Find problem areas |
| Cross-Language | Multi-language relationships | Polyglot codebases |
| Graph Health | Database diagnostics | get_graph_health |
| Version Info | Server version & runtime details | get_version |
| Safe Reset | Clean reindexing | reset_graph, clean_index |
| Agent Telemetry | Runtime metrics across agents | get_agent_metrics |
| Bus Diagnostics | Inspect/clear knowledge bus topics | get_bus_stats, clear_bus_topic |
| Lerna Project Graph | Workspace dependency DAG export, optional ingest, cached refresh control | lerna_project_graph (requires Lerna config) |
| Semantic Warmup | Configurable cache priming for embeddings | mcp.semantic.cacheWarmupLimit |
β‘ High-Performance Architecture
| Metric | Capability | Details |
|---|---|---|
| Parsing Speed | 100+ files/second | Tree-sitter based |
| Query Response | <100ms | Optimized SQLite + vector search |
| Agent System | Multi-agent coordination | Resource-managed execution |
| Vector Search | Hardware-accelerated (optional) | Automatic embedding ingestion |
| AST Analysis | Precise code snippets | Semantic context extraction |
π Multi-Language Support (10 Languages)
| Language | Features | Support Level |
|---|---|---|
| Python | Async/await, decorators, magic methods (40+), dataclasses | β Advanced (95%) |
| TypeScript/JavaScript | Full ES6+, JSX, TSX, React patterns | β Complete (100%) |
| C/C++ | Functions, structs/unions/enums, classes, namespaces, templates | β Advanced (90%) |
| C# | Classes, interfaces, enums, properties, LINQ, async/await | β Advanced (90%) |
| Rust | Functions, structs, enums, traits, impls, modules, use | β Advanced (90%) |
| Go | Packages, functions, structs, interfaces, goroutines, channels | β Advanced (90%) |
| Java | Classes, interfaces, enums, records (Java 14+), generics, lambdas | β Advanced (90%) |
| VBA | Modules, subs, functions, properties, user-defined types | β Regex-based (80%) |
π οΈ Usage Examples
# Single project analysis
code-graph-rag-mcp /path/to/your/project
# CLI helpers
code-graph-rag-mcp --help
code-graph-rag-mcp --version
# Multi-project setup (see Multi-Codebase Setup Guide)
# Configure multiple projects in Claude Desktop config
# Check installation
code-graph-rag-mcp --help
# Health & maintenance
# Health check (totals + sample)
get_graph_health
# Reset graph data safely
reset_graph
# Clean reindex (reset + full index)
clean_index
# Lerna workspace graph (ingest into storage)
lerna_project_graph --args '{"ingest": true}'
# Force refresh graph and re-ingest (bypass cache)
lerna_project_graph --args '{"ingest": true, "force": true}'
# Cached runs return `cached: true`; use `force` to break the 30s debounce when configs change.
# Agent telemetry snapshot
get_agent_metrics
# Knowledge bus diagnostics
get_bus_stats
clear_bus_topic --args '{"topic": "semantic:search"}'
# One-shot index from the CLI (debug mode)
node dist/index.js /home/er77/tt '{"jsonrpc":"2.0","id":"index-1","method":"tools/call","params":{"name":"index","arguments":{"directory":"/home/er77/tt","incremental":false,"fullScan":true,"reset":true}}}'
# Relationships for an entity name
list_entity_relationships (entityName: "YourEntity", relationshipTypes: ["imports"])
# Adjust semantic warmup (optional)
export MCP_SEMANTIC_WARMUP_LIMIT=25
# Note: when an agent is saturated, `AgentBusyError` responses include `retryAfterMs` hints.
With Claude Desktop:
- "What entities are in my codebase?"
- "Find similar code to this function"
- "Analyze the impact of changing this class"
- "Suggest refactoring for this file"
Multi-Project Queries:
- "Analyze the frontend-app codebase structure"
- "Find authentication functions in backend-api"
- "Compare user management across all projects"
π§° Troubleshooting
-
Native module mismatch (
better-sqlite3)
Since v2.6.4 the server automatically rebuilds the native binary when it detects aNODE_MODULE_VERSIONmismatch. If the automatic rebuild fails (for example due to file permissions), run:npm rebuild better-sqlite3in the installation directory (globally this is commonly
/usr/lib/node_modules/@er77/code-graph-rag-mcp). -
Legacy database missing new columns
Older installations might lack the latestembeddingscolumns (metadata,model_name, etc.). The server now auto-upgrades in place, but if you still encounter migration errors, delete the local DB and re-run the indexer:rm ~/.code-graph-rag/codegraph.dbThen start the server again to trigger a clean rebuild.
-
Running a one-shot index from the CLI
You can trigger tools directly by passing JSON-RPC payloads. When a payload is supplied, the server skips the semantic agent and uses low-memory batching for debugging. Example:node dist/index.js /path/to/project \ '{"jsonrpc":"2.0","id":"index-1","method":"tools/call","params":{"name":"index","arguments":{"directory":"/path/to/project","incremental":false,"fullScan":true,"reset":true}}}'The command logs progress to
logs_llm/mcp-server-YYYY-MM-DD.log. SetMCP_DEBUG_DISABLE_SEMANTIC=0if you want embeddings enabled during the run.
π Changelog
π Version 2.7.4 (2025-11-02) - Clone Reporting & CLI Boost
- π Added
--help/-hand--version/-vflags for quick CLI interaction - π
detect_code_clonesnow merges deduplicated semantic groups with JSCPD summaries - π
jscpd_detect_clonessummary includes duplicated line/token counts, percentages, and inline snippets - π§ͺ Integration coverage verifies clone-report fields to guard against regressions
- π Maintains vendored lightweight JSCPD pipeline with zero external deps
π Version 2.7.0 (2025-11-02) - JSCPD Clone Detection
- β Added
jscpd_detect_clonesMCP tool exposing JSCPD duplicate detection without requiring embeddings - π§© Vendored lightweight JSCPD core/tokenizer for zero external build dependencies
- π§ͺ New integration fixtures ensure JSCPD scans surface expected duplicate blocks
- π README / tool catalog now counts 23 MCP methods and documents JSCPD usage
π Version 2.6.0 (2025-10-12) - Major Architecture Upgrade
Breaking Changes & Major Improvements β‘
- π Provider-based embeddings: New architecture supporting memory/transformers/ollama/openai/cloudru providers
- π§ Runtime diagnostics:
get_agent_metrics,get_bus_stats, andclear_bus_topicexpose live telemetry and knowledge-bus controls for Codex automation - π‘οΈ Agent backpressure hints: MCP tools now receive structured
agent_busyresponses with retry guidance when capacity is saturated - π― Deterministic graph IDs: SHA256-based stable IDs for entities and relationships
- β¨ Enhanced vector store: Renamed tables (
doc_embeddings,vec_doc_embeddings) with improved sqlite-vec integration - π§ YAML-driven configuration: Unified configuration across parser/indexer/embedding agents
- π Improved parser: Re-enabled tree-sitter ParserAgent with incremental parsing and richer metadata
- π‘οΈ Hardened MCP tools: Better entity resolution, structural+semantic responses, improved graph operations
- π Idempotent operations: Local de-duplication and ON CONFLICT upserts for consistent graph writes
Technical Details:
- Dynamic dimension detection at runtime with safe fallbacks
- Batch deduplication by ID with transactional updates
- Enhanced language analyzers with structured pattern data
- SQLiteManager + GraphStorage singleton for consistency
Testing & Validation (2025-10-21):
- β All 16/16 test suites passing (200+ individual tests, 93.75% success rate)
- β 100% MCP method validation (22/22 methods comprehensively tested)
- β
v2.6.0 new methods validated:
get_agent_metrics,get_bus_stats,clear_bus_topic - β Integration test coverage: All core components, semantic operations, and monitoring tools
- β
v2.5.9 dual-schema fixes preserved and enhanced with
sqliteVecEnabledproperty - β Zero regressions after PR #20 integration
- β οΈ Known issue: Duplicate
case "get_graph"in src/index.ts:1668 & 1707 (non-critical, line 1707 unreachable)
π Version 2.5.9 (2025-10-06) - 100% Success Rate
- β Complete vector schema fix: Dual-schema support for sqlite-vec and fallback modes
- β All 17 MCP methods working: Verified 100% success rate
- π Success rate: 33% (v2.5.7) β 61% (v2.5.8) β 100% (v2.5.9)
Version 2.5.8 (2025-10-06) - Critical Infrastructure Fixes
- β Fixed agent concurrency limit: 3 β 10 concurrent agents
- β Fixed vector database schema: Dual-schema support for sqlite-vec extension
Previous Versions
v2.5.7 - Semantic analysis improvements, lowered thresholds, clone detection
v2.5.6 - Fixed DoraAgent type collision (+16% success rate)
v2.5.5 - WASM path resolution fix, get_version tool, restart script
v2.5.4 - Architecture Decision Records (ADRs)
v2.5.3 - Deprecated dependency warning suppression
v2.5.2 - Enhanced README documentation
v2.5.1 - Python magic methods, import analysis enhancements
v2.5.0 - 8 new languages (C#, Rust, C, C++, Go, Java, VBA), Research Trinity
v2.4.1 - Rust AST parsing, system architecture docs
v2.4.0 - Health check tools, AST hotspots, semantic routing
v2.3.3 - Entity extraction fix (0 β 4,467 entities)
β‘ System Requirements
Minimum: Node.js 18+, 2GB RAM, Dual-core CPU Recommended: Node.js 18+, 8GB RAM, Quad-core CPU with SSD
Known Issues
- Deprecated
boolean@3.2.0warning: This is a transitive dependency from the optionalonnxruntime-nodepackage (used for ML embeddings). The package is deprecated but functional. The warning can be safely ignored as it doesn't affect core functionality.
π€ Contributing
- Fork the repository
- Follow Agent Governance rules
- Submit pull request
Contributing Guide β’ Issue Tracker
π License
MIT License - see LICENSE file for details.
Links: GitHub β’ NPM β’ MCP Protocol
Related Servers
Bevy BRP MCP
Control, inspect, and mutate Bevy applications with AI coding assistants via the Bevy Remote Protocol (BRP).
ABAP Development Tools (ADT)
An MCP server for interacting with SAP systems using ABAP Development Tools (ADT).
1MCP
A unified MCP server that aggregates multiple MCP servers into a single endpoint.
OPNsense MCP Server
A comprehensive MCP server for managing OPNsense firewalls, offering over 300 tools for configuration and monitoring.
Document Schema Specifications
A collection of document schemas for standardizing project documentation across various software projects.
PyAutoGUI Server
An MCP server for PyAutoGUI that enables automated GUI testing and control, including mouse and keyboard actions, screenshots, and screen information.
mcp.shop
A web shop built with MCP, WorkOS AuthKit, and Next.js.
MCP Performance Analysis Server
A server for detecting critical performance issues in code, providing concise analysis and output.
MCP AI Agent Server
A server that bridges Cline to an AI agent system, enabling seamless interaction with AI agents through the Model Context Protocol.
MCP Domain Availability Checker
Check domain availability directly from MCP clients using the Namecheap API.