Skip to main content
Glama
hrz8

DSP Booking MCP Server

by hrz8

initialize_booking_session

Start a flight booking session by providing travel details like routes, dates, and passenger information to validate parameters and obtain a session token for subsequent searches.

Instructions

Initialize a new booking session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestBodyYesInitial flight search parameters to validate and establish booking session. This creates the foundation for subsequent flight searches.

Implementation Reference

  • Zod input schema for the initialize_booking_session tool, which requires a requestBody matching FlightSearchBodySchema.
    export const InitializeBookingSchema = z.object({
      requestBody: FlightSearchBodySchema
        .describe('Initial flight search parameters to validate and establish booking session. This creates the foundation for subsequent flight searches.'),
    }).describe('REQUIRED FIRST STEP: Initialize booking session with airline system. Call this endpoint first to receive a session token, then use that token for actual flight searches. The session token will be returned in the response headers and must be captured for the next step.');
  • Definition and registration of the initialize_booking_session tool in the tools Map, specifying HTTP POST to '/initialisation', input schema, security requirements, and custom response serializer that extracts session token from headers.
    [
      'initialize_booking_session',
      {
        name: 'initialize_booking_session',
        description: 'Initialize a new booking session.',
        inputSchema: InitializeBookingSchema,
        method: 'post',
        pathTemplate: '/initialisation',
        executionParameters: [],
        requestBodyContentType: 'application/json',
        securityRequirements: [
          {
            HeaderApiToken: [],
            HeaderApimSubscriptionKey: [],
            HeaderApiVersion: [],
          },
        ],
        serializer: (response: AxiosResponse): string => {
          const sessionToken = response.headers['session-token'];
    
          let output = 'BOOKING SESSION INITIALIZED\n';
          output += '='.repeat(80) + '\n\n';
    
          if (sessionToken) {
            output += `Session Token: ${sessionToken}\n`;
            output += '(Token has been captured and will be used automatically for subsequent requests)\n\n';
          }
    
          output += 'Status: Ready\n';
          output += 'Next step: Use search_flights tool to find available flights\n';
    
          return output;
        },
      },
    ],
  • MCP server registration of all tools from the tools map, handling list_tools and call_tool requests by retrieving tool definition and executing via executeApiTool.
    export function registerTools(server: Server): void {
      server.setRequestHandler(ListToolsRequestSchema, async () => {
        const toolsForClient: Tool[] = [];
        for (const def of Array.from(tools.values())) {
          toolsForClient.push({
            name: def.name,
            description: def.description,
            inputSchema: zodToMcpJsonSchema(def.inputSchema),
          });
        }
        return {
          tools: toolsForClient,
        };
      });
    
      server.setRequestHandler(
        CallToolRequestSchema,
        async (request: CallToolRequest): Promise<CallToolResult> => {
          const { name: toolName, arguments: toolArgs } = request.params;
          console.info(`Attempt to use custom tool: ${toolName}`);
    
          const toolDefinition = tools.get(toolName);
    
          if (!toolDefinition) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Error: Unknown tool requested: ${toolName}`,
                },
              ],
            };
          }
    
          return await executeApiTool(
            toolName,
            toolDefinition,
            toolArgs ?? {},
            securitySchemes,
          );
        },
      );
    }
  • Generic handler function that executes API tools: validates inputs with schema, builds HTTP request from tool definition (method, path, params, body), applies security, makes axios call to booking API, and formats response using the tool's custom serializer.
    export async function executeApiTool(
      toolName: string,
      definition: McpToolDefinition,
      toolArgs: Record<string, unknown>,
      securityRequirementDictionaries: Record<string, SecurityScheme>,
    ): Promise<CallToolResult> {
      // 1. Validate arguments
      const validation = validateToolArguments(toolName, definition, toolArgs);
      if (!validation.success) {
        return validation.result;
      }
    
      try {
        // 2. Build request configuration
        const baseUrl = DSP_BOOKING_BASE_URL;
        const requestConfig = buildRequestConfig(definition, validation.data);
    
        // 3. Validate and apply security
        const securityContext = validateSecurity(definition, securityRequirementDictionaries);
        if (!securityContext.isValid) {
          console.warn(`Tool '${toolName}' ${securityContext.errorMessage}`);
          return {
            content: [
              {
                type: 'text',
                text: `Internal error during tool setup: '${toolName}'`,
              },
            ],
          };
        }
    
        if (securityContext.appliedSecurity) {
          await applySecurity(
            requestConfig.headers,
            securityContext.appliedSecurity,
            securityRequirementDictionaries,
          );
        }
    
        // 4. Create axios configuration
        const axiosConfig: AxiosRequestConfig = {
          method: definition.method.toUpperCase(),
          url: baseUrl + requestConfig.urlPath,
          params: requestConfig.queryParams,
          headers: requestConfig.headers,
          ...(requestConfig.requestBodyData !== undefined && { data: requestConfig.requestBodyData }),
        };
    
        // 5. Execute request
        console.info(`Executing tool "${toolName}": ${axiosConfig.method} ${axiosConfig.url}`);
        const response = await axios(axiosConfig);
    
        // 6. Format and return response - pass definition instead of toolName
        return formatResponse(response, definition);
      } catch (error) {
        return formatError(toolName, error);
      }
    }
Behavior3/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 mentions that this creates a session token for subsequent steps, which is useful context, but lacks details on error handling, rate limits, authentication needs, or what happens if parameters are invalid. It provides some behavioral insight but not comprehensive coverage for a session-initialization tool.

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 extremely concise with just one sentence ('Initialize a new booking session.') and the schema includes a detailed description that adds necessary context without redundancy. Every part earns its place, making it front-loaded and efficient.

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 (nested objects, 1 parameter with rich schema) and no output schema, the description is reasonably complete. It explains the tool's role as a first step and hints at the response (session token), but could be more detailed about behavioral aspects like error cases or session management, given the lack of annotations.

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 all parameters thoroughly. The description adds minimal parameter semantics beyond the schema, such as emphasizing it's for 'initial flight search parameters,' but doesn't provide additional context like examples or edge cases. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Initialize') and resource ('booking session'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'create_cart' or 'search_flights', which might be related booking operations, so it doesn't achieve full sibling distinction.

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 explicitly states 'REQUIRED FIRST STEP' and provides clear guidance on when to use it ('Call this endpoint first to receive a session token, then use that token for actual flight searches'), including the sequence of operations and the alternative tools to use next.

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