home / mcp / neo4j mcp server

Neo4j MCP Server

Provides a Python-based MCP server to query and modify Neo4j using parameterized Cypher and schema introspection.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "cxt9-neo4j-mcp": {
      "command": "neo4j-mcp-server",
      "args": [],
      "env": {
        "NEO4J_HOST": "localhost or your host",
        "NEO4J_PORT": "7687",
        "NEO4J_DATABASE": "neo4j",
        "NEO4J_PASSWORD": "your-password",
        "NEO4J_USERNAME": "neo4j or your username",
        "NEO4J_ENCRYPTED": "true or false",
        "NEO4J_URI_SCHEME": "neo4j or neo4j+s if using encrypted Aura"
      }
    }
  }
}

This MCP server enables large language models to query and modify a Neo4j graph database through natural language prompts. It supports both reading and writing Cypher queries, automatically discovers the database schema, and can run securely with or without authentication. It is designed to integrate with MCP clients like Cursor and other compatible tools, providing robust error handling and safe parameterized queries.

How to use

You interact with the Neo4j MCP Server through an MCP client by starting the local server and then issuing read and write Cypher queries via the clientโ€™s MCP endpoints. Use the client to request schemas, execute queries with parameters, and verify connections. The server supports both stdio-based and SSE-based transports, so you can work with command-line tools or web-based clients depending on your setup.

How to install

Prerequisites: Python 3.8 or later, a running Neo4j instance (local, Docker, or cloud), and pip for installing packages.

Step 1: Install dependencies in editable mode so the server is linked to your source code.

Step 2: Start the MCP server in stdio mode to listen on the standard input/output channel, or start with an SSE transport for web-based clients.

Additional sections

Configuration is handled via a .env file located in the project directory. Create the file and populate your Neo4j connection details. You can connect without authentication or with user credentials, and you can enable encrypted connections for Aura if needed.

Security and reliability are emphasized through environment-based configuration, parameterized queries to prevent injection, and clear error messages for connection and query issues.

Notes on usage: you can run the MCP server locally with standard commands or enable an SSE transport for web clients. The server exposes tools for reading and writing queries, inspecting the database schema, and testing the connection.

Troubleshooting often involves checking that your Neo4j service is reachable at the configured host and port, and ensuring credentials (if used) are correct in the .env file. If you see authentication or connection errors, verify your environment variables and that the Neo4j instance is running.

Available tools

read_cypher_query

Execute a read-only Cypher query and return results, with optional parameters and database selection.

write_cypher_query

Execute a write Cypher query to modify data, with optional parameters and database selection.

get_database_schema

Retrieve database schema information including labels and relationship types to support dynamic query construction.

test_database_connection

Verify the connection to the Neo4j server and retrieve server information.

run_cypher_query

Execute a Cypher query with explicit read/write mode and optional parameters and database.