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
80 lines
2.8 KiB
Python
80 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Test Neo4j database parameter configuration."""
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Setup path for imports
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
|
|
def test_neo4j_database_parameter():
|
|
"""Test that Neo4j database parameter is included in configuration."""
|
|
from src.config.schema import GraphitiConfig
|
|
from src.services.factories import DatabaseDriverFactory
|
|
|
|
print('\n' + '=' * 70)
|
|
print('Testing Neo4j Database Parameter Configuration')
|
|
print('=' * 70 + '\n')
|
|
|
|
# Test 1: Default database value
|
|
print('Test 1: Default database value')
|
|
config = GraphitiConfig()
|
|
db_config = DatabaseDriverFactory.create_config(config.database)
|
|
|
|
assert 'database' in db_config, 'Database parameter missing from config!'
|
|
print(f' ✓ Database parameter present in config')
|
|
print(f' ✓ Default database value: {db_config["database"]}')
|
|
assert db_config['database'] == 'neo4j', (
|
|
f'Expected default "neo4j", got {db_config["database"]}'
|
|
)
|
|
print(f' ✓ Default value matches expected: neo4j\n')
|
|
|
|
# Test 2: Environment variable override
|
|
print('Test 2: Environment variable override')
|
|
os.environ['NEO4J_DATABASE'] = 'graphiti'
|
|
config2 = GraphitiConfig()
|
|
db_config2 = DatabaseDriverFactory.create_config(config2.database)
|
|
|
|
assert 'database' in db_config2, 'Database parameter missing from config!'
|
|
print(f' ✓ Database parameter present in config')
|
|
print(f' ✓ Overridden database value: {db_config2["database"]}')
|
|
assert db_config2['database'] == 'graphiti', (
|
|
f'Expected "graphiti", got {db_config2["database"]}'
|
|
)
|
|
print(f' ✓ Environment override works correctly\n')
|
|
|
|
# Clean up
|
|
del os.environ['NEO4J_DATABASE']
|
|
|
|
# Test 3: Verify all required parameters are present
|
|
print('Test 3: Verify all required Neo4j parameters')
|
|
required_params = ['uri', 'user', 'password', 'database']
|
|
for param in required_params:
|
|
assert param in db_config, f'Required parameter "{param}" missing!'
|
|
print(f' ✓ {param}: present')
|
|
|
|
print('\n' + '=' * 70)
|
|
print('✅ All database parameter tests passed!')
|
|
print('=' * 70)
|
|
print('\nSummary:')
|
|
print(' - database parameter is included in Neo4j config')
|
|
print(' - Default value is "neo4j"')
|
|
print(' - Environment variable NEO4J_DATABASE override works')
|
|
print(' - All required parameters (uri, user, password, database) present')
|
|
print()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
test_neo4j_database_parameter()
|
|
except AssertionError as e:
|
|
print(f'\n❌ Test failed: {e}\n')
|
|
sys.exit(1)
|
|
except Exception as e:
|
|
print(f'\n❌ Unexpected error: {e}\n')
|
|
import traceback
|
|
|
|
traceback.print_exc()
|
|
sys.exit(1)
|