File size: 1,440 Bytes
d317445 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #!/usr/bin/env python3
"""
Long Term Memory MCP Server & Gradio Demo
A Model Context Protocol server that provides long-term memory capabilities for LLM conversations.
"""
import os
import sys
import threading
import time
import subprocess
from pathlib import Path
# Add the current directory to the Python path
sys.path.insert(0, str(Path(__file__).parent))
from gradio_demo import demo
def run_mcp_server():
"""Run the MCP server in a separate thread."""
try:
# Import and run the MCP server
from mcp_server import main
import asyncio
# Create new event loop for this thread
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
# Run the server
loop.run_until_complete(main())
except Exception as e:
print(f"MCP Server error: {e}")
def main():
"""Main entry point."""
print("🧠 Starting Long Term Memory MCP Server & Demo...")
# Start MCP server in background thread
mcp_thread = threading.Thread(target=run_mcp_server, daemon=True)
mcp_thread.start()
# Give the MCP server a moment to start
time.sleep(2)
print("✅ MCP Server started!")
print("🚀 Launching Gradio demo...")
# Launch Gradio demo
demo.launch(
server_name="0.0.0.0",
server_port=7860,
share=True,
show_error=True
)
if __name__ == "__main__":
main() |