CodeGraphContext

CodeGraphContext

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.

Category
Visit Server

README

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

  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"}'

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-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."
  • Code Quality and Maintenance:

    • "Is there any dead or unused code in this project?"

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured