rigshare_list_my_bookings
Retrieve your current RIGShare bookings with details on equipment, dates, status, and totals. Use this to review existing rentals before booking new equipment or to track a confirmation code.
Instructions
REQUIRES API KEY (RIGSHARE_API_KEY env var, bookings:read scope). Returns the authenticated user's RIGShare bookings — equipment, dates, status, totals. Use this to check an existing rental before creating a new one, or to track a confirmation code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | Filter to a specific booking status. | |
| limit | No | ||
| page | No |
Implementation Reference
- src/index.ts:199-229 (registration)Registration of the rigshare_list_my_bookings tool in the ListToolsRequestSchema handler, defining its name, description, and input schema (status filter, pagination limit/page). It's one of the authenticated tools (requires RIGSHARE_API_KEY).
{ name: "rigshare_list_my_bookings", description: "REQUIRES API KEY (RIGSHARE_API_KEY env var, bookings:read scope). Returns the authenticated user's RIGShare bookings — equipment, dates, status, totals. Use this to check an existing rental before creating a new one, or to track a confirmation code.", inputSchema: { type: "object", properties: { status: { type: "string", enum: [ "PENDING", "APPROVED", "CONFIRMED", "IN_PROGRESS", "COMPLETED", "CANCELLED", "REFUNDED", "DISPUTED", ], description: "Filter to a specific booking status.", }, limit: { type: "integer", minimum: 1, maximum: 100, default: 10, }, page: { type: "integer", minimum: 1, default: 1 }, }, }, }, - src/index.ts:648-677 (handler)Handler function for rigshare_list_my_bookings. Checks for API key, calls the authenticated agent API endpoint /api/v1/agent/bookings with optional status/limit/page query params, transforms the response into a formatted text listing of bookings (confirmation code, status, equipment, dates, total amount, deposit, booking ID).
async function listMyBookings(args: Record<string, unknown>) { if (!RIGSHARE_API_KEY) return toolError(API_KEY_ERROR_MSG); const params = new URLSearchParams(); if (args.status) params.set("status", String(args.status)); if (args.limit) params.set("limit", String(args.limit)); if (args.page) params.set("page", String(args.page)); const res = await fetchAuthJson( RIGSHARE_API_KEY, `${RIGSHARE_AGENT_API}/bookings?${params.toString()}`, ); if (res.error) return toolError(res.error); const bookings = ((res.data as any)?.bookings || []) as any[]; if (bookings.length === 0) { return toolText( `No bookings found${args.status ? ` with status ${args.status}` : ""}.`, ); } const lines = bookings.map((b, i) => { return [ `${i + 1}. ${b.confirmationCode} — ${b.status}`, ` ${b.equipment?.title || "—"} (${b.equipment?.category || "—"})`, ` ${new Date(b.startDate).toLocaleDateString()} → ${new Date(b.endDate).toLocaleDateString()} · ${b.durationType}`, ` Total: $${((b.totalAmount || 0) / 100).toFixed(2)} · Deposit: $${((b.securityDeposit || 0) / 100).toFixed(2)}`, ` Booking ID: ${b.id}`, ].join("\n"); }); return toolText(`Your bookings:\n\n${lines.join("\n\n")}`); } - src/index.ts:203-228 (schema)Input schema for rigshare_list_my_bookings — accepts optional status filter (enum of 8 booking states), pagination limit (1-100, default 10), and page number (default 1).
inputSchema: { type: "object", properties: { status: { type: "string", enum: [ "PENDING", "APPROVED", "CONFIRMED", "IN_PROGRESS", "COMPLETED", "CANCELLED", "REFUNDED", "DISPUTED", ], description: "Filter to a specific booking status.", }, limit: { type: "integer", minimum: 1, maximum: 100, default: 10, }, page: { type: "integer", minimum: 1, default: 1 }, }, }, - src/index.ts:617-646 (helper)Helper function fetchAuthJson used by listMyBookings to make authenticated fetch requests. It attaches the Bearer token via the RIGSHARE_API_KEY, sends JSON content-type headers, and parses the response, returning either data or an error.
async function fetchAuthJson( apiKey: string, url: string, init: RequestInit = {}, ): Promise<{ data?: any; status?: number; error?: string }> { try { const res = await fetch(url, { ...init, headers: { ...(init.headers || {}), Accept: "application/json", "Content-Type": "application/json", "User-Agent": USER_AGENT, Authorization: `Bearer ${apiKey}`, }, }); const data = await res.json().catch(() => ({})); if (!res.ok) { return { status: res.status, error: (data as any)?.error || `RIGShare Agent API returned HTTP ${res.status}`, }; } return { data, status: res.status }; } catch (err: any) { return { error: err?.message || "Network error contacting RIGShare Agent API" }; } }