Skip to main content
Glama

cancel_flight

Cancel Southwest Airlines reservations using confirmation number and passenger details. Wanna Get Away fares receive travel funds valid 12 months; Anytime/Business Select fares are fully refundable. Preview cancellation details before confirming.

Instructions

Cancel a Southwest reservation. Wanna Get Away fares receive travel funds (valid 12 months). Anytime/Business Select fares are fully refundable.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
confirmationNumberYes6-character booking confirmation number
firstNameYesPassenger first name
lastNameYesPassenger last name
confirmNoSet to true to confirm cancellation. If false, returns cancellation details without actually cancelling.

Implementation Reference

  • The main handler function that executes the cancel_flight tool logic. Navigates to Southwest's manage reservation page, looks up the booking by confirmation number and passenger name, checks if cancellation is available, determines refund eligibility based on fare type, and either returns cancellation details or proceeds with cancellation if confirmed.
    export async function cancelFlight(input: CancelFlightInput) {
      const page = await getPage();
    
      // Navigate to manage reservation
      await page.goto(
        "https://www.southwest.com/air/manage-reservation/index.html",
        { waitUntil: "networkidle" }
      );
    
      await page.fill(
        '[data-qa="confirmation-number"], [name="confirmationNumber"]',
        input.confirmationNumber.toUpperCase()
      );
      await page.fill('[data-qa="first-name"], [name="firstName"]', input.firstName);
      await page.fill('[data-qa="last-name"], [name="lastName"]', input.lastName);
    
      await page.click('[data-qa="search-button"], [data-qa="retrieve-button"]');
      await page.waitForNavigation({ waitUntil: "networkidle" }).catch(() => {});
    
      // Get refund preview before cancelling
      const cancelButton = page.locator(
        '[data-qa="cancel-flight-btn"], [data-qa*="cancel"], a[href*="cancel"]'
      );
      const cancelAvailable = await cancelButton.isVisible().catch(() => false);
    
      if (!cancelAvailable) {
        return {
          success: false,
          message:
            "Cancel option not found. The flight may have already departed or is within the non-cancellable window.",
        };
      }
    
      // Get fare type to determine refund type
      const fareType = await page
        .locator('[data-qa="fare-type"], .fare-type-label')
        .first()
        .textContent()
        .catch(() => null);
    
      const isRefundable =
        fareType?.toLowerCase().includes("anytime") ||
        fareType?.toLowerCase().includes("business");
    
      const refundNote = isRefundable
        ? "This fare is refundable — you'll receive a full refund to your original payment method."
        : "Non-refundable fare — you'll receive Southwest travel funds valid for 12 months from original purchase date.";
    
      if (!input.confirm) {
        return {
          success: false,
          requiresConfirmation: true,
          confirmationNumber: input.confirmationNumber.toUpperCase(),
          passengerName: `${input.firstName} ${input.lastName}`,
          fareType: fareType?.trim() || "Unknown",
          isRefundable,
          refundNote,
          message: `To confirm cancellation, call this tool again with confirm: true. ${refundNote}`,
        };
      }
    
      // Proceed with cancellation
      await cancelButton.first().click();
      await page.waitForNavigation({ waitUntil: "networkidle" }).catch(() => {});
    
      // Confirm cancellation on the next page
      const confirmCancelButton = page.locator(
        '[data-qa="confirm-cancel"], [data-qa="cancel-confirm-btn"]'
      );
      if (await confirmCancelButton.isVisible().catch(() => false)) {
        await confirmCancelButton.click();
        await page.waitForNavigation({ waitUntil: "networkidle" }).catch(() => {});
      }
    
      const cancelled = await page
        .locator('[data-qa="cancellation-confirmed"], .cancellation-success')
        .isVisible()
        .catch(() => false);
    
      const travelFundsAmount = await page
        .locator('[data-qa="travel-funds-amount"], .travel-funds-value')
        .textContent()
        .catch(() => null);
    
      return {
        success: cancelled,
        confirmationNumber: input.confirmationNumber.toUpperCase(),
        passengerName: `${input.firstName} ${input.lastName}`,
        isRefundable,
        travelFundsIssued: !isRefundable,
        travelFundsAmount: travelFundsAmount?.trim() || null,
        refundNote,
        message: cancelled
          ? isRefundable
            ? "Flight cancelled. Refund will be processed to original payment method within 7 business days."
            : `Flight cancelled. Travel funds of ${travelFundsAmount || "the paid amount"} will be available in your account for 12 months.`
          : "Cancellation may have been processed — check your email for confirmation.",
      };
    }
  • Zod schema defining the input validation for cancel_flight tool. Requires confirmationNumber (6-char string), firstName, lastName, and an optional confirm boolean (defaults to false) that determines whether to actually cancel or just return cancellation details.
    export const cancelFlightSchema = z.object({
      confirmationNumber: z
        .string()
        .describe("6-character booking confirmation number"),
      firstName: z.string().describe("Passenger first name"),
      lastName: z.string().describe("Passenger last name"),
      confirm: z
        .boolean()
        .default(false)
        .describe(
          "Set to true to confirm cancellation. If false, returns cancellation details without actually cancelling."
        ),
    });
    
    export type CancelFlightInput = z.infer<typeof cancelFlightSchema>;
  • src/index.ts:139-144 (registration)
    Tool registration in the TOOLS array, defining the tool name as 'cancel_flight', providing a description about cancellation policies for different fare types, and linking to the cancelFlightSchema for input validation.
    {
      name: "cancel_flight",
      description:
        "Cancel a Southwest reservation. Wanna Get Away fares receive travel funds (valid 12 months). Anytime/Business Select fares are fully refundable.",
      inputSchema: zodToJsonSchema(cancelFlightSchema),
    },
  • src/index.ts:220-222 (registration)
    The case handler in the CallToolRequestSchema switch statement that routes 'cancel_flight' tool calls to the cancelFlight function, parsing input arguments with cancelFlightSchema.
    case "cancel_flight":
      result = await cancelFlight(cancelFlightSchema.parse(args));
      break;
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. It effectively describes key behavioral traits: the tool cancels reservations, specifies outcomes based on fare types (Wanna Get Away fares get travel funds valid 12 months, Anytime/Business Select fares are fully refundable), and implies a mutation operation. However, it does not cover aspects like error handling, authentication needs, or rate limits.

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

