Skip to content

Add MCP server for Neo4j graph queries #10

@rysweet

Description

@rysweet

Feature: MCP Server for AI Agent Graph Queries

Overview

Build an MCP (Model Context Protocol) server that provides AI coding agents with sophisticated tools to query and analyze the Blarify graph database. This will enable AI agents to understand codebases deeply by accessing the rich graph representations Blarify creates.

Problem

AI coding agents currently lack standardized ways to:

  • Query complex code relationships in the Blarify graph
  • Retrieve contextual information about code elements
  • Plan changes based on codebase structure
  • Access the semantic knowledge stored in Neo4j

Solution

Create an MCP server with three primary tools:

  1. getContextForFiles: Retrieve comprehensive context for specified files

    • Traverses graph to find related classes, functions, dependencies
    • Includes LLM summaries and documentation links
    • Returns organized Markdown structure
  2. getContextForSymbol: Get context for a specific symbol (class/function/variable)

    • Finds definitions, usages, and relationships
    • Includes inheritance chains and implementations
    • Shows where symbol is used across codebase
  3. buildPlanForChange: Generate implementation plan for a change request

    • Analyzes impact across codebase
    • Identifies files to modify/create
    • Orders changes by dependency
    • Includes test and documentation updates

Technical Approach

  • Build on existing neo4j-cypher and gds-agent MCP servers
  • Use Cypher queries for graph traversal
  • Integrate Azure OpenAI for organizing results into coherent Markdown
  • Handle complex multi-hop traversals efficiently

Implementation Steps

  1. Set up MCP server scaffold
  2. Implement Neo4j connection and base queries
  3. Build graph traversal logic for context extraction
  4. Integrate LLM for result processing
  5. Implement the three custom tools
  6. Add error handling and query optimization
  7. Write comprehensive tests
  8. Create documentation and examples

Testing

  • Unit tests for query builders
  • Integration tests with sample graphs
  • End-to-end MCP tool tests
  • Mocked LLM response tests

Success Criteria

  • AI agents can query code relationships effectively
  • Context retrieval is accurate and well-organized
  • Change planning identifies all dependencies
  • Performance is acceptable for large codebases

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions