Skip to main content

agent-framework-neo4j

Neo4j Context Provider for Microsoft Agent Framework - RAG with knowledge graphs.

Quick Install

pip install agent-framework-neo4j --pre

# With Azure AI embeddings support
pip install agent-framework-neo4j[azure] --pre

Supported Platforms

  • Python 3.10+
  • Windows, macOS, Linux

Setup

Configure Neo4j credentials via environment variables or constructor parameters:

# Environment variables
export NEO4J_URI="neo4j+s://xxx.databases.neo4j.io"
export NEO4J_USERNAME="neo4j"
export NEO4J_PASSWORD="your-password"

Quick Start

Basic Fulltext Search

from agent_framework_neo4j import Neo4jContextProvider, Neo4jSettings

settings = Neo4jSettings()  # Loads from environment

provider = Neo4jContextProvider(
    uri=settings.uri,
    username=settings.username,
    password=settings.get_password(),
    index_name="search_chunks",
    index_type="fulltext",
)

async with provider:
    # Use with Microsoft Agent Framework agent
    pass

Vector Search with Azure AI Embeddings

from agent_framework_neo4j import Neo4jContextProvider, AzureAIEmbedder, AzureAISettings
from azure.identity.aio import AzureCliCredential

credential = AzureCliCredential()
ai_settings = AzureAISettings()  # Loads from AZURE_AI_* env vars

embedder = AzureAIEmbedder(
    endpoint=ai_settings.project_endpoint,
    model_name=ai_settings.embedding_model,
    credential=credential,
)

provider = Neo4jContextProvider(
    uri="neo4j+s://xxx.databases.neo4j.io",
    username="neo4j",
    password="your-password",
    index_name="chunkEmbeddings",
    index_type="vector",
    embedder=embedder,
    top_k=5,
)

Hybrid Search (Vector + Fulltext)

provider = Neo4jContextProvider(
    uri=settings.uri,
    username=settings.username,
    password=settings.get_password(),
    index_name="chunkEmbeddings",        # Vector index
    fulltext_index_name="search_chunks", # Fulltext index
    index_type="hybrid",
    embedder=embedder,
)

Graph-Enriched Retrieval

Use custom Cypher queries to traverse relationships after the initial index search:

provider = Neo4jContextProvider(
    uri=settings.uri,
    username=settings.username,
    password=settings.get_password(),
    index_name="chunkEmbeddings",
    index_type="vector",
    embedder=embedder,
    retrieval_query="""
        MATCH (node)-[:FROM_DOCUMENT]->(doc:Document)
        RETURN node.text AS text, score, doc.title AS title
        ORDER BY score DESC
    """,
)

Retrieval query requirements:

  • Must use node and score variables from the index search
  • Must return at least text and score columns
  • Use ORDER BY score DESC to maintain relevance ranking

Features

  • Vector Search - Semantic similarity using embeddings
  • Fulltext Search - Keyword matching with Lucene
  • Hybrid Search - Combined vector + fulltext for best of both
  • Graph Enrichment - Custom Cypher queries for relationship traversal
  • Message History - Configurable conversation context windowing
  • Pydantic Settings - Environment-based configuration with validation

Configuration Parameters

Connection

Parameter Description
uri Neo4j connection URI
username Database username
password Database password

Search

Parameter Default Description
index_name required Name of the Neo4j index to query
index_type "vector" Search type: "vector", "fulltext", or "hybrid"
fulltext_index_name None Fulltext index name (required for hybrid)
embedder None Embedder for vector/hybrid search (required for those types)
top_k 5 Number of results to retrieve
retrieval_query None Custom Cypher for graph traversal
message_history_count 10 Recent messages used for search query
filter_stop_words None Filter stop words (defaults True for fulltext)

Environment Variables

Variable Description
NEO4J_URI Neo4j connection URI
NEO4J_USERNAME Database username
NEO4J_PASSWORD Database password
NEO4J_INDEX_NAME Default index name
NEO4J_VECTOR_INDEX_NAME Vector index name (default: chunkEmbeddings)
NEO4J_FULLTEXT_INDEX_NAME Fulltext index name (default: search_chunks)
AZURE_AI_PROJECT_ENDPOINT Azure AI project endpoint (for embeddings)
AZURE_AI_EMBEDDING_NAME Embedding model name

More Examples

See the samples directory for complete working examples.

Documentation

License

MIT

Metadata

Release files for agent-framework-neo4j 0.5.4

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

Source distribution (sdist)

Source distribution for agent-framework-neo4j 0.5.4
File Size Uploaded
agent_framework_neo4j-0.5.4.tar.gz 13.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-framework-neo4j 0.5.4
File Interpreter ABI Platform
agent_framework_neo4j-0.5.4-py3-none-any.whl Python 3 none any Details

Total release size: 28.9 kB

Release files / agent_framework_neo4j-0.5.4.tar.gz

Download URL agent_framework_neo4j-0.5.4.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
afded2f7f93a1ae769eddb49814c4f0fe3ce82e1f7fdf011878233a3fec9ac5f
BLAKE2b-256 checksum
How to use checksums
374ae322da45744fbfb6647497f709fbc29fe3c2377b64e2a53084269bd64804
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Feb 26, 2026.

Transparency log

Release files / agent_framework_neo4j-0.5.4-py3-none-any.whl

Download URL agent_framework_neo4j-0.5.4-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e69a55740c4714bcf4e1eeff31b2169dbef96533a7d8d6588309729074ce317a
BLAKE2b-256 checksum
How to use checksums
4ba83a186c79146f7bff64918703c38f6e2ef016259581ef4be43b8b6fcb9f4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Feb 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.4 This release

2 release files

0.4.0

2 release files

0.1.0

2 release files

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