Multi-Domain Booking MCP Server

Multi-Domain Booking MCP Server

Enables booking for movies, flights, trains, and buses with a 2-step confirmation flow and idempotency keys.

Category
Visit Server

README

Multi-Domain Booking MCP Server

A production-ready Model Context Protocol (MCP) server demonstrating a scalable, extensible architecture for multi-domain booking. Supports 4 domains (Movies, Flights, Trains, Buses) with 20 tools (5 per domain).

🎯 Quick Overview

Feature Details
Domains Movies, Flights, Trains, Buses
Total Tools 20 (5 per domain)
Pattern Thin-wrapper connector pattern
Safety 2-step confirmation + idempotency keys
State Conversation-scoped in-memory store
Framework NitroStack + TypeScript
Status βœ… Production Ready

πŸ“š Documentation

Getting Started

Architecture & Implementation


πŸš€ Quick Start

Installation

npm install
npm run build

Running the Server

npm start

The server will be available as an MCP endpoint.


🎬 Domains at a Glance

1. Movies

  • Tools: search_movies, get_movie_details, hold_movie_tickets, confirm_movie_booking, cancel_movie_booking
  • Mock Data: 3 movies in NYC
  • Price Range: $14.99–$16.99 per ticket
  • File: src/modules/booking/movies-connector.tools.ts

2. Flights

  • Tools: search_flights, get_flight_details, hold_flight_seats, confirm_flight_booking, cancel_flight_booking
  • Mock Data: 4 flights (NYC↔LAX)
  • Price Range: $189.99–$249.99 per passenger
  • File: src/modules/booking/flights-connector.tools.ts

3. Trains

  • Tools: search_trains, get_train_details, hold_train_seats, confirm_train_booking, cancel_train_booking
  • Mock Data: 4 trains (Amtrak)
  • Price Range: $89.99–$139.99 per passenger
  • File: src/modules/booking/train-connector.tools.ts

4. Buses

  • Tools: search_buses, get_bus_details, hold_bus_seats, confirm_bus_booking, cancel_bus_booking
  • Mock Data: 4 buses (Greyhound/Megabus)
  • Price Range: $24.99–$49.99 per passenger
  • File: src/modules/booking/bus-connector.tools.ts

πŸ”§ Architecture

Core Components

Intent Router
    ↓
    β”œβ”€β†’ Movies Connector (5 tools)
    β”œβ”€β†’ Flights Connector (5 tools)
    β”œβ”€β†’ Trains Connector (5 tools)
    └─→ Buses Connector (5 tools)
    ↓
State Store Service (conversation-scoped)
    ↓
Response Formatter Service (standardized JSON)

The 5-Tool Pattern

Every domain exposes exactly 5 tools:

  1. search β€” Find available items
  2. get_details β€” Retrieve detailed information
  3. hold β€” Reserve item (step 1 of 2-step confirm)
  4. confirm β€” Execute booking (step 2 of 2-step confirm)
  5. cancel β€” Refund and release

πŸ’‘ Key Features

βœ… 2-Step Confirmation

All bookings require a hold (step 1) followed by a confirm (step 2) to prevent accidental bookings.

User: "Book 2 tickets for The Matrix"
  ↓
Tool: hold_movie_tickets(movieId, quantity=2)
  ↓ Returns: "Ready to book 2 tickets for $31.98. Please confirm."
  ↓
User: "Confirm"
  ↓
Tool: confirm_movie_booking(idempotencyKey)
  ↓ Returns: "Booking confirmed! Confirmation: CONF_ABC12345"

βœ… Idempotency Keys

Every confirm_*_booking tool accepts an idempotency key to prevent duplicate bookings on retries.

// First call
confirm_train_booking(conversationId, idempotencyKey="idem_12345")
β†’ Returns: { confirmationId: "CONF_TRAIN001", ... }

// Retry with same key (safe β€” no duplicate charge)
confirm_train_booking(conversationId, idempotencyKey="idem_12345")
β†’ Returns: { confirmationId: "CONF_TRAIN001", ... } (same result)

βœ… Conversation-Scoped State

Each conversation has its own state store, preventing interference between concurrent bookings.

βœ… Intent Routing

The intent router automatically classifies queries and extracts relevant information (origin, destination, date, quantity).

Query: "Book 2 passengers on the 6 AM train from NYC to Boston"
β†’ Intent: hold, Domain: trains
β†’ Slots: { origin: "NYC", destination: "BOSTON", quantity: 2, date: "today" }

βœ… Standardized Response Format

All tools return a consistent JSON shape:

{
  "status": "success|pending|needs_input|error",
  "domain": "movies|flights|trains|buses",
  "confirmationId": "CONF_ABC12345",
  "message": "Human-readable summary",
  "data": { /* domain-specific payload */ }
}

πŸ“‹ Example Workflows

Workflow 1: Search β†’ Hold β†’ Confirm (Trains)

1. search_trains(origin="NYC", destination="Boston", date="2024-01-15")
   ↓ Returns: List of trains with prices and times

2. hold_train_seats(trainId="train_001", passengers=2)
   ↓ Returns: "Ready to book 2 passengers for $179.98. Please confirm."

3. confirm_train_booking(idempotencyKey="idem_12345")
   ↓ Returns: "Booking confirmed! Confirmation: CONF_TRAIN001"

Workflow 2: Cancel Booking

1. cancel_train_booking(confirmationId="CONF_TRAIN001")
   ↓ Returns: "Booking canceled. 2 passengers refunded."

Workflow 3: Get Details Before Booking

1. search_buses(origin="LAX", destination="San Francisco", date="2024-01-15")
   ↓ Returns: List of buses

