getAllReservations
Retrieve filtered reservations from the Mews hospitality platform using specific IDs, customer details, states, or date ranges. Supports pagination and ensures results within a 100-hour time interval. Streamline reservation management with precise queries.
Instructions
Get reservations with filters. Note: The time interval between StartUtc and EndUtc must not exceed 100 hours.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| CustomerIds | No | Filter by customer IDs | |
| EndUtc | Yes | End date for search (ISO 8601) | |
| Limitation | No | Pagination settings | |
| ReservationIds | No | Specific reservation IDs to retrieve | |
| StartUtc | Yes | Start date for search (ISO 8601) | |
| States | No | Filter by reservation states (Confirmed, Canceled, etc.) |
Implementation Reference
- Handler function that invokes the mewsRequest helper to POST to the Mews API /reservations/getAll endpoint with provided arguments and returns the prettified JSON response.async execute(config: MewsAuthConfig, args: unknown): Promise<ToolResult> { const result = await mewsRequest(config, '/api/connector/v1/reservations/getAll', args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- Input schema defining the structure and validation for tool parameters including filters, date range (required), and pagination options.inputSchema: { type: 'object', properties: { ReservationIds: { type: 'array', items: { type: 'string' }, description: 'Specific reservation IDs to retrieve' }, CustomerIds: { type: 'array', items: { type: 'string' }, description: 'Filter by customer IDs' }, States: { type: 'array', items: { type: 'string' }, description: 'Filter by reservation states (Confirmed, Canceled, etc.)' }, StartUtc: { type: 'string', description: 'Start date for search (ISO 8601)' }, EndUtc: { type: 'string', description: 'End date for search (ISO 8601)' }, Limitation: { type: 'object', properties: { Count: { type: 'number', description: 'Maximum number of reservations to return' }, Cursor: { type: 'string', description: 'Pagination cursor for next page' } }, description: 'Pagination settings' } }, required: ['StartUtc', 'EndUtc'] },
- src/tools/index.ts:21-21 (registration)Import statement that brings the getAllReservationsTool into the central tools index module.import { getAllReservationsTool } from './reservations/getAllReservations.js';
- src/tools/index.ts:106-106 (registration)Includes the getAllReservationsTool in the allTools array used for tool registry and lookup.getAllReservationsTool,
- src/utils/http.ts:8-49 (helper)Shared utility function mewsRequest that handles authenticated POST requests to the Mews API, adding auth tokens to the request body, error handling, and response parsing.export async function mewsRequest<B = Record<string, unknown>, R = unknown>( config: MewsAuthConfig, endpoint: string, data: B ): Promise<MewsResponse<R>> { const url = `${config.baseUrl}${endpoint}`; const body = { ClientToken: config.clientToken, AccessToken: config.accessToken, Client: config.client, ...data, }; try { const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(body), }); if (!response.ok) { const errorText = await response.text(); throw new Error(`Mews API request failed: ${response.status} ${response.statusText}. ${errorText}`); } // Handle empty responses const contentLength = response.headers.get('content-length'); if (contentLength === '0') { return {} as MewsResponse<R>; } const result = await response.json(); return result as MewsResponse<R>; } catch (error) { if (error instanceof Error) { throw new Error(`Mews API request failed: ${error.message}`); } throw new Error('Unknown error occurred during Mews API request'); }