neo4j-guard
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+
neo4j5.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.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| neo4j_guard-0.1.1.tar.gz | 178.7 kB | With provenance | Details for neo4j_guard-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neo4j_guard-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for neo4j_guard-0.1.1-py3-none-any.whl |
Total release size: 366.5 kB
Release files / neo4j_guard-0.1.1.tar.gz
| Download URL | neo4j_guard-0.1.1.tar.gz |
|---|---|
| Size | 178.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16eb9fb85f70f363263e30858bf3b18b3c50a7fa86d8df0dd3746ace5cbdd983
|
|
BLAKE2b-256 checksum How to use checksums |
faddfc27428ef652a1a3f010f069de3d3a1ae1741a2e1b83048da21c43d33fa8
|
| 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 21, 2026.
Transparency logRelease files / neo4j_guard-0.1.1-py3-none-any.whl
| Download URL | neo4j_guard-0.1.1-py3-none-any.whl |
|---|---|
| Size | 187.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6df81bbd96985746d1d9be983e0b3f2a39fb134ed23dbc54ba44cb8e95bf4803
|
|
BLAKE2b-256 checksum How to use checksums |
f79d66955dbf7469f27f2e6a14d06135662fea83d81a951a0a10f8faaeb31f71
|
| 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 21, 2026.
Transparency logSecurity for neo4j-guard 0.1.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.
Attestation for neo4j_guard-0.1.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 21, 2026.
Transparency logA 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.