Skip to main content
Glama
Paul-1511

Travel Tools MCP Server

by Paul-1511
README.md
# Travel Tools MCP Server

MCP server that helps travel agents cover the full trip-quoting lifecycle:
flight/accommodation search, personalized itineraries, entry requirements,
booking creation and monitoring, upsell recommendations, and cancellation
policy lookups with refund calculation.

## Why this is not a trivial server
It exposes **10 tools** backed by **6 distinct data collections** (flights,
accommodations, entry requirements, cancellation policies, activities,
upsell offers) plus a **mutable bookings collection**, and combines several
of them in a single call (e.g. `build_trip_itinerary` merges live weather +
activities + accommodation pricing; `cancel_booking` merges a policy lookup
with a booking write and computes a refund).

## Data source
All catalog data (flights, accommodations, entry requirements, cancellation
policies, activities, upsell offers) is **fictional**, seeded from
`seeds/*.json` into MongoDB via `seed_db.py`. This keeps demos reliable and
independent of third-party sandbox availability. Real-time weather still
comes from Open-Meteo (no API key required).

If MongoDB is unreachable, every read tool falls back to small in-memory
mock data so the server stays demoable even without a database connection.
Write tools (`create_booking`, `simulate_booking_alert`, `cancel_booking`)
require MongoDB and return a clear error otherwise.

## Requirements
- Python 3.11+
- MongoDB running locally or remotely (e.g. `docker run -p 27017:27017 mongo`)
- `pip install -r requirements.txt`

## Setup
```bash
# 1. Start MongoDB (example with Docker)
docker run -d --name travel-mongo -p 27017:27017 mongo

# 2. Seed the catalog collections
cd servers/travel_tools_server
python seed_db.py

# 3. Run the server standalone (for testing with Claude Desktop, etc.)
python server.py
```

Re-run `python seed_db.py` any time you want to reset the catalog to its
original fictional data. It never touches `bookings` unless you pass
`--reset-bookings`.

## Collections

| Collection | Access | Seeded from |
|---|---|---|
| `flights` | read-only | `seeds/flights.json` |
| `accommodations` | read-only | `seeds/accommodations.json` |
| `entry_requirements` | read-only | `seeds/entry_requirements.json` |
| `cancellation_policies` | read-only | `seeds/cancellation_policies.json` |
| `activities` | read-only | `seeds/activities.json` |
| `upsell_offers` | read-only | `seeds/upsell_offers.json` |
| `bookings` | read/write | created at runtime by the chatbot |

## Tools

### Read-only
- `search_flights(origin, destination, date=None, max_price=None)`
- `search_accommodations(city, accommodation_type=None, max_price_per_night=None, min_guests=None)`
- `get_entry_requirements(destination_country, nationality="Guatemalteca")`
- `get_cancellation_policy(provider, product_type=None)`
- `get_upsell_recommendations(destination)`
- `build_trip_itinerary(destination, start_date, days, interests)` — combines weather + activities + accommodations

### Read/write (bookings)
- `create_booking(client_name, product_type, reference_id, start_date, end_date, total_price_usd)`
- `get_booking_status(booking_id)`
- `simulate_booking_alert(booking_id, new_status, note)` — simulates a GDS/monitoring alert (Case 4)
- `cancel_booking(booking_id, provider, product_type, hours_before_departure)` — reads the policy, computes the refund, writes the new status

**Example call:**
```json
{
  "name": "cancel_booking",
  "arguments": {
    "booking_id": "BK-A1B2C3D4",
    "provider": "Avianca",
    "product_type": "flight",
    "hours_before_departure": 20
  }
}
```

## Configuration
Add to your MCP host config (e.g. `mcp_servers.json`):
```json
{
  "name": "travel_tools",
  "transport": "stdio",
  "command": "python",
  "args": ["server.py"]
}
```

Environment variables (see project root `.env.example`):
```
MONGO_URI=mongodb://localhost:27017
MONGO_DB_NAME=travel_agency
```