Files
t6_mem0_v2/test-mcp-server-live.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

81 lines
2.4 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Live test of T6 Mem0 MCP Server
Tests the actual MCP protocol communication
"""
import asyncio
import json
import sys
from mcp_server.main import T6Mem0Server
async def test_mcp_server():
"""Test MCP server with actual tool calls"""
print("=" * 60)
print("T6 Mem0 v2 MCP Server Live Test")
print("=" * 60)
try:
# Initialize server
print("\n[1/6] Initializing MCP server...")
server = T6Mem0Server()
await server.initialize()
print("✓ Server initialized")
# List tools
print("\n[2/6] Listing available tools...")
tools = server.tools.get_tool_definitions()
print(f"✓ Found {len(tools)} tools:")
for tool in tools:
print(f"{tool.name}")
# Test 1: Add memory
print("\n[3/6] Testing add_memory...")
add_result = await server.tools.handle_add_memory({
"messages": [
{"role": "user", "content": "I am a software engineer who loves Python and TypeScript"},
{"role": "assistant", "content": "Got it! I'll remember that."}
],
"user_id": "mcp_test_user",
"metadata": {"test": "mcp_live_test"}
})
print(add_result[0].text)
# Test 2: Search memories
print("\n[4/6] Testing search_memories...")
search_result = await server.tools.handle_search_memories({
"query": "What programming languages does the user know?",
"user_id": "mcp_test_user",
"limit": 5
})
print(search_result[0].text)
# Test 3: Get all memories
print("\n[5/6] Testing get_all_memories...")
get_all_result = await server.tools.handle_get_all_memories({
"user_id": "mcp_test_user"
})
print(get_all_result[0].text)
# Clean up - delete test memories
print("\n[6/6] Cleaning up test data...")
delete_result = await server.tools.handle_delete_all_memories({
"user_id": "mcp_test_user"
})
print(delete_result[0].text)
print("\n" + "=" * 60)
print("✅ All MCP server tests passed!")
print("=" * 60)
return 0
except Exception as e:
print(f"\n❌ Test failed: {e}", file=sys.stderr)
import traceback
traceback.print_exc()
return 1
if __name__ == "__main__":
exit_code = asyncio.run(test_mcp_server())
sys.exit(exit_code)