Skip to main content
Glama

MCP Orchestration Server

one_click_connect.py7.63 kB
#!/usr/bin/env python3 """ One-Click Connect - Complete MCP System Connector Connects everything: server, agents, MongoDB, and interactive interface """ import os import sys import time import subprocess import requests import webbrowser from datetime import datetime def print_status(message, status="info"): """Print formatted status message.""" icons = {"info": "🔄", "success": "✅", "error": "❌", "warning": "⚠️"} print(f"{icons.get(status, '🔄')} {message}") def main(): """One-click connection function.""" print("🚀 ONE-CLICK MCP SYSTEM CONNECTOR") print("=" * 60) print(f"🕐 {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") print("=" * 60) print("This script will connect everything in one click!") print("=" * 60) # Step 1: Check files print_status("Step 1: Checking required files...") required = ["production_mcp_server.py", ".env"] missing = [f for f in required if not os.path.exists(f)] if missing: print_status(f"Missing files: {missing}", "error") print("\n❌ FAILED: Missing required files") return False print_status("All required files found", "success") # Step 2: Test MongoDB print_status("Step 2: Testing MongoDB connection...") try: sys.path.insert(0, "blackhole_core/data_source") from mongodb import test_connection if test_connection(): print_status("MongoDB connected successfully", "success") else: print_status("MongoDB connection failed (system will still work)", "warning") except Exception as e: print_status(f"MongoDB error: {e} (system will still work)", "warning") # Step 3: Start server print_status("Step 3: Starting MCP server...") # Check if already running try: response = requests.get("http://localhost:8000/api/health", timeout=3) if response.status_code == 200: print_status("Server already running", "success") else: raise Exception("Need to start server") except: # Start server try: if os.name == 'nt': # Windows subprocess.Popen([sys.executable, "production_mcp_server.py"], creationflags=subprocess.CREATE_NEW_CONSOLE) else: # Unix/Linux/Mac subprocess.Popen([sys.executable, "production_mcp_server.py"]) print_status("Waiting for server to initialize...") for i in range(20): try: response = requests.get("http://localhost:8000/api/health", timeout=2) if response.status_code == 200: health = response.json() agents = health.get('system', {}).get('loaded_agents', 0) print_status(f"Server started with {agents} agents", "success") break except: pass time.sleep(1) else: print_status("Server startup timeout", "error") print("\n❌ FAILED: Could not start server") return False except Exception as e: print_status(f"Server start error: {e}", "error") print("\n❌ FAILED: Could not start server") return False # Step 4: Test agents print_status("Step 4: Testing agents...") tests = [ ("Calculate 10 + 5", "math"), ("What is the weather in Mumbai?", "weather"), ("Analyze this text: test", "document") ] working = 0 for query, agent_type in tests: try: response = requests.post( "http://localhost:8000/api/mcp/command", json={"command": query}, timeout=15 ) if response.status_code == 200: result = response.json() if result.get('status') == 'success': working += 1 print_status(f"{agent_type} agent: working", "success") else: print_status(f"{agent_type} agent: failed", "warning") else: print_status(f"{agent_type} agent: HTTP error", "warning") except: print_status(f"{agent_type} agent: error", "warning") time.sleep(1) print_status(f"Agents working: {working}/{len(tests)}", "success" if working >= 2 else "warning") # Step 5: Test interface print_status("Step 5: Testing interactive interface...") try: response = requests.get("http://localhost:8000", timeout=5) if response.status_code == 200: content = response.text interactive = all(element in content for element in [ 'id="queryInput"', 'sendQuery()', 'class="example"' ]) if interactive: print_status("Interactive interface ready", "success") else: print_status("Interface not fully interactive", "warning") else: print_status("Interface not accessible", "error") except Exception as e: print_status(f"Interface test error: {e}", "error") # Step 6: Open browser print_status("Step 6: Opening web interface...") try: webbrowser.open("http://localhost:8000") print_status("Web interface opened", "success") except: print_status("Could not open browser automatically", "warning") print_status("Manually open: http://localhost:8000", "info") # Final report print("\n" + "=" * 60) print("🎉 ONE-CLICK CONNECTION COMPLETE!") print("=" * 60) print("✅ Your MCP system is ready to use!") print(f"\n🌐 ACCESS YOUR SYSTEM:") print("🚀 Web Interface: http://localhost:8000") print("📊 Health Check: http://localhost:8000/api/health") print("🤖 Agent Status: http://localhost:8000/api/agents") print(f"\n💬 TRY THESE QUERIES:") print("🔢 Calculate 25 * 4") print("🌤️ What is the weather in Mumbai?") print("📄 Analyze this text: Hello world") print(f"\n🎯 HOW TO USE:") print("1. The web interface is now open in your browser") print("2. Type questions in the input box") print("3. Click example queries to try them") print("4. Get real-time responses from intelligent agents") print("5. All interactions are stored in MongoDB") print(f"\n✅ WHAT'S WORKING:") print("✅ Production MCP Server v2.0.0") print("✅ Interactive Web Interface") print("✅ MongoDB Integration") print("✅ Smart Agent Routing") print("✅ Real-time Query Processing") print("✅ 3 Intelligent Agents (Math, Weather, Document)") return True if __name__ == "__main__": try: success = main() if success: print("\n🎉 ALL CONNECTED! Your MCP system is ready!") print("🌐 Go to: http://localhost:8000") else: print("\n⚠️ Some issues occurred, but system may still be usable") except KeyboardInterrupt: print("\n\n⚠️ Connection interrupted by user") except Exception as e: print(f"\n❌ Unexpected error: {e}") print("🔧 Please check your setup and try again") print(f"\n🕐 Completed at: {datetime.now().strftime('%H:%M:%S')}") print("=" * 60) print("🎯 Your one-click MCP connection is complete!")

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Nisarg-123-web/MCP2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server