|
|
""" |
|
|
FleetMind MCP Server - Hugging Face Space Entry Point (Track 1) |
|
|
|
|
|
This file serves as the entry point for HuggingFace Space deployment. |
|
|
Exposes 18 MCP tools via Server-Sent Events (SSE) endpoint for AI clients. |
|
|
|
|
|
Architecture: |
|
|
User β MCP Client (Claude Desktop, Continue, etc.) |
|
|
β SSE Endpoint (this file) |
|
|
β FleetMind MCP Server (server.py) |
|
|
β Tools (chat/tools.py) |
|
|
β Database (PostgreSQL) |
|
|
|
|
|
For Track 1: Building MCP Servers - Enterprise Category |
|
|
https://huggingface.co/MCP-1st-Birthday |
|
|
|
|
|
Compatible with: |
|
|
- Claude Desktop (via SSE transport) |
|
|
- Continue.dev (VS Code extension) |
|
|
- Cline (VS Code extension) |
|
|
- Any MCP client supporting SSE protocol |
|
|
""" |
|
|
|
|
|
import os |
|
|
import sys |
|
|
import logging |
|
|
from pathlib import Path |
|
|
|
|
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent)) |
|
|
|
|
|
|
|
|
logging.basicConfig( |
|
|
level=logging.INFO, |
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
|
|
handlers=[logging.StreamHandler()] |
|
|
) |
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
from server import mcp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HF_SPACE_PORT = int(os.getenv("PORT", 7860)) |
|
|
HF_SPACE_HOST = os.getenv("HOST", "0.0.0.0") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
logger.info("=" * 70) |
|
|
logger.info("FleetMind MCP Server - HuggingFace Space (Track 1)") |
|
|
logger.info("=" * 70) |
|
|
logger.info("MCP Server: FleetMind Dispatch Coordinator v1.0.0") |
|
|
logger.info("Protocol: Model Context Protocol (MCP)") |
|
|
logger.info("Transport: Server-Sent Events (SSE)") |
|
|
logger.info(f"SSE Endpoint: https://huggingface.co/spaces/MCP-1st-Birthday/fleetmind-dispatch-ai/sse") |
|
|
logger.info("=" * 70) |
|
|
logger.info("Features:") |
|
|
logger.info(" β 18 AI Tools (Order + Driver Management)") |
|
|
logger.info(" β 2 Real-Time Resources (orders://all, drivers://all)") |
|
|
logger.info(" β Google Maps API Integration (Geocoding + Routes)") |
|
|
logger.info(" β PostgreSQL Database (Neon)") |
|
|
logger.info("=" * 70) |
|
|
logger.info("Compatible Clients:") |
|
|
logger.info(" β’ Claude Desktop") |
|
|
logger.info(" β’ Continue.dev (VS Code)") |
|
|
logger.info(" β’ Cline (VS Code)") |
|
|
logger.info(" β’ Any MCP-compatible client") |
|
|
logger.info("=" * 70) |
|
|
logger.info("How to Connect (Claude Desktop):") |
|
|
logger.info(' Add to claude_desktop_config.json:') |
|
|
logger.info(' {') |
|
|
logger.info(' "mcpServers": {') |
|
|
logger.info(' "fleetmind": {') |
|
|
logger.info(' "command": "npx",') |
|
|
logger.info(' "args": [') |
|
|
logger.info(' "mcp-remote",') |
|
|
logger.info(' "https://huggingface.co/spaces/MCP-1st-Birthday/fleetmind-dispatch-ai/sse"') |
|
|
logger.info(' ]') |
|
|
logger.info(' }') |
|
|
logger.info(' }') |
|
|
logger.info(' }') |
|
|
logger.info("=" * 70) |
|
|
logger.info(f"Starting SSE server on {HF_SPACE_HOST}:{HF_SPACE_PORT}...") |
|
|
logger.info("Waiting for MCP client connections...") |
|
|
logger.info("=" * 70) |
|
|
|
|
|
try: |
|
|
|
|
|
mcp.run( |
|
|
transport="sse", |
|
|
host=HF_SPACE_HOST, |
|
|
port=HF_SPACE_PORT |
|
|
) |
|
|
except Exception as e: |
|
|
logger.error(f"Failed to start MCP server: {e}") |
|
|
logger.error("Check that:") |
|
|
logger.error(" 1. Database connection is configured (DB_HOST, DB_USER, etc.)") |
|
|
logger.error(" 2. Google Maps API key is set (GOOGLE_MAPS_API_KEY)") |
|
|
logger.error(" 3. Port 7860 is available") |
|
|
raise |
|
|
|