Commit graph

2 commits

Author SHA1 Message Date
Claude
21c0eae78f
Add: Graph exploration tools for general-purpose PKM
Implemented two new MCP tools and enhanced workflow instructions to enable
effective Personal Knowledge Management across all use cases (architecture
decisions, projects, coaching, research, etc.).

## New Tools

1. **get_entity_connections** - Direct graph traversal showing ALL relationships
   - Returns complete connection data for an entity
   - Guarantees completeness vs semantic search
   - Essential for pattern detection and exploration
   - Leverages EntityEdge.get_by_node_uuid()

2. **get_entity_timeline** - Chronological episode history
   - Shows ALL episodes mentioning an entity
   - Enables temporal tracking and evolution analysis
   - Critical for understanding how concepts evolved
   - Leverages EpisodicNode.get_by_entity_node_uuid()

## Enhanced Workflow Instructions

Updated GRAPHITI_MCP_INSTRUCTIONS with:
- Clear "SEARCH FIRST, THEN ADD" workflow with decision flowcharts
- Tool selection guide (when to use each tool)
- Distinction between graph traversal vs semantic search
- Multiple concrete examples across different domains
- Key principles for effective PKM usage

## Updated add_memory Docstring

Added prominent warning to search before adding:
- Step-by-step workflow guidance
- Emphasizes creating connections vs isolated nodes
- References new exploration tools

## Benefits

- Prevents disconnected/duplicate entities
- Enables reliable pattern recognition with complete data
- Cost-effective (single graph query vs multiple semantic searches)
- Temporal tracking for evolution analysis
- Works equally well for technical and personal knowledge

## Implementation Details

- 0 changes to graphiti_core (uses existing features only)
- All new code in mcp_server/src/graphiti_mcp_server.py
- Backward compatible (adds tools, doesn't modify existing)
- Follows existing MCP tool patterns and conventions
- Passes all lint and syntax checks

Related: DOCS/IMPLEMENTATION-Graph-Exploration-Tools.md
2025-11-15 09:51:11 +00:00
Lars Varming
341efd8c3d Fix: Critical database parameter bug + index creation error handling
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>
2025-11-10 11:37:16 +01:00