The Miles Booking API now supports the Model Context Protocol (MCP), allowing AI assistants like Claude to interact with the booking system programmatically.
MCP is a protocol that enables AI assistants to:
- Call tools (write operations like creating/updating bookings)
- Access resources (read operations like viewing locations and availability)
- Stream updates via Server-Sent Events (SSE)
All MCP endpoints are available under:
/api/mcp
Get information about the MCP server and its capabilities.
Endpoint: GET /api/mcp/info
Response:
{
"name": "miles-booking-api",
"version": "1.0.0",
"description": "Model Context Protocol server for Miles Booking API",
"capabilities": {
"tools": true,
"resources": true
},
"protocol": "mcp",
"protocolVersion": "1.0"
}View all tools that can be called via MCP.
Endpoint: GET /api/mcp/tools
Response:
{
"success": true,
"count": 7,
"tools": [
{
"name": "create_booking",
"description": "Create a new room booking...",
"inputSchema": { ... }
},
...
]
}Execute a specific tool with parameters.
Endpoint: POST /api/mcp/tools/:toolName
Example: Create a booking
curl -X POST http://localhost:3000/api/mcp/tools/create_booking \
-H "Content-Type: application/json" \
-d '{
"userId": "user123",
"roomId": "room456",
"startTime": "2025-10-20T14:00:00Z",
"endTime": "2025-10-20T15:00:00Z",
"title": "Team Meeting",
"description": "Weekly standup"
}'Response:
{
"content": [
{
"type": "text",
"text": "{\"success\":true,\"booking\":{...}}"
}
]
}View all resources that can be accessed via MCP.
Endpoint: GET /api/mcp/resources
Response:
{
"success": true,
"count": 10,
"resources": [
{
"uri": "miles://locations",
"name": "All Locations",
"description": "List of all office locations",
"mimeType": "application/json"
},
...
]
}Access a specific resource by its URI.
Endpoint: GET /api/mcp/resources/*
Examples:
Get all locations:
curl http://localhost:3000/api/mcp/resources/locationsGet specific location:
curl http://localhost:3000/api/mcp/resources/locations/loc123Check room availability:
curl "http://localhost:3000/api/mcp/resources/rooms/room456/availability?startTime=2025-10-20T14:00:00Z&endTime=2025-10-20T15:00:00Z"Get calendar feed (iCal):
curl http://localhost:3000/api/mcp/resources/calendar/location/loc123Send JSON-RPC messages for programmatic access.
Endpoint: POST /api/mcp/messages
Example: Initialize connection
curl -X POST http://localhost:3000/api/mcp/messages \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {}
}'Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "1.0",
"serverInfo": {
"name": "miles-booking-api",
"version": "1.0.0"
},
"capabilities": {
"tools": {},
"resources": {}
}
}
}Stream real-time updates from the MCP server.
Endpoint: GET /api/mcp/sse
Example:
curl -N http://localhost:3000/api/mcp/sseResponse Stream:
data: {"type":"connection","status":"connected","serverInfo":{...}}
data: {"type":"heartbeat","timestamp":"2025-10-19T14:30:00.000Z"}
Create a new room booking.
Parameters:
userId(string, required): User IDroomId(string, required): Room IDstartTime(string, required): Start time (ISO 8601)endTime(string, required): End time (ISO 8601)title(string, required): Booking titledescription(string, optional): Additional details
Update an existing booking.
Parameters:
bookingId(string, required): Booking ID to updateuserId(string, required): User making the changestartTime(string, optional): New start timeendTime(string, optional): New end timetitle(string, optional): New titledescription(string, optional): New description
Cancel a booking (sets status to CANCELLED).
Parameters:
bookingId(string, required): Booking ID to canceluserId(string, required): User cancelling the booking
Create a new room in a location.
Parameters:
userId(string, required): User creating the room (ADMIN or MANAGER)name(string, required): Room namelocationId(string, required): Location IDcapacity(number, required): Room capacityamenities(array, optional): List of amenitiesdescription(string, optional): Room descriptionisActive(boolean, optional): Active status
Update an existing room.
Parameters:
roomId(string, required): Room ID to updateuserId(string, required): User making the change- Plus any optional fields from create_room
Smart tool to find available rooms based on criteria.
Parameters:
startTime(string, required): Desired start timeendTime(string, required): Desired end timelocationId(string, optional): Filter by locationcapacity(number, optional): Minimum capacityamenities(array, optional): Required amenities
AI-powered tool that suggests the next available time slot for a room.
Parameters:
roomId(string, required): Room to find availability forduration(number, required): Duration in minutespreferredDate(string, optional): Preferred start date
miles://locations- All locationsmiles://locations/{locationId}- Specific location details
miles://rooms- All roomsmiles://rooms/{roomId}- Specific room detailsmiles://rooms/{roomId}/availability?startTime=...&endTime=...- Room availability
miles://bookings?userId=...&locationId=...&roomId=...&status=...- Filtered bookingsmiles://bookings/{bookingId}- Specific booking details
miles://calendar/location/{locationId}- All bookings for a locationmiles://calendar/room/{roomId}- All bookings for a roommiles://calendar/user/{userId}- All bookings for a user
# Step 1: Find available rooms
curl "http://localhost:3000/api/mcp/tools/find_available_rooms" \
-X POST -H "Content-Type: application/json" \
-d '{
"startTime": "2025-10-20T14:00:00Z",
"endTime": "2025-10-20T15:00:00Z",
"capacity": 6,
"amenities": ["projector", "whiteboard"]
}'
# Step 2: Create booking
curl "http://localhost:3000/api/mcp/tools/create_booking" \
-X POST -H "Content-Type: application/json" \
-d '{
"userId": "user123",
"roomId": "room456",
"startTime": "2025-10-20T14:00:00Z",
"endTime": "2025-10-20T15:00:00Z",
"title": "Product Planning",
"description": "Q4 roadmap discussion"
}'curl "http://localhost:3000/api/mcp/tools/suggest_booking_time" \
-X POST -H "Content-Type: application/json" \
-d '{
"roomId": "room456",
"duration": 60,
"preferredDate": "2025-10-20"
}'curl "http://localhost:3000/api/mcp/resources/calendar/location/loc123" \
-o office-calendar.icsTo use this MCP server with Claude:
- Via HTTP API: Use the endpoints above directly
- Via MCP Client: Configure an MCP client to connect to
http://localhost:3000/api/mcp - Via SSE Stream: Connect to
/api/mcp/ssefor real-time updates
{
"mcpServers": {
"miles-booking": {
"url": "http://localhost:3000/api/mcp",
"type": "http"
}
}
}The MCP endpoints currently use the same authentication as the REST API:
- Tools that modify data check user permissions (ADMIN, MANAGER, USER roles)
- Resources are generally read-only and accessible based on user context
- For production use, add JWT bearer token authentication to MCP endpoints
MCP endpoints return errors in consistent formats:
Tool Errors:
{
"content": [
{
"type": "text",
"text": "{\"error\":\"Room not found\"}"
}
]
}JSON-RPC Errors:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32603,
"message": "Internal error: ..."
}
}The MCP server runs alongside the main API:
npm run devUse the provided examples above with curl, or use an MCP client library.
To add new tools:
- Add tool schema to
src/mcp/tools.tsinregisterTools() - Implement tool logic in the same file
- Add to
callTool()switch statement
To add new resources:
- Add resource definition to
src/mcp/resources.tsinlistResources() - Implement resource reader in
readResource()
Want to interact with the booking system through natural language? Check out the Miles Booking Chat Assistant!
The chat-app provides an AI-powered chat interface using Ollama that connects to this MCP server:
cd ../chat-app
npm install
npm startVisit Chat App Documentation for more details.