place-availability
Check campsite availability by entering place ID, site IDs, and date range to verify booking options for specific locations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| placeId | Yes | The id of the place to check availability for. | |
| siteIds | No | The ids of the sites to check availability for. | |
| startDate | Yes | The start date to check availability for. Format: YYYY-MM-DD | |
| endDate | Yes | The end date to check availability for. Format: YYYY-MM-DD |
Implementation Reference
- src/tools/place_availability.ts:14-31 (handler)The asynchronous handler function that implements the core logic of the 'place-availability' tool. It makes a POST request to the Campertunity API with placeId, siteIds, startDate, and endDate, and returns the availability data as JSON or an error message.async ({ placeId, siteIds, startDate, endDate }) => { try { const availability = await campertunityClient.post(`/place/availability`, { placeId, siteIds, startDate, endDate, }); return { content: [{ type: 'text', text: JSON.stringify(availability), mimeType: 'application/json' }], }; } catch (error) { return { content: [{ type: 'text', text: 'Error: ' + (error as Error).message }], isError: true, }; } }
- src/tools/place_availability.ts:8-13 (schema)Zod schema defining the input parameters for the 'place-availability' tool, including placeId (required), siteIds (optional array), startDate, and endDate, all as strings with descriptions.{ placeId: z.string().describe('The id of the place to check availability for.'), siteIds: z.array(z.string()).optional().describe('The ids of the sites to check availability for.'), startDate: z.string().describe('The start date to check availability for. Format: YYYY-MM-DD'), endDate: z.string().describe('The end date to check availability for. Format: YYYY-MM-DD'), },
- src/tools/place_availability.ts:6-32 (registration)The server.tool() call within the placeAvailabilityTool function that registers the 'place-availability' tool on the MCP server, specifying the tool name, input schema, and handler function. This function is invoked from src/index.ts.server.tool( 'place-availability', { placeId: z.string().describe('The id of the place to check availability for.'), siteIds: z.array(z.string()).optional().describe('The ids of the sites to check availability for.'), startDate: z.string().describe('The start date to check availability for. Format: YYYY-MM-DD'), endDate: z.string().describe('The end date to check availability for. Format: YYYY-MM-DD'), }, async ({ placeId, siteIds, startDate, endDate }) => { try { const availability = await campertunityClient.post(`/place/availability`, { placeId, siteIds, startDate, endDate, }); return { content: [{ type: 'text', text: JSON.stringify(availability), mimeType: 'application/json' }], }; } catch (error) { return { content: [{ type: 'text', text: 'Error: ' + (error as Error).message }], isError: true, }; } } );
- src/index.ts:23-23 (registration)Invocation of the placeAvailabilityTool function to register the 'place-availability' tool on the main MCP server instance.placeAvailabilityTool(server, campertunityClient);