Skip to main content
Glama

rigshare_create_booking

Create an equipment booking on RIGShare. The server computes prices from equipment rates, verifies identity, holds a security deposit, and applies a budget cap.

Instructions

REQUIRES API KEY (bookings:write scope). Creates a new RIGShare booking for the authenticated user. Server computes all prices from the equipment's canonical rates — client-side price hints are ignored. Enforces identity verification, security deposit hold, and a daily/monthly budget cap configured on the API key. Returns confirmation code + booking ID on success. Use rigshare_list_my_bookings to check status afterwards.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
equipment_idYesFrom rigshare_search_equipment or rigshare_get_equipment.
start_dateYesISO-8601 start datetime.
end_dateYesISO-8601 end datetime. Must be after start_date.
duration_typeYesDetermines which rate is used. Must match a rate the equipment actually offers (e.g., use HOURLY only when equipment has a rateHourly).
pickup_typeNoDefault REMOTE_ACCESS for robotics/AI equipment. Use SELF_PICKUP or OWNER_DELIVERY for construction equipment.REMOTE_ACCESS
idempotency_keyNoOptional. If provided, repeated calls with the same key within 5 minutes return the same booking instead of creating duplicates.

Implementation Reference

  • Tool definition and input schema for rigshare_create_booking, registered in the ListToolsRequestSchema handler. Describes required fields (equipment_id, start_date, end_date, duration_type) and optional fields (pickup_type, idempotency_key).
    {
      name: "rigshare_create_booking",
      description:
        "REQUIRES API KEY (bookings:write scope). Creates a new RIGShare booking for the authenticated user. Server computes all prices from the equipment's canonical rates — client-side price hints are ignored. Enforces identity verification, security deposit hold, and a daily/monthly budget cap configured on the API key. Returns confirmation code + booking ID on success. Use rigshare_list_my_bookings to check status afterwards.",
      inputSchema: {
        type: "object",
        required: ["equipment_id", "start_date", "end_date", "duration_type"],
        properties: {
          equipment_id: {
            type: "string",
            format: "uuid",
            description:
              "From rigshare_search_equipment or rigshare_get_equipment.",
          },
          start_date: {
            type: "string",
            format: "date-time",
            description: "ISO-8601 start datetime.",
          },
          end_date: {
            type: "string",
            format: "date-time",
            description: "ISO-8601 end datetime. Must be after start_date.",
          },
          duration_type: {
            type: "string",
            enum: ["HOURLY", "FOUR_HOURS", "DAILY", "WEEKLY", "MONTHLY"],
            description:
              "Determines which rate is used. Must match a rate the equipment actually offers (e.g., use HOURLY only when equipment has a rateHourly).",
          },
          pickup_type: {
            type: "string",
            enum: [
              "SELF_PICKUP",
              "OWNER_DELIVERY",
              "PLATFORM_DELIVERY",
              "REMOTE_ACCESS",
            ],
            default: "REMOTE_ACCESS",
            description:
              "Default REMOTE_ACCESS for robotics/AI equipment. Use SELF_PICKUP or OWNER_DELIVERY for construction equipment.",
          },
          idempotency_key: {
            type: "string",
            maxLength: 100,
            description:
              "Optional. If provided, repeated calls with the same key within 5 minutes return the same booking instead of creating duplicates.",
          },
        },
      },
    },
  • src/index.ts:301-325 (registration)
    Tool dispatch — maps the tool name 'rigshare_create_booking' to the createBooking handler function.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
      try {
        switch (name) {
          case "rigshare_search_equipment":
            return await searchEquipment(args || {});
          case "rigshare_get_equipment":
            return await getEquipment(args || {});
          case "rigshare_list_categories":
            return await listCategories();
          case "rigshare_get_owner_onboarding":
            return getOwnerOnboarding(args || {});
          case "rigshare_list_my_bookings":
            return await listMyBookings(args || {});
          case "rigshare_list_my_sessions":
            return await listMySessions(args || {});
          case "rigshare_create_booking":
            return await createBooking(args || {});
          default:
            return toolError(`Unknown tool: ${name}`);
        }
      } catch (err: any) {
        return toolError(err?.message || "Unknown error");
      }
    });
  • Core handler function for rigshare_create_booking: validates required args, builds a POST body, calls the authenticated RIGShare Agent API /bookings endpoint, and formats the response with confirmation code, booking ID, status, total, and security deposit.
    async function createBooking(args: Record<string, unknown>) {
      if (!RIGSHARE_API_KEY) return toolError(API_KEY_ERROR_MSG);
    
      // Minimum-viable validation client-side before hitting the server
      if (!args.equipment_id || typeof args.equipment_id !== "string") {
        return toolError("equipment_id is required (uuid)");
      }
      if (!args.start_date || typeof args.start_date !== "string") {
        return toolError("start_date is required (ISO-8601)");
      }
      if (!args.end_date || typeof args.end_date !== "string") {
        return toolError("end_date is required (ISO-8601)");
      }
      if (!args.duration_type) {
        return toolError(
          "duration_type is required (HOURLY | FOUR_HOURS | DAILY | WEEKLY | MONTHLY)",
        );
      }
    
      const body: Record<string, unknown> = {
        equipment_id: args.equipment_id,
        start_date: args.start_date,
        end_date: args.end_date,
        duration_type: args.duration_type,
        pickup_type: args.pickup_type || "REMOTE_ACCESS",
      };
      if (args.idempotency_key) body.idempotency_key = args.idempotency_key;
    
      const res = await fetchAuthJson(RIGSHARE_API_KEY, `${RIGSHARE_AGENT_API}/bookings`, {
        method: "POST",
        body: JSON.stringify(body),
      });
      if (res.error) return toolError(res.error);
    
      const d = res.data as any;
      const idempotent = d?.idempotent ? " (idempotent — matched existing booking)" : "";
      return toolText(
        [
          `Booking created${idempotent}:`,
          ``,
          `Confirmation code: ${d?.confirmation_code || d?.booking?.confirmationCode || "—"}`,
          `Booking ID: ${d?.booking_id || d?.booking?.id || "—"}`,
          `Status: ${d?.booking?.status || "PENDING"}`,
          `Total: $${((d?.booking?.totalAmount || 0) / 100).toFixed(2)}`,
          `Security deposit hold: $${((d?.booking?.securityDeposit || 0) / 100).toFixed(2)}`,
          ``,
          `View at: https://www.rigshare.app/booking/${d?.booking_id || d?.booking?.id}`,
          ``,
          `Next steps: the owner will approve or decline. Use rigshare_list_my_bookings to check status.`,
        ].join("\n"),
      );
    }
  • Authenticated HTTP helper used by createBooking — sends requests with Bearer token auth, returns parsed JSON data or 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" };
      }
    }
  • Response formatting helpers — toolError returns an MCP error response, toolText returns a success text response. Both used by createBooking.
    function toolText(text: string) {
      return {
        content: [{ type: "text" as const, text }],
      };
    }
    
    function toolError(message: string) {
      return {
        content: [{ type: "text" as const, text: `Error: ${message}` }],
        isError: true,
      };
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses important behaviors: server computes prices (ignoring client hints), enforces identity verification, security deposit hold, and budget cap. No annotations exist, so description carries full burden, and it does so well.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Concise paragraph with front-loaded requirement. Each sentence adds unique information; no redundancy. Slightly dense but effective.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers auth, return value, idempotency, constraints, and follow-up action. Lacks error scenarios, but for a creation tool with no output schema, provides solid contextual completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but description adds value by explaining server-side pricing and providing context for pickup_type and idempotency_key behavior, enhancing understanding beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it creates a booking for the authenticated user, with prerequisite API key and scope. Distinguishes from siblings by noting follow-up use of rigshare_list_my_bookings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides context on server-side pricing and idempotency, and suggests post-usage check, but lacks explicit when-to-use vs. alternatives (other booking tools are not creation-related).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/RPER2001/rigshare-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server