File size: 13,934 Bytes
d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6b34b01 6eba330 6b34b01 d69447e 6eba330 0e59aa0 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 d69447e 6eba330 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 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 |
---
title: FleetMind MCP Server
emoji: π
colorFrom: blue
colorTo: purple
sdk: docker
app_file: app.py
pinned: false
tags:
- mcp
- building-mcp-servers
- model-context-protocol
- delivery-management
- postgresql
- fastmcp
- enterprise
- logistics
---
# π FleetMind MCP Server
**π MCP 1st Birthday Hackathon - Track 1: Building MCP Servers (Enterprise Category)**
Industry-standard Model Context Protocol server for AI-powered delivery dispatch management. Exposes 18 AI tools and 2 real-time resources for managing delivery operations through any MCP-compatible client.
[](https://github.com/jlowin/fastmcp)
[](https://www.python.org/)
[](https://modelcontextprotocol.io)
---
## π Links
- **GitHub Repository:** https://github.com/mashrur-rahman-fahim/fleetmind-mcp
- **HuggingFace Space:** https://huggingface.co/spaces/MCP-1st-Birthday/fleetmind-dispatch-ai
- **SSE Endpoint:** `https://huggingface.co/spaces/MCP-1st-Birthday/fleetmind-dispatch-ai/sse`
---
## π₯ Team
**Team Members:**
- **[Your Name]** - [@your-hf-username](https://huggingface.co/your-hf-username) - Lead Developer
- **[Partner Name]** - [@partner-username](https://huggingface.co/partner-username) - [Role]
*(Note: Update with actual team information for hackathon submission)*
---
## π― What is FleetMind MCP?
FleetMind is a production-ready **Model Context Protocol (MCP) server** that transforms delivery dispatch management into AI-accessible tools. Any MCP client (Claude Desktop, Continue, Cline, custom apps) can connect and use 18 powerful tools to manage orders, drivers, routes, and more.
### Key Features
β
**18 AI Tools** - Order & Driver Management
β
**2 Real-Time Resources** - Live data feeds (orders://all, drivers://all)
β
**Google Maps Integration** - Geocoding & Route Calculation
β
**PostgreSQL Database** - Production-grade data storage (Neon)
β
**SSE Endpoint** - Server-Sent Events for web connectivity
β
**Multi-Client Support** - Works with any MCP-compatible client
---
## π Quick Start
### Connect from Claude Desktop
1. **Install Claude Desktop** from https://claude.ai/download
2. **Configure MCP Server** - Edit your `claude_desktop_config.json`:
```json
{
"mcpServers": {
"fleetmind": {
"url": "https://huggingface.co/spaces/MCP-1st-Birthday/fleetmind-dispatch-ai/sse"
}
}
}
```
3. **Restart Claude Desktop** - FleetMind tools will appear automatically!
4. **Try it out:**
- "Create an urgent delivery order for Sarah at 456 Oak Ave, San Francisco"
- "Show me all available drivers"
- "Calculate route from downtown SF to Oakland Airport"
### Connect from VS Code (Continue)
1. Install Continue extension
2. Add FleetMind to MCP servers in settings
3. Use tools directly in your editor
### Connect from Custom App
```python
import mcp
client = mcp.Client(
url="https://huggingface.co/spaces/MCP-1st-Birthday/fleetmind-dispatch-ai/sse"
)
# Use any of the 18 tools
result = client.call_tool("create_order", {
"customer_name": "John Doe",
"delivery_address": "123 Main St, SF CA 94102",
"delivery_lat": 37.7749,
"delivery_lng": -122.4194
})
```
---
## π οΈ Available Tools (18 Total)
### Order Management (10 tools)
| Tool | Description | Example Use |
|------|-------------|-------------|
| `geocode_address` | Convert address to GPS coordinates | "Geocode 123 Main St, San Francisco" |
| `calculate_route` | Find shortest route between locations | "Route from SF City Hall to Oakland Airport" |
| `create_order` | Create new delivery orders | "Create delivery for Sarah at 456 Oak Ave" |
| `count_orders` | Count orders with filters | "How many urgent orders are pending?" |
| `fetch_orders` | Retrieve orders with pagination | "Show me the 10 most recent orders" |
| `get_order_details` | Get complete order information | "Show details for order ORD-20251114..." |
| `search_orders` | Search by customer/ID | "Find orders for customer John Smith" |
| `get_incomplete_orders` | List active deliveries | "Show all orders not yet delivered" |
| `update_order` | Update order details | "Mark order ORD-... as delivered" |
| `delete_order` | Permanently remove orders | "Delete test order ORD-TEST-001" |
### Driver Management (8 tools)
| Tool | Description | Example Use |
|------|-------------|-------------|
| `create_driver` | Onboard new drivers | "Add driver Mike with plate ABC-123" |
| `count_drivers` | Count drivers with filters | "How many active drivers are online?" |
| `fetch_drivers` | Retrieve drivers with pagination | "List all drivers sorted by name" |
| `get_driver_details` | Get driver info + location | "Show details for driver DRV-..." |
| `search_drivers` | Search by name/plate/ID | "Find driver with plate XYZ-789" |
| `get_available_drivers` | List drivers ready for dispatch | "Show available drivers near downtown" |
| `update_driver` | Update driver information | "Update driver DRV-... status to busy" |
| `delete_driver` | Remove drivers from fleet | "Remove driver DRV-TEST-001" |
---
## π Real-Time Resources (2 Total)
### `orders://all`
Live orders dataset (last 30 days, max 1000 orders)
**Example:**
```
"What's the status of recent orders?"
```
Claude automatically accesses this resource to provide context-aware answers.
### `drivers://all`
Live drivers dataset with current locations
**Example:**
```
"Which drivers are currently available?"
```
---
## ποΈ Architecture
```
βββββββββββββββββββββββββββββββββββββββββββ
β MCP Clients β
β (Claude Desktop, Continue, Custom) β
βββββββββββββββββββ¬ββββββββββββββββββββββββ
β MCP Protocol (SSE)
β
βββββββββββββββββββββββββββββββββββββββββββ
β FleetMind MCP Server (HF Space) β
β β’ app.py (SSE endpoint) β
β β’ server.py (18 tools, 2 resources) β
βββββββββββββββββββ¬ββββββββββββββββββββββββ
β
βββββββββββ΄βββββββββββ
β β
βββββββββββββββββ ββββββββββββββββ
β Google Maps β β PostgreSQL β
β Geocoding API β β Database β
β Directions APIβ β (Neon) β
βββββββββββββββββ ββββββββββββββββ
```
**Benefits of MCP Architecture:**
- β
Multi-client support (use from Claude, VS Code, mobile apps)
- β
Standardized protocol (MCP is industry-standard)
- β
Real-time data access (resources provide live context)
- β
Tool composability (AI combines tools intelligently)
- β
Easy integration (any MCP client can connect)
---
## π Usage Examples
### Example 1: Create & Assign Order
**Prompt:**
```
Create an urgent delivery for Sarah Johnson at 456 Oak Ave, San Francisco CA.
Phone: 555-1234. Then assign it to the nearest available driver.
```
**What happens:**
1. Claude calls `geocode_address("456 Oak Ave, San Francisco CA")`
2. Gets coordinates: `(37.7749, -122.4194)`
3. Calls `create_order(...)` with all details
4. Calls `get_available_drivers(limit=10)`
5. Calls `calculate_route(...)` for each driver to find nearest
6. Calls `update_order(...)` to assign driver
7. Returns: "Order ORD-... created and assigned to John Smith (DRV-...), 5.2 km away, ETA 12 mins"
### Example 2: Track Active Deliveries
**Prompt:**
```
Show me all urgent orders that are currently in transit, sorted by deadline.
```
**What happens:**
1. Claude calls `fetch_orders(status="in_transit", priority="urgent", sort_by="time_window_end")`
2. Returns formatted list with customer names, addresses, drivers, and ETAs
### Example 3: Driver Management
**Prompt:**
```
How many drivers do we have available right now? Where are they located?
```
**What happens:**
1. Claude accesses `drivers://all` resource automatically
2. Filters for `status="active"`
3. Calls `get_driver_details(...)` for location addresses
4. Returns summary with driver count and locations
---
## ποΈ Database Schema
### Orders Table (26 columns)
```sql
CREATE TABLE orders (
order_id VARCHAR(50) PRIMARY KEY,
customer_name VARCHAR(255) NOT NULL,
customer_phone VARCHAR(20),
customer_email VARCHAR(255),
delivery_address TEXT NOT NULL,
delivery_lat DECIMAL(10,8),
delivery_lng DECIMAL(11,8),
status VARCHAR(20) CHECK (status IN ('pending','assigned','in_transit','delivered','failed','cancelled')),
priority VARCHAR(20) CHECK (priority IN ('standard','express','urgent')),
time_window_end TIMESTAMP,
assigned_driver_id VARCHAR(50),
weight_kg DECIMAL(10,2),
special_instructions TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
-- ... additional fields
);
```
### Drivers Table (15 columns)
```sql
CREATE TABLE drivers (
driver_id VARCHAR(50) PRIMARY KEY,
name VARCHAR(255) NOT NULL,
phone VARCHAR(20),
email VARCHAR(255),
status VARCHAR(20) CHECK (status IN ('active','busy','offline','unavailable')),
vehicle_type VARCHAR(50),
vehicle_plate VARCHAR(20),
capacity_kg DECIMAL(10,2),
current_lat DECIMAL(10,8),
current_lng DECIMAL(11,8),
last_location_update TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
```
---
## π§ Local Development
### Prerequisites
- Python 3.10+
- PostgreSQL database (or use Neon serverless)
- Google Maps API key
### Setup
```bash
# Clone repository
git clone https://github.com/mashrur-rahman-fahim/fleetmind-mcp.git
cd fleetmind-mcp
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your credentials:
# DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD
# GOOGLE_MAPS_API_KEY
# Test server
python -c "import server; print('Server ready!')"
# Run locally (stdio mode for Claude Desktop)
python server.py
# Run locally (SSE mode for web clients)
python app.py
```
### Testing
```bash
# Test with MCP Inspector
npx @modelcontextprotocol/inspector python server.py
# Test with Claude Desktop
# Add to claude_desktop_config.json:
{
"mcpServers": {
"fleetmind-local": {
"command": "python",
"args": ["F:\\path\\to\\fleetmind-mcp\\server.py"]
}
}
}
```
---
## π Deployment to HuggingFace Space
This project is designed for **Track 1: Building MCP Servers** deployment on HuggingFace Spaces.
### Automatic Deployment
1. **Fork this repository** to your GitHub account
2. **Create HuggingFace Space:**
- Go to https://huggingface.co/new-space
- Name: `fleetmind-mcp` (or your choice)
- SDK: Docker
- Link to GitHub repository
3. **Configure Secrets** in HF Space settings:
- `DB_HOST` - PostgreSQL host
- `DB_PORT` - PostgreSQL port (5432)
- `DB_NAME` - Database name
- `DB_USER` - Database user
- `DB_PASSWORD` - Database password
- `GOOGLE_MAPS_API_KEY` - Google Maps API key
4. **Push to GitHub** - Space auto-updates via GitHub Actions!
### Manual Deployment
Upload files directly to HF Space:
- `app.py` (entry point)
- `server.py` (MCP server)
- `requirements.txt`
- `chat/`, `database/` directories
- `.env` (configure secrets in HF Space settings instead)
---
## π Environment Variables
Required:
```bash
# Database (PostgreSQL/Neon)
DB_HOST=your-postgres-host.neon.tech
DB_PORT=5432
DB_NAME=fleetmind
DB_USER=your_user
DB_PASSWORD=your_password
# Google Maps API
GOOGLE_MAPS_API_KEY=your_api_key
```
Optional:
```bash
# Server configuration
PORT=7860
HOST=0.0.0.0
LOG_LEVEL=INFO
```
---
## π Why FleetMind for Track 1?
### Production-Ready MCP Server β
- **Real Business Value:** Solves actual delivery dispatch problems
- **18 Tools:** Comprehensive order & driver management
- **2 Resources:** Live data feeds for contextual AI responses
- **Industry Standard:** Uses FastMCP framework and MCP protocol
- **Scalable:** PostgreSQL database, stateless design
- **Well-Documented:** Comprehensive API reference and examples
### Enterprise Category Perfect Fit β
- **Complex Operations:** Order creation, assignment, routing, tracking
- **External Integrations:** Google Maps API (geocoding + directions)
- **Database Operations:** Production PostgreSQL with 6 tables
- **Real-Time Data:** Live resources for orders and drivers
- **Multi-Tool Workflows:** Tools compose together (geocode β create β assign)
### Technical Excellence β
- **882 lines** of well-structured MCP server code
- **2,099 lines** of battle-tested tool handlers
- **Type hints** throughout for reliability
- **Error handling** with graceful fallbacks
- **Logging infrastructure** for debugging
- **SSE transport** for web connectivity
---
## π License
MIT License - see LICENSE file for details.
---
## π€ Contributing
Contributions welcome! Please:
1. Fork the repository
2. Create a feature branch
3. Commit your changes
4. Push and open a Pull Request
---
## π Support
- **Issues:** https://github.com/mashrur-rahman-fahim/fleetmind-mcp/issues
- **Hackathon:** https://huggingface.co/MCP-1st-Birthday
---
**Built with β€οΈ using [FastMCP](https://github.com/jlowin/fastmcp) for the MCP 1st Birthday Hackathon**
**Track 1: Building MCP Servers - Enterprise Category**
|