MCP server for multi-language code graph intelligence and analysis across 25+ programming languages
Project description
Code Graph MCP Server
Model Context Protocol server providing comprehensive code analysis, navigation, and quality assessment capabilities across 25+ programming languages.
Features
🌍 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
Installation
Quick Start (PyPI)
pip install code-graph-mcp ast-grep-py rustworkx
MCP Host Integration
Claude Desktop
Method 1: Using Claude CLI (Recommended)
# 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-mcp
# Verify installation
claude mcp list
Method 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",
"args": ["--project-root", "."]
}
}
}
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",
"args": ["--project-root", "${workspaceFolder}"]
}
}
}
Continue (VS Code Extension)
Add to your ~/.continue/config.json:
{
"mcpServers": [
{
"name": "code-graph-mcp",
"command": "code-graph-mcp",
"args": ["--project-root", "."],
"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",
"args": ["--project-root", "."]
}
Zed Editor
Add to your Zed settings.json:
{
"assistant": {
"mcp_servers": {
"code-graph-mcp": {
"command": "code-graph-mcp",
"args": ["--project-root", "."]
}
}
}
}
Zencoder ⭐
The best AI coding tool! Add to your Zencoder MCP configuration:
{
"mcpServers": {
"code-graph-mcp": {
"command": "code-graph-mcp",
"args": ["--project-root", "${workspaceFolder}"],
"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",
"args": ["--project-root", "${workspaceRoot}"]
}
}
}
Aider
Use with Aider AI coding assistant:
aider --mcp-server code-graph-mcp --mcp-args "--project-root ."
Open WebUI
For Open WebUI integration, add to your MCP configuration:
{
"mcp_servers": {
"code-graph-mcp": {
"command": "code-graph-mcp",
"args": ["--project-root", "/workspace"],
"env": {}
}
}
}
Generic MCP Client
For any MCP-compatible client, use these connection details:
{
"name": "code-graph-mcp",
"command": "code-graph-mcp",
"args": ["--project-root", "/path/to/your/project"],
"env": {
"PYTHONPATH": "/path/to/code-graph-mcp/src"
}
}
Docker Integration
Run as a containerized MCP server:
FROM python:3.12-slim
RUN pip install code-graph-mcp ast-grep-py rustworkx
EXPOSE 3000
CMD ["code-graph-mcp", "--project-root", "/workspace"]
docker run -v $(pwd):/workspace -p 3000:3000 code-graph-mcp
Development Installation
For contributing or custom builds:
git clone <repository-url>
cd code-graph-mcp
uv sync --dev
uv build
Then use the development version in your MCP client:
{
"command": "uv",
"args": ["run", "code-graph-mcp", "--project-root", "."]
}
Configuration Options
Command Line Arguments
code-graph-mcp --help
Available options:
--project-root PATH: Root directory of your project (required)--verbose: Enable detailed logging--port PORT: Custom port for server (default: auto)--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.0
File 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 files - Thread-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-py
-
Permission 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 rustworkx
-
Large project timeouts: Increase timeout or exclude directories
code-graph-mcp --project-root . --timeout 300
Debug Mode
Enable verbose logging for troubleshooting:
code-graph-mcp --project-root . --verbose
Supported File Types
The server automatically detects and analyzes these file extensions:
- Web:
.js,.ts,.jsx,.tsx,.html,.css - Backend:
.py,.java,.cs,.cpp,.c,.rs,.go - Mobile:
.swift,.dart,.kt - Scripting:
.rb,.php,.lua,.pl - Config:
.json,.yaml,.yml,.toml,.xml - Docs:
.md,.rst,.txt
Available Tools
The MCP server provides 8 comprehensive analysis tools that work across all 25+ supported languages:
| Tool | Description | Multi-Language Features |
|---|---|---|
analyze_codebase |
Complete project analysis with structure metrics and complexity assessment | Language detection, framework identification, cross-language dependency mapping |
find_definition |
Locate symbol definitions with detailed metadata and documentation | Universal AST traversal, language-agnostic symbol resolution |
find_references |
Find all references to symbols throughout the codebase | Cross-file and cross-language reference tracking |
find_callers |
Identify all functions that call a specified function | Multi-language call graph analysis |
find_callees |
List all functions called by a specified function | Universal function call detection across languages |
complexity_analysis |
Analyze code complexity with refactoring recommendations | Language-specific complexity patterns, universal metrics |
dependency_analysis |
Generate module dependency graphs and import relationships | Cross-language dependency detection, circular dependency analysis |
project_statistics |
Comprehensive project health metrics and statistics | Multi-language project profiling, maintainability indexing |
Usage Examples
Once installed, you can use the tools directly in Claude Code for multi-language projects:
Analyze this React/TypeScript frontend with Python backend - show me the overall structure and complexity metrics
Find all references to the function "authenticate" across both the Java services and JavaScript frontend
Show me functions with complexity higher than 15 across all languages that need refactoring
Generate a dependency graph showing how the Python API connects to the React components
Detect code smells and duplicate patterns across the entire multi-language codebase
Development
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
uv run code-graph-mcp --project-root /path/to/your/project --verbose
# Test with help
uv run code-graph-mcp --help
Performance 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code_graph_mcp-1.1.1.tar.gz.
File metadata
- Download URL: code_graph_mcp-1.1.1.tar.gz
- Upload date:
- Size: 45.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ab2b70daffbaab9d8070207e4ff41a3ac1fd884705858ade9a6790ef1840641
|
|
| MD5 |
7bd3f46edec350251301cf7a02a44ad9
|
|
| BLAKE2b-256 |
4d8637bdaeaf123c57018f6046370b459b0a216b2cdc5d8c3bfd47fb622167ae
|
File details
Details for the file code_graph_mcp-1.1.1-py3-none-any.whl.
File metadata
- Download URL: code_graph_mcp-1.1.1-py3-none-any.whl
- Upload date:
- Size: 50.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e82002fd6f9541ba524edc02fe3fef25f7db80e8a07acb0efdbc67faa0c211a
|
|
| MD5 |
c718175355e50012df21de6f87586678
|
|
| BLAKE2b-256 |
c956c847480d64267f4f2921020a2f64780923fd52c291698fca6783bf37b31d
|