Docker Image GitHub Repository β’ Docker Hub β’ Documentation β’ Main Project GitHub Repository β’ PyPI Package
- Overview
- Quick Start
- Configuration
- MCP Client Setup
- Available Tools
- Neo4j Setup
- Remote Deployment
- Troubleshooting
- Resources & Support
CodeGraphContext MCP Server transforms your codebase into a queryable knowledge graph powered by Neo4j. It provides AI assistants with deep contextual understanding of code relationships, dependencies, and architecture patterns, integrating seamlessly with VS Code, Cursor, Windsurf, and Claude Desktop.
β¨ Intelligent Code Indexing - Automatically analyzes and graphs code structure with background job processing
π Relationship Analysis - Query callers, callees, class hierarchies, and dependencies
π Live Updates - Real-time file watching with automatic graph synchronization
π― Dead Code Detection - Identify unused functions and quality issues
π Complexity Analysis - Calculate cyclomatic complexity and find hotspots
π Call Chain Tracing - Track execution flows across hundreds of files
π Multiple Protocols - HTTP, SSE, and WebSocket support
ποΈ Graph Database Powered - Neo4j backend for lightning-fast queries
β‘ Async Processing - Background jobs for large codebases
Architecture | Status | Notes |
---|---|---|
x86-64 | β Stable | Intel/AMD processors |
ARM64 | β Stable | Raspberry Pi, Apple Silicon |
Tag | Stability | Use Case |
---|---|---|
stable |
βββ | Production (recommended) |
latest |
βββ | Latest stable features |
0.1.x |
βββ | Version pinning |
beta |
Testing only |
- Docker Engine 23.0+
- Neo4j database (local or hosted)
services:
neo4j:
image: neo4j:latest
container_name: neo4j
restart: unless-stopped
ports:
- "7474:7474"
- "7687:7687"
environment:
- NEO4J_AUTH=neo4j/your-secure-password
- NEO4J_PLUGINS=["apoc"]
volumes:
- neo4j_data:/data
codegraphcontext-mcp:
image: mekayelanik/codegraphcontext-mcp:stable
container_name: cgc-mcp
restart: unless-stopped
ports:
- "8045:8045"
environment:
- PORT=8045
- NEO4J_URI=bolt://neo4j:7687
- NEO4J_USERNAME=neo4j
- NEO4J_PASSWORD=your-secure-password
- PUID=1000
- PGID=1000
- TZ=Asia/Dhaka
- PROTOCOL=SHTTP
- CORS=*
volumes:
- /path/to/your/projects:/workspace:ro
depends_on:
- neo4j
volumes:
neo4j_data:
Deploy:
docker compose up -d
docker compose logs -f cgc-mcp
docker run -d \
--name=cgc-mcp \
--restart=unless-stopped \
-p 8045:8045 \
-v /path/to/your/projects:/workspace:ro \
-e PORT=8045 \
-e NEO4J_URI=bolt://your-neo4j:7687 \
-e NEO4J_USERNAME=neo4j \
-e NEO4J_PASSWORD=your-password \
-e PUID=1000 \
-e PGID=1000 \
-e PROTOCOL=SHTTP \
mekayelanik/codegraphcontext-mcp:stable
Protocol | Endpoint | Use Case |
---|---|---|
HTTP | http://host-ip:8045/mcp |
Recommended |
SSE | http://host-ip:8045/sse |
Real-time streaming |
WebSocket | ws://host-ip:8045/message |
Bidirectional |
Health | http://host-ip:8045/healthz |
Monitoring |
β±οΈ Allow 30-60 seconds for initialization on ARM devices
Variable | Default | Description |
---|---|---|
PORT |
8045 |
Internal server port |
NEO4J_URI |
bolt://localhost:7687 |
Neo4j connection string |
NEO4J_USERNAME |
neo4j |
Database username |
NEO4J_PASSWORD |
(required) | Database password |
PUID |
1000 |
User ID for permissions |
PGID |
1000 |
Group ID for permissions |
TZ |
Asia/Dhaka |
Container timezone |
PROTOCOL |
SHTTP |
Transport protocol (SHTTP , SSE , WS ) |
CORS |
(none) | Cross-Origin config (* , domains, regex) |
API_KEY |
(none) | Optional authentication |
DEBUG_MODE |
false |
Enable debug mode |
Mount your project directories to make them accessible to the MCP server:
volumes:
- /home/user/projects:/workspace:ro # Read-only recommended
- /var/www/apps:/apps:ro
- /opt/repositories:/repos:ro
Then reference paths as /workspace/project-name
, /apps/app-name
, etc.
# Local Docker
environment:
- NEO4J_URI=bolt://neo4j:7687
- NEO4J_USERNAME=neo4j
- NEO4J_PASSWORD=your-password
# Remote Server
environment:
- NEO4J_URI=bolt://server.com:7687
- NEO4J_USERNAME=neo4j
- NEO4J_PASSWORD=your-password
# Neo4j AuraDB (Cloud)
environment:
- NEO4J_URI=neo4j+s://xxxxx.databases.neo4j.io
- NEO4J_USERNAME=neo4j
- NEO4J_PASSWORD=your-auradb-password
# Development only
environment:
- CORS=*
# Production - specific domains
environment:
- CORS=https://example.com,https://app.example.com
# Mixed domains and IPs
environment:
- CORS=https://example.com,192.168.1.100:3000
β οΈ Security: Never useCORS=*
in production
Client | HTTP | SSE | WebSocket | Recommended |
---|---|---|---|---|
VS Code (Cline/Roo-Cline) | β | β | β | HTTP |
Claude Desktop | β | β | HTTP | |
Cursor | β | β | HTTP | |
Windsurf | β | β | HTTP |
β οΈ *WebSocket is experimental
Add to .vscode/settings.json
:
{
"mcp.servers": {
"codegraphcontext": {
"url": "http://host-ip:8045/mcp",
"transport": "http",
"autoApprove": [
"add_code_to_graph",
"check_job_status",
"list_jobs",
"find_code",
"analyze_code_relationships",
"watch_directory",
"execute_cypher_query",
"add_package_to_graph",
"find_dead_code",
"calculate_cyclomatic_complexity",
"find_most_complex_functions",
"list_indexed_repositories",
"delete_repository",
"list_watched_paths",
"unwatch_directory"
]
}
}
}
Config Locations:
- Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"codegraphcontext": {
"transport": "http",
"url": "http://localhost:8045/mcp"
}
}
}
Add to ~/.cursor/mcp.json
:
{
"mcpServers": {
"codegraphcontext": {
"transport": "http",
"url": "http://host-ip:8045/mcp"
}
}
}
Add to .codeium/mcp_settings.json
:
{
"mcpServers": {
"codegraphcontext": {
"transport": "http",
"url": "http://host-ip:8045/mcp"
}
}
}
Add to ~/.config/claude-code/mcp_config.json
:
{
"mcpServers": {
"codegraphcontext": {
"transport": "http",
"url": "http://localhost:8045/mcp"
}
}
}
Or configure via CLI:
claude-code config mcp add codegraphcontext \
--transport http \
--url http://localhost:8045/mcp
Add to ~/.github-copilot/mcp.json
:
{
"mcpServers": {
"codegraphcontext": {
"transport": "http",
"url": "http://host-ip:8045/mcp"
}
}
}
Or use environment variable:
export GITHUB_COPILOT_MCP_SERVERS='{"codegraphcontext":{"transport":"http","url":"http://localhost:8045/mcp"}}'
Performs a one-time scan of a local folder to add its code to the graph. Ideal for indexing libraries, dependencies, or projects not being actively modified. Returns a job ID for background processing.
Parameters: directory
(required), repository_name
(optional)
Example: "Index the code in /workspace/my-project"
Check the status and progress of a background job.
Parameters: job_id
(required)
Example: "Check status of job abc123"
List all background jobs and their current status.
Example: "Show all jobs"
Find relevant code snippets related to a keyword (e.g., function name, class name, or content).
Parameters: name
(required), type
(optional)
Example: "Find the calculate_total function"
Analyze code relationships like 'who calls this function' or 'class hierarchy'. Supported query types include: find_callers, find_callees, find_all_callers, find_all_callees, find_importers, who_modifies, class_hierarchy, overrides, dead_code, call_chain, module_deps, variable_scope, find_complexity, find_functions_by_argument, find_functions_by_decorator.
Parameters: name
(required), relationship_type
(optional), max_depth
(optional)
Example: "Show what calls the process_payment function"
Performs an initial scan of a directory and then continuously monitors it for changes, automatically keeping the graph up-to-date. Ideal for projects under active development. Returns a job ID for the initial scan.
Parameters: directory
(required), repository_name
(optional)
Example: "Watch /workspace/active-project for changes"
Fallback tool to run a direct, read-only Cypher query against the code graph. Use this for complex questions not covered by other tools. The graph contains nodes representing code structures and relationships between them.
Schema Overview:
- Nodes: Repository, File, Module, Class, Function
- Properties: name, path, cyclomatic_complexity (on Function nodes), code
- Relationships: CONTAINS, CALLS, IMPORTS, INHERITS
Parameters: query
(required), parameters
(optional)
Example: "Execute: MATCH (f:Function) RETURN f.name LIMIT 10"
Add a package to the graph by discovering its location. Supports multiple languages. Returns immediately with a job ID.
Parameters: package_name
(required)
Example: "Add the requests package to the graph"
Find potentially unused functions (dead code) across the entire indexed codebase, optionally excluding functions with specific decorators.
Parameters: repository_name
(optional), exclude_decorators
(optional)
Example: "Find dead code in my-project"
Calculate the cyclomatic complexity of a specific function to measure its complexity.
Parameters: function_name
(required), file_path
(optional)
Example: "Calculate complexity of process_data"
Find the most complex functions in the codebase based on cyclomatic complexity.
Parameters: limit
(optional), repository_name
(optional)
Example: "Find the 5 most complex functions"
List all indexed repositories.
Example: "Show all indexed repositories"
Delete an indexed repository from the graph.
Parameters: repository_path
(required)
Example: "Delete repository at /workspace/old-project"
Generates a URL to visualize the results of a Cypher query in the Neo4j Browser. The user can open this URL in their web browser to see the graph visualization.
Parameters: query
(required), parameters
(optional)
Example: "Visualize: MATCH (n)-[r]->(m) RETURN n, r, m LIMIT 50"
Lists all directories currently being watched for live file changes.
Example: "Show watched directories"
Stops watching a directory for live file changes.
Parameters: directory
(required)
Example: "Stop watching /workspace/project"
services:
neo4j:
image: neo4j:latest
ports:
- "7474:7474"
- "7687:7687"
environment:
- NEO4J_AUTH=neo4j/your-password
- NEO4J_PLUGINS=["apoc"]
- NEO4J_dbms_memory_heap_max__size=2G
volumes:
- neo4j_data:/data
Access: http://localhost:7474
- Create account at neo4j.com/cloud/aura
- Create instance and note credentials
- Configure container with AuraDB URI
- Download Neo4j Desktop
- Create and start database
- Use
bolt://localhost:7687
connection
The MCP server can be deployed remotely and accessed via URL from your IDE clients. However, understand these requirements:
Filesystem Access Required:
add_code_to_graph
andwatch_directory
need direct access to code directories- Mount your project directories into the container via Docker volumes
- Alternative: Use
add_package_to_graph
for public packages
Query Operations Work Remotely:
- All analysis tools (
find_code
,analyze_code_relationships
, etc.) work perfectly over remote connections - Once code is indexed in Neo4j, location doesn't matter
Server (where code exists):
services:
codegraphcontext-mcp:
image: mekayelanik/codegraphcontext-mcp:stable
ports:
- "8045:8045"
volumes:
- /var/repositories:/repos:ro
- /home/user/projects:/projects:ro
environment:
- NEO4J_URI=bolt://neo4j-server:7687
- NEO4J_USERNAME=neo4j
- NEO4J_PASSWORD=password
- CORS=https://your-domain.com
Client (IDE configuration):
{
"mcpServers": {
"codegraphcontext": {
"transport": "http",
"url": "http://your-server-ip:8045/mcp"
}
}
}
- Use HTTPS reverse proxy (nginx/Caddy) for production
- Configure specific CORS domains, never use
*
in production - Consider VPN/SSH tunneling for sensitive codebases
- Enable
API_KEY
authentication for additional security - Use read-only volume mounts (
:ro
) when possible
- β Docker 23.0+
- β Neo4j running and accessible
- β Port 8045 available
- β Latest stable image
- β Correct configuration
- β Project directories mounted
Container Won't Start
docker logs cgc-mcp
docker pull mekayelanik/codegraphcontext-mcp:stable
Neo4j Connection Failed
# Test connectivity
docker exec cgc-mcp python3 -c "
from neo4j import GraphDatabase
driver = GraphDatabase.driver('bolt://neo4j:7687', auth=('neo4j', 'password'))
driver.verify_connectivity()
"
Permission Errors
id $USER # Get your UID/GID
# Update PUID and PGID in config
Cannot Access Mounted Directories
# Verify mount inside container
docker exec cgc-mcp ls -la /workspace
# Check permissions
docker exec cgc-mcp stat /workspace/your-project
Client Cannot Connect
curl http://localhost:8045/healthz
curl http://localhost:8045/mcp
CORS Errors
# Development
environment:
- CORS=*
# Production
environment:
- CORS=https://yourdomain.com
Job Processing Issues
# Check job status via tool
# "List all jobs" or "Check status of job <job_id>"
# View logs
docker logs cgc-mcp --tail 100 -f
- π PyPI Package
- π¦ GitHub Repository
- π Full Documentation
- π₯ Demo Video
- π¬ Discord Community
- π Neo4j Documentation
- π GraphAcademy
- π Cypher Language
Docker Image Issues:
Package Issues:
# Docker Compose
docker compose pull
docker compose up -d
# Docker CLI
docker pull mekayelanik/codegraphcontext-mcp:stable
docker stop cgc-mcp && docker rm cgc-mcp
# Run your docker run command again
Docker Image GPL License - See LICENSE
Main Project MIT License - See LICENSE
Disclaimer: Unofficial Docker image for CodeGraphContext. Not affiliated with Neo4j or Anthropic. Users are responsible for proper Neo4j licensing, security, and compliance.
Privacy: This Docker image does not collect, store, or transmit your code or personal data. All data resides on Neo4j instance of your choice.