code-graph-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@code-graph-mcp analyze the main module for code smells"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Code Graph MCP Server
Model Context Protocol server providing comprehensive code analysis, navigation, and quality assessment capabilities across 25+ programming languages.
Features
🎯 Enhanced Tool Guidance & AI Optimization ⭐ NEW in v1.2.0
Comprehensive Usage Guide - Built-in
get_usage_guidetool with workflows, best practices, and examplesRich Tool Descriptions - Visual hierarchy with 🎯 PURPOSE, 🔧 USAGE, ⚡ PERFORMANCE, 🔄 WORKFLOW, 💡 TIP sections
Performance-Aware Design - Clear expectations for Fast (<3s), Moderate (3-15s), and Expensive (10-60s) operations
Workflow Orchestration - Optimal tool sequences for Code Exploration, Refactoring Analysis, and Architecture Analysis
AI Model Optimization - Reduces trial-and-error, improves tool orchestration, enables strategic usage patterns
🌍 Multi-Language Support
25+ Programming Languages: JavaScript, TypeScript, Python, Java, C#, C++, C, Rust, Go, Kotlin, Scala, Swift, Dart, Ruby, PHP, Elixir, Elm, Lua, HTML, CSS, SQL, YAML, JSON, XML, Markdown, Haskell, OCaml, F#
Intelligent Language Detection: Extension-based, MIME type, shebang, and content signature analysis
Framework Recognition: React, Angular, Vue, Django, Flask, Spring, and 15+ more
Universal AST Abstraction: Language-agnostic code analysis and graph structures
🔍 Advanced Code Analysis
Complete codebase structure analysis with metrics across all languages
Universal AST parsing with ast-grep backend and intelligent caching
Cyclomatic complexity calculation with language-specific patterns
Project health scoring and maintainability indexing
Code smell detection: long functions, complex logic, duplicate patterns
Cross-language similarity analysis and pattern matching
🧭 Navigation & Search
Symbol definition lookup across mixed-language codebases
Reference tracking across files and languages
Function caller/callee analysis with cross-language calls
Dependency mapping and circular dependency detection
Call graph generation across entire project
⚡ Performance Optimized
Debounced File Watcher - Automatic re-analysis when files change with 2-second intelligent debouncing
Real-time Updates - Code graph automatically updates during active development
Aggressive LRU caching with 50-90% speed improvements on repeated operations
Cache sizes optimized for 500+ file codebases (up to 300K entries)
Sub-microsecond response times on cache hits
Memory-efficient universal graph building
🏢 Enterprise Ready
Production-quality error handling across all languages
Comprehensive logging and monitoring with language context
UV package management with ast-grep integration
Related MCP server: code-graph-rag-mcp
Installation
Quick Start (PyPI)
pip install code-graph-mcp ast-grep-py rustworkxMCP Host Integration
Claude Desktop
Method 1: Using Claude CLI (Recommended)
For PyPI installation:
# Project-specific installation
claude mcp add --scope project code-graph-mcp code-graph-mcp
# User-wide installation
claude mcp add --scope user code-graph-mcp code-graph-mcpFor development installation:
# Project-specific installation
claude mcp add --scope project code-graph-mcp uv run code-graph-mcp
# User-wide installation
claude mcp add --scope user code-graph-mcp uv run code-graph-mcpVerify installation:
claude mcp listMethod 2: Manual Configuration
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"code-graph-mcp": {
"command": "code-graph-mcp"
}
}
}Cline (VS Code Extension)
Add to your Cline MCP settings in VS Code:
Open VS Code Settings (Ctrl/Cmd + ,)
Search for "Cline MCP"
Add server configuration:
{
"cline.mcp.servers": {
"code-graph-mcp": {
"command": "code-graph-mcp"
}
}
}Continue (VS Code Extension)
Add to your ~/.continue/config.json:
{
"mcpServers": [
{
"name": "code-graph-mcp",
"command": "code-graph-mcp",
"env": {}
}
]
}Cursor
Add to Cursor's MCP configuration:
Open Cursor Settings
Navigate to Extensions → MCP
Add server:
{
"name": "code-graph-mcp",
"command": "code-graph-mcp"
}Zed Editor
Add to your Zed settings.json:
{
"assistant": {
"mcp_servers": {
"code-graph-mcp": {
"command": "code-graph-mcp"
}
}
}
}Zencoder ⭐
The best AI coding tool! Add to your Zencoder MCP configuration:
{
"mcpServers": {
"code-graph-mcp": {
"command": "code-graph-mcp",
"env": {},
"description": "Multi-language code analysis with 25+ language support"
}
}
}Pro Tip: Zencoder's advanced AI capabilities work exceptionally well with Code Graph MCP's comprehensive multi-language analysis. Perfect combination for professional development! 🚀
Windsurf
Add to Windsurf's MCP configuration:
{
"mcpServers": {
"code-graph-mcp": {
"command": "code-graph-mcp"
}
}
}Aider
Use with Aider AI coding assistant:
aider --mcp-server code-graph-mcpOpen WebUI
For Open WebUI integration, add to your MCP configuration:
{
"mcp_servers": {
"code-graph-mcp": {
"command": "code-graph-mcp",
"env": {}
}
}
}Generic MCP Client
For any MCP-compatible client, use these connection details:
{
"name": "code-graph-mcp",
"command": "code-graph-mcp",
"env": {}
}Docker Integration
Run as a containerized MCP server:
FROM python:3.12-slim
RUN pip install code-graph-mcp ast-grep-py rustworkx
WORKDIR /workspace
CMD ["code-graph-mcp"]docker run -v $(pwd):/workspace code-graph-mcpDevelopment Installation
For contributing or custom builds:
git clone <repository-url>
cd code-graph-mcp
uv sync --dev
uv buildAdd to Claude Code (development):
# Project-specific
claude mcp add --scope project code-graph-mcp uv run code-graph-mcp
# User-wide
claude mcp add --scope user code-graph-mcp uv run code-graph-mcpFor other MCP clients, use:
{
"command": "uv",
"args": ["run", "code-graph-mcp"]
}Configuration Options
Command Line Arguments
code-graph-mcp --helpAvailable options:
--project-root PATH: Root directory of your project (optional, defaults to current directory)--verbose: Enable detailed logging--no-file-watcher: Disable automatic file change detection
Environment Variables
export CODE_GRAPH_MCP_LOG_LEVEL=DEBUG
export CODE_GRAPH_MCP_CACHE_SIZE=500000
export CODE_GRAPH_MCP_MAX_FILES=10000
export CODE_GRAPH_MCP_FILE_WATCHER=true
export CODE_GRAPH_MCP_DEBOUNCE_DELAY=2.0File Watcher (v1.1.0+)
The server includes an intelligent file watcher that automatically updates the code graph when files change:
Automatic Detection: Monitors all supported file types in your project
Smart Debouncing: 2-second delay prevents excessive re-analysis during rapid changes
Efficient Filtering: Respects
.gitignorepatterns and only watches relevant filesThread-Safe: Runs in background without blocking analysis operations
Zero Configuration: Starts automatically after first analysis
File Watcher Features:
Real-time graph updates during development
Batch processing of multiple rapid changes
Duplicate change prevention
Graceful error recovery
Resource cleanup on shutdown
Troubleshooting
Common Issues
"Command not found": Ensure
code-graph-mcpis in your PATHpip install --upgrade code-graph-mcp which code-graph-mcp"ast-grep not found": Install the required dependency
pip install ast-grep-pyPermission errors: Use virtual environment
python -m venv venv source venv/bin/activate # Linux/Mac # or venv\Scripts\activate # Windows pip install code-graph-mcp ast-grep-py rustworkxLarge project performance: Use verbose mode for debugging
code-graph-mcp --verbose
Debug Mode
Enable verbose logging for troubleshooting:
code-graph-mcp --verboseSupported File Types
The server automatically detects and analyzes these file extensions:
Web:
.js,.ts,.jsx,.tsx,.html,.cssBackend:
.py,.java,.cs,.cpp,.c,.rs,.goMobile:
.swift,.dart,.ktScripting:
.rb,.php,.lua,.plConfig:
.json,.yaml,.yml,.toml,.xmlDocs:
.md,.rst,.txt
Available Tools
The MCP server provides 9 comprehensive analysis tools with enhanced guidance that work across all 25+ supported languages:
🎯 Enhanced Tool Experience ⭐ NEW in v1.2.0
Each tool now includes rich guidance with visual hierarchy:
🎯 PURPOSE - Clear explanation of what the tool does
🔧 USAGE - When and how to use the tool effectively
⚡ PERFORMANCE - Speed expectations and caching information
🔄 WORKFLOW - Optimal tool sequencing recommendations
💡 TIP - Pro tips for maximum effectiveness
📚 Usage Guide Tool
Tool | Description | Key Features |
| NEW - Comprehensive guidance with workflows, best practices, and examples | Complete documentation, workflow patterns, performance guidelines |
🛠️ Analysis Tools
Tool | Description | Multi-Language Features | Performance |
| Complete project analysis with structure metrics and complexity assessment | Language detection, framework identification, cross-language dependency mapping | ⚡ Expensive (10-60s) |
| Locate symbol definitions with detailed metadata and documentation | Universal AST traversal, language-agnostic symbol resolution | ⚡ Fast (<3s) |
| Find all references to symbols throughout the codebase | Cross-file and cross-language reference tracking | ⚡ Fast (<3s) |
| Identify all functions that call a specified function | Multi-language call graph analysis | ⚡ Fast (<3s) |
| List all functions called by a specified function | Universal function call detection across languages | ⚡ Fast (<3s) |
| Analyze code complexity with refactoring recommendations | Language-specific complexity patterns, universal metrics | ⚡ Moderate (5-15s) |
| Generate module dependency graphs and import relationships | Cross-language dependency detection, circular dependency analysis | ⚡ Moderate (3-10s) |
| Comprehensive project health metrics and statistics | Multi-language project profiling, maintainability indexing | ⚡ Fast (<3s) |
Usage Examples
🎯 Getting Started with Enhanced Guidance ⭐ NEW in v1.2.0
First, get comprehensive guidance on using the tools effectively:
get_usage_guide🔍 Multi-Language Analysis Workflows
Code Exploration Workflow:
1. analyze_codebase (build the foundation)
2. project_statistics (get overview)
3. find_definition("MyClass") (locate specific symbols)
4. find_references("MyClass") (understand usage patterns)Refactoring Analysis Workflow:
1. analyze_codebase
2. complexity_analysis (threshold=15 for critical issues)
3. find_callers("complex_function") (impact analysis)
4. find_callees("complex_function") (dependency analysis)Architecture Analysis Workflow:
1. analyze_codebase
2. dependency_analysis (identify circular dependencies)
3. project_statistics (health metrics)
4. complexity_analysis (quality assessment)💬 Natural Language Examples
Analyze this React/TypeScript frontend with Python backend - show me the overall structure and complexity metricsFind all references to the function "authenticate" across both the Java services and JavaScript frontendShow me functions with complexity higher than 15 across all languages that need refactoringGenerate a dependency graph showing how the Python API connects to the React componentsDetect code smells and duplicate patterns across the entire multi-language codebaseDevelopment
Requirements
Python 3.12+
UV package manager
MCP SDK
ast-grep-py (for multi-language support)
rustworkx (for high-performance graph operations)
Running locally
# Install dependencies
uv sync
# Run the server directly (auto-detects current directory)
uv run code-graph-mcp --verbose
# Test with help
uv run code-graph-mcp --helpPerformance Features
LRU Caching: 50-90% speed improvements with cache sizes up to 300K entries for large codebases
High-Performance Analytics: PageRank at 4.9M nodes/second, Betweenness Centrality at 104K nodes/second
Sub-microsecond Response: Cache hits deliver sub-microsecond response times for repeated operations
Memory Optimized: Cache configurations optimized for 500+ file codebases with 500MB memory allocation
Comprehensive Benchmarks: Performance monitoring with detailed cache effectiveness metrics
Supported Languages
Category | Languages | Count |
Web & Frontend | JavaScript, TypeScript, HTML, CSS | 4 |
Backend & Systems | Python, Java, C#, C++, C, Rust, Go | 7 |
JVM Languages | Java, Kotlin, Scala | 3 |
Functional | Elixir, Elm | 2 |
Mobile | Swift, Dart | 2 |
Scripting | Ruby, PHP, Lua | 3 |
Data & Config | SQL, YAML, JSON, TOML | 4 |
Markup & Docs | XML, Markdown | 2 |
Additional | Haskell, OCaml, F# | 3 |
Total | 25+ |
Status
✅ Multi-Language Support - 25+ programming languages with ast-grep backend
✅ MCP SDK integrated - Full protocol compliance across all languages
✅ Universal Architecture - Language-agnostic graph structures and analysis
✅ Server architecture complete - Enterprise-grade multi-language structure
✅ Core tools implemented - 8 comprehensive analysis tools working across all languages
✅ Performance optimized - Multi-language AST caching with intelligent routing
✅ Production ready - comprehensive error handling, defensive security
Available Tools
9 toolsanalyze_codebaseA
🔍 Perform comprehensive codebase analysis with metrics and structure overview.
🎯 PURPOSE: Builds the foundational code graph and provides project-wide insights including file counts, language distribution, complexity metrics, and architectural overview. 🔧 USAGE: Run this FIRST before using other analysis tools - it builds the code graph that powers all subsequent operations. ⚡ PERFORMANCE: Expensive operation (10-60s for large codebases) - results are cached for subsequent tool calls. Progress is shown during analysis. 🔄 WORKFLOW: analyze_codebase → specific analysis tools (find_definition, complexity_analysis, etc.) → insights and recommendations. 💡 TIP: Use rebuild_graph=true only if code has changed significantly since last analysis.
Inputs: rebuild_graph.
complexity_analysisA
📊 Analyze code complexity and identify refactoring opportunities.
🎯 PURPOSE: Calculates cyclomatic complexity, identifies code smells, and suggests specific refactoring opportunities with priority rankings. 🔧 USAGE: Use after basic analysis to identify problematic code areas that need attention. Essential for code quality assessment. ⚡ PERFORMANCE: Moderate operation (5-15s) - analyzes complexity metrics across the entire codebase. 🔄 WORKFLOW: analyze_codebase → complexity_analysis → examine high-complexity functions → find_callers/find_callees for refactoring impact. 💡 TIP: Start with threshold=15 for critical issues, lower to 10 for comprehensive analysis. Focus on functions with complexity >20 first.
Inputs: threshold.
dependency_analysisA
🔗 Analyze module dependencies and import relationships.
🎯 PURPOSE: Maps module interdependencies, identifies circular dependencies, and reveals architectural patterns and potential issues. 🔧 USAGE: Use for architectural analysis, identifying tightly coupled modules, or planning module restructuring. ⚡ PERFORMANCE: Moderate operation (3-10s) - analyzes import relationships and builds dependency graph. 🔄 WORKFLOW: analyze_codebase → dependency_analysis → identify problematic dependencies → complexity_analysis for detailed insights. 💡 TIP: Look for circular dependencies and modules with high fan-in/fan-out ratios - these often indicate architectural problems.
Inputs: no named parameters.
find_calleesA
📱 Find all functions called by the specified function.
🎯 PURPOSE: Maps function dependencies - what other functions does the target function rely on, revealing complexity and coupling. 🔧 USAGE: Use to understand function complexity, identify potential extraction opportunities, or analyze dependency chains. ⚡ PERFORMANCE: Fast operation (1-2s) - leverages indexed call relationships for instant results. 🔄 WORKFLOW: find_definition → find_callees → complexity_analysis → identify refactoring opportunities. 💡 TIP: High callee count often indicates functions that are doing too much and could benefit from decomposition.
Inputs: function (required).
find_callersA
📞 Find all functions that call the specified function.
🎯 PURPOSE: Identifies the call hierarchy - which functions depend on the target function, essential for understanding code dependencies. 🔧 USAGE: Use when analyzing function dependencies, planning refactoring, or understanding code flow patterns. ⚡ PERFORMANCE: Fast operation (1-2s) - uses pre-built call graph for efficient traversal. 🔄 WORKFLOW: find_definition → find_callers → analyze call patterns → find_callees for complete dependency picture. 💡 TIP: Crucial for refactoring - shows all functions that would break if you change the target function's signature.
Inputs: function (required).
find_definitionA
🎯 Find the definition location of a symbol (function, class, variable, method).
🎯 PURPOSE: Locates where a symbol is originally defined, providing file path, line number, and context. 🔧 USAGE: Use after analyze_codebase when you need to understand where a specific symbol is implemented. ⚡ PERFORMANCE: Fast operation (sub-second) - leverages cached code graph for instant lookups. 🔄 WORKFLOW: analyze_codebase → find_definition → examine definition context → find_references/find_callers for usage patterns. 💡 TIP: Works with partial names - 'MyClass' will find 'MyClass', 'MyClassImpl', etc. Use exact names for precision.
Inputs: symbol (required).
find_referencesA
📍 Find all references to a symbol throughout the codebase.
🎯 PURPOSE: Discovers everywhere a symbol is used, imported, or referenced, showing usage patterns and dependencies. 🔧 USAGE: Use after find_definition to understand how a symbol is used across the codebase. ⚡ PERFORMANCE: Fast operation (1-3s) - efficiently searches the indexed code graph. 🔄 WORKFLOW: find_definition → find_references → analyze usage patterns → complexity_analysis for refactoring insights. 💡 TIP: Essential for impact analysis before refactoring - shows all code that would be affected by changes.
Inputs: symbol (required).
get_usage_guideA
📚 Get comprehensive guidance on effectively using code analysis tools.
🎯 PURPOSE: Provides detailed instructions, best practices, and workflow recommendations for optimal tool usage. 🔧 USAGE: Call this FIRST if you need guidance on tool selection, sequencing, or best practices. ⚡ PERFORMANCE: Lightweight operation - provides strategic guidance without analysis overhead. 🔄 WORKFLOW: Use before starting complex analysis tasks to understand optimal tool orchestration.
Inputs: no named parameters.
project_statisticsA
📈 Get comprehensive project statistics and health metrics.
🎯 PURPOSE: Provides high-level project overview including file counts, language distribution, complexity trends, and overall health score. 🔧 USAGE: Use for project assessment, progress tracking, or generating project reports. Great for understanding project scale and characteristics. ⚡ PERFORMANCE: Fast operation (1-3s) - aggregates pre-calculated metrics from the code graph. 🔄 WORKFLOW: analyze_codebase → project_statistics → drill down with specific analysis tools based on findings. 💡 TIP: Use regularly to track code quality trends over time. Health score below 7/10 indicates areas needing attention.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool targets a distinct aspect of code analysis: setup, stats, symbol lookup, references, callers/callees, complexity, and dependencies. There is no meaningful overlap that would cause an agent to confuse one tool for another.
Most tools follow a verb_noun pattern (find_definition, analyze_codebase, get_usage_guide), but a few use noun_analysis (complexity_analysis, dependency_analysis) or noun_noun (project_statistics). While the pattern is not perfectly uniform, the conventions are consistent within functional subgroups (find_* and *_analysis), keeping it readable and predictable.
With 9 tools, the server is well-scoped for its purpose of code graph analysis. Each tool serves a clear role, from graph construction to querying definitions, references, dependencies, and complexity—no redundancy or excessive granularity.
The tool set covers the full lifecycle of code analysis: building the graph (analyze_codebase), high-level stats (project_statistics), symbol navigation (find_definition, find_references), call hierarchy (find_callers, find_callees), and deeper analysis (complexity_analysis, dependency_analysis). There are no obvious missing operations for the stated domain.
Maintenance
Related MCP Connectors
MCP server for static security analysis of Android source code
Repository knowledge graph MCP server for codebase understanding and debugging.
A MCP server built for developers enabling Git based project management with project and personal…
Shared context for your codebase: a hosted code knowledge graph over MCP. Free plan, OAuth sign-up.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides comprehensive code analysis through three MCP servers: static analysis for code quality and security, dependency analysis for package management and vulnerabilities, and complexity analysis for maintainability assessment across multiple programming languages.1MIT
- AlicenseNot gradedqualityFmaintenanceA powerful Model Context Protocol server that creates intelligent graph representations of your codebase with comprehensive semantic analysis capabilities, supporting 11 languages and 26 MCP methods.38 npm122MIT
- AlicenseNot gradedqualityDmaintenanceA production-grade MCP server providing advanced code intelligence capabilities such as semantic search, dependency analysis, and natural language Q&A across multiple programming languages.MIT
- AlicenseNot gradedqualityBmaintenanceA production-ready MCP server that enables AI assistants to intelligently understand, analyze, edit, navigate, and review software projects with multi-workspace support, Git integration, and semantic search.1MIT