An MCP server that indexes local code into a graph database to provide context to AI assistants.
Project description
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:
{
"mcpServers": {
"CodeGraphContext": {
"command": "cgc",
"args": [
"start"
],
"env": {
"NEO4J_URI": "************",
"NEO4J_USER": "************",
"NEO4J_PASSWORD": "**************"
},
"tools": {
"alwaysAllow": [
"list_imports",
"add_code_to_graph",
"add_package_to_graph",
"check_job_status",
"list_jobs",
"find_code",
"analyze_code_relationships",
"watch_directory",
"find_dead_code",
"execute_cypher_query"
],
"disabled": false
},
"disabled": false,
"alwaysAllow": []
}
}
}
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-projectdirectory." OR - "Add the project at
~/dev/my-other-projectto the code graph."
- "Please index the code in the
-
To start watching a directory for live changes:
- "Watch the
/path/to/my-active-projectdirectory 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_idto 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_paymentfunction?" - "Find the
Userclass 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_idfunction?" - "If I change the
calculate_taxfunction, what other parts of the code will be affected?" - "Show me the inheritance hierarchy for the
BaseControllerclass." - "What methods does the
Orderclass have?"
- "What other functions call the
-
Exploring dependencies:
- "Which files import the
requestslibrary?" - "Find all implementations of the
rendermethod."
- "Which files import the
-
Code Quality and Maintenance:
- "Is there any dead or unused code in this project?"
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 codegraphcontext-0.1.5.tar.gz.
File metadata
- Download URL: codegraphcontext-0.1.5.tar.gz
- Upload date:
- Size: 36.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da019ce40e723e875e597d623d17bd115b7eee825f8ecab8d912fd3f8c02ece2
|
|
| MD5 |
ba00eccaf2e14354ea1d02e727d968d9
|
|
| BLAKE2b-256 |
dd9a00916092bc4d721ca1de89ff387254bfbbfdf748d1b47c145314a2652690
|
File details
Details for the file codegraphcontext-0.1.5-py3-none-any.whl.
File metadata
- Download URL: codegraphcontext-0.1.5-py3-none-any.whl
- Upload date:
- Size: 39.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
188e00b3431e38e7de05492eabf8941cc8e1e41582b28a947a5308b453687e70
|
|
| MD5 |
b8f867ec75f12b738c9827f5937cf9ba
|
|
| BLAKE2b-256 |
3d62f696356256e566667a520171193d42423c9adb39de46987bba93e664eb9a
|