Files
t6_mem0_v2/cleanup-neo4j.py
Claude Code 1998bef6f4 Add MCP HTTP/SSE server and complete n8n integration
Major Changes:
- Implemented MCP HTTP/SSE transport server for n8n and web clients
- Created mcp_server/http_server.py with FastAPI for JSON-RPC 2.0 over HTTP
- Added health check endpoint (/health) for container monitoring
- Refactored mcp-server/ to mcp_server/ (Python module structure)
- Updated Dockerfile.mcp to run HTTP server with health checks

MCP Server Features:
- 7 memory tools exposed via MCP (add, search, get, update, delete)
- HTTP/SSE transport on port 8765 for n8n integration
- stdio transport for Claude Code integration
- JSON-RPC 2.0 protocol implementation
- CORS support for web clients

n8n Integration:
- Successfully tested with AI Agent workflows
- MCP Client Tool configuration documented
- Working webhook endpoint tested and verified
- System prompt optimized for automatic user_id usage

Documentation:
- Created comprehensive Mintlify documentation site
- Added docs/mcp/introduction.mdx - MCP server overview
- Added docs/mcp/installation.mdx - Installation guide
- Added docs/mcp/tools.mdx - Complete tool reference
- Added docs/examples/n8n.mdx - n8n integration guide
- Added docs/examples/claude-code.mdx - Claude Code setup
- Updated README.md with MCP HTTP server info
- Updated roadmap to mark Phase 1 as complete

Bug Fixes:
- Fixed synchronized delete operations across Supabase and Neo4j
- Updated memory_service.py with proper error handling
- Fixed Neo4j connection issues in delete operations

Configuration:
- Added MCP_HOST and MCP_PORT environment variables
- Updated .env.example with MCP server configuration
- Updated docker-compose.yml with MCP container health checks

Testing:
- Added test scripts for MCP HTTP endpoint verification
- Created test workflows in n8n
- Verified all 7 memory tools working correctly
- Tested synchronized operations across both stores

Version: 1.0.0
Status: Phase 1 Complete - Production Ready

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 13:56:41 +02:00

73 lines
2.4 KiB
Python

#!/usr/bin/env python3
"""Clean up orphaned Neo4j graph data"""
import asyncio
from neo4j import GraphDatabase
from config import settings
async def cleanup_neo4j():
"""Remove all nodes and relationships from Neo4j"""
print("=" * 60)
print("Neo4j Graph Store Cleanup")
print("=" * 60)
try:
driver = GraphDatabase.driver(
settings.neo4j_uri,
auth=(settings.neo4j_user, settings.neo4j_password)
)
with driver.session() as session:
# Count before cleanup
result = session.run("MATCH (n) RETURN count(n) as count")
nodes_before = result.single()['count']
result = session.run("MATCH ()-[r]->() RETURN count(r) as count")
rels_before = result.single()['count']
print(f"\nBefore cleanup:")
print(f" • Nodes: {nodes_before}")
print(f" • Relationships: {rels_before}")
# Delete all relationships first
print("\n[1] Deleting all relationships...")
result = session.run("MATCH ()-[r]->() DELETE r RETURN count(r) as deleted")
rels_deleted = result.single()['deleted']
print(f"✓ Deleted {rels_deleted} relationships")
# Delete all nodes
print("\n[2] Deleting all nodes...")
result = session.run("MATCH (n) DELETE n RETURN count(n) as deleted")
nodes_deleted = result.single()['deleted']
print(f"✓ Deleted {nodes_deleted} nodes")
# Verify cleanup
result = session.run("MATCH (n) RETURN count(n) as count")
nodes_after = result.single()['count']
result = session.run("MATCH ()-[r]->() RETURN count(r) as count")
rels_after = result.single()['count']
print(f"\nAfter cleanup:")
print(f" • Nodes: {nodes_after}")
print(f" • Relationships: {rels_after}")
if nodes_after == 0 and rels_after == 0:
print("\n✅ Neo4j graph store successfully cleaned!")
else:
print(f"\n⚠️ Warning: {nodes_after} nodes and {rels_after} relationships remain")
driver.close()
except Exception as e:
print(f"\n❌ Error during cleanup: {e}")
import traceback
traceback.print_exc()
return 1
print("\n" + "=" * 60)
return 0
if __name__ == "__main__":
exit_code = asyncio.run(cleanup_neo4j())
exit(exit_code)