# Ithaca Travel — Agent MCP Server

Bookable hotel inventory for AI agents: search → quote → book → manage,
backed by live supplier rates. One implementation serves two transports:

- **MCP (this doc):** `POST https://ithacatravel.app/mcp` (Streamable HTTP, stateless, JSON responses)
- **REST:** `https://ithaca.binkupi.com/api/v1/agent/hotels/*` (same operations, same auth)

## Auth — two separate proofs

1. **Connection auth (API key).** Every request carries a key, either
   `Authorization: Bearer <key>` or `X-Agent-Api-Key: <key>`. Keys are
   issued per client (`chatgpt`, `claude`, a partner…) and configured
   server-side in `AGENT_API_KEYS`. No key configured ⇒ the surface is
   inert (503). OAuth 2.1 replaces this layer for public directory
   listings; the tools below do not change.
2. **Per-booking proof (`management_token`).** `start_booking` returns a
   token **once**. `get_booking`, `cancel_booking`, and `request_booking_change`
   require it — it unlocks only that one booking and is not a login.

## Tools

| Tool | Purpose |
|---|---|
| `search_hotels` | Curated hotels near `latitude`/`longitude` for dates; totals for the whole stay, `pay_at_hotel` extra at the property; each result has an `offer_handle` (~15 min validity) |
| `quote_hotel` | Refresh one offer's live price + cancellation terms; returns a fresh `offer_handle` |
| `start_booking` | Lock the rate for a guest (holder name/email); returns `payment_page_url` (guest pays the supplier there; booking confirms automatically) and the one-time `management_token` |
| `get_booking` | Status by `checkout_id` (or `booking_id`) + `management_token` |
| `cancel_booking` | Cancel; reports refund outcome. Non-refundable / past-window bookings return an error unchanged |
| `request_booking_change` | Current supply can't amend in place: returns `supported=false, mode=cancel_rebook` + the booking's cancellation terms, and changes nothing |

Prices are always the charged total (`retailRate.total`). `pay_at_hotel`
(city tax / resort fee) is **not** included in the price — surface it to
the traveler as an extra due at the property.

## Connect a client

### MCP Inspector (quickest smoke test)

```bash
npx @modelcontextprotocol/inspector \
  --header "Authorization: Bearer <key>" \
  https://ithacatravel.app/mcp
```

### Claude Code

```bash
claude mcp add --transport http ithaca-travel https://ithacatravel.app/mcp \
  --header "Authorization: Bearer <key>"
```

### Any MCP client (JSON config)

```json
{
  "mcpServers": {
    "ithaca-travel": {
      "url": "https://ithacatravel.app/mcp",
      "headers": { "Authorization": "Bearer <key>" }
    }
  }
}
```

### ChatGPT / Claude.ai consumer connectors — OAuth 2.1

Ithaca runs its own OAuth 2.1 authorization server (authorization code
flow + PKCE S256, dynamic client registration). Point a consumer
connector at the MCP URL and it discovers everything itself:

- Protected-resource metadata: `https://ithacatravel.app/.well-known/oauth-protected-resource`
- Authorization-server metadata: `https://ithacatravel.app/.well-known/oauth-authorization-server`
- Registration: `POST https://ithacatravel.app/oauth/register` (RFC 7591)
- No sign-in is required: the traveler approves as a guest — no account,
  no credentials — and bookings are proved by the booking reference +
  management token, not an account. Signing in with Google on the same
  page is optional, for travelers who want bookings tied to an Ithaca
  account. Access tokens last 1 hour; refresh tokens rotate and last
  30 days.

The API-key flow above remains for developer clients (Inspector,
Claude Code, custom agents) and partner integrations.

## Example flow

1. `search_hotels(latitude=40.758, longitude=-73.9855, check_in_date="2026-12-07", check_out_date="2026-12-09")`
2. `quote_hotel(offer_handle=<from the chosen hotel>)` → fresh price + fresh handle
3. `start_booking(offer_handle=<fresh>, holder_first_name="Ada", holder_last_name="Lovelace", holder_email="ada@example.com")`
   → send the user `payment_page_url`; save `management_token` + `checkout_id`
4. `get_booking(checkout_id, management_token)` → `confirmed` after payment
5. `cancel_booking(checkout_id, management_token)` if plans change
