Commit
Β·
0bd0fd1
1
Parent(s):
5d901a6
update readme file
Browse files
README.md
CHANGED
|
@@ -22,224 +22,62 @@ tags:
|
|
| 22 |
- ai-routing
|
| 23 |
---
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
**π MCP 1st Birthday Hackathon - Track 1: Building MCP Servers (Enterprise Category)**
|
| 28 |
-
|
| 29 |
-
Industry-standard Model Context Protocol server for AI-powered delivery dispatch management. Exposes **29 AI tools** (including Gemini 2.0 Flash intelligent assignment) and 2 real-time resources for managing delivery operations through any MCP-compatible client. Features **multi-tenant authentication** with complete data isolation and a professional web landing page.
|
| 30 |
-
|
| 31 |
-
[](https://github.com/jlowin/fastmcp)
|
| 32 |
-
[](https://www.python.org/)
|
| 33 |
-
[](https://modelcontextprotocol.io)
|
| 34 |
-
|
| 35 |
-
---
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
- **GitHub Repository:** https://github.com/mashrur-rahman-fahim/fleetmind-mcp
|
| 40 |
-
- **HuggingFace Space (Landing Page):** https://huggingface.co/spaces/MCP-1st-Birthday/fleetmind-dispatch-ai
|
| 41 |
-
- **Live Space URL:** https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space
|
| 42 |
-
- **MCP SSE Endpoint:** https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/sse
|
| 43 |
-
- **Generate API Key:** https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/generate-key
|
| 44 |
-
- **Note:** Visit the Space URL above to see connection instructions and tool documentation
|
| 45 |
-
|
| 46 |
-
## πΊ Demo & Submission
|
| 47 |
-
|
| 48 |
-
- **Demo Video:** [Coming Soon - Will showcase Gemini 2.0 Flash AI assignment in action]
|
| 49 |
-
- **Social Media Post:** [Will be added upon submission]
|
| 50 |
-
- **Submission Date:** November 2025
|
| 51 |
-
|
| 52 |
-
---
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
-
**
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
-
**
|
| 61 |
-
- Team members and HuggingFace profile links will be added before final submission
|
| 62 |
-
- For collaboration inquiries, please open an issue on the GitHub repository
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
FleetMind is a production-ready **Model Context Protocol (MCP) server** that transforms delivery dispatch management into AI-accessible tools.
|
| 69 |
-
|
| 70 |
-
**Access Methods:**
|
| 71 |
-
- **Web Landing Page**: Professional HTML page with connection instructions and tool documentation
|
| 72 |
-
- **MCP SSE Endpoint**: Direct API access for Claude Desktop, Continue, Cline, or any MCP client
|
| 73 |
-
|
| 74 |
-
### Key Features
|
| 75 |
-
|
| 76 |
-
β
**π Multi-Tenant API Key Authentication** - Secure access with personal API keys and complete data isolation
|
| 77 |
-
β
**29 AI Tools** - Order, Driver & Assignment Management (including Gemini 2.0 Flash AI)
|
| 78 |
-
β
**2 Real-Time Resources** - Live data feeds (orders://all, drivers://all)
|
| 79 |
-
β
**Google Maps Integration** - Geocoding & Route Calculation with traffic data
|
| 80 |
-
β
**PostgreSQL Database** - Production-grade data storage (Neon)
|
| 81 |
-
β
**SSE Endpoint** - Standard MCP protocol via Server-Sent Events
|
| 82 |
-
β
**Multi-Client Support** - Works with any MCP-compatible client
|
| 83 |
-
β
**Proxy-Based Auth** - Seamless authentication via URL query parameters
|
| 84 |
-
|
| 85 |
-
### β Unique Features
|
| 86 |
-
|
| 87 |
-
#### π€ Gemini 2.0 Flash AI Assignment
|
| 88 |
-
- Latest Google Gemini 2.0 Flash model (`gemini-2.0-flash-exp`) analyzes 10+ parameters
|
| 89 |
-
- Considers order priority, driver skills, traffic, weather, and complex tradeoffs
|
| 90 |
-
- Returns detailed AI reasoning explaining why each driver was selected
|
| 91 |
-
- Confidence scoring for transparency and accountability
|
| 92 |
-
|
| 93 |
-
#### π¦οΈ Weather-Aware Routing
|
| 94 |
-
- OpenWeatherMap API integration for real-time conditions
|
| 95 |
-
- Weather impact analysis for delivery planning and safety
|
| 96 |
-
- Safety-first routing during adverse conditions (rain, fog, snow)
|
| 97 |
-
- Vehicle-specific weather safety warnings (especially for motorcycles)
|
| 98 |
-
|
| 99 |
-
#### ποΈ Vehicle-Specific Optimization
|
| 100 |
-
- Motorcycle (TWO_WHEELER), Bicycle, Car/Van/Truck routing modes
|
| 101 |
-
- Different route optimization for each vehicle type
|
| 102 |
-
- Toll detection and avoidance capabilities
|
| 103 |
-
- Highway and ferry avoidance options for cost optimization
|
| 104 |
-
|
| 105 |
-
#### π SLA & Performance Tracking
|
| 106 |
-
- Mandatory delivery deadlines with configurable grace periods
|
| 107 |
-
- Automatic on-time vs late vs very_late classification
|
| 108 |
-
- Structured failure reason tracking (9 categories: customer unavailable, wrong address, etc.)
|
| 109 |
-
- Delivery performance analytics for reporting and optimization
|
| 110 |
-
|
| 111 |
-
#### π¦ Real-Time Traffic Integration
|
| 112 |
-
- Google Routes API with live traffic data
|
| 113 |
-
- Traffic delay breakdown and alternative routes
|
| 114 |
-
- Triple fallback system (Routes API β Directions API β Mock calculation)
|
| 115 |
-
- 17+ traffic segments analyzed per route
|
| 116 |
-
|
| 117 |
-
#### π― Three Assignment Methods
|
| 118 |
-
1. **Manual Assignment** - Direct driver selection for specific needs
|
| 119 |
-
2. **Auto Assignment** - Nearest driver with capacity/skill validation
|
| 120 |
-
3. **Intelligent AI Assignment** - Gemini 2.0 Flash analyzes all parameters with detailed reasoning
|
| 121 |
|
| 122 |
---
|
| 123 |
|
| 124 |
-
##
|
| 125 |
-
|
| 126 |
-
FleetMind uses a **proxy-based authentication architecture** that enables seamless multi-tenant access:
|
| 127 |
-
|
| 128 |
-
```
|
| 129 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 130 |
-
β MCP Clients β
|
| 131 |
-
β (Claude Desktop, Continue, Cline, Custom Applications) β
|
| 132 |
-
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
|
| 133 |
-
β
|
| 134 |
-
β SSE Connection: /sse?api_key=fm_xxx
|
| 135 |
-
β
|
| 136 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 137 |
-
β Authentication Proxy (port 7860) β
|
| 138 |
-
β proxy.py β
|
| 139 |
-
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
| 140 |
-
β β 1. Captures api_key from initial SSE connection β β
|
| 141 |
-
β β 2. Stores api_key mapped to session_id β β
|
| 142 |
-
β β 3. Injects api_key into /messages requests β β
|
| 143 |
-
β β 4. SSE keep-alive pings every 30 seconds β β
|
| 144 |
-
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
| 145 |
-
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
|
| 146 |
-
β
|
| 147 |
-
β Forwarded requests with api_key
|
| 148 |
-
β
|
| 149 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 150 |
-
β FastMCP Server (port 7861) β
|
| 151 |
-
β server.py + app.py β
|
| 152 |
-
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
| 153 |
-
β β β’ ApiKeyAuthMiddleware validates api_key β β
|
| 154 |
-
β β β’ Extracts user_id from authenticated user β β
|
| 155 |
-
β β β’ Injects user context into FastMCP state β β
|
| 156 |
-
β β β’ 29 MCP tools with user_id filtering β β
|
| 157 |
-
β β β’ 2 MCP resources with user_id filtering β β
|
| 158 |
-
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
| 159 |
-
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
|
| 160 |
-
β
|
| 161 |
-
βββββββββββββββΌββββββββββββββ¬ββββββββββββββ
|
| 162 |
-
β β β β
|
| 163 |
-
βββββββββββββββ βββββββββββββ βββββββββββββ βββββββββββββ
|
| 164 |
-
β PostgreSQL β β Google β β Google β β OpenWeatherβ
|
| 165 |
-
β Database β β Maps API β β Gemini AI β β Map API β
|
| 166 |
-
β (Neon) β β β β β β β
|
| 167 |
-
β user_id FK β β Geocoding β β Intelligentβ β Weather β
|
| 168 |
-
β isolation β β Routing β β Assignment β β Data β
|
| 169 |
-
βββββββββββββββ βββββββββββββ βββββββββββββ βββββββββββββ
|
| 170 |
-
```
|
| 171 |
-
|
| 172 |
-
### Why Proxy-Based Authentication?
|
| 173 |
-
|
| 174 |
-
MCP clients like Claude Desktop use `mcp-remote` which doesn't forward environment variables to remote servers. The proxy solves this by:
|
| 175 |
-
|
| 176 |
-
1. **Capturing API keys** from the initial SSE connection URL (`?api_key=fm_xxx`)
|
| 177 |
-
2. **Linking sessions** - Maps `session_id` to `api_key` for subsequent tool calls
|
| 178 |
-
3. **Injecting authentication** - Adds `api_key` to all `/messages` requests automatically
|
| 179 |
-
4. **Maintaining connections** - SSE keep-alive pings prevent timeout disconnections
|
| 180 |
-
|
| 181 |
-
---
|
| 182 |
|
| 183 |
-
|
|
|
|
|
|
|
| 184 |
|
| 185 |
-
|
|
|
|
| 186 |
|
| 187 |
-
###
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
- **Real-Time Traffic Analysis** - Google Routes API with live traffic data and delay predictions
|
| 191 |
-
- **AI Reasoning & Transparency** - Detailed explanations for every intelligent assignment decision
|
| 192 |
|
| 193 |
-
###
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
- **SLA Tracking & Analytics** - Automatic performance monitoring with grace periods and violation detection
|
| 197 |
-
- **Triple Fallback System** - Routes API β Directions API β Mock calculation for 99.9% uptime
|
| 198 |
-
- **Multi-Client Support** - Standard MCP protocol works with Claude Desktop, Continue, Cline, and custom clients
|
| 199 |
-
- **SSE Web Transport** - Server-Sent Events for web-based MCP connectivity
|
| 200 |
|
| 201 |
-
###
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
- **Environment Management** - Secure API key handling for Google Maps, Gemini, and OpenWeatherMap
|
| 205 |
-
- **29 Production Tools** - Complete fleet management suite ready for real-world use
|
| 206 |
|
| 207 |
-
###
|
| 208 |
-
|
| 209 |
-
-
|
| 210 |
-
- **Cascading Status Updates** - Order β Assignment β Driver state management with FK constraints
|
| 211 |
-
- **Three Assignment Methods** - Manual, Auto (distance-based), and Intelligent AI (parameter-based)
|
| 212 |
|
| 213 |
-
|
| 214 |
|
| 215 |
---
|
| 216 |
|
| 217 |
-
##
|
| 218 |
|
| 219 |
-
###
|
|
|
|
| 220 |
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
Visit the FleetMind server and generate your personal API key:
|
| 224 |
-
|
| 225 |
-
π **https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/generate-key**
|
| 226 |
-
|
| 227 |
-
1. Enter your email address
|
| 228 |
-
2. Enter your name (optional)
|
| 229 |
-
3. Click "Generate API Key"
|
| 230 |
-
4. **Copy your API key immediately** - it won't be shown again!
|
| 231 |
-
|
| 232 |
-
Your API key will look like: `fm_xxxxxxxxxxxxxxxxxxxxxxxx`
|
| 233 |
-
|
| 234 |
-
#### **Step 2: Install Claude Desktop**
|
| 235 |
-
|
| 236 |
-
Download from: https://claude.ai/download
|
| 237 |
-
|
| 238 |
-
#### **Step 3: Configure MCP Server**
|
| 239 |
-
|
| 240 |
-
Edit your `claude_desktop_config.json`:
|
| 241 |
-
|
| 242 |
-
**For Production (HuggingFace Space):**
|
| 243 |
```json
|
| 244 |
{
|
| 245 |
"mcpServers": {
|
|
@@ -247,780 +85,240 @@ Edit your `claude_desktop_config.json`:
|
|
| 247 |
"command": "npx",
|
| 248 |
"args": [
|
| 249 |
"mcp-remote",
|
| 250 |
-
"https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/sse?api_key=
|
| 251 |
-
]
|
| 252 |
-
}
|
| 253 |
-
}
|
| 254 |
-
}
|
| 255 |
-
```
|
| 256 |
-
|
| 257 |
-
β οΈ **Important:** Replace `fm_your_api_key_here` with your actual API key from Step 1!
|
| 258 |
-
|
| 259 |
-
π‘ **Note:** The API key is passed as a **query parameter** (`?api_key=...`) in the URL. This is because `mcp-remote` doesn't forward environment variables to remote servers.
|
| 260 |
-
|
| 261 |
-
**For Local Development (with API Key):**
|
| 262 |
-
```json
|
| 263 |
-
{
|
| 264 |
-
"mcpServers": {
|
| 265 |
-
"fleetmind_local": {
|
| 266 |
-
"command": "npx",
|
| 267 |
-
"args": [
|
| 268 |
-
"mcp-remote",
|
| 269 |
-
"http://localhost:7860/sse?api_key=your_local_api_key"
|
| 270 |
-
]
|
| 271 |
-
}
|
| 272 |
-
}
|
| 273 |
-
}
|
| 274 |
-
```
|
| 275 |
-
|
| 276 |
-
**For Local Development (SKIP_AUTH mode):**
|
| 277 |
-
```json
|
| 278 |
-
{
|
| 279 |
-
"mcpServers": {
|
| 280 |
-
"fleetmind_local": {
|
| 281 |
-
"command": "npx",
|
| 282 |
-
"args": [
|
| 283 |
-
"mcp-remote",
|
| 284 |
-
"http://localhost:7860/sse"
|
| 285 |
]
|
| 286 |
}
|
| 287 |
}
|
| 288 |
}
|
| 289 |
```
|
| 290 |
-
*Set `SKIP_AUTH=true` in your `.env` file for local testing without API keys*
|
| 291 |
|
| 292 |
-
|
| 293 |
-
```json
|
| 294 |
-
{
|
| 295 |
-
"mcpServers": {
|
| 296 |
-
"fleetmind_local": {
|
| 297 |
-
"command": "npx",
|
| 298 |
-
"args": [
|
| 299 |
-
"mcp-remote",
|
| 300 |
-
"http://localhost:7860/sse?api_key=your_local_key"
|
| 301 |
-
]
|
| 302 |
-
},
|
| 303 |
-
"fleetmind": {
|
| 304 |
-
"command": "npx",
|
| 305 |
-
"args": [
|
| 306 |
-
"mcp-remote",
|
| 307 |
-
"https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/sse?api_key=your_production_key"
|
| 308 |
-
]
|
| 309 |
-
}
|
| 310 |
-
}
|
| 311 |
-
}
|
| 312 |
```
|
|
|
|
|
|
|
| 313 |
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
#### **Step 5: Try It Out!**
|
| 319 |
-
- "Create an urgent delivery order for Sarah at 456 Oak Ave, San Francisco"
|
| 320 |
-
- "Use intelligent AI assignment to find the best driver for this order"
|
| 321 |
-
- "Show me all available drivers"
|
| 322 |
-
- "Calculate route from downtown SF to Oakland Airport with weather conditions"
|
| 323 |
-
|
| 324 |
-
### Connect from VS Code (Continue)
|
| 325 |
-
|
| 326 |
-
1. Install Continue extension
|
| 327 |
-
2. Add FleetMind to MCP servers in settings
|
| 328 |
-
3. Use tools directly in your editor
|
| 329 |
-
|
| 330 |
-
### Connect from Custom App
|
| 331 |
-
|
| 332 |
-
```python
|
| 333 |
-
import mcp
|
| 334 |
-
|
| 335 |
-
client = mcp.Client(
|
| 336 |
-
url="https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/sse"
|
| 337 |
-
)
|
| 338 |
-
|
| 339 |
-
# Use any of the 29 tools
|
| 340 |
-
result = client.call_tool("create_order", {
|
| 341 |
-
"customer_name": "John Doe",
|
| 342 |
-
"delivery_address": "123 Main St, SF CA 94102",
|
| 343 |
-
"delivery_lat": 37.7749,
|
| 344 |
-
"delivery_lng": -122.4194
|
| 345 |
-
})
|
| 346 |
```
|
| 347 |
|
| 348 |
---
|
| 349 |
|
| 350 |
-
##
|
| 351 |
-
|
| 352 |
-
### Geocoding & Routing (3 tools)
|
| 353 |
-
|
| 354 |
-
| Tool | Description | Example Use |
|
| 355 |
-
|------|-------------|-------------|
|
| 356 |
-
| `geocode_address` | Convert address to GPS coordinates | "Geocode 123 Main St, San Francisco" |
|
| 357 |
-
| `calculate_route` | Vehicle-specific routing with real-time traffic | "Route from SF City Hall to Oakland Airport for motorcycle" |
|
| 358 |
-
| `calculate_intelligent_route` | **AI-powered weather + traffic aware routing** | "Calculate smart route considering weather and traffic" |
|
| 359 |
-
|
| 360 |
-
### Order Management (8 tools)
|
| 361 |
-
|
| 362 |
-
| Tool | Description | Example Use |
|
| 363 |
-
|------|-------------|-------------|
|
| 364 |
-
| `create_order` | Create new delivery orders with mandatory deadlines | "Create delivery for Sarah at 456 Oak Ave" |
|
| 365 |
-
| `count_orders` | Count orders with filters | "How many urgent orders are pending?" |
|
| 366 |
-
| `fetch_orders` | Retrieve orders with pagination | "Show me the 10 most recent orders" |
|
| 367 |
-
| `get_order_details` | Get complete order information with SLA data | "Show details for order ORD-20251114..." |
|
| 368 |
-
| `search_orders` | Search by customer/ID | "Find orders for customer John Smith" |
|
| 369 |
-
| `get_incomplete_orders` | List active deliveries | "Show all orders not yet delivered" |
|
| 370 |
-
| `update_order` | Update order details with cascading | "Mark order ORD-... as delivered" |
|
| 371 |
-
| `delete_order` | Safely remove orders with checks | "Delete test order ORD-TEST-001" |
|
| 372 |
-
|
| 373 |
-
### Driver Management (8 tools)
|
| 374 |
-
|
| 375 |
-
| Tool | Description | Example Use |
|
| 376 |
-
|------|-------------|-------------|
|
| 377 |
-
| `create_driver` | Onboard new drivers with skills validation | "Add driver Mike with plate ABC-123, motorcycle, fragile_handler skill" |
|
| 378 |
-
| `count_drivers` | Count drivers with filters | "How many active drivers are online?" |
|
| 379 |
-
| `fetch_drivers` | Retrieve drivers with pagination | "List all drivers sorted by name" |
|
| 380 |
-
| `get_driver_details` | Get driver info + location with reverse geocoding | "Show details for driver DRV-..." |
|
| 381 |
-
| `search_drivers` | Search by name/plate/ID | "Find driver with plate XYZ-789" |
|
| 382 |
-
| `get_available_drivers` | List drivers ready for dispatch | "Show available drivers near downtown" |
|
| 383 |
-
| `update_driver` | Update driver information with validation | "Update driver DRV-... status to busy" |
|
| 384 |
-
| `delete_driver` | Safely remove drivers with assignment checks | "Remove driver DRV-TEST-001" |
|
| 385 |
-
|
| 386 |
-
### Assignment Management (8 tools) β NEW
|
| 387 |
-
|
| 388 |
-
| Tool | Description | Example Use |
|
| 389 |
-
|------|-------------|-------------|
|
| 390 |
-
| `create_assignment` | Manually assign order to specific driver | "Assign order ORD-... to driver DRV-..." |
|
| 391 |
-
| **`auto_assign_order`** | **Automatic nearest driver assignment with validation** | **"Auto-assign this order to nearest available driver"** |
|
| 392 |
-
| **`intelligent_assign_order`** | **π€ Gemini 2.0 Flash AI-powered assignment with reasoning** | **"Use AI to find the best driver for this urgent fragile delivery"** |
|
| 393 |
-
| `get_assignment_details` | View assignment details with route data | "Show assignment details for ASN-..." |
|
| 394 |
-
| `update_assignment` | Update assignment status with cascading | "Mark assignment ASN-... as in_progress" |
|
| 395 |
-
| `unassign_order` | Remove driver assignment safely | "Unassign order ORD-... from current driver" |
|
| 396 |
-
| `complete_delivery` | Mark delivery complete + auto-update driver location | "Complete delivery for assignment ASN-..." |
|
| 397 |
-
| `fail_delivery` | Track failed deliveries with GPS + structured reason | "Mark delivery failed: customer not available at current location" |
|
| 398 |
-
|
| 399 |
-
### Bulk Operations (2 tools)
|
| 400 |
-
|
| 401 |
-
| Tool | Description | Example Use |
|
| 402 |
-
|------|-------------|-------------|
|
| 403 |
-
| `delete_all_orders` | Bulk delete orders by status with safety checks | "Delete all cancelled orders" |
|
| 404 |
-
| `delete_all_drivers` | Bulk delete drivers by status with assignment checks | "Delete all offline drivers" |
|
| 405 |
-
|
| 406 |
-
---
|
| 407 |
-
|
| 408 |
-
## π Real-Time Resources (2 Total)
|
| 409 |
-
|
| 410 |
-
### `orders://all`
|
| 411 |
-
Live orders dataset (last 30 days, max 1000 orders)
|
| 412 |
-
|
| 413 |
-
**Example:**
|
| 414 |
-
```
|
| 415 |
-
"What's the status of recent orders?"
|
| 416 |
-
```
|
| 417 |
-
|
| 418 |
-
Claude automatically accesses this resource to provide context-aware answers.
|
| 419 |
-
|
| 420 |
-
### `drivers://all`
|
| 421 |
-
Live drivers dataset with current locations
|
| 422 |
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
|
| 428 |
---
|
| 429 |
|
| 430 |
-
##
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
|
| 449 |
---
|
| 450 |
|
| 451 |
-
## ποΈ
|
| 452 |
-
|
| 453 |
-
```
|
| 454 |
-
|
| 455 |
-
β
|
| 456 |
-
β
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
β
|
| 463 |
-
β
|
| 464 |
-
β β’
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
β
|
| 476 |
-
β
|
| 477 |
-
β
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
βββββββββββββββΌββββββββββββββ¬ββββββββββββββ
|
| 481 |
-
β β β β
|
| 482 |
-
βββββββββββββββ βββββββββββββ βββββββββββββ βββββββββββββ
|
| 483 |
-
β PostgreSQL β β Google β β Google β β OpenWeatherβ
|
| 484 |
-
β Database β β Maps API β β Gemini AI β β Map API β
|
| 485 |
-
β (Neon) β β β β β β β
|
| 486 |
-
β multi-tenantβ β Geocoding β β Intelligentβ β Weather β
|
| 487 |
-
β user_id FK β β Routing β β Assignment β β Data β
|
| 488 |
-
βββββββββββββββ βββββββββββββ βββββββββββββ βββββββββββββ
|
| 489 |
```
|
| 490 |
|
| 491 |
-
**Key Architecture Benefits:**
|
| 492 |
-
- β
**Multi-client support** - Works with Claude Desktop, VS Code, mobile apps
|
| 493 |
-
- β
**Standardized protocol** - MCP is industry-standard for AI tool integration
|
| 494 |
-
- β
**Multi-tenant isolation** - Complete data separation via user_id
|
| 495 |
-
- β
**Proxy-based auth** - Seamless API key handling for MCP clients
|
| 496 |
-
- β
**Real-time data access** - Resources provide live context to AI
|
| 497 |
-
- β
**Tool composability** - AI combines tools intelligently for complex workflows
|
| 498 |
-
- β
**Easy integration** - Any MCP client can connect via SSE
|
| 499 |
-
|
| 500 |
---
|
| 501 |
|
| 502 |
-
##
|
| 503 |
|
| 504 |
-
|
| 505 |
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
|
| 512 |
-
**
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
5. Calls `calculate_route(...)` for each driver to find nearest
|
| 518 |
-
6. Calls `update_order(...)` to assign driver
|
| 519 |
-
7. Returns: "Order ORD-... created and assigned to John Smith (DRV-...), 5.2 km away, ETA 12 mins"
|
| 520 |
|
| 521 |
-
|
|
|
|
| 522 |
|
| 523 |
-
**Prompt:**
|
| 524 |
```
|
| 525 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
```
|
| 527 |
|
| 528 |
-
|
| 529 |
-
1. Claude calls `fetch_orders(status="in_transit", priority="urgent", sort_by="time_window_end")`
|
| 530 |
-
2. Returns formatted list with customer names, addresses, drivers, and ETAs
|
| 531 |
-
|
| 532 |
-
### Example 3: Driver Management
|
| 533 |
-
|
| 534 |
-
**Prompt:**
|
| 535 |
-
```
|
| 536 |
-
How many drivers do we have available right now? Where are they located?
|
| 537 |
-
```
|
| 538 |
-
|
| 539 |
-
**What happens:**
|
| 540 |
-
1. Claude accesses `drivers://all` resource automatically
|
| 541 |
-
2. Filters for `status="active"`
|
| 542 |
-
3. Calls `get_driver_details(...)` for location addresses
|
| 543 |
-
4. Returns summary with driver count and locations
|
| 544 |
|
| 545 |
---
|
| 546 |
|
| 547 |
-
##
|
| 548 |
-
|
| 549 |
-
### Orders Table (26 columns)
|
| 550 |
-
|
| 551 |
-
```sql
|
| 552 |
-
CREATE TABLE orders (
|
| 553 |
-
order_id VARCHAR(50) PRIMARY KEY,
|
| 554 |
-
customer_name VARCHAR(255) NOT NULL,
|
| 555 |
-
customer_phone VARCHAR(20),
|
| 556 |
-
customer_email VARCHAR(255),
|
| 557 |
-
delivery_address TEXT NOT NULL,
|
| 558 |
-
delivery_lat DECIMAL(10,8),
|
| 559 |
-
delivery_lng DECIMAL(11,8),
|
| 560 |
-
status VARCHAR(20) CHECK (status IN ('pending','assigned','in_transit','delivered','failed','cancelled')),
|
| 561 |
-
priority VARCHAR(20) CHECK (priority IN ('standard','express','urgent')),
|
| 562 |
-
time_window_end TIMESTAMP,
|
| 563 |
-
assigned_driver_id VARCHAR(50),
|
| 564 |
-
weight_kg DECIMAL(10,2),
|
| 565 |
-
special_instructions TEXT,
|
| 566 |
-
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
| 567 |
-
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
| 568 |
-
-- ... additional fields
|
| 569 |
-
);
|
| 570 |
-
```
|
| 571 |
|
| 572 |
-
###
|
| 573 |
-
|
| 574 |
-
```sql
|
| 575 |
-
CREATE TABLE drivers (
|
| 576 |
-
driver_id VARCHAR(50) PRIMARY KEY,
|
| 577 |
-
name VARCHAR(255) NOT NULL,
|
| 578 |
-
phone VARCHAR(20),
|
| 579 |
-
email VARCHAR(255),
|
| 580 |
-
status VARCHAR(20) CHECK (status IN ('active','busy','offline','unavailable')),
|
| 581 |
-
vehicle_type VARCHAR(50),
|
| 582 |
-
vehicle_plate VARCHAR(20),
|
| 583 |
-
capacity_kg DECIMAL(10,2),
|
| 584 |
-
current_lat DECIMAL(10,8),
|
| 585 |
-
current_lng DECIMAL(11,8),
|
| 586 |
-
last_location_update TIMESTAMP,
|
| 587 |
-
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
| 588 |
-
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
| 589 |
-
);
|
| 590 |
-
```
|
| 591 |
-
|
| 592 |
-
---
|
| 593 |
-
|
| 594 |
-
## π§ Local Development
|
| 595 |
-
|
| 596 |
-
### Prerequisites
|
| 597 |
-
|
| 598 |
-
- Python 3.10+
|
| 599 |
-
- PostgreSQL database (or use Neon serverless)
|
| 600 |
-
- Google Maps API key
|
| 601 |
-
- Google Gemini API key (for AI features)
|
| 602 |
-
|
| 603 |
-
### Setup
|
| 604 |
|
|
|
|
| 605 |
```bash
|
| 606 |
-
# Clone repository
|
| 607 |
git clone https://github.com/mashrur-rahman-fahim/fleetmind-mcp.git
|
| 608 |
cd fleetmind-mcp
|
| 609 |
-
|
| 610 |
-
# Install dependencies
|
| 611 |
pip install -r requirements.txt
|
| 612 |
|
| 613 |
-
# Configure
|
| 614 |
-
|
| 615 |
-
# Edit .env with your credentials:
|
| 616 |
-
# DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD
|
| 617 |
-
# GOOGLE_MAPS_API_KEY
|
| 618 |
-
# GOOGLE_API_KEY (for Gemini)
|
| 619 |
-
# SKIP_AUTH=true # For local development without API keys
|
| 620 |
-
|
| 621 |
-
# Run database migrations
|
| 622 |
-
python database/migrations/001_initial_schema.py
|
| 623 |
-
# ... run all migrations
|
| 624 |
-
|
| 625 |
-
# Run locally (SSE mode for web clients)
|
| 626 |
-
python app.py
|
| 627 |
-
```
|
| 628 |
-
|
| 629 |
-
### API Key Management (Local)
|
| 630 |
-
|
| 631 |
-
**Generate API Keys:**
|
| 632 |
-
```bash
|
| 633 |
-
# Interactive mode
|
| 634 |
-
python generate_api_key.py
|
| 635 |
-
|
| 636 |
-
# With arguments
|
| 637 |
-
python generate_api_key.py --email user@example.com --name "Test User"
|
| 638 |
-
|
| 639 |
-
# List all keys
|
| 640 |
-
python generate_api_key.py --list
|
| 641 |
-
|
| 642 |
-
# Revoke a key
|
| 643 |
-
python generate_api_key.py --revoke user@example.com
|
| 644 |
-
```
|
| 645 |
-
|
| 646 |
-
**Web Interface:**
|
| 647 |
-
Visit http://localhost:7860/generate-key to generate keys via web form.
|
| 648 |
-
|
| 649 |
-
**Development Mode (No API Keys):**
|
| 650 |
-
Set `SKIP_AUTH=true` in `.env` to bypass authentication for local testing.
|
| 651 |
-
|
| 652 |
-
### Testing
|
| 653 |
-
|
| 654 |
-
```bash
|
| 655 |
-
# Test with MCP Inspector
|
| 656 |
-
npx @modelcontextprotocol/inspector python server.py
|
| 657 |
-
|
| 658 |
-
# Test with Claude Desktop
|
| 659 |
-
# Add to claude_desktop_config.json:
|
| 660 |
-
{
|
| 661 |
-
"mcpServers": {
|
| 662 |
-
"fleetmind-local": {
|
| 663 |
-
"command": "python",
|
| 664 |
-
"args": ["F:\\path\\to\\fleetmind-mcp\\server.py"]
|
| 665 |
-
}
|
| 666 |
-
}
|
| 667 |
-
}
|
| 668 |
```
|
| 669 |
|
| 670 |
---
|
| 671 |
|
| 672 |
-
##
|
| 673 |
-
|
| 674 |
-
This project is designed for **Track 1: Building MCP Servers** deployment on HuggingFace Spaces.
|
| 675 |
-
|
| 676 |
-
### Automatic Deployment
|
| 677 |
-
|
| 678 |
-
1. **Fork this repository** to your GitHub account
|
| 679 |
-
|
| 680 |
-
2. **Create HuggingFace Space:**
|
| 681 |
-
- Go to https://huggingface.co/new-space
|
| 682 |
-
- Name: `fleetmind-mcp` (or your choice)
|
| 683 |
-
- SDK: Docker
|
| 684 |
-
- Link to GitHub repository
|
| 685 |
-
|
| 686 |
-
3. **Configure Secrets** in HF Space settings:
|
| 687 |
-
- `DB_HOST` - PostgreSQL host
|
| 688 |
-
- `DB_PORT` - PostgreSQL port (5432)
|
| 689 |
-
- `DB_NAME` - Database name
|
| 690 |
-
- `DB_USER` - Database user
|
| 691 |
-
- `DB_PASSWORD` - Database password
|
| 692 |
-
- `GOOGLE_MAPS_API_KEY` - Google Maps API key
|
| 693 |
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
- `.env` (configure secrets in HF Space settings instead)
|
| 704 |
|
| 705 |
---
|
| 706 |
|
| 707 |
-
##
|
| 708 |
-
|
| 709 |
-
FleetMind uses a **multi-layered authentication system** with proxy-based API key capture and FastMCP middleware for secure multi-tenant access:
|
| 710 |
-
|
| 711 |
-
### Authentication Architecture
|
| 712 |
-
|
| 713 |
-
The authentication system consists of three layers:
|
| 714 |
-
|
| 715 |
-
```
|
| 716 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 717 |
-
β Layer 1: Authentication Proxy (proxy.py) β
|
| 718 |
-
β οΏ½οΏ½οΏ½ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
| 719 |
-
β β’ Captures api_key from SSE connection URL β
|
| 720 |
-
β β’ Maps session_id β api_key for tool calls β
|
| 721 |
-
β β’ Injects api_key into /messages requests β
|
| 722 |
-
β β’ Maintains session_api_keys dictionary β
|
| 723 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 724 |
-
β
|
| 725 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 726 |
-
β Layer 2: FastMCP Middleware (server.py - ApiKeyAuthMiddleware) β
|
| 727 |
-
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
| 728 |
-
β β’ Intercepts all tool calls via on_call_tool() β
|
| 729 |
-
β β’ Validates api_key using verify_api_key() β
|
| 730 |
-
β β’ Injects user context into FastMCP state: β
|
| 731 |
-
β - user_id, user_email, user_scopes, user_name β
|
| 732 |
-
β β’ Blocks unauthenticated requests in production β
|
| 733 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 734 |
-
β
|
| 735 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 736 |
-
β Layer 3: Tool-Level Authentication (each MCP tool) β
|
| 737 |
-
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
| 738 |
-
β β’ get_authenticated_user() extracts user from context β
|
| 739 |
-
β β’ check_permission() validates required scopes β
|
| 740 |
-
β β’ All database queries filter by user_id β
|
| 741 |
-
β β’ Complete multi-tenant data isolation β
|
| 742 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 743 |
-
```
|
| 744 |
-
|
| 745 |
-
### Complete Authentication Flow
|
| 746 |
-
|
| 747 |
-
```
|
| 748 |
-
1οΈβ£ USER GENERATES API KEY
|
| 749 |
-
βββ POST /generate-key (email: user@example.com)
|
| 750 |
-
βββ user_id = user_{MD5(email)[:12]} = "user_a85ddf4d664b"
|
| 751 |
-
βββ api_key = fm_3bGKV40B47NJ43zQ_4d3j-60a2gyoeLOVffoyyhRtBc
|
| 752 |
-
βββ api_key_hash = SHA-256(api_key) stored in database
|
| 753 |
-
βββ Key shown ONCE - user must copy immediately
|
| 754 |
-
|
| 755 |
-
2οΈβ£ USER CONFIGURES CLAUDE DESKTOP
|
| 756 |
-
βββ claude_desktop_config.json:
|
| 757 |
-
{
|
| 758 |
-
"mcpServers": {
|
| 759 |
-
"fleetmind": {
|
| 760 |
-
"command": "npx",
|
| 761 |
-
"args": ["mcp-remote", "https://...hf.space/sse?api_key=fm_xxx"]
|
| 762 |
-
}
|
| 763 |
-
}
|
| 764 |
-
}
|
| 765 |
-
|
| 766 |
-
3οΈβ£ SSE CONNECTION ESTABLISHED
|
| 767 |
-
βββ Client connects: GET /sse?api_key=fm_xxx
|
| 768 |
-
βββ Proxy (proxy.py) captures api_key
|
| 769 |
-
βββ Stores: session_api_keys['_pending_api_key'] = api_key
|
| 770 |
-
βββ Forwards to FastMCP (port 7861)
|
| 771 |
-
|
| 772 |
-
4οΈβ£ TOOL CALL MADE
|
| 773 |
-
βββ Client sends: POST /messages/?session_id=xxx
|
| 774 |
-
βββ Proxy links: session_api_keys[session_id] = pending_api_key
|
| 775 |
-
βββ Proxy injects: api_key into query params
|
| 776 |
-
βββ Forwards to FastMCP with api_key
|
| 777 |
-
|
| 778 |
-
5οΈβ£ FASTMCP MIDDLEWARE VALIDATES
|
| 779 |
-
βββ ApiKeyAuthMiddleware.on_call_tool() intercepts
|
| 780 |
-
βββ Extracts api_key from request.query_params
|
| 781 |
-
βββ verify_api_key(api_key) β hashes and queries database
|
| 782 |
-
βββ Returns: {user_id, email, name, scopes}
|
| 783 |
-
βββ Sets FastMCP context state with user info
|
| 784 |
-
|
| 785 |
-
6οΈβ£ TOOL EXECUTES WITH USER CONTEXT
|
| 786 |
-
βββ get_authenticated_user(ctx) reads from context state
|
| 787 |
-
βββ Extracts user_id: "user_a85ddf4d664b"
|
| 788 |
-
βββ Database query: WHERE user_id = 'user_a85ddf4d664b'
|
| 789 |
-
βββ Returns only user's own data
|
| 790 |
-
|
| 791 |
-
7οΈβ£ COMPLETE ISOLATION ACHIEVED
|
| 792 |
-
βββ User A sees only User A's orders/drivers/assignments
|
| 793 |
-
βββ User B sees only User B's orders/drivers/assignments
|
| 794 |
-
βββ Database enforces via user_id foreign keys
|
| 795 |
-
```
|
| 796 |
-
|
| 797 |
-
### User ID Generation (Deterministic)
|
| 798 |
-
|
| 799 |
-
```python
|
| 800 |
-
# database/api_keys.py
|
| 801 |
-
user_id = f"user_{hashlib.md5(email.encode()).hexdigest()[:12]}"
|
| 802 |
-
|
| 803 |
-
# Examples:
|
| 804 |
-
# "admin@gmail.com" β "user_a85ddf4d664b"
|
| 805 |
-
# "user@example.com" β "user_b45fa8c9e12d"
|
| 806 |
-
```
|
| 807 |
-
|
| 808 |
-
**Benefits:**
|
| 809 |
-
- Same email always generates same user_id
|
| 810 |
-
- Key rotation doesn't lose data ownership
|
| 811 |
-
- Enables consistent multi-tenant isolation
|
| 812 |
-
|
| 813 |
-
### API Key Storage
|
| 814 |
-
|
| 815 |
-
```sql
|
| 816 |
-
CREATE TABLE api_keys (
|
| 817 |
-
key_id SERIAL PRIMARY KEY,
|
| 818 |
-
user_id VARCHAR(100) NOT NULL UNIQUE, -- Deterministic from email
|
| 819 |
-
email VARCHAR(255) NOT NULL, -- For lookup/revocation
|
| 820 |
-
name VARCHAR(255), -- Display name (optional)
|
| 821 |
-
api_key_hash VARCHAR(64) NOT NULL UNIQUE, -- SHA-256 hash (never plaintext!)
|
| 822 |
-
api_key_prefix VARCHAR(20) NOT NULL, -- First 12 chars for display
|
| 823 |
-
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
| 824 |
-
last_used_at TIMESTAMP, -- Updated on each use
|
| 825 |
-
is_active BOOLEAN DEFAULT true -- For revocation
|
| 826 |
-
);
|
| 827 |
-
```
|
| 828 |
-
|
| 829 |
-
### Security Features
|
| 830 |
-
|
| 831 |
-
| Feature | Implementation |
|
| 832 |
-
|---------|---------------|
|
| 833 |
-
| β
**Hashed Storage** | SHA-256 hashing, API keys never stored in plaintext |
|
| 834 |
-
| β
**One-Time Display** | Keys shown only once during generation |
|
| 835 |
-
| β
**Deterministic User IDs** | Same email always gets same user_id |
|
| 836 |
-
| β
**Multi-Tenant Isolation** | All tables have user_id column with FK constraints |
|
| 837 |
-
| β
**Database-Level Enforcement** | Every query includes `WHERE user_id = %s` |
|
| 838 |
-
| β
**FastMCP Middleware** | Validates authentication before every tool call |
|
| 839 |
-
| β
**Proxy Session Linking** | session_id β api_key mapping for tool calls |
|
| 840 |
-
| β
**ContextVar Storage** | Thread-safe per-request user context |
|
| 841 |
-
| β
**Scope-Based Permissions** | Tools check required scopes before execution |
|
| 842 |
-
| β
**Production Safeguards** | SKIP_AUTH blocked when ENV=production |
|
| 843 |
-
| β
**Easy Revocation** | Keys can be deactivated via CLI or web interface |
|
| 844 |
-
|
| 845 |
-
### API Key Format
|
| 846 |
-
|
| 847 |
-
```
|
| 848 |
-
fm_LAISKBMKmQxoapDbLIhr_KqbVL69AS58wBtdpYfbQ10
|
| 849 |
-
β ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 850 |
-
β 43 random characters
|
| 851 |
-
βββ Prefix: "fm_" (FleetMind)
|
| 852 |
-
|
| 853 |
-
Generated with: secrets.token_urlsafe(32)
|
| 854 |
-
```
|
| 855 |
-
|
| 856 |
-
### Managing API Keys
|
| 857 |
-
|
| 858 |
-
**Web Interface:**
|
| 859 |
-
```
|
| 860 |
-
https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/generate-key
|
| 861 |
-
```
|
| 862 |
-
|
| 863 |
-
**Command Line:**
|
| 864 |
-
```bash
|
| 865 |
-
# Generate new key
|
| 866 |
-
python generate_api_key.py --email user@example.com --name "John Doe"
|
| 867 |
-
|
| 868 |
-
# List all keys (shows user_id, email, key preview)
|
| 869 |
-
python generate_api_key.py --list
|
| 870 |
-
|
| 871 |
-
# Revoke a key (deactivates, doesn't delete)
|
| 872 |
-
python generate_api_key.py --revoke user@example.com
|
| 873 |
-
|
| 874 |
-
# Verify a key (test authentication)
|
| 875 |
-
python generate_api_key.py --verify fm_your_api_key_here
|
| 876 |
-
```
|
| 877 |
-
|
| 878 |
-
### Database Tables with Multi-Tenant Isolation
|
| 879 |
-
|
| 880 |
-
All core tables include `user_id` column for data isolation:
|
| 881 |
-
|
| 882 |
-
```sql
|
| 883 |
-
-- orders table
|
| 884 |
-
CREATE TABLE orders (
|
| 885 |
-
order_id VARCHAR(50) PRIMARY KEY,
|
| 886 |
-
user_id VARCHAR(100) NOT NULL, -- Multi-tenant isolation
|
| 887 |
-
customer_name VARCHAR(255),
|
| 888 |
-
...
|
| 889 |
-
FOREIGN KEY (user_id) REFERENCES api_keys(user_id)
|
| 890 |
-
);
|
| 891 |
-
CREATE INDEX idx_orders_user_id ON orders(user_id);
|
| 892 |
-
CREATE INDEX idx_orders_user_status ON orders(user_id, status);
|
| 893 |
-
|
| 894 |
-
-- drivers table
|
| 895 |
-
CREATE TABLE drivers (
|
| 896 |
-
driver_id VARCHAR(50) PRIMARY KEY,
|
| 897 |
-
user_id VARCHAR(100) NOT NULL, -- Multi-tenant isolation
|
| 898 |
-
name VARCHAR(255),
|
| 899 |
-
...
|
| 900 |
-
FOREIGN KEY (user_id) REFERENCES api_keys(user_id)
|
| 901 |
-
);
|
| 902 |
-
CREATE INDEX idx_drivers_user_id ON drivers(user_id);
|
| 903 |
-
CREATE INDEX idx_drivers_user_status ON drivers(user_id, status);
|
| 904 |
-
|
| 905 |
-
-- assignments table
|
| 906 |
-
CREATE TABLE assignments (
|
| 907 |
-
assignment_id VARCHAR(50) PRIMARY KEY,
|
| 908 |
-
user_id VARCHAR(100) NOT NULL, -- Multi-tenant isolation
|
| 909 |
-
order_id VARCHAR(50),
|
| 910 |
-
driver_id VARCHAR(50),
|
| 911 |
-
...
|
| 912 |
-
FOREIGN KEY (user_id) REFERENCES api_keys(user_id)
|
| 913 |
-
);
|
| 914 |
-
CREATE INDEX idx_assignments_user_id ON assignments(user_id);
|
| 915 |
-
```
|
| 916 |
-
|
| 917 |
-
### Environment Configuration
|
| 918 |
-
|
| 919 |
-
```bash
|
| 920 |
-
# Environment mode (controls SKIP_AUTH behavior)
|
| 921 |
-
ENV=development # Options: development, staging, production
|
| 922 |
-
|
| 923 |
-
# Authentication bypass (ONLY works when ENV != production)
|
| 924 |
-
SKIP_AUTH=false # Set to true ONLY for local testing
|
| 925 |
-
|
| 926 |
-
# Database connection (multi-tenant PostgreSQL)
|
| 927 |
-
DB_HOST=your-postgres-host.neon.tech
|
| 928 |
-
DB_PORT=5432
|
| 929 |
-
DB_NAME=fleetmind
|
| 930 |
-
DB_USER=your_user
|
| 931 |
-
DB_PASSWORD=your_password
|
| 932 |
-
```
|
| 933 |
-
|
| 934 |
-
**Security Note**: `SKIP_AUTH=true` is automatically blocked when `ENV=production`, preventing accidental authentication bypass in production deployments.
|
| 935 |
-
|
| 936 |
-
---
|
| 937 |
-
|
| 938 |
-
## π Environment Variables
|
| 939 |
-
|
| 940 |
-
Required:
|
| 941 |
-
```bash
|
| 942 |
-
# Database (PostgreSQL/Neon)
|
| 943 |
-
DB_HOST=your-postgres-host.neon.tech
|
| 944 |
-
DB_PORT=5432
|
| 945 |
-
DB_NAME=fleetmind
|
| 946 |
-
DB_USER=your_user
|
| 947 |
-
DB_PASSWORD=your_password
|
| 948 |
-
|
| 949 |
-
# Google Maps API
|
| 950 |
-
GOOGLE_MAPS_API_KEY=your_api_key
|
| 951 |
-
|
| 952 |
-
# Google Gemini API
|
| 953 |
-
GOOGLE_API_KEY=your_gemini_key
|
| 954 |
-
AI_PROVIDER=gemini
|
| 955 |
-
```
|
| 956 |
|
| 957 |
-
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
|
| 962 |
-
|
| 963 |
-
|
| 964 |
-
|
| 965 |
-
# Authentication
|
| 966 |
-
SKIP_AUTH=true # Set to false for production
|
| 967 |
-
```
|
| 968 |
|
| 969 |
---
|
| 970 |
|
| 971 |
-
##
|
| 972 |
-
|
| 973 |
-
### Production-Ready MCP Server β
|
| 974 |
-
|
| 975 |
-
- **Real Business Value:** Solves actual delivery dispatch problems
|
| 976 |
-
- **29 Tools:** Comprehensive order, driver & assignment management (including Gemini 2.0 Flash AI)
|
| 977 |
-
- **2 Resources:** Live data feeds for contextual AI responses
|
| 978 |
-
- **Industry Standard:** Uses FastMCP framework and MCP protocol
|
| 979 |
-
- **Scalable:** PostgreSQL database, stateless design
|
| 980 |
-
- **Well-Documented:** Comprehensive API reference and examples
|
| 981 |
-
|
| 982 |
-
### Enterprise Category Perfect Fit β
|
| 983 |
-
|
| 984 |
-
- **Complex Operations:** Order creation, assignment, routing, tracking
|
| 985 |
-
- **External Integrations:** Google Maps API (geocoding + directions)
|
| 986 |
-
- **Database Operations:** Production PostgreSQL with 6 tables
|
| 987 |
-
- **Real-Time Data:** Live resources for orders and drivers
|
| 988 |
-
- **Multi-Tool Workflows:** Tools compose together (geocode β create β assign)
|
| 989 |
|
| 990 |
-
|
| 991 |
|
| 992 |
-
|
| 993 |
-
- **2,099 lines** of battle-tested tool handlers
|
| 994 |
-
- **Type hints** throughout for reliability
|
| 995 |
-
- **Error handling** with graceful fallbacks
|
| 996 |
-
- **Logging infrastructure** for debugging
|
| 997 |
-
- **SSE transport** for web connectivity
|
| 998 |
|
| 999 |
---
|
| 1000 |
|
| 1001 |
## π License
|
| 1002 |
|
| 1003 |
-
MIT License - see LICENSE
|
| 1004 |
-
|
| 1005 |
-
---
|
| 1006 |
-
|
| 1007 |
-
## π€ Contributing
|
| 1008 |
-
|
| 1009 |
-
Contributions welcome! Please:
|
| 1010 |
-
1. Fork the repository
|
| 1011 |
-
2. Create a feature branch
|
| 1012 |
-
3. Commit your changes
|
| 1013 |
-
4. Push and open a Pull Request
|
| 1014 |
|
| 1015 |
---
|
| 1016 |
|
| 1017 |
-
|
| 1018 |
|
| 1019 |
-
|
| 1020 |
-
- **Hackathon:** https://huggingface.co/MCP-1st-Birthday
|
| 1021 |
|
| 1022 |
-
|
| 1023 |
-
|
| 1024 |
-
|
| 1025 |
|
| 1026 |
-
|
|
|
|
| 22 |
- ai-routing
|
| 23 |
---
|
| 24 |
|
| 25 |
+
<div align="center">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
# π FleetMind MCP Server
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
### AI-Powered Delivery Dispatch for the Modern Enterprise
|
| 30 |
|
| 31 |
+
**The Problem:** Delivery dispatch is complexβcoordinating drivers, optimizing routes, handling weather delays, and meeting SLAs requires constant human oversight.
|
| 32 |
|
| 33 |
+
**The Solution:** FleetMind exposes **29 AI-accessible tools** that let Claude (or any MCP client) manage your entire delivery operation through natural conversation.
|
| 34 |
|
| 35 |
+
**The Impact:** Dispatch managers can now say *"Assign this urgent fragile delivery to the best available driver considering weather and traffic"* and watch AI handle the complexity.
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
[](https://www.youtube.com/watch?v=demo_video_id)
|
| 38 |
+
[](https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space)
|
| 39 |
+
[](https://github.com/mashrur-rahman-fahim/fleetmind-mcp)
|
| 40 |
|
| 41 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
---
|
| 44 |
|
| 45 |
+
## πΊ See It In Action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
> **π¬ Demo Video:** [Watch FleetMind in action β](https://www.youtube.com/watch?v=demo_video_id)
|
| 48 |
+
>
|
| 49 |
+
> Watch Gemini 2.0 Flash AI analyze weather, traffic, and driver capabilities to make intelligent assignment decisions with full reasoning transparency.
|
| 50 |
|
| 51 |
+
<details>
|
| 52 |
+
<summary><b>πΈ Screenshots (Click to expand)</b></summary>
|
| 53 |
|
| 54 |
+
### Landing Page
|
| 55 |
+

|
| 56 |
+
*Professional web interface with connection instructions and API key generation*
|
|
|
|
|
|
|
| 57 |
|
| 58 |
+
### Claude Desktop Integration
|
| 59 |
+

|
| 60 |
+
*29 tools available in Claude Desktop's tool menu*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
### Intelligent Assignment in Action
|
| 63 |
+

|
| 64 |
+
*Gemini 2.0 Flash analyzing order parameters and driver capabilities*
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
### Weather-Aware Routing
|
| 67 |
+

|
| 68 |
+
*Real-time weather and traffic data affecting route decisions*
|
|
|
|
|
|
|
| 69 |
|
| 70 |
+
</details>
|
| 71 |
|
| 72 |
---
|
| 73 |
|
| 74 |
+
## β‘ Quick Start (2 Minutes)
|
| 75 |
|
| 76 |
+
### Step 1: Get Your API Key
|
| 77 |
+
π **[Generate API Key](https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/generate-key)** (copy immediatelyβshown once!)
|
| 78 |
|
| 79 |
+
### Step 2: Configure Claude Desktop
|
| 80 |
+
Add to your `claude_desktop_config.json`:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
```json
|
| 82 |
{
|
| 83 |
"mcpServers": {
|
|
|
|
| 85 |
"command": "npx",
|
| 86 |
"args": [
|
| 87 |
"mcp-remote",
|
| 88 |
+
"https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/sse?api_key=YOUR_KEY_HERE"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
]
|
| 90 |
}
|
| 91 |
}
|
| 92 |
}
|
| 93 |
```
|
|
|
|
| 94 |
|
| 95 |
+
### Step 3: Start Dispatching!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
```
|
| 97 |
+
You: "Create an urgent delivery for Sarah at 456 Oak Ave, San Francisco,
|
| 98 |
+
then use AI to find the best driver considering the current rain"
|
| 99 |
|
| 100 |
+
Claude: Uses geocode_address β create_order β intelligent_assign_order
|
| 101 |
+
Returns: "Order ORD-... assigned to Mike (DRV-...).
|
| 102 |
+
AI selected Mike because: closest driver with cold-storage van,
|
| 103 |
+
safest route in current weather, 15 min ETA."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
```
|
| 105 |
|
| 106 |
---
|
| 107 |
|
| 108 |
+
## π Why FleetMind?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
+
| Feature | What It Does | Why It Matters |
|
| 111 |
+
|---------|--------------|----------------|
|
| 112 |
+
| **π€ Gemini 2.0 Flash AI** | Analyzes 10+ parameters for intelligent driver assignment | Better decisions than rule-based systems |
|
| 113 |
+
| **π¦οΈ Weather-Aware Routing** | OpenWeatherMap integration for safety-first planning | Reduces weather-related delivery failures |
|
| 114 |
+
| **π Multi-Tenant Auth** | Complete data isolation via deterministic user_id | Enterprise-ready security out of the box |
|
| 115 |
+
| **π SLA Tracking** | Automatic on-time/late/very-late classification | Built-in performance analytics |
|
| 116 |
+
| **π¦ Real-Time Traffic** | Google Routes API with live traffic data | Accurate ETAs, not guesstimates |
|
| 117 |
+
| **ποΈ Vehicle Optimization** | Motorcycle, bicycle, car, van, truck routing | Right routes for each vehicle type |
|
| 118 |
|
| 119 |
---
|
| 120 |
|
| 121 |
+
## π οΈ The 29 Tools
|
| 122 |
+
|
| 123 |
+
<details>
|
| 124 |
+
<summary><b>π Geocoding & Routing (3 tools)</b></summary>
|
| 125 |
+
|
| 126 |
+
| Tool | Description |
|
| 127 |
+
|------|-------------|
|
| 128 |
+
| `geocode_address` | Convert address β GPS coordinates |
|
| 129 |
+
| `calculate_route` | Vehicle-specific routing with traffic, tolls, fuel estimates |
|
| 130 |
+
| `calculate_intelligent_route` | AI-powered routing with weather + traffic analysis |
|
| 131 |
+
|
| 132 |
+
</details>
|
| 133 |
+
|
| 134 |
+
<details>
|
| 135 |
+
<summary><b>π¦ Order Management (8 tools)</b></summary>
|
| 136 |
+
|
| 137 |
+
| Tool | Description |
|
| 138 |
+
|------|-------------|
|
| 139 |
+
| `create_order` | Create delivery with mandatory deadline & SLA tracking |
|
| 140 |
+
| `count_orders` | Count by status/priority with breakdowns |
|
| 141 |
+
| `fetch_orders` | Paginated list with filters |
|
| 142 |
+
| `get_order_details` | Full order info including timing data |
|
| 143 |
+
| `search_orders` | Find by customer name/email/phone/ID |
|
| 144 |
+
| `get_incomplete_orders` | Active deliveries shortcut |
|
| 145 |
+
| `update_order` | Modify order with cascading updates |
|
| 146 |
+
| `delete_order` | Safe deletion with assignment checks |
|
| 147 |
+
|
| 148 |
+
</details>
|
| 149 |
+
|
| 150 |
+
<details>
|
| 151 |
+
<summary><b>π₯ Driver Management (8 tools)</b></summary>
|
| 152 |
+
|
| 153 |
+
| Tool | Description |
|
| 154 |
+
|------|-------------|
|
| 155 |
+
| `create_driver` | Onboard with vehicle type, skills, capacity |
|
| 156 |
+
| `count_drivers` | Count by status/vehicle with breakdowns |
|
| 157 |
+
| `fetch_drivers` | Paginated list with filters |
|
| 158 |
+
| `get_driver_details` | Full info with reverse-geocoded location |
|
| 159 |
+
| `search_drivers` | Find by name/plate/phone/ID |
|
| 160 |
+
| `get_available_drivers` | Ready-for-dispatch shortcut |
|
| 161 |
+
| `update_driver` | Modify with location auto-timestamp |
|
| 162 |
+
| `delete_driver` | Safe deletion with assignment checks |
|
| 163 |
+
|
| 164 |
+
</details>
|
| 165 |
+
|
| 166 |
+
<details>
|
| 167 |
+
<summary><b>π Assignment Management (8 tools) β</b></summary>
|
| 168 |
+
|
| 169 |
+
| Tool | Description |
|
| 170 |
+
|------|-------------|
|
| 171 |
+
| `create_assignment` | Manual driver selection |
|
| 172 |
+
| **`auto_assign_order`** | **Nearest driver + capacity/skill validation** |
|
| 173 |
+
| **`intelligent_assign_order`** | **π€ Gemini 2.0 Flash AI with full reasoning** |
|
| 174 |
+
| `get_assignment_details` | Query by assignment/order/driver ID |
|
| 175 |
+
| `update_assignment` | Status transitions with cascading |
|
| 176 |
+
| `unassign_order` | Revert to pending safely |
|
| 177 |
+
| `complete_delivery` | Mark done + auto-update driver location |
|
| 178 |
+
| `fail_delivery` | Track failure with GPS + structured reason |
|
| 179 |
+
|
| 180 |
+
</details>
|
| 181 |
+
|
| 182 |
+
<details>
|
| 183 |
+
<summary><b>ποΈ Bulk Operations (2 tools)</b></summary>
|
| 184 |
+
|
| 185 |
+
| Tool | Description |
|
| 186 |
+
|------|-------------|
|
| 187 |
+
| `delete_all_orders` | Mass delete with status filter & safety checks |
|
| 188 |
+
| `delete_all_drivers` | Mass delete with assignment safety blocks |
|
| 189 |
+
|
| 190 |
+
</details>
|
| 191 |
|
| 192 |
---
|
| 193 |
|
| 194 |
+
## ποΈ Architecture
|
| 195 |
+
|
| 196 |
+
```
|
| 197 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 198 |
+
β MCP Clients β
|
| 199 |
+
β Claude Desktop β’ Continue β’ Cline β’ Custom Apps β
|
| 200 |
+
βββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
|
| 201 |
+
β SSE: /sse?api_key=fm_xxx
|
| 202 |
+
βΌ
|
| 203 |
+
ββββββββββββββββββββββββββββββββββοΏ½οΏ½οΏ½βββββββββββββββββββββββββββββ
|
| 204 |
+
β Authentication Proxy (proxy.py) β
|
| 205 |
+
β β’ Captures API key from SSE connection β
|
| 206 |
+
β β’ Links session_id β api_key for tool calls β
|
| 207 |
+
β β’ Keep-alive pings every 30s β
|
| 208 |
+
βββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
|
| 209 |
+
βΌ
|
| 210 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 211 |
+
β FastMCP Server (server.py) β
|
| 212 |
+
β β’ ApiKeyAuthMiddleware validates every call β
|
| 213 |
+
β β’ 29 tools with user_id filtering β
|
| 214 |
+
β β’ 2 real-time resources (orders://all, drivers://all) β
|
| 215 |
+
ββββββββββββ¬βββββββββββ¬βββββββββββββ¬βββββββββββ¬βββββββββββββββββ
|
| 216 |
+
βΌ βΌ βΌ βΌ
|
| 217 |
+
ββββββββββββ βββββββββββ ββββββββββββ βββββββββββββ
|
| 218 |
+
βPostgreSQLβ β Google β β Gemini β βOpenWeatherβ
|
| 219 |
+
β (Neon) β βMaps API β β2.0 Flash β β Map API β
|
| 220 |
+
β user_id β βGeocodingβ βIntelligentββ Weather β
|
| 221 |
+
βisolation β β Routing β βAssignmentβ β Data β
|
| 222 |
+
ββββββββββββ βββββββββββ ββββββββββββ βββββββββββββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
```
|
| 224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
---
|
| 226 |
|
| 227 |
+
## π Authentication & Security
|
| 228 |
|
| 229 |
+
FleetMind uses a **3-layer authentication system** for enterprise-grade security:
|
| 230 |
|
| 231 |
+
| Layer | Component | Function |
|
| 232 |
+
|-------|-----------|----------|
|
| 233 |
+
| 1 | **Proxy** | Captures API key from URL, links sessions |
|
| 234 |
+
| 2 | **Middleware** | Validates every tool call, injects user context |
|
| 235 |
+
| 3 | **Database** | All queries filter by `user_id` (complete isolation) |
|
| 236 |
|
| 237 |
+
**Security Features:**
|
| 238 |
+
- β
SHA-256 hashed key storage (never plaintext)
|
| 239 |
+
- β
One-time key display (can't retrieve later)
|
| 240 |
+
- β
Deterministic user_id from email (key rotation preserves data)
|
| 241 |
+
- β
Production safeguards (SKIP_AUTH blocked when ENV=production)
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
+
<details>
|
| 244 |
+
<summary><b>View Complete Auth Flow</b></summary>
|
| 245 |
|
|
|
|
| 246 |
```
|
| 247 |
+
1. Generate API Key β user_id = user_{MD5(email)[:12]}
|
| 248 |
+
2. Configure Claude β URL includes ?api_key=fm_xxx
|
| 249 |
+
3. SSE Connection β Proxy captures and stores key
|
| 250 |
+
4. Tool Call β Proxy injects key, middleware validates
|
| 251 |
+
5. Database Query β WHERE user_id = 'user_xxx'
|
| 252 |
+
6. Result β Only user's own data returned
|
| 253 |
```
|
| 254 |
|
| 255 |
+
</details>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
|
| 257 |
---
|
| 258 |
|
| 259 |
+
## π Deployment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
|
| 261 |
+
### Production (HuggingFace Space)
|
| 262 |
+
Already deployed at: **https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
|
| 264 |
+
### Local Development
|
| 265 |
```bash
|
|
|
|
| 266 |
git clone https://github.com/mashrur-rahman-fahim/fleetmind-mcp.git
|
| 267 |
cd fleetmind-mcp
|
|
|
|
|
|
|
| 268 |
pip install -r requirements.txt
|
| 269 |
|
| 270 |
+
# Configure .env with your API keys
|
| 271 |
+
python start_with_proxy.py # Runs proxy (7860) + FastMCP (7861)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
```
|
| 273 |
|
| 274 |
---
|
| 275 |
|
| 276 |
+
## π Technical Specifications
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
|
| 278 |
+
| Metric | Value |
|
| 279 |
+
|--------|-------|
|
| 280 |
+
| **Tools** | 29 |
|
| 281 |
+
| **Resources** | 2 (orders://all, drivers://all) |
|
| 282 |
+
| **Database** | PostgreSQL (Neon serverless) |
|
| 283 |
+
| **AI Model** | Gemini 2.0 Flash (gemini-2.0-flash-exp) |
|
| 284 |
+
| **Transport** | SSE (Server-Sent Events) |
|
| 285 |
+
| **Framework** | FastMCP 2.13.0 |
|
| 286 |
+
| **Language** | Python 3.10+ |
|
|
|
|
| 287 |
|
| 288 |
---
|
| 289 |
|
| 290 |
+
## π Links
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
|
| 292 |
+
| Resource | URL |
|
| 293 |
+
|----------|-----|
|
| 294 |
+
| **Live Demo** | https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space |
|
| 295 |
+
| **MCP Endpoint** | https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/sse |
|
| 296 |
+
| **Generate API Key** | https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space/generate-key |
|
| 297 |
+
| **GitHub** | https://github.com/mashrur-rahman-fahim/fleetmind-mcp |
|
| 298 |
+
| **HuggingFace Space** | https://huggingface.co/spaces/MCP-1st-Birthday/fleetmind-dispatch-ai |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
---
|
| 301 |
|
| 302 |
+
## π₯ Team
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
|
| 304 |
+
**FleetMind Development Team**
|
| 305 |
|
| 306 |
+
*MCP 1st Birthday Hackathon - Track 1: Building MCP Servers (Enterprise Category)*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
---
|
| 309 |
|
| 310 |
## π License
|
| 311 |
|
| 312 |
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
|
| 314 |
---
|
| 315 |
|
| 316 |
+
<div align="center">
|
| 317 |
|
| 318 |
+
**Built with β€οΈ using [FastMCP](https://gofastmcp.com) for the MCP 1st Birthday Hackathon**
|
|
|
|
| 319 |
|
| 320 |
+
[](https://modelcontextprotocol.io)
|
| 321 |
+
[](https://gofastmcp.com)
|
| 322 |
+
[](https://python.org)
|
| 323 |
|
| 324 |
+
</div>
|