# Restful Booker MCP

> Restful Booker manages hotel reservations by exposing eight distinct tools through an MCP server. Your AI client can execute full CRUD operations—creating, retrieving, updating, and deleting bookings—using simple natural language prompts instead of complex API calls.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Tags:** hotel-booking, api-testing, reservation-management, crud-operations, hospitality

## Description

# Restful Booker Server

Your agent handles every single part of hotel reservations with this server. It's built to let your AI client run full CRUD operations—meaning you can create, read, update, and delete bookings—all using natural language prompts instead of some complicated API calls that make your fingers hurt.

This whole system is designed around eight specific tools. You'll use these in sequence when you need to book or change anything. The first thing you gotta know: any time you plan on writing new data or deleting a record, you first run `create_token` **to generate an access token**. That token is your key; it gives your agent the permission it needs for write and delete operations.

## Checking Things Out

Want to see if the whole thing's working? Run `health_check`. It just confirms that the API endpoint itself is up and running, so you know where you stand before you get started.

If you need booking information, your agent starts with retrieval. You can list all existing reservation IDs using `get_booking_ids`. This tool lets you pull every ID off the books or narrow it down by filtering results based on a specific guest name and date range. Once you have an ID, if you want the full picture—the complete metadata, the pricing details, and the exact dates—you run `get_booking` with that single reservation ID.

## Making Changes to Records

If you're making a new booking, it’s simple: use `create_booking`. You just give your agent the details in plain language, and it instantly creates a brand-new record in the system.

When you need to adjust an existing reservation, you've got two ways to do it. If you know exactly which fields are wrong or outdated, you run `partial_update_booking`. This is smart because it only modifies specific data points—you don’t overwrite everything by accident. But if the whole record needs a full overhaul and you want every field overwritten with new information, you use `update_booking` instead. Remember, both of these update tools require that active token generated earlier.

## Deletion

When it's time to ditch a booking, your agent uses `delete_booking`. You have to provide the specific booking ID here because this tool deletes an entire record, and it also requires that valid, active authentication token you got from `create_token`.

Basically, everything flows like this: First, get your key with **`create_token`**. Then, use **`get_booking_ids`** or **`get_booking`** to see what's there. If you need a new spot booked, hit **`create_booking`**. To tweak it up? Use **`partial_update_booking`** for small fixes or **`update_booking`** if you gotta replace the whole thing. And when you’re done with a record, use **`delete_booking`**. It's that straightforward.

## Tools

### create_booking
Creates a new reservation record in the system.

### create_token
Generates an access token required for write and delete operations.

### delete_booking
Deletes a specific booking record; requires an active authentication token.

### get_booking_ids
Lists all booking IDs or filters them by guest name and date range.

### get_booking
Retrieves the full metadata, pricing, and dates for one specified reservation ID.

### health_check
Verifies that the API endpoint is running correctly.

### partial_update_booking
Modifies only specific fields of an existing booking; requires an active authentication token.

### update_booking
Overwrites all data for a current booking record; requires an active authentication token.

## Prompt Examples

**Prompt:** 
```
Find all booking IDs for guests with the last name 'Smith'.
```

**Response:** 
```
I found 3 booking IDs for 'Smith': 45, 102, and 215. Would you like me to fetch the full details for any of these?
```

**Prompt:** 
```
Create a new booking for John Doe, price 150, deposit paid, from 2024-12-01 to 2024-12-05.
```

**Response:** 
```
Booking successfully created! The new booking ID is 882. The guest is John Doe with a check-in on Dec 1st and check-out on Dec 5th.
```

**Prompt:** 
```
Update booking 882 to change the total price to 200.
```

**Response:** 
```
I've updated the total price for booking 882 to 200 using a partial update. All other details remain the same.
```

## Capabilities

### Search and Retrieve Booking Data
Your agent can list all booking IDs using `get_booking_ids` or fetch complete details, including pricing and dates, for a single reservation with `get_booking`.

### Create New Reservations
Use `create_booking` to instantly add new reservations to the system using natural language input.

### Update Existing Records
The server supports two update methods: modifying all fields with `update_booking`, or targeting specific data points only via `partial_update_booking`.

### Delete Bookings
Requires an active token. The agent deletes a record using the `delete_booking` tool.

### Manage API Access
The first step for any write or delete action is generating a secure access credential with the `create_token` tool.

## Use Cases

