BlackWarTurtle/pk-mcp-testing
If you are the rightful owner of pk-mcp-testing and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
MCP Server for parking is a specialized server designed to manage and optimize parking operations using Model Context Protocol (MCP) technology.
🅿️ Parking Management MCP Server
A comprehensive Model Context Protocol (MCP) server for managing a parking facility with 300 spots across 3 floors using PostgreSQL and Prisma ORM.
📋 Features
- 300 Parking Spots distributed across 3 floors (100 spots per floor)
- PostgreSQL Database with Prisma ORM for reliable data persistence
- Multiple Spot Types: Standard, Disabled, Electric, and VIP
- Vehicle Management: Register and track vehicles with owner information
- Reservation System: Reserve and release parking spots with transaction safety
- Real-time Statistics: Get occupancy rates and availability by floor and type
- 12 MCP Tools for comprehensive parking operations
🏗️ Architecture
┌─────────────────────────────────────────┐
│ MCP Tools Layer │
│ (12 tools for parking operations) │
└──────────────┬──────────────────────────┘
│
┌──────────────▼──────────────────────────┐
│ Services Layer │
│ - ParkingService │
│ - ReservationService │
│ - VehicleService │
│ - InitializationService │
└──────────────┬──────────────────────────┘
│
┌──────────────▼──────────────────────────┐
│ Database Layer │
│ - Prisma Client │
│ - PostgreSQL Database │
└─────────────────────────────────────────┘
🚀 Quick Start
Prerequisites
- Node.js (v18 or higher)
- PostgreSQL (v14 or higher)
- npm or yarn
Installation
-
Clone the repository
git clone https://github.com/BlackWarTurtle/pk-mcp-testing.git cd pk-mcp-testing -
Install dependencies
npm install -
Configure environment variables
cp .env.example .envEdit
.envand update the database connection:DATABASE_URL="postgresql://username:password@localhost:5432/parking_db?schema=public" -
Set up the database
# Generate Prisma client npm run db:generate # Run database migrations npm run db:migrate -
Start the server
npm start
🛠️ Available MCP Tools
Initialization Tools
initialize_parking- Initialize 300 parking spots across 3 floorsget_database_status- Check database status and statisticsreset_database- Reset and reinitialize the entire system
Parking Spot Tools
register_parking_spot- Manually register a new parking spotget_available_spots- Query available spots with filters (floor, type)get_spot_status- Get detailed information about a specific spotlist_all_spots- List all spots with optional filtersget_parking_statistics- Get comprehensive parking statistics
Reservation Tools
reserve_spot- Reserve a parking spot for a vehiclerelease_spot- Release a spot and end the parking sessionget_active_reservations- List all active reservations
Vehicle Tools
register_vehicle- Register a new vehicle in the systemget_vehicle_info- Get vehicle details and parking history
📊 Database Schema
ParkingSpot
- Spot number (e.g., "1-001", "2-050")
- Floor (1-3)
- Status (AVAILABLE, OCCUPIED, RESERVED, MAINTENANCE)
- Type (STANDARD, DISABLED, ELECTRIC, VIP)
Vehicle
- License plate (unique)
- Owner name and phone
- Vehicle type
Reservation
- Links vehicle to parking spot
- Start and end times
- Status (ACTIVE, COMPLETED, CANCELLED)
📝 Usage Examples
Initialize the Parking System
// Call the initialize_parking tool
// This creates 300 spots across 3 floors
Reserve a Parking Spot
// Call reserve_spot with:
{
"spotNumber": "1-001",
"licensePlate": "ABC123",
"ownerName": "John Doe",
"ownerPhone": "+34600111222",
"vehicleType": "sedan"
}
Get Available Spots on Floor 2
// Call get_available_spots with:
{
"floor": 2
}
Release a Parking Spot
// Call release_spot with:
{
"spotNumber": "1-001"
}
Get Parking Statistics
// Call get_parking_statistics
// Returns overall stats, stats by floor, and stats by type
🗂️ Project Structure
pk-mcp-testing/
├── config/
│ ├── constants.js # System constants and enums
│ └── database.js # Prisma client singleton
├── prisma/
│ └── schema.prisma # Database schema
├── services/
│ ├── parkingService.js # Parking spot operations
│ ├── reservationService.js # Reservation management
│ ├── vehicleService.js # Vehicle tracking
│ └── initializationService.js # Database initialization
├── tools/
│ └── parkingTools.js # MCP tool registrations
├── utils/
│ └── errorHandler.js # Custom error classes
├── .env # Environment variables
├── .env.example # Environment template
├── package.json # Dependencies and scripts
├── server.js # Main server entry point
└── README.md # This file
🔧 Development
Available Scripts
npm start- Start the MCP servernpm run dev- Start with auto-reload on file changesnpm run db:generate- Generate Prisma clientnpm run db:migrate- Run database migrationsnpm run db:push- Push schema changes to databasenpm run db:studio- Open Prisma Studio (database GUI)
Database Management
View database in Prisma Studio:
npm run db:studio
Reset database:
Use the reset_database MCP tool or manually:
npx prisma migrate reset
🎯 Spot Distribution
Each floor has 100 spots with the following distribution:
- 5 spots for disabled parking (001-005)
- 10 spots for electric vehicles (006-015)
- 5 spots for VIP (016-020)
- 80 spots standard parking (021-100)
Spot numbering format: {Floor}-{Number} (e.g., "1-001", "2-050", "3-100")
🔒 Error Handling
The system includes comprehensive error handling:
SpotNotFoundError- Parking spot doesn't existSpotNotAvailableError- Spot is already occupiedVehicleNotFoundError- Vehicle not registeredInvalidFloorError- Floor number out of rangeDuplicateSpotError- Spot already existsDuplicateVehicleError- Vehicle already registered
📄 License
ISC
👤 Author
BlackWarTurtle
🤝 Contributing
Contributions, issues, and feature requests are welcome!
⭐ Show your support
Give a ⭐️ if this project helped you!