Neo4j Graph MCP server

Integrates Neo4j graph databases, enabling natural language interactions for complex relationship modeling and graph-based analytics.
Back to servers
Setup instructions
Provider
Rebots Online
Release date
Jan 11, 2025
Language
TypeScript
Stats
2 stars

This MCP server provides a Neo4j-based implementation of the Model Context Protocol, allowing you to create and manage knowledge graphs for AI applications with environment variable support and improved configuration options.

Configuration

The server can be configured using the following environment variables:

  • NEO4J_URL - Neo4j connection URL (default: "bolt://localhost:7687")
  • NEO4J_USER - Neo4j username (default: "neo4j")
  • NEO4J_PASSWORD - Neo4j password (default: "neo4j")

Installation

First, ensure you have Node.js installed on your system. Then install and start the MCP server:

# Install dependencies
npm install

# Build the project
npm run build

# Start the server
npm start

Running the Server

You can run the server with custom Neo4j connection details:

NEO4J_URL="bolt://192.168.0.157:28687" \
NEO4J_USER="neo4j" \
NEO4J_PASSWORD="your-password" \
node dist/servers/mcp-neo4j-memory/main.js

Available Capabilities

The Neo4j MCP server provides the following capabilities for managing your knowledge graph:

Creating and Managing Entities

  • create_entities - Create multiple new entities in the knowledge graph
  • create_relations - Create relations between entities (in active voice)
  • add_observations - Add new observations to existing entities
  • delete_entities - Delete entities and their relations
  • delete_observations - Delete specific observations from entities
  • delete_relations - Delete specific relations

Querying the Knowledge Graph

  • read_graph - Read the entire knowledge graph
  • search_nodes - Search for nodes based on a query
  • open_nodes - Open specific nodes by their names

Usage Examples

Creating Entities

To create new entities in the knowledge graph:

// Example API request to create entities
const response = await fetch('http://localhost:3000/mcp', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    type: 'create_entities',
    entities: [
      { name: 'Person', properties: { age: 30, occupation: 'Engineer' } },
      { name: 'Company', properties: { founded: 2010, industry: 'Technology' } }
    ]
  })
});

Creating Relations

To establish relationships between entities:

// Example API request to create relations
const response = await fetch('http://localhost:3000/mcp', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    type: 'create_relations',
    relations: [
      { 
        source: 'Person', 
        relation: 'WORKS_AT', 
        target: 'Company' 
      }
    ]
  })
});

Searching Nodes

To search for nodes in the knowledge graph:

// Example API request to search nodes
const response = await fetch('http://localhost:3000/mcp', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    type: 'search_nodes',
    query: 'Engineer'
  })
});

Reading the Graph

To read the entire knowledge graph:

// Example API request to read the graph
const response = await fetch('http://localhost:3000/mcp', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    type: 'read_graph'
  })
});

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp-neo4j-memory" '{"command":"node","args":["dist/servers/mcp-neo4j-memory/main.js"],"env":{"NEO4J_URL":"bolt://localhost:7687","NEO4J_USER":"neo4j","NEO4J_PASSWORD":"neo4j"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mcp-neo4j-memory": {
            "command": "node",
            "args": [
                "dist/servers/mcp-neo4j-memory/main.js"
            ],
            "env": {
                "NEO4J_URL": "bolt://localhost:7687",
                "NEO4J_USER": "neo4j",
                "NEO4J_PASSWORD": "neo4j"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mcp-neo4j-memory": {
            "command": "node",
            "args": [
                "dist/servers/mcp-neo4j-memory/main.js"
            ],
            "env": {
                "NEO4J_URL": "bolt://localhost:7687",
                "NEO4J_USER": "neo4j",
                "NEO4J_PASSWORD": "neo4j"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later