mashrur950 commited on
Commit
0bd0fd1
Β·
1 Parent(s): 5d901a6

update readme file

Browse files
Files changed (1) hide show
  1. README.md +205 -907
README.md CHANGED
@@ -22,224 +22,62 @@ tags:
22
  - ai-routing
23
  ---
24
 
25
- # 🚚 FleetMind MCP Server
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
- [![FastMCP](https://img.shields.io/badge/FastMCP-2.13.0-blue)](https://github.com/jlowin/fastmcp)
32
- [![Python](https://img.shields.io/badge/Python-3.10%2B-brightgreen)](https://www.python.org/)
33
- [![MCP](https://img.shields.io/badge/MCP-1.0-orange)](https://modelcontextprotocol.io)
34
-
35
- ---
36
 
37
- ## πŸ”— Links
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
- ## πŸ‘₯ Team
55
 
56
- **FleetMind Development Team**
57
 
58
- This project is submitted as part of the **MCP 1st Birthday Hackathon** (Track 1: Building MCP - Enterprise Category).
59
 
60
- **Team Information:**
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
- ## 🎯 What is FleetMind MCP?
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
- ## πŸ—οΈ System Architecture
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
- ## πŸ† Why Track 1: Building MCP Servers (Enterprise Category)?
 
 
184
 
185
- FleetMind demonstrates **enterprise-grade MCP server development** with cutting-edge AI integration and production-ready architecture:
 
186
 
187
- ### πŸ€– Advanced AI Integration
188
- - **Gemini 2.0 Flash** - Latest Google AI model for intelligent decision-making
189
- - **Weather-Aware Routing** - OpenWeatherMap API integration for safety-first planning
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
- ### 🏒 Enterprise-Ready Features
194
- - **PostgreSQL Database** - Production-grade data storage with Neon serverless PostgreSQL
195
- - **Multi-Tenant Isolation** - Complete data separation per user via deterministic user_id
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
- ### πŸš€ Production Deployment
202
- - **HuggingFace Space** - Live production deployment with public SSE endpoint
203
- - **Docker Containerization** - Reproducible deployment with Python 3.11 slim base
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
- ### πŸ“Š Innovation & Complexity
208
- - **Vehicle-Specific Optimization** - Motorcycle/Bicycle/Car/Van/Truck routing with toll detection
209
- - **Structured Failure Tracking** - 9 failure reason categories for analytics and reporting
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
- FleetMind isn't just an MCP serverβ€”it's a **blueprint for enterprise AI integration** showcasing how MCP can transform complex logistics workflows into AI-accessible tools.
214
 
215
  ---
216
 
217
- ## πŸš€ Quick Start
218
 
219
- ### Connect from Claude Desktop
 
220
 
221
- #### **Step 1: Get Your API Key** πŸ”‘
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=fm_your_api_key_here"
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
- **Both (Production + Local):**
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
- #### **Step 4: Restart Claude Desktop**
315
-
316
- Restart Claude Desktop - FleetMind tools will appear automatically!
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
- ## πŸ› οΈ Available Tools (29 Total)
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
- **Example:**
424
- ```
425
- "Which drivers are currently available?"
426
- ```
 
 
 
 
427
 
428
  ---
429
 
430
- ## πŸ”§ Technology Stack
431
-
432
- **MCP Framework:**
433
- - FastMCP 2.13.0 - MCP server implementation
434
- - Model Context Protocol 1.0 - Standardized AI tool protocol
435
-
436
- **AI & APIs:**
437
- - Google Gemini 2.0 Flash (gemini-2.0-flash-exp) - Intelligent assignment
438
- - Google Routes API - Real-time traffic routing
439
- - Google Directions API - Fallback routing
440
- - Google Geocoding API - Address conversion
441
- - OpenWeatherMap API - Weather data integration
442
-
443
- **Backend:**
444
- - Python 3.10+ - Server runtime
445
- - PostgreSQL (Neon) - Production database
446
- - SSE (Server-Sent Events) - Web transport
447
- - Docker - Containerized deployment
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
 
449
  ---
450
 
451
- ## πŸ—οΈ Detailed Architecture
452
-
453
- ```
454
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
455
- β”‚ MCP Clients β”‚
456
- β”‚ (Claude Desktop, Continue, Cline, Custom Applications) β”‚
457
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
458
- β”‚
459
- β”‚ SSE Connection: /sse?api_key=fm_xxx
460
- ↓
461
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
462
- β”‚ Authentication Proxy (port 7860) β”‚
463
- β”‚ proxy.py β”‚
464
- β”‚ β€’ Captures api_key from SSE connection URL β”‚
465
- β”‚ β€’ Links session_id β†’ api_key β”‚
466
- β”‚ β€’ Injects api_key into tool call requests β”‚
467
- β”‚ β€’ SSE keep-alive pings (30s intervals) β”‚
468
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
469
- β”‚
470
- ↓
471
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
472
- β”‚ FastMCP Server (port 7861) β”‚
473
- β”‚ server.py + app.py β”‚
474
- β”‚ β€’ ApiKeyAuthMiddleware - validates every tool call β”‚
475
- β”‚ β€’ 29 MCP tools (Order/Driver/Assignment management) β”‚
476
- β”‚ β€’ 2 MCP resources (orders://all, drivers://all) β”‚
477
- β”‚ β€’ User context injection via FastMCP state β”‚
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
- ## πŸ“– Usage Examples
503
 
504
- ### Example 1: Create & Assign Order
505
 
506
- **Prompt:**
507
- ```
508
- Create an urgent delivery for Sarah Johnson at 456 Oak Ave, San Francisco CA.
509
- Phone: 555-1234. Then assign it to the nearest available driver.
510
- ```
511
 
512
- **What happens:**
513
- 1. Claude calls `geocode_address("456 Oak Ave, San Francisco CA")`
514
- 2. Gets coordinates: `(37.7749, -122.4194)`
515
- 3. Calls `create_order(...)` with all details
516
- 4. Calls `get_available_drivers(limit=10)`
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
- ### Example 2: Track Active Deliveries
 
522
 
523
- **Prompt:**
524
  ```
525
- Show me all urgent orders that are currently in transit, sorted by deadline.
 
 
 
 
 
526
  ```
527
 
528
- **What happens:**
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
- ## πŸ—„οΈ Database Schema
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
- ### Drivers Table (15 columns)
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 environment
614
- cp .env.example .env
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
- ## πŸš€ Deployment to HuggingFace Space
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
- 4. **Push to GitHub** - Space auto-updates via GitHub Actions!
695
-
696
- ### Manual Deployment
697
-
698
- Upload files directly to HF Space:
699
- - `app.py` (entry point)
700
- - `server.py` (MCP server)
701
- - `requirements.txt`
702
- - `chat/`, `database/` directories
703
- - `.env` (configure secrets in HF Space settings instead)
704
 
705
  ---
706
 
707
- ## πŸ”’ Authentication & Security
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
- Optional:
958
- ```bash
959
- # Server configuration
960
- PORT=7860
961
- HOST=0.0.0.0
962
- LOG_LEVEL=INFO
963
- SERVER_URL=http://localhost:7860
964
-
965
- # Authentication
966
- SKIP_AUTH=true # Set to false for production
967
- ```
968
 
969
  ---
970
 
971
- ## πŸ† Why FleetMind for Track 1?
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
- ### Technical Excellence βœ…
991
 
992
- - **882 lines** of well-structured MCP server code
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 file for details.
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
- ## πŸ“ž Support
1018
 
1019
- - **Issues:** https://github.com/mashrur-rahman-fahim/fleetmind-mcp/issues
1020
- - **Hackathon:** https://huggingface.co/MCP-1st-Birthday
1021
 
1022
- ---
1023
-
1024
- **Built with ❀️ using [FastMCP](https://github.com/jlowin/fastmcp) for the MCP 1st Birthday Hackathon**
1025
 
1026
- **Track 1: Building MCP Servers - Enterprise Category**
 
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
+ [![Demo Video](https://img.shields.io/badge/β–Ά_Watch_Demo-FF0000?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/watch?v=demo_video_id)
38
+ [![Try It Live](https://img.shields.io/badge/πŸš€_Try_It_Live-7C3AED?style=for-the-badge)](https://mcp-1st-birthday-fleetmind-dispatch-ai.hf.space)
39
+ [![GitHub](https://img.shields.io/badge/GitHub-181717?style=for-the-badge&logo=github)](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
+ ![FleetMind Landing Page](screenshots/landing-page.png)
56
+ *Professional web interface with connection instructions and API key generation*
 
 
57
 
58
+ ### Claude Desktop Integration
59
+ ![Claude Desktop with FleetMind](screenshots/claude-desktop.png)
60
+ *29 tools available in Claude Desktop's tool menu*
 
 
 
 
61
 
62
+ ### Intelligent Assignment in Action
63
+ ![AI Assignment](screenshots/ai-assignment.png)
64
+ *Gemini 2.0 Flash analyzing order parameters and driver capabilities*
 
 
65
 
66
+ ### Weather-Aware Routing
67
+ ![Weather Routing](screenshots/weather-routing.png)
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
+ [![MCP](https://img.shields.io/badge/MCP-1.0-orange)](https://modelcontextprotocol.io)
321
+ [![FastMCP](https://img.shields.io/badge/FastMCP-2.13.0-blue)](https://gofastmcp.com)
322
+ [![Python](https://img.shields.io/badge/Python-3.10+-brightgreen)](https://python.org)
323
 
324
+ </div>