### The Guest Data Audit
A QA engineer needs to validate that all bookings for 'Smith' are active. Instead of running a complex, multi-parameter query, they prompt their agent: "Find all booking IDs for Smith." The agent runs `get_booking_ids`, gets the list (e.g., 45, 102), and then proactively uses `get_booking` on each ID to confirm active status.

### Quick Price Change
A manager finds an error in a booking's total price. They don't want to resubmit the whole record. They tell their agent: "Change the price for booking 102 to $350." The agent runs `partial_update_booking`, ensuring only the price field is touched, keeping all other data intact.

### New Client Onboarding
A developer needs to simulate a new client reservation. They prompt: "Create a booking for Jane Doe, check-in Dec 1, check-out Dec 5." The agent executes `create_booking`, handles all required fields (dates, names), and confirms the new ID.

### Data Cleanup
An old booking needs to be removed from the active system. First, the agent gets a fresh token using `create_token`. Then, when prompted: "Delete booking 45," the agent runs `delete_booking` and completes the cleanup task.

## Benefits

- **Full Lifecycle Management:** Instead of writing separate API calls for each step, your agent handles the full cycle—from initial `create_booking` to final `delete_booking`—using a single conversation prompt. This saves time and reduces code complexity.
- **Granular Updates:** You don't have to overwrite an entire record just to change one field. The `partial_update_booking` tool lets your agent modify only the necessary data points, like changing the price without touching dates or guest names.
- **Bulk Discovery:** Need IDs for multiple guests? Use `get_booking_ids`. This allows your agent to quickly gather a list of relevant booking identifiers, which you can then pass to `get_booking` for detailed inspection.
- **Secure Operations:** The `create_token` tool forces proper authentication flow. Your AI client must acquire the token first, ensuring that sensitive actions like `delete_booking` are properly authorized before execution.
- **Zero-Code Integration:** You bypass writing custom HTTP request logic in your application code. You just talk to your agent and tell it what needs fixing or creating.

## How It Works

The bottom line is, you prompt your client, and it handles the entire API call chain—including authentication checks—for you.

1. Run the `create_token` tool using your credentials to generate an active API token.
2. Instruct your AI client on the desired action (e.g., "Create a booking for John Doe").
3. Your agent executes the appropriate sequence of tools (`get_booking`, `create_booking`, etc.), passing the required token and parameters.

## Frequently Asked Questions

**How do I start using the Restful Booker with `get_booking_ids`?**
You must first run `create_token` to get an access token. Then, use `get_booking_ids` and pass your search filters (like a guest name) as query strings in your prompt.

**Can I change just the price of a booking using `partial_update_booking`?**
Yes. The primary function of `partial_update_booking` is to modify specific fields without impacting others. You tell your agent which field needs changing, and it handles the rest.

**If I want to create a booking, do I need an auth token using `create_token`?**
No, creating a booking (`create_booking`) is usually read-only from a security standpoint. However, for any operation that modifies or deletes data, you must use the token generated by `create_token`.

**What's the difference between `get_booking` and `get_booking_ids`?**
`get_booking_ids` gives you a list of IDs based on filters. `get_booking` takes one specific ID from that list and fetches all associated details for just that single booking.

**What's the difference between using `update_booking` versus `partial_update_booking`?**
Use `partial_update_booking` when you only need to adjust a specific field, like changing the total price. If you have to replace all the data for the reservation, then use `update_booking`.

**How do I properly delete a record using `delete_booking`?**
You must first get an access token via `create_token`, as this tool handles sensitive write operations. Then, your agent passes the required authentication token to execute the `delete_booking` command.

**How can I verify that the Restful Booker API is working before running complex queries?**
Your agent simply calls the `health_check` tool. This confirms connectivity and ensures the entire API endpoint is responding correctly, letting you proceed with other tools like `get_booking`.

**If I'm building an automated workflow, how often should I refresh my auth token using `create_token`?**
It's best practice to build a check for token expiry into your agent logic. Always use the latest token returned by `create_token`; don't wait until it fails.

**How do I find a booking ID for a specific guest?**
Use the `get_booking_ids` tool. You can provide optional parameters like `firstname` or `lastname` to filter the results and find the exact ID you need.

**Do I need an auth token to view booking details?**
No, `get_booking` and `get_booking_ids` are public queries. You only need a token generated via `create_token` for `update_booking`, `partial_update_booking`, and `delete_booking` actions.

**Can I update only the price of a booking without changing other details?**
Yes! Use the `partial_update_booking` tool. It allows you to send only the fields you want to change, such as `totalprice`, while keeping the rest of the booking intact.