Neo4j MCP server

Provides a TypeScript-based server for executing Cypher queries against Neo4j graph databases via stdio transport, enabling secure and flexible database interactions for developers and data analysts.
Back to servers
Provider
Tobarrientos2
Release date
Feb 16, 2025
Language
TypeScript
Package
Stats
307 downloads
2 stars

A Neo4j MCP server implementation that manages graph database operations through the Model Context Protocol. This server allows you to interact with Neo4j databases directly from AI assistants like Cursor and Claude Desktop.

Quick Start

You can run the server directly using npx without installation:

# Using a single connection string
NEO4J_CONNECTION=neo4j+s://your-instance.databases.neo4j.io,neo4j,your-password npx neo4j-mcpserver

# Or using separate environment variables
NEO4J_URI=neo4j+s://your-instance.databases.neo4j.io NEO4J_USER=neo4j NEO4J_PASSWORD=your-password npx neo4j-mcpserver

Installation

If you prefer a global installation:

npm install -g neo4j-mcpserver

Then run it:

NEO4J_CONNECTION=neo4j+s://your-instance.databases.neo4j.io,neo4j,your-password neo4j-mcpserver

Connecting to Neo4j

You can connect to your Neo4j database using two methods:

Using a Single Connection String

NEO4J_CONNECTION=<uri>,<user>,<password>

Using Separate Environment Variables

NEO4J_URI=<your-uri>
NEO4J_USER=<your-user>
NEO4J_PASSWORD=<your-password>

You can also create a .env file in your project root:

NEO4J_URI=neo4j+s://your-instance.databases.neo4j.io
NEO4J_USER=neo4j
NEO4J_PASSWORD=your-password

Setting Up With Cursor

To configure the Neo4j MCP server in Cursor:

  1. Open Cursor Settings

  2. Navigate to Features > MCP Servers

  3. Click on the "+ Add New MCP Server" button

  4. Fill out the following information:

    • Name: Enter a nickname (e.g., "neo4j-mcp")
    • Type: Select "command"
    • Command: Enter the command to run the server:
    env=NEO4J_URI=your-neo4j-uri,NEO4J_USER=your-neo4j-user,NEO4J_PASSWORD=your-neo4j-password npx -y @neobarrientos/neo4j_mcpserver
    

    Important: Replace the credentials with your actual Neo4j database credentials.

Using the MCP Server

Running Cypher Queries

The server provides the neo4j-query tool for executing Cypher queries against your Neo4j database.

Example usage in Cursor:

MATCH (n) RETURN n LIMIT 5

Troubleshooting

If you encounter issues connecting to your database:

  • Verify Neo4j Credentials

    • Check that your Neo4j URI, username, and password are correct
    • Ensure your Neo4j database is accessible
  • Path Issues

    • Ensure there are no spaces in the installation path
    • Use forward slashes (/) in paths
  • Tool Detection Issues

    • Try restarting Cursor
    • Verify the server is running (check Cursor's MCP server list)
    • Check that environment variables are properly set

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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