CRITICAL FIX - Database Parameter (graphiti_core):
- Fixed graphiti_core/driver/neo4j_driver.py execute_query method
- database_ parameter was incorrectly added to params dict instead of kwargs
- Now correctly passed as keyword argument to Neo4j driver
- Impact: All queries now execute in configured database (not default 'neo4j')
- Root cause: Violated Neo4j Python driver API contract
Technical Details:
Previous code (BROKEN):
params.setdefault('database_', self._database) # Wrong - in params dict
result = await self.client.execute_query(cypher_query_, parameters_=params, **kwargs)
Fixed code (CORRECT):
kwargs.setdefault('database_', self._database) # Correct - in kwargs
result = await self.client.execute_query(cypher_query_, parameters_=params, **kwargs)
FIX - Index Creation Error Handling (MCP server):
- Added graceful handling for Neo4j IF NOT EXISTS bug
- Prevents MCP server crash when indices already exist
- Logs warning instead of failing initialization
- Handles EquivalentSchemaRuleAlreadyExists error gracefully
Files Modified:
- graphiti_core/driver/neo4j_driver.py (3 lines changed)
- mcp_server/src/graphiti_mcp_server.py (12 lines added error handling)
- mcp_server/pyproject.toml (version bump to 1.0.5)
Testing:
- Python syntax validation: PASSED
- Ruff formatting: PASSED
- Ruff linting: PASSED
Closes issues with:
- Data being stored in wrong Neo4j database
- MCP server crashing on startup with EquivalentSchemaRuleAlreadyExists
- NEO4J_DATABASE environment variable being ignored
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2.3 KiB
Database Parameter Fix - November 2025
Summary
Fixed critical bug in graphiti_core where the database parameter was not being passed correctly to the Neo4j Python driver, causing all queries to execute against the default neo4j database instead of the configured database.
Root Cause
In graphiti_core/driver/neo4j_driver.py, the execute_query method was incorrectly adding database_ to the query parameters dict instead of passing it as a keyword argument to the Neo4j driver's execute_query method.
Incorrect code (before fix):
params.setdefault('database_', self._database) # Wrong - adds to params dict
result = await self.client.execute_query(cypher_query_, parameters_=params, **kwargs)
Correct code (after fix):
kwargs.setdefault('database_', self._database) # Correct - adds to kwargs
result = await self.client.execute_query(cypher_query_, parameters_=params, **kwargs)
Impact
- Before fix: All Neo4j queries executed against the default
neo4jdatabase, regardless of thedatabaseparameter passed toNeo4jDriver.__init__ - After fix: Queries execute against the configured database (e.g.,
graphiti)
Neo4j Driver API
According to Neo4j Python driver documentation, database_ must be a keyword argument to execute_query(), not a query parameter:
driver.execute_query(
"MATCH (n) RETURN n",
{"name": "Alice"}, # parameters_ - query params
database_="graphiti" # database_ - kwarg (NOT in parameters dict)
)
Additional Fix: Index Creation Error Handling
Added graceful error handling in MCP server for Neo4j's known IF NOT EXISTS bug where fulltext and relationship indices throw EquivalentSchemaRuleAlreadyExists errors instead of being idempotent.
This prevents MCP server crashes when indices already exist.
Files Modified
graphiti_core/driver/neo4j_driver.py- Fixed database_ parameter handlingmcp_server/src/graphiti_mcp_server.py- Added index error handling
Testing
- ✅ Python syntax validation passed
- ✅ Ruff formatting applied
- ✅ Ruff linting passed with no errors
- Manual testing required:
- Verify indices created in configured database (not default)
- Verify data stored in configured database
- Verify MCP server starts successfully with existing indices
Version
This fix will be released as v1.0.5