Skip to main content

neo4j-guard

PyPI version PyPI downloads CI License: MIT

neo4j-guard is a Python library that blocks dangerous Cypher queries before execution. It wraps the official neo4j driver and parses every query with Neo4j's own Cypher 25 grammar.

Features

  • Configurable read and write modes
  • Dangerous queries blocked by default
  • Error messages an agent can act on

Requirements

  • Python 3.10+
  • neo4j 5.8+

Installation

pip install neo4j-guard

Use with Neo4j driver

from neo4j import GraphDatabase
from neo4j_guard import GuardError, guard

driver = guard(GraphDatabase.driver(URL, auth=AUTH))
try:
    driver.execute_query("CREATE (:Person {name: 'Ada'})")
except GuardError as error:
    print(error)  # CREATE is not allowed in read mode

Use with LangChain

from langchain_neo4j import Neo4jGraph
from neo4j_guard import guard

graph = Neo4jGraph(url=URL, username=USERNAME, password=PASSWORD)
guard(graph._driver)

Use with Neo4j MCP server

import asyncio
from mcp_neo4j_cypher.server import create_mcp_server
from neo4j import AsyncGraphDatabase
from neo4j_guard import guard


async def main() -> None:
    driver = guard(
        AsyncGraphDatabase.driver(URL, auth=AUTH),
        allow=["apoc.meta.schema"],
    )
    await create_mcp_server(driver, read_only=True).run_stdio_async()


asyncio.run(main())

Configuration

neo4j-guard is configurable. By default, a guarded driver can only run a small set of read-only Cypher.

guard(
    driver,
    mode="write",  # "read" (default) or "write"
    allow=["DELETE", "apoc.load.json"],
    disallow=["apoc.meta.*", "Employee", "Person.ssn"],
)

Metadata

Release files for neo4j-guard 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neo4j-guard 0.2.1
File Size Uploaded Provenance Actions
neo4j_guard-0.2.1.tar.gz 178.7 kB With provenance Details for neo4j_guard-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for neo4j-guard 0.2.1
File Interpreter ABI Platform Actions
neo4j_guard-0.2.1-py3-none-any.whl Python 3 none any Details for neo4j_guard-0.2.1-py3-none-any.whl

Total release size: 366.6 kB

Release files / neo4j_guard-0.2.1.tar.gz

Download URL neo4j_guard-0.2.1.tar.gz
Size 178.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d2551c9b70a0ba2252195fc31412070d1fb671f0c4a7bef6229eb8a6b0c91f49
BLAKE2b-256 checksum
How to use checksums
6430106e8bc7cc7efa36a0dbcecfbf95fe3a1a2a863e6eba5a9372b639dc31af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / neo4j_guard-0.2.1-py3-none-any.whl

Download URL neo4j_guard-0.2.1-py3-none-any.whl
Size 187.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97e56f9433a381483fd90eb611711750eb34dbd36c97d9565a21f14b89ed8928
BLAKE2b-256 checksum
How to use checksums
7f8ec65dcac8b7796b1cd4fae87c93a4177275cfe6905883ceb17ff3bf3c251c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for neo4j-guard 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for neo4j_guard-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page