2. get_bus_details(busId="bus_003")
   ↓ Returns: Full details including amenities, seat class, etc.

3. hold_bus_seats(busId="bus_003", passengers=3)
   ↓ Returns: Booking summary

4. confirm_bus_booking(idempotencyKey="idem_bus_001")
   ↓ Returns: Confirmation ID

πŸ› οΈ Adding a New Domain

3-Step Process

Step 1: Create connector class

// src/modules/booking/hotels-connector.tools.ts
@Injectable({ deps: [StateStoreService, ResponseFormatterService] })
export class HotelsConnectorTools {
  @Tool({ name: 'search_hotels', ... })
  async searchHotels(...) { ... }
  
  // ... 4 more tools (get_details, hold, confirm, cancel)
}

Step 2: Register in module

// src/modules/booking/booking.module.ts
import { HotelsConnectorTools } from './hotels-connector.tools.js';

@Module({
  controllers: [..., HotelsConnectorTools],
  providers: [StateStoreService, ResponseFormatterService],
})
export class BookingModule { }

Step 3: Update intent router

// src/modules/booking/intent-router.tools.ts
if (query.includes('hotel') || query.includes('accommodation')) {
  domain = 'hotels';
}

Done! The new domain is now available with all 5 tools.


πŸ“ Project Structure

src/
β”œβ”€β”€ app.module.ts                          # Root module
└── modules/
    └── booking/
        β”œβ”€β”€ booking.module.ts              # Booking module (registers all tools)
        β”œβ”€β”€ intent-router.tools.ts         # Query classification + slot extraction
        β”œβ”€β”€ movies-connector.tools.ts      # 5 movie tools
        β”œβ”€β”€ flights-connector.tools.ts     # 5 flight tools
        β”œβ”€β”€ train-connector.tools.ts       # 5 train tools
        β”œβ”€β”€ bus-connector.tools.ts         # 5 bus tools
        β”œβ”€β”€ state-store.service.ts         # Conversation state management
        └── response-formatter.service.ts  # Standardized JSON responses

tool_registry.json                         # Complete API documentation
README.md                                  # This file
QUICK_REFERENCE.md                         # Quick start guide
DOMAINS_SUMMARY.md                         # Domain comparison
IMPLEMENTATION_SUMMARY.md                  # Architecture guide

πŸ§ͺ Testing

Smoke Tests (All Passing βœ…)

# Test Movies
npm run test:movies

# Test Flights
npm run test:flights

# Test Trains
npm run test:trains

# Test Buses
npm run test:buses

Manual Testing

# Search trains
curl -X POST http://localhost:3000/mcp/tools/search_trains \
  -H "Content-Type: application/json" \
  -d '{
    "origin": "NYC",
    "destination": "Boston",
    "date": "2024-01-15",
    "conversationId": "conv_001"
  }'

# Hold train seats
curl -X POST http://localhost:3000/mcp/tools/hold_train_seats \
  -H "Content-Type: application/json" \
  -d '{
    "trainId": "train_001",
    "passengers": 2,
    "conversationId": "conv_001"
  }'

# Confirm train booking
curl -X POST http://localhost:3000/mcp/tools/confirm_train_booking \
  -H "Content-Type: application/json" \
  -d '{
    "conversationId": "conv_001",
    "idempotencyKey": "idem_12345"
  }'

πŸ“Š Statistics

Metric Value
Total Domains 4
Total Tools 20
Tools per Domain 5
Mock Data Entries 15
Lines of Code ~2,165
TypeScript Coverage 100%
Smoke Tests All passing βœ…

πŸŽ“ Key Concepts

Thin-Wrapper Pattern

Each domain is a self-contained connector with 5 standard tools. No shared business logic between domains.

2-Step Confirmation

All bookings require a hold (step 1) followed by a confirm (step 2) to prevent accidental bookings.

Conversation-Scoped State

Each conversation has its own state store, preventing interference between concurrent bookings.

Idempotency

Confirmation tools use idempotency keys to ensure retries don't create duplicate bookings.

Intent Routing

The router classifies queries and extracts relevant slots (origin, destination, date, quantity) automatically.


πŸš€ Production Readiness

βœ… Implemented

  • [x] Multi-domain architecture (4 domains)
  • [x] 2-step confirmation flow
  • [x] Idempotency keys
  • [x] Conversation-scoped state
  • [x] Standardized response format
  • [x] Intent routing with slot extraction
  • [x] Extensible thin-wrapper pattern
  • [x] Comprehensive error handling
  • [x] Type-safe Zod schemas
  • [x] Full TypeScript support
  • [x] NitroStack framework integration

πŸ”„ Future Enhancements

  • [ ] Persistent database (replace in-memory state)
  • [ ] Real API integrations (Ticketmaster, Amadeus, Amtrak, Greyhound)
  • [ ] Payment processing (Stripe, PayPal)
  • [ ] Email confirmations
  • [ ] User authentication
  • [ ] Booking history
  • [ ] Multi-currency support
  • [ ] Rate limiting & quotas

πŸ“ž Support

For detailed information:

  1. Quick Start: See QUICK_REFERENCE.md
  2. Domain Details: See DOMAINS_SUMMARY.md
  3. Architecture: See IMPLEMENTATION_SUMMARY.md
  4. API Docs: See tool_registry.json

πŸ“„ License

This project is part of the NitroStack framework.


βœ… Status

Production Ready β€” All 20 tools fully functional and tested. Ready for deployment or further customization.


Version: 1.0.0
Last Updated: 2024-01-14
Framework: NitroStack + TypeScript
MCP Spec: Aligned

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured