#!/usr/bin/env python3 """ Test MCP server implementation """ import asyncio import json import sys import subprocess import time import signal async def test_mcp_server_startup(): """Test MCP server startup""" print("๐Ÿš€ Testing MCP server startup...") # Test if LangMem API is running try: import httpx async with httpx.AsyncClient() as client: response = await client.get("http://localhost:8765/health", timeout=5.0) if response.status_code == 200: print("โœ… LangMem API is running") else: print("โŒ LangMem API is not healthy") return False except Exception as e: print(f"โŒ LangMem API is not accessible: {e}") return False # Test MCP server imports try: sys.path.insert(0, '/home/klas/langmem-project/src/mcp') from server import LangMemMCPServer print("โœ… MCP server imports successfully") except Exception as e: print(f"โŒ MCP server import failed: {e}") return False # Test MCP server initialization try: server = LangMemMCPServer() print("โœ… MCP server initializes successfully") return True except Exception as e: print(f"โŒ MCP server initialization failed: {e}") return False async def main(): """Main function""" print("๐Ÿงช Testing LangMem MCP Server...") success = await test_mcp_server_startup() if success: print("\n๐ŸŽ‰ MCP server tests passed!") print("\n๐Ÿ“‹ Integration instructions:") print("1. Add MCP server to Claude Code configuration:") print(" - Copy mcp_config.json to your Claude Code settings") print(" - Or add manually in Claude Code settings") print("\n2. Start the MCP server:") print(" ./start-mcp-server.sh") print("\n3. Available tools in Claude Code:") print(" - store_memory: Store memories with AI relationship extraction") print(" - search_memories: Search memories with hybrid vector + graph search") print(" - retrieve_memories: Retrieve relevant memories for conversation context") print(" - get_user_memories: Get all memories for a specific user") print(" - delete_memory: Delete a specific memory") print(" - health_check: Check LangMem system health") print("\n4. Available resources:") print(" - langmem://memories: Memory storage resource") print(" - langmem://search: Search capabilities resource") print(" - langmem://relationships: AI relationships resource") print(" - langmem://health: System health resource") else: print("\nโŒ MCP server tests failed!") if __name__ == "__main__": asyncio.run(main())