Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ NEO4J_URI=
NEO4J_PORT=
NEO4J_USER=
NEO4J_PASSWORD=
# NEO4J_DATABASE= # Not supported in Neo4j Community Edition

# FalkorDB database connection
FALKORDB_URI=
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,8 @@ must be set.

### Database Configuration

Database names are configured directly in the driver constructors:

- **Neo4j**: Database name defaults to `neo4j` (hardcoded in Neo4jDriver)
- **FalkorDB**: Database name defaults to `default_db` (hardcoded in FalkorDriver)
- **Neo4j**: Database name defaults to `neo4j`. Custom database names require Neo4j Enterprise Edition and can be configured via `NEO4J_DATABASE` environment variable or driver constructor
- **FalkorDB**: Database name defaults to `default_db` (configured in driver constructor)

As of v0.17.0, if you need to customize your database configuration, you can instantiate a database driver and pass it
to the Graphiti constructor using the `graph_driver` parameter.
Expand Down
7 changes: 6 additions & 1 deletion graphiti_core/graphiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def __init__(
uri: str | None = None,
user: str | None = None,
password: str | None = None,
database: str | None = None,
llm_client: LLMClient | None = None,
embedder: EmbedderClient | None = None,
cross_encoder: CrossEncoderClient | None = None,
Expand All @@ -142,6 +143,10 @@ def __init__(
The username for authenticating with the Neo4j database.
password : str
The password for authenticating with the Neo4j database.
database : str | None, optional
The Neo4j database name to connect to. Defaults to 'neo4j'.
Only used when connecting directly to Neo4j (i.e., when graph_driver is None).
For other database backends, configure the database name in the driver constructor.
llm_client : LLMClient | None, optional
An instance of LLMClient for natural language processing tasks.
If not provided, a default OpenAIClient will be initialized.
Expand Down Expand Up @@ -188,7 +193,7 @@ def __init__(
else:
if uri is None:
raise ValueError('uri must be provided when graph_driver is None')
self.driver = Neo4jDriver(uri, user, password)
self.driver = Neo4jDriver(uri, user, password, database or 'neo4j')

self.store_raw_episode_content = store_raw_episode_content
self.max_coroutines = max_coroutines
Expand Down
1 change: 1 addition & 0 deletions mcp_server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=demodemo
# NEO4J_DATABASE=neo4j # Not supported in Neo4j Community Edition

# OpenAI API Configuration
# Required for LLM operations
Expand Down
3 changes: 3 additions & 0 deletions mcp_server/graphiti_mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ class Neo4jConfig(BaseModel):
uri: str = 'bolt://localhost:7687'
user: str = 'neo4j'
password: str = 'password'
database: str = 'neo4j'

@classmethod
def from_env(cls) -> 'Neo4jConfig':
Expand All @@ -463,6 +464,7 @@ def from_env(cls) -> 'Neo4jConfig':
uri=os.environ.get('NEO4J_URI', 'bolt://localhost:7687'),
user=os.environ.get('NEO4J_USER', 'neo4j'),
password=os.environ.get('NEO4J_PASSWORD', 'password'),
database=os.environ.get('NEO4J_DATABASE', 'neo4j'),
)


Expand Down Expand Up @@ -594,6 +596,7 @@ async def initialize_graphiti():
uri=config.neo4j.uri,
user=config.neo4j.user,
password=config.neo4j.password,
database=config.neo4j.database,
llm_client=llm_client,
embedder=embedder_client,
max_coroutines=SEMAPHORE_LIMIT,
Expand Down
3 changes: 2 additions & 1 deletion server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ NEO4J_PORT=7687
# Only used if not running a neo4j container in docker
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=password
NEO4J_PASSWORD=password
# NEO4J_DATABASE=neo4j # Not supported in Neo4j Community Edition
27 changes: 26 additions & 1 deletion tests/test_graphiti_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from graphiti_core.search.search_filters import ComparisonOperator, DateFilter, SearchFilters
from graphiti_core.search.search_helpers import search_results_to_context_string
from graphiti_core.utils.datetime_utils import utc_now
from tests.helpers_test import GraphProvider
from tests.helpers_test import NEO4J_PASSWORD, NEO4J_URI, NEO4J_USER, GraphProvider

pytestmark = pytest.mark.integration
pytest_plugins = ('pytest_asyncio',)
Expand Down Expand Up @@ -78,3 +78,28 @@ async def test_graphiti_init(graph_driver):
logger.info(pretty_results)

await graphiti.close()


@pytest.mark.asyncio
async def test_graphiti_neo4j_database_parameter(graph_driver):
"""Test that Graphiti constructor accepts database parameter for Neo4j connections."""
# Only test this for Neo4j since database parameter is Neo4j-specific
if graph_driver.provider != GraphProvider.NEO4J:
pytest.skip('Database parameter only supported for Neo4j')

# Test direct Neo4j connection with explicit database parameter
graphiti = Graphiti(
uri=NEO4J_URI,
user=NEO4J_USER,
password=NEO4J_PASSWORD,
database='neo4j', # Explicitly set database parameter
)

# Verify it initializes without error
await graphiti.build_indices_and_constraints()

# Basic functionality test
assert graphiti.driver is not None
assert graphiti.driver.provider == GraphProvider.NEO4J

await graphiti.close()
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.