Skip to main content
Glama

CodeGraphContext

CodeGraphContext

An MCP server that indexes local code into a graph database to provide context to AI assistants.

Project Details

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.

Used By

CodeGraphContext is already being explored by developers and projects for:

  • Static code analysis in AI assistants
  • Graph-based visualization of Python projects
  • Dead code and complexity detection

If you’re using CodeGraphContext in your project, feel free to open a PR and add it here! 🚀

Dependencies

  • neo4j>=5.15.0
  • watchdog>=3.0.0
  • requests>=2.31.0
  • stdlibs>=2023.11.18
  • typer[all]>=0.9.0
  • rich>=13.7.0
  • inquirerpy>=0.3.4
  • python-dotenv>=1.0.0

Getting Started

  1. Install: pip install codegraphcontext
  2. Setup: cgc setup
  3. Start: cgc start
  4. Index Code: cgc tool add-code-to-graph '{"path": "/path/to/your/project"}' (Under active development)

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", "calculate_cyclomatic_complexity", "find_most_complex_functions", "list_indexed_repositories", "delete_repository" ], "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-project directory." OR
    • "Add the project at ~/dev/my-other-project to the code graph."
  • 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:

    1. 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.
    2. 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.

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'."
  • 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?"
  • Exploring dependencies:
    • "Which files import the requests library?"
    • "Find all implementations of the render method."
  • Advanced Call Chain and Dependency Tracking (Spanning Hundreds of Files): The CodeGraphContext excels at tracing complex execution flows and dependencies across vast codebases. Leveraging the power of graph databases, it can identify direct and indirect callers and callees, even when a function is called through multiple layers of abstraction or across numerous files. This is invaluable for:
    • Impact Analysis: Understand the full ripple effect of a change to a core function.
    • Debugging: Trace the path of execution from an entry point to a specific bug.
    • Code Comprehension: Grasp how different parts of a large system interact.
    • "Show me the full call chain from the main function to process_data."
    • "Find all functions that directly or indirectly call validate_input."
    • "What are all the functions that initialize_system eventually calls?"
    • "Trace the dependencies of the DatabaseManager module."
  • Code Quality and Maintenance:
    • "Is there any dead or unused code in this project?"
    • "Calculate the cyclomatic complexity of the process_data function in src/utils.py."
    • "Find the 5 most complex functions in the codebase."
  • Repository Management:
    • "List all currently indexed repositories."
    • "Delete the indexed repository at /path/to/old-project."

Contributing

Contributions are welcome! 🎉
If you have ideas for new features, integrations, or improvements, open an issue or submit a PR.

Join discussions and help shape the future of CodeGraphContext.

-
security - not tested
A
license - permissive license
-
quality - not tested

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.

  1. Project Details
    1. Features
      1. Used By
        1. Dependencies
          1. Getting Started
            1. MCP Client Configuration
              1. Natural Language Interaction Examples
                1. Indexing and Watching Files
                2. Querying and Understanding Code
              2. Contributing

                Related MCP Servers

                • -
                  security
                  F
                  license
                  -
                  quality
                  A 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 -
                  22
                • -
                  security
                  F
                  license
                  -
                  quality
                  An 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 -
                  12
                  4
                • -
                  security
                  F
                  license
                  -
                  quality
                  Enables 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 -
                  3
                  • Linux
                • -
                  security
                  A
                  license
                  -
                  quality
                  An 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 -
                  5
                  MIT License

                View all related MCP servers

                MCP directory API

                We provide all the information about MCP servers via our MCP API.

                curl -X GET 'https://glama.ai/api/mcp/v1/servers/Shashankss1205/CodeGraphContext'

                If you have feedback or need assistance with the MCP directory API, please join our Discord server