Skip to main content
Glama
hrz8

DSP Booking MCP Server

by hrz8

create_cart

Add selected flight options to a shopping cart for booking. This step validates flight availability, calculates final pricing, and generates a cart ID required for completing the reservation.

Instructions

Create a shopping cart with selected flight options. PREREQUISITES: Must call 'initialize_booking_session' first, then 'search_flights' to get available flight options. This endpoint adds the customer's selected flights (identified by airBoundIds from search results) to a cart for booking. The cart validates selections, checks availability, and calculates final pricing. WORKFLOW POSITION: Step 3 of the booking flow (after initialization and search, before passenger details and payment). RESPONSE: Returns a cartId which is required for subsequent booking operations. IMPORTANT: All airBoundIds must come from the most recent search_flights response within the same session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session-tokenYesRequired authentication token obtained from the initialize_booking_session step. This token maintains the booking session context and must be included to create a cart. The token is returned in the response headers of the initialization call (look for "Session-Token" header).
requestBodyYesCart creation request containing the selected flight options the customer wants to purchase.

Implementation Reference

  • Input schema definition for the create_cart tool using Zod for validation of session token and airBoundIds.
    export const CreateCartSchema = z.object({
      'session-token': z.string()
        .min(1)
        .describe('Required authentication token obtained from the initialize_booking_session step. This token maintains the booking session context and must be included to create a cart. The token is returned in the response headers of the initialization call (look for "Session-Token" header).'),
      requestBody: z.object({
        airBoundIds: z.array(AirBoundId)
          .min(1)
          .max(10)
          .describe('List of selected flight bound identifiers to add to the shopping cart. These IDs come from the flight search results returned by search_flights. Each ID represents a flight segment the customer wants to book. For a one-way trip, include 1 airBoundId. For a round-trip, include 2 airBoundIds (outbound + return). For multi-city trips, include multiple airBoundIds in the order of travel. IMPORTANT: Only use airBoundIds that were returned in the most recent search_flights response for this session.'),
      }).describe('Cart creation request containing the selected flight options the customer wants to purchase.'),
    }).describe('STEP 3: Create a shopping cart with selected flights. After searching for flights using search_flights, use this endpoint to add the customer\'s chosen flight options to a cart. The cart creation validates the selections and prepares them for booking. This step is required before proceeding to passenger details and payment.');
  • Registration of the create_cart tool in the MCP tools Map, defining name, description, input schema, HTTP endpoint (/carts POST), parameters, security, and custom response serializer.
    [
      'create_cart',
      {
        name: 'create_cart',
        description: `Create a shopping cart with selected flight options. PREREQUISITES: Must call 'initialize_booking_session' first, then 'search_flights' to get available flight options. This endpoint adds the customer's selected flights (identified by airBoundIds from search results) to a cart for booking. The cart validates selections, checks availability, and calculates final pricing. WORKFLOW POSITION: Step 3 of the booking flow (after initialization and search, before passenger details and payment). RESPONSE: Returns a cartId which is required for subsequent booking operations. IMPORTANT: All airBoundIds must come from the most recent search_flights response within the same session.`,
        inputSchema: CreateCartSchema,
        method: 'post',
        pathTemplate: '/carts',
        executionParameters: [
          {
            name: 'session-token',
            in: 'header',
          },
        ],
        requestBodyContentType: 'application/json',
        securityRequirements: [
          {
            HeaderApiToken: [],
            HeaderApimSubscriptionKey: [],
            HeaderApiVersion: [],
          },
        ],
        serializer: (response: AxiosResponse<{
          data: {
            cartId: string;
          };
          warnings?: Warning[];
          errors?: ErrorDetail[];
        }>): string => {
          const { data } = response;
    
          let output = 'CART CREATION RESULT\n';
          output += '='.repeat(80) + '\n\n';
    
          if (data.errors && data.errors.length > 0) {
            output += 'ERRORS:\n';
            data.errors.forEach((error) => {
              output += `  - [${error.code}] ${error.message}\n`;
              if (error.details) {
                output += `    Details: ${JSON.stringify(error.details)}\n`;
              }
            });
            return output;
          }
    
          output += `Cart created successfully!\n\n`;
          output += `Cart ID: ${data.data.cartId}\n\n`;
    
          if (data.warnings && data.warnings.length > 0) {
            output += 'WARNINGS:\n';
            data.warnings.forEach((warning) => {
              output += `  - [${warning.code}] ${warning.message}\n`;
            });
            output += '\n';
          }
    
          output += 'Next steps:\n';
          output += '  1. Add passenger details\n';
          output += '  2. Select ancillary services (baggage, meals, etc.)\n';
          output += '  3. Proceed to payment\n';
    
          return output;
        },
      },
    ],
  • TypeScript interface defining the expected response structure for the create_cart tool.
    export interface CreateCartResponse {
      data: {
        cartId: string;
      };
      warnings?: Warning[];
      errors?: ErrorDetail[];
    }
  • Custom serializer function acting as the response handler for the create_cart tool, formatting API response into user-friendly output.
      serializer: (response: AxiosResponse<{
        data: {
          cartId: string;
        };
        warnings?: Warning[];
        errors?: ErrorDetail[];
      }>): string => {
        const { data } = response;
    
        let output = 'CART CREATION RESULT\n';
        output += '='.repeat(80) + '\n\n';
    
        if (data.errors && data.errors.length > 0) {
          output += 'ERRORS:\n';
          data.errors.forEach((error) => {
            output += `  - [${error.code}] ${error.message}\n`;
            if (error.details) {
              output += `    Details: ${JSON.stringify(error.details)}\n`;
            }
          });
          return output;
        }
    
        output += `Cart created successfully!\n\n`;
        output += `Cart ID: ${data.data.cartId}\n\n`;
    
        if (data.warnings && data.warnings.length > 0) {
          output += 'WARNINGS:\n';
          data.warnings.forEach((warning) => {
            output += `  - [${warning.code}] ${warning.message}\n`;
          });
          output += '\n';
        }
    
        output += 'Next steps:\n';
        output += '  1. Add passenger details\n';
        output += '  2. Select ancillary services (baggage, meals, etc.)\n';
        output += '  3. Proceed to payment\n';
    
        return output;
      },
    },
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure and does so effectively. It explains that the cart validates selections, checks availability, calculates final pricing, and returns a cartId required for subsequent operations. However, it doesn't mention potential errors, rate limits, or authentication details beyond the session-token, leaving some behavioral aspects uncovered.

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?

