Skip to main content

A graph database and analysis tool for AI assistants via MCP

Project description

MCP Graph Engine

A graph database and analysis tool that plugs into AI assistants via the Model Context Protocol (MCP). Build relationship graphs, run analysis algorithms, and visualise everything in real-time.

Graph visualisation demo

What's This For?

You know how you're debugging something gnarly and you end up with a whiteboard full of boxes and arrows? Or you're trying to understand a codebase and the dependencies are doing your head in? This is that whiteboard, except your AI assistant can build it, query it, and run proper graph algorithms on it.

Some things it's good for:

  • Mapping code dependencies and finding circular imports
  • Building knowledge graphs while researching a topic
  • Tracing request flows through a system
  • Debugging complex issues (symptoms, causes, evidence)
  • Understanding relationships in any domain

The key bit: your AI assistant builds the graph as you work together, then you can both reason about it. The live visualisation means you can see what's being built in real-time.

Quick Demo

You: "Map out the auth system dependencies"

Claude: *adds nodes for AuthService, UserRepository, TokenValidator, Database*
        *adds edges showing what depends on what*

You: "What's the most critical component?"

Claude: *runs PageRank* "Database has the highest centrality -
         everything flows through it eventually"

You: "Any circular dependencies?"

Claude: *runs cycle detection* "Yeah, AuthService and TokenValidator
         have a circular dep through SessionManager"

Meanwhile, you're watching the graph build in your browser at http://localhost:8765.

Cycle detection example

Installation

Requirements: Python 3.10+ and an MCP-compatible client (Claude Code, Claude Desktop, Cursor, etc.)

1. Install the package

pipx install mcp-graph-engine

That's it. pipx installs the tool in an isolated environment and adds it to your PATH.

Optional: Enable semantic matching with embeddings

The default install uses exact and normalised string matching for node lookups. For semantic/fuzzy matching (e.g., "auth service" matching "AuthService"), install with embeddings support:

pipx install mcp-graph-engine[embeddings]

This adds sentence-transformers (PyTorch-based) which increases install size but enables smarter node matching.

Alternative installation methods
# Using uv (fast Python package manager)
uv tool install mcp-graph-engine

# Using pip (may require manual PATH setup)
pip install mcp-graph-engine

# With embeddings support
pip install mcp-graph-engine[embeddings]

# From source
git clone https://github.com/utilitydelta/mcp-graph-engine.git
cd mcp-graph-engine
pip install -e .

2. Add to your MCP client

Add this to your MCP configuration file:

{
  "mcpServers": {
    "graph-engine": {
      "command": "mcp-graph-engine"
    }
  }
}

Where's the config file?

Client Location
Claude Code ~/.mcp.json (global) or .mcp.json (project)
Claude Desktop ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
Cursor .cursor/mcp.json

3. Restart your client

Restart Claude Code / Claude Desktop / Cursor. The graph tools should now be available - ask your assistant to list its tools to verify.

Usage

Adding Data

The easiest way is the knowledge DSL - just plain text relationships:

Alice knows Bob
Bob works_at TechCorp
TechCorp located_in Sydney

Or with type hints:

AuthService:service depends_on UserRepository:repository
UserRepository:repository queries Database:infrastructure

You can also use structured facts if you need more control:

{
  "facts": [
    {"from": "AuthService", "to": "Database", "rel": "depends_on", "from_type": "service"}
  ]
}

Querying

Natural language patterns (via ask_graph):

  • "what depends on Database"
  • "what does AuthService depend on"
  • "path from Frontend to Database"
  • "find cycles"
  • "most connected nodes"

Cypher queries for the fancy stuff:

MATCH (s:service)-[r]->(d)
WHERE r.relation = "depends_on"
RETURN s.label, d.label

Analysis Tools

Tool What It Does
shortest_path Find the shortest route between two nodes
all_paths Find every possible path (careful with large graphs)
pagerank Identify the most important/central nodes
find_cycles Detect circular dependencies
connected_components Find clusters of related nodes
degree_centrality See which nodes have the most connections
transitive_reduction Clean up redundant edges

Visualisation

visualize_graph(graph="my-graph")

Opens http://localhost:8765/graphs/my-graph in your browser. It's a D3 force-directed graph that updates in real-time as nodes and edges are added.

Real-time updates demo

You can filter the visualisation with Cypher:

update_visualization_filter(filter='MATCH (n)-[r]->(m) WHERE n.type = "service" RETURN n,r,m')

Import/Export

