Code Graph RAG

Code Graph RAG

er77

Analyzes codebases across 11 programming languages using Tree-sitter parsing and creates a semantic knowledge graph stored in SQLite. Enables natural language queries about code structure, relationships, and functionality with hybrid search combining graph traversal and vector similarity.

Provides advanced code graph analysis through specialized agents for parsing, indexing, querying, and semantic search across codebases with Tree-sitter parsing for multiple languages, SQLite vector storage, and hybrid search combining structural graph traversal with semantic similarity for code review workflows, refactoring analysis, and natural language codebase understanding.

92795 views17Local (stdio)

What it does

  • Parse and index codebases in 11+ programming languages
  • Query code structure using natural language
  • Search for functions, classes, and dependencies semantically
  • Analyze code relationships and call graphs
  • Generate graph visualizations of codebase architecture
  • Perform hybrid search combining structural and semantic matching

Best for

Code review and refactoring analysisUnderstanding large unfamiliar codebasesDeveloper onboarding and documentationCodebase exploration and dependency analysis
11 languages supported with Tree-sitter parsing26 MCP methods available5.5x faster performance

About Code Graph RAG

Code Graph RAG is a community-built MCP server published by er77 that provides AI assistants with tools and capabilities via the Model Context Protocol. Code Graph RAG enables advanced code analysis with graph traversal, semantic search, and multi-language support for smar It is categorized under developer tools.

How to install

You can install Code Graph RAG in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.

License

Code Graph RAG is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.

Code Graph RAG MCP Server

License: MIT Node.js

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.

🌟 11 Languages Supported | ⚑ 5.5x Faster | πŸ” Semantic Search | πŸ“Š 26 MCP Methods


πŸš€ Quick Start

Installation

LATEST VERSION ONLY FROM GitHub Realeases

do not use npm repository any more

# Install globally
npm install -g ./er77-code-graph-rag-mcp-2.7.12.tgz
code-graph-rag-mcp --version

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

# Example
gemini mcp add-json code-graph-rag '{
  "command": "npx",
  "args": ["@er77/code-graph-rag-mcp", "/path/to/your/codebase"]
}'

Codex CLI Integration

# Recommended: add a *global* MCP server entry (works from any project folder)
codex mcp remove code-graph-rag  # optional cleanup
codex mcp add code-graph-rag -- code-graph-rag-mcp

# Or point Codex directly at a local dev build (no npm/npx required)
codex mcp remove code-graph-rag  # optional cleanup
codex mcp add code-graph-rag -- node /absolute/path/to/code-graph-rag-mcp/dist/index.js

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 [directory]
  • Claude: use Inspector (above) or see Quick Start
  • Gemini: configure via gemini mcp add-json ... (above)
  • Codex: configure via codex mcp add ... (above)

πŸ† Performance

5.5x faster than Native Claude tools with comprehensive testing results:

MetricNative ClaudeMCP CodeGraphImprovement
Execution Time55.84s<10s5.5x faster
Memory UsageProcess-heavy65MBOptimized
FeaturesBasic patterns26 methodsComprehensive
AccuracyPattern-basedSemanticSuperior

πŸ” Key Features

πŸ”¬ Advanced Analysis Tools (26 MCP Methods)

FeatureDescriptionUse Case
Semantic SearchNatural language code search"Find authentication functions"
Code SimilarityDuplicate & clone detectionIdentify refactoring opportunities
JSCPD Clone ScanJSCPD-based copy/paste detection without embeddingsTargeted duplicate sweeps
Impact AnalysisChange impact predictionAssess modification risks
AI RefactoringIntelligent code suggestionsImprove code quality
Hotspot AnalysisComplexity & coupling metricsFind problem areas
Cross-LanguageMulti-language relationshipsPolyglot codebases
Graph HealthDatabase diagnosticsget_graph_health
Version InfoServer version & runtime detailsget_version
Safe ResetClean reindexingreset_graph, clean_index
Batched IndexingResumable indexing with progress (Codex-safe for big repos)batch_index
Agent TelemetryRuntime metrics across agentsget_agent_metrics
Bus DiagnosticsInspect/clear knowledge bus topicsget_bus_stats, clear_bus_topic
Lerna Project GraphWorkspace dependency DAG export, optional ingest, cached refresh controllerna_project_graph (requires Lerna config)
Semantic WarmupConfigurable cache priming for embeddingsmcp.semantic.cacheWarmupLimit

⚑ High-Performance Architecture

MetricCapabilityDetails
Parsing Speed100+ files/secondTree-sitter based
Query Response<100msOptimized SQLite + vector search
Agent SystemMulti-agent coordinationResource-managed execution
Vector SearchHardware-accelerated (optional)Automatic embedding ingestion
AST AnalysisPrecise code snippetsSemantic context extraction

🌐 Multi-Language Support (11 Languages)

LanguageFeaturesSupport Level
PythonAsync/await, decorators, magic methods (40+), dataclassesβœ… Advanced (95%)
TypeScript/JavaScriptFull 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%)
RustFunctions, structs, enums, traits, impls, modules, useβœ… Advanced (90%)
GoPackages, functions, structs, interfaces, goroutines, channelsβœ… Advanced (90%)
JavaClasses, interfaces, enums, records (Java 14+), generics, lambdasβœ… Advanced (90%)
KotlinPackages/imports, classes/objects, functions/properties, relationshipsβœ… Implemented
VBAModules, subs, functions, properties, user-defined typesβœ… Regex-based (80%)