The description is well-structured with clear sections (PREREQUISITES, WORKFLOW POSITION, RESPONSE, IMPORTANT) and front-loaded key information. It's appropriately sized, but some redundancy exists (e.g., repeating the importance of recent search_flights data), which slightly reduces efficiency without major waste.

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?

Given the complexity of a multi-step booking flow with no annotations and no output schema, the description does a good job explaining prerequisites, workflow position, and response. However, it lacks details on error handling, session expiration, or what happens if availability changes, which would be helpful for a tool with mutation implications.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds some context by emphasizing that 'airBoundIds must come from the most recent search_flights response within the same session', but this is partially covered in the schema. It doesn't provide additional semantic meaning beyond what the schema offers, meeting the baseline for high coverage.

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?

The description clearly states the specific action ('Create a shopping cart with selected flight options') and resource ('cart'), distinguishing it from sibling tools like 'initialize_booking_session' and 'search_flights' by explaining its role in the booking flow. It explicitly mentions the tool adds selected flights to a cart for booking, which is distinct from session initialization or flight searching.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool: 'PREREQUISITES: Must call 'initialize_booking_session' first, then 'search_flights' to get available flight options' and 'WORKFLOW POSITION: Step 3 of the booking flow (after initialization and search, before passenger details and payment)'. It also specifies an alternative by referencing the sibling tools, making it clear this is not the first step in the workflow.

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/hrz8/mcp-openapi'

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