CodeGraphContext
An MCP server that indexes local code into a graph database to provide context to AI assistants.
Features
- Code Indexing: Analyzes Python code and builds a knowledge graph of its components.
- Relationship Analysis: Query for callers, callees, class hierarchies, and more.
- Live Updates: Watches local files for changes and automatically updates the graph.
- Interactive Setup: A user-friendly command-line wizard for easy setup.
Getting Started
- Install:
pip install codegraphcontext
- Setup:
cgc setup
- Start:
cgc start
- Index Code:
cgc tool add-code-to-graph '{"path": "/path/to/your/project"}'
MCP Client Configuration
Add the following to your MCP client's configuration:
Natural Language Interaction Examples
Once the server is running, you can interact with it through your AI assistant using plain English. Here are some examples of what you can say:
Indexing and Watching Files
- To index a new project:
- "Please index the code in the
/path/to/my-project
directory." OR - "Add the project at
~/dev/my-other-project
to the code graph."
- "Please index the code in the
- To start watching a directory for live changes:
- "Watch the
/path/to/my-active-project
directory for changes." OR - "Keep the code graph updated for the project I'm working on at
~/dev/main-app
."
When you ask to watch a directory, the system performs two actions at once:
- It kicks off a full scan to index all the code in that directory. This process runs in the background, and you'll receive a
job_id
to track its progress. - It begins watching the directory for any file changes to keep the graph updated in real-time.
This means you can start by simply telling the system to watch a directory, and it will handle both the initial indexing and the continuous updates automatically.
- "Watch the
Querying and Understanding Code
- Finding where code is defined:
- "Where is the
process_payment
function?" - "Find the
User
class for me." - "Show me any code related to 'database connection'."
- "Where is the
- Analyzing relationships and impact:
- "What other functions call the
get_user_by_id
function?" - "If I change the
calculate_tax
function, what other parts of the code will be affected?" - "Show me the inheritance hierarchy for the
BaseController
class." - "What methods does the
Order
class have?"
- "What other functions call the
- Exploring dependencies:
- "Which files import the
requests
library?" - "Find all implementations of the
render
method."
- "Which files import the
- Code Quality and Maintenance:
- "Is there any dead or unused code in this project?"
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Indexes local Python code into a Neo4j graph database to provide AI assistants with deep code understanding and relationship analysis. Enables querying code structure, dependencies, and impact analysis through natural language interactions.
Related MCP Servers
- -securityFlicense-qualityA Python-based local indexing server that creates semantic search capabilities for codebases using ChromaDB, allowing Cursor IDE to perform vector searches on your code without sending data to external services.Last updated -22Python
- -securityFlicense-qualityAn implementation for managing Neo4j graph database operations through the Model Context Protocol, enabling users to execute Cypher queries against their Neo4j database via AI assistants like Cursor and Claude Desktop.Last updated -84JavaScript
- -securityFlicense-qualityEnables storage and retrieval of knowledge in a graph database format, allowing users to create, update, search, and delete entities and relationships in a Neo4j-powered knowledge graph through natural language.Last updated -3Python
- -securityAlicense-qualityAn MCP server that transforms codebases into knowledge graphs using Neo4J, enabling AI assistants to understand code structure, relationships, and metrics for more context-aware assistance.Last updated -3TypeScriptMIT License