Skip to main content

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

  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?"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codegraphcontext-0.1.5.tar.gz (36.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codegraphcontext-0.1.5-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

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

Hashes for codegraphcontext-0.1.5.tar.gz
Algorithm Hash digest
SHA256 da019ce40e723e875e597d623d17bd115b7eee825f8ecab8d912fd3f8c02ece2
MD5 ba00eccaf2e14354ea1d02e727d968d9
BLAKE2b-256 dd9a00916092bc4d721ca1de89ff387254bfbbfdf748d1b47c145314a2652690

See more details on using hashes here.

File details

Details for the file codegraphcontext-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for codegraphcontext-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 188e00b3431e38e7de05492eabf8941cc8e1e41582b28a947a5308b453687e70
MD5 b8f867ec75f12b738c9827f5937cf9ba
BLAKE2b-256 3d62f696356256e566667a520171193d42423c9adb39de46987bba93e664eb9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page