πŸ› οΈ Usage Examples

# Single project analysis
code-graph-rag-mcp
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
# Batched index with progress (recommended for strict clients/timeouts)
batch_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:

  1. "What entities are in my codebase?"
  2. "Find similar code to this function"
  3. "Analyze the impact of changing this class"
  4. "Suggest refactoring for this file"

Multi-Project Queries:

  1. "Analyze the frontend-app codebase structure"
  2. "Find authentication functions in backend-api"
  3. "Compare user management across all projects"

🧰 Troubleshooting

  • Codex/VSCode MCP stdio fails to start
    Codex is strict about stdio: stdout must be JSON-RPC only. As of v2.7.12, console stdout logs are redirected to stderr during MCP runs, and heavy initialization is deferred until after handshake / first tool call.
    Recommended Codex config: omit the directory argument and let the server use the workspace root via roots/list:

    [mcp_servers.code-graph-rag]
    command = "code-graph-rag-mcp"
    args = []
    

    If index / clean_index time out on large repos and the transport closes, prefer batch_index with a small maxFilesPerBatch and keep calling it with the returned sessionId until done:true. If you must see logs on stdout for local debugging, set MCP_STDIO_ALLOW_STDOUT_LOGS=1 (not recommended for strict clients). If startup still fails, check the global tmp log mirror: /tmp/code-graph-rag-mcp/mcp-server-YYYY-MM-DD.log (Linux/macOS; uses os.tmpdir()).

  • batch_index fails with agent_busy / memory_limit
    Increase the coordinator/conductor limits (these gate task routing in-process): set COORDINATOR_MEMORY_LIMIT / CONDUCTOR_MEMORY_LIMIT and COORDINATOR_MAX_MEMORY_MB / CONDUCTOR_MAX_MEMORY_MB, or edit config/default.yaml.
    If you see a real Node.js OOM, also start the server with a larger heap, e.g. NODE_OPTIONS="--max-old-space-size=4096" code-graph-rag-mcp.

  • Database location / multi-repo isolation By default, the server stores its SQLite DB under ./.code-graph-rag/vectors.db (per repo). Add /.code-graph-rag/ to your project’s .gitignore.

  • Native module mismatch (better-sqlite3)
    Since v2.6.4 the server automatically rebuilds the native binary when it detects a NODE_MODULE_VERSION mismatch. If the automatic rebuild fails (for example due to file permissions), run:

    npm rebuild better-sqlite3
    

    in 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 latest `embe


README truncated. View full README on GitHub.

Alternatives

Related Skills

Browse all skills
performing-security-audits

This skill allows Claude to conduct comprehensive security audits of code, infrastructure, and configurations. It leverages various tools within the security-pro-pack plugin, including vulnerability scanning, compliance checking, cryptography review, and infrastructure security analysis. Use this skill when a user requests a "security audit," "vulnerability assessment," "compliance review," or any task involving identifying and mitigating security risks. It helps to ensure code and systems adhere to security best practices and compliance standards.

10
skill-sync

Syncs Claude Skills with other AI coding tools like Cursor, Copilot, and Codeium by creating cross-references and shared knowledge bases. Invoke when user wants to leverage skills across multiple tools or create unified AI context.

10
automating-api-testing

This skill automates API endpoint testing, including request generation, validation, and comprehensive test coverage for REST and GraphQL APIs. It is used when the user requests API testing, contract testing, or validation against OpenAPI specifications. The skill analyzes API endpoints and generates test suites covering CRUD operations, authentication flows, and security aspects. It also validates response status codes, headers, and body structure. Use this skill when the user mentions "API testing", "REST API tests", "GraphQL API tests", "contract tests", or "OpenAPI validation".

6
ai-sdk

Answer questions about the AI SDK and help build AI-powered features. Use when developers: (1) Ask about AI SDK functions like generateText, streamText, ToolLoopAgent, embed, or tools, (2) Want to build AI agents, chatbots, RAG systems, or text generation features, (3) Have questions about AI providers (OpenAI, Anthropic, Google, etc.), streaming, tool calling, structured output, or embeddings, (4) Use React hooks like useChat or useCompletion. Triggers on: "AI SDK", "Vercel AI SDK", "generateText", "streamText", "add AI to my app", "build an agent", "tool calling", "structured output", "useChat".

6
smart-model-switching-glm

Auto-route tasks to the cheapest z.ai (GLM) model that works correctly. Three-tier progression: Flash β†’ Standard β†’ Plus/32B. Classify before responding. FLASH (default): factual Q&A, greetings, reminders, status checks, lookups, simple file ops, heartbeats, casual chat, 1–2 sentence tasks, cron jobs. ESCALATE TO STANDARD: code >10 lines, analysis, comparisons, planning, reports, multi-step reasoning, tables, long writing >3 paragraphs, summarization, research synthesis, most user conversations. ESCALATE TO PLUS/32B: architecture decisions, complex debugging, multi-file refactoring, strategic planning, nuanced judgment, deep research, critical production decisions. Rule: If a human needs >30 seconds of focused thinking, escalate. If Standard struggles with complexity, go to Plus/32B. Save major API costs by starting cheap and escalating only when needed.

1
sui-coverage

Analyze Sui Move test coverage, identify untested code, write missing tests, and perform security audits. Includes Python tools for parsing coverage output and generating reports.

1