CodeGraphMCPServer
Integrates with GitHub Copilot via MCP to provide structural code understanding, dependency analysis, and GraphRAG-powered code search directly in the IDE.
Supports OpenAI as an LLM provider for GraphRAG capabilities, enabling global and local code search using OpenAI models.
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., "@CodeGraphMCPServerfind all dependencies of the main function"
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.
CodeGraphMCPServer
A lightweight, high-performance source code analysis MCP server with zero configuration
Overview
CodeGraphMCPServer is an MCP server that understands codebase structure and provides GraphRAG (Graph Retrieval-Augmented Generation) capabilities. With a self-contained architecture requiring no external database, it enables structural understanding and efficient code completion from MCP-compatible AI tools (GitHub Copilot, Claude Desktop, Cursor, etc.).
š§ GraphRAG Features
Community Detection: Automatic code module clustering using Louvain algorithm
LLM Integration: Multi-provider design supporting OpenAI/Anthropic/Local LLMs
Global Search: Codebase-wide understanding using community summaries
Local Search: Context retrieval from entity neighborhoods
⨠Features
Feature | Description |
š Zero Configuration | No external DB required, |
š³ AST Analysis | Fast and accurate code analysis with Tree-sitter |
š Graph Construction | Builds graphs of relationships between code entities |
š 14 MCP Tools | Dependency analysis, call tracing, code search |
š 4 MCP Resources | Entities, files, communities, statistics |
š¬ 6 MCP Prompts | Code review, feature implementation, debug assistance |
ā” Fast Indexing | 100K lines in under 30 seconds, incremental updates in under 2 seconds |
š Multi-language Support | Python, TypeScript, JavaScript, Rust, Go, Java, PHP, C#, C, C++, HCL, Ruby, Kotlin, Swift, Scala, Lua (16 languages) |
Related MCP server: LiLBrain
Requirements
Python 3.11+
MCP-compatible client (GitHub Copilot, Claude Desktop, Cursor, Windsurf)
Installation
Install with pip
pip install codegraph-mcp-serverInstall from source (for development)
git clone https://github.com/nahisaho/CodeGraphMCPServer.git
cd CodeGraphMCPServer
python -m venv .venv
source .venv/bin/activate # Linux/macOS
pip install -e ".[dev]"Quick Start
1. Index a Repository
# Full index
codegraph-mcp index /path/to/repository --full
# Incremental index (default)
codegraph-mcp index /path/to/repository
# Auto re-index with file watching (v0.7.0 NEW)
codegraph-mcp watch /path/to/repository
codegraph-mcp watch /path/to/repository --debounce 2.0 # 2 second debounce
codegraph-mcp watch /path/to/repository --community # Community detection after re-indexOutput example:
Indexed 16 entities, 37 relations in 0.81s2. Check Statistics
codegraph-mcp stats /path/to/repositoryOutput example:
Repository Statistics
=====================
Repository: /path/to/repository
Entities: 16
Relations: 37
Communities: 0
Files: 1
Entities by type:
- class: 2
- function: 2
- method: 11
- module: 13. Search Code
codegraph-mcp query "Calculator" --repo /path/to/repository4. Start as MCP Server
# stdio transport (default)
codegraph-mcp serve --repo /path/to/repository
# SSE transport
codegraph-mcp start --repo /path/to/repository --port 8080MCP Client Configuration
Claude Desktop
~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"codegraph": {
"command": "codegraph-mcp",
"args": ["serve", "--repo", "/path/to/your/project"]
}
}
}Claude Code
# stdio transport
claude mcp add codegraph -- codegraph-mcp serve --repo /path/to/project
# HTTP transport (SSE server)
codegraph-mcp start --port 8080 # In another terminal
claude mcp add --transport http codegraph http://0.0.0.0:8080VS Code (GitHub Copilot)
.vscode/settings.json:
{
"mcp.servers": {
"codegraph": {
"command": "codegraph-mcp",
"args": ["serve", "--repo", "${workspaceFolder}"]
}
}
}Cursor
~/.cursor/mcp.json:
{
"mcpServers": {
"codegraph": {
"command": "codegraph-mcp",
"args": ["serve", "--repo", "/path/to/your/project"]
}
}
}š MCP Tools (14)
Graph Query Tools
Tool | Description | Main Arguments |
| Search code graph with natural language |
|
| Find entity dependencies |
|
| Find callers of function/method |
|
| Find callees of function/method |
|
| Find interface implementations |
|
| Analyze module structure |
|
Code Retrieval Tools
Tool | Description | Main Arguments |
| Get entity source code |
|
| Get file content |
|
| Get file structure overview |
|
GraphRAG Tools
Tool | Description | Main Arguments |
| Cross-community global search |
|
| Local search in entity neighborhood |
|
Management Tools
Tool | Description | Main Arguments |
| Suggest refactoring |
|
| Re-index repository |
|
| Execute shell command |
|
š MCP Resources (4)
URI Pattern | Description |
| Entity details |
| Entities in file |
| Community information |
| Graph statistics |
š¬ MCP Prompts (6)
Prompt | Description | Arguments |
| Perform code review |
|
| Explain codebase |
|
| Feature implementation guide |
|
| Debug assistance |
|
| Refactoring guide |
|
| Test generation |
|
Usage Examples
Conversation with AI Assistant
You: What are the dependencies of the UserService class?
AI: [Using find_dependencies tool]
UserService depends on:
- DatabaseConnection (database.py)
- Logger (utils/logging.py)
- UserRepository (repositories/user.py)You: What would be affected if I modify the authenticate method?
AI: [Using find_callers tool]
Callers of authenticate:
- LoginController.login() (controllers/auth.py:45)
- APIMiddleware.verify_token() (middleware/api.py:23)
- TestUserService.test_auth() (tests/test_user.py:78)You: Explain the main components of this project
AI: [Using global_search tool]
[Using explain_codebase prompt]
This project uses a 3-tier architecture:
1. Controllers layer: HTTP request handling
2. Services layer: Business logic
3. Repositories layer: Data accessDevelopment
Run Tests
# Run all tests
pytest
# With coverage
pytest --cov=src/codegraph_mcp --cov-report=html
# Specific tests
pytest tests/unit/test_parser.py -vLint & Format
# Lint with Ruff
ruff check src tests
# Format with Ruff
ruff format src tests
# Type check with MyPy
mypy srcArchitecture
src/codegraph_mcp/
āāā __init__.py # Package initialization
āāā __main__.py # CLI entry point
āāā server.py # MCP server
āāā config.py # Configuration management
āāā core/ # Core logic
ā āāā parser.py # Tree-sitter AST parser
ā āāā graph.py # NetworkX graph engine
ā āāā indexer.py # Repository indexer
ā āāā community.py # Community detection (Louvain)
ā āāā semantic.py # Semantic analysis
ā āāā llm.py # LLM integration (OpenAI/Anthropic/Local)
ā āāā graphrag.py # GraphRAG search engine
āāā storage/ # Storage layer
ā āāā sqlite.py # SQLite persistence
ā āāā cache.py # File cache
ā āāā vectors.py # Vector store
āāā mcp/ # MCP interface
ā āāā tools.py # 14 MCP Tools
ā āāā resources.py # 4 MCP Resources
ā āāā prompts.py # 6 MCP Prompts
āāā languages/ # Language support (12 languages)
āāā python.py # Python extractor
āāā typescript.py # TypeScript extractor
āāā javascript.py # JavaScript extractor
āāā rust.py # Rust extractor
āāā go.py # Go extractor
āāā java.py # Java extractor
āāā php.py # PHP extractor
āāā csharp.py # C# extractor
āāā c.py # C extractor
āāā cpp.py # C++ extractor
āāā hcl.py # HCL (Terraform) extractor
āāā ruby.py # Ruby extractorPerformance
Measured Values (v0.3.0)
Metric | Measured | Notes |
Indexing speed | 32 entities/sec | 67 files, 941 entities |
File processing speed | 0.44 sec/file | Python/TS/Rust mixed |
Incremental index | < 2 sec | Changed files only |
Query response | < 2ms | Graph search |
Target Values
Metric | Target |
Initial index (100K lines) | < 30 sec |
Incremental index | < 2 sec |
Query response | < 500ms |
Startup time | < 2 sec |
Memory usage | < 500MB |
License
MIT License - See LICENSE
Acknowledgments
Model Context Protocol - MCP specification
Tree-sitter - AST analysis
NetworkX - Graph algorithms
Microsoft GraphRAG - GraphRAG concept
Related Links
This server cannot be deployed
Maintenance
Related MCP Connectors
Repository knowledge graph MCP server for codebase understanding and debugging.
An MCP server that gives your AI access to the source code and docs of all public github repos
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Related MCP Servers
- AlicenseAqualityDmaintenanceUniversal MCP server that analyzes any codebase and provides structured context to AI assistants. Dynamic, accurate, and token-efficient.1811 npmMIT
- AlicenseBqualityDmaintenanceInstant codebase knowledge graph MCP server. It auto-detects languages, indexes functions, classes, and call chains, enabling LLMs to navigate code in milliseconds.24MIT
- AlicenseNot gradedqualityAmaintenanceMCP server for local-first code intelligence, providing structural code graph, semantic search, and impact analysis to AI agents.2MIT
- AlicenseNot gradedqualityAmaintenanceUltra-lightweight, local-first MCP server for AI-powered code intelligence, providing AST-based analysis and 20+ tools while ensuring zero data leakage.869 npm10MIT