Neo4j GDS MCP Server for Graph Algorithms
Analyze complex networks with the Neo4j GDS MCP server using comprehensive graph algorithms for advanced reasoning and Q&A.
Overview
The Neo4j GDS MCP Server exposes Neo4j Graph Data Science (GDS) capabilities through a Model Context Protocol (MCP) compatible server so language models and agent frameworks can call graph algorithms as tools. By wrapping GDS algorithms in a simple HTTP/MCP tool interface, the server enables advanced graph reasoning, retrieval-augmented Q&A, and explainable results directly from a Neo4j graph database.
This is useful when you want to augment an LLM with structured graph reasoning: use centrality and community detection for entity ranking, shortest-paths and subgraph extraction for evidence chains, and similarity algorithms for recommendation or entity linking. The server is intended for developers integrating graph analytics into AI agents, chains, and automated workflows.
Features
- Exposes common Neo4j GDS algorithms (PageRank, community detection, shortest path, node similarity, embeddings) as callable tools
- MCP-compatible interface so LLMs and orchestration frameworks can invoke graph operations
- Configurable Neo4j connection (database, host, credentials) via environment variables
- Returns algorithm outputs as structured JSON suitable for LLM consumption and downstream tooling
- Supports subgraph extraction and lightweight explainability (top-K contributing nodes/edges)
- Runs as a standalone FastAPI/uvicorn server (Docker-friendly)
Installation / Configuration
- Clone the repository and create a virtual environment:
- Install dependencies:
# or install the package in editable mode
- Configure environment variables for Neo4j and server options:
# target database for GDS operations
- Start the server (example using uvicorn):
Or run via Docker (example Dockerfile or image may be provided in the repo):
Available Tools / Resources
The server exposes a set of graph-algorithm tools. Typical endpoints and resources (HTTP JSON) you can expect:
- GET /algorithms
- Returns a list of available algorithms and their parameters
- POST /run
- Run an algorithm:
- body: { “algorithm”: “pagerank”, “graph”: “myGraph”, “params”: { … } }
- Run an algorithm:
- GET /graphs
- List graphs available in GDS catalog
- POST /subgraph
- Extract a subgraph for a set of nodes for evidence and context
- POST /explain
- Return top-K contributors for a result (e.g., top influencing nodes for PageRank)
Example “run” request:
Response: structured JSON with ranked nodes, scores, and optional subgraph evidence.
Use Cases
Influencer detection in social networks
- Run PageRank on a social graph to identify high-impact accounts. Return top-K nodes and a subgraph of their 1-hop neighborhoods to be used as evidence in an LLM response.
Community detection for topic clustering
- Use Louvain or label propagation to group related entities (products, authors, customers). Feed cluster labels back into your application for targeted recommendations or summarization.
Explainable Q&A and reasoning chains
- For a question like “How are product A and B related?”, compute shortest paths and extract the connecting subgraph. Return node/edge sequences as an evidence chain the LLM can reference.
Recommendation and similarity search
- Run node similarity or embedding-based nearest neighbors to provide personalized recommendations or to expand context when answering an LLM query.
Graph-based retrieval for RAG (Retrieval-Augmented Generation)
- Extract a focused subgraph around query-relevant entities and pass structured facts to the model to improve factuality and traceability.
Tips for Developers
- Keep the graph used for GDS (named graph/catalyst graph) reasonably sized for the algorithms you intend to run; some algorithms are memory sensitive.
- Use the server’s explain/subgraph endpoints to produce concise evidence for LLM responses rather than sending raw graph dumps.
- Combine algorithm outputs with provenance (timestamps, relationship types) to improve trustworthiness in an LLM-driven workflow.
For full implementation details, algorithm-specific parameters, and Docker examples, see the project README and source in the repository: https://github.com/neo4j-contrib/gds-agent.