Conciseness5/5

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

The description is highly concise and front-loaded, consisting of two sentences that directly convey the tool's purpose and key behavioral details. Every sentence earns its place by providing essential information without redundancy or fluff, making it efficient and easy to parse.

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

Completeness3/5

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

Given the tool's complexity (a mutation operation with no annotations and no output schema), the description is somewhat complete but has gaps. It covers the action and fare-specific outcomes, but lacks details on return values, error conditions, or side effects. For a cancellation tool with no structured output, more context on what to expect post-execution would be beneficial.

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?

The input schema has 100% description coverage, so the schema already documents all parameters (confirmationNumber, firstName, lastName, confirm). The description does not add any parameter-specific details beyond what the schema provides, such as explaining how parameters interact or their impact on behavior. The baseline score of 3 is appropriate since the schema handles the heavy lifting.

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 ('Cancel a Southwest reservation') and distinguishes it from sibling tools like 'change_flight' or 'get_reservation' by focusing on cancellation rather than modification or retrieval. It specifies the resource type (Southwest reservation) and the verb (cancel), making the purpose unambiguous.

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?

The description implies usage for cancelling Southwest reservations but does not explicitly state when to use this tool versus alternatives like 'change_flight' or provide exclusions. It mentions fare-specific outcomes (e.g., travel funds vs. refunds), which hints at context, but lacks direct guidance on prerequisites or when-not-to-use scenarios.

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/markswendsen-code/mcp-southwest'

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