Supported formats: DOT, CSV, GraphML, JSON, Mermaid

# Export to Mermaid for documentation
export_graph(format="mermaid")

# Import an existing DOT file
import_graph(format="dot", file_path="/path/to/deps.dot")

Full Tool Reference

Graph Management

Tool Description
add_facts Add relationships (auto-creates nodes)
add_knowledge Add relationships using simple DSL
list_graphs List all named graphs
delete_graph Delete a graph
get_graph_info Get stats (node count, edge count, density, etc.)

Querying

Tool Description
ask_graph Natural language queries for common patterns
cypher_query Full Cypher query support
dump_context Get a complete summary of the graph state

Analysis

Tool Description
shortest_path Dijkstra's shortest path
all_paths All simple paths between nodes
pagerank PageRank centrality scores
find_cycles Cycle detection
connected_components Find clusters
degree_centrality In/out degree analysis
transitive_reduction Remove redundant edges
subgraph Extract a subset of nodes

Node/Edge Operations

Tool Description
forget Remove a node (and its edges)
forget_relationship Remove an edge

Import/Export

Tool Description
import_graph Import from DOT, CSV, GraphML, JSON
export_graph Export to DOT, CSV, GraphML, JSON, Mermaid
create_from_mermaid Create graph from Mermaid syntax

Visualisation

Tool Description
visualize_graph Open browser visualisation
update_visualization_filter Apply Cypher filter to the view
stop_visualization Stop the visualisation server

Configuration

Environment variables:

Variable Default Description
VIS_ENABLED true Enable/disable visualisation server
VIS_PORT 8765 Port for the visualisation server
VIS_HOST localhost Host to bind the visualisation server

Architecture

src/mcp_graph_engine/
├── server.py           # MCP server, tool handlers
├── graph_engine.py     # NetworkX wrapper, algorithms
├── session.py          # Named graph sessions
├── matcher.py          # Fuzzy matching (exact, normalised, embeddings)
├── cypher.py           # Cypher query execution
└── visualization/
    ├── web_server.py   # FastAPI + WebSocket server
    └── broadcast.py    # Real-time update broadcasting

Key dependencies:

Things to Know

It's transient. Graphs live in memory only. When the server stops, they're gone. This is by design - it's a working memory tool, not a database. If you need persistence, export to JSON and import later.

Fuzzy matching is on by default. Type "auth service" and it'll match "AuthService". It uses three strategies: exact match, normalised match (case/whitespace), and embedding similarity for semantic matches. Usually this is what you want.

Multiple graphs are supported. Each graph is independent. Default graph is called "default". Use the graph parameter on any tool to work with a different one.

Cypher has quirks. Use double quotes for strings (single quotes don't work). Edge type syntax [r:type] doesn't work - use WHERE r.relation = "type" instead. The server tries to auto-fix common mistakes but check the error messages if something's off.

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run the server directly
python -m mcp_graph_engine.server

Contributing

Issues and PRs welcome. Keep it simple, test your changes, and don't break the existing tools.

License

MIT. See LICENSE for details.


Built by utilitydelta. If you find this useful, star the repo or let me know what you're using it for.

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

mcp_graph_engine-0.1.2.tar.gz (162.2 kB view details)

Uploaded Source

Built Distribution

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

mcp_graph_engine-0.1.2-py3-none-any.whl (138.0 kB view details)

Uploaded Python 3

File details

Details for the file mcp_graph_engine-0.1.2.tar.gz.

File metadata

  • Download URL: mcp_graph_engine-0.1.2.tar.gz
  • Upload date:
  • Size: 162.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_graph_engine-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6c8a4ec7b7e66df606127963641e580017ce572fd11200c022d41cfb40d496cb
MD5 3bbd07ec79f2189d7bb0f075b1ff1550
BLAKE2b-256 c3fc86a5ecced1c46b0dba3f49e6f1152f8bebdd6d40bf4f6e48f1af525bda71

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_graph_engine-0.1.2.tar.gz:

Publisher: publish.yml on utilitydelta/mcp-graph-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_graph_engine-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_graph_engine-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 93588d4e7256a187887e4e103e5b5eadb455775f47d4f3eff4490eb42d1d15a3
MD5 9ec0cf6200f4c6a751b17afea0dbf564
BLAKE2b-256 1bc70bf9ea3b7f04f1982a67d7fb212f44200624a3e71cf37561c71bf4d3143e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_graph_engine-0.1.2-py3-none-any.whl:

Publisher: publish.yml on utilitydelta/mcp-graph-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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