prakashsanker_flights_mcp_server

prakashsanker_flights_mcp_server

by prakashsanker
A Multi Context Protocol (MCP) server for handling complex travel planning queries, including flight and hotel searches.

Travel Planning MCP Server

โœˆ๏ธ Overview

The Travel Planning MCP Server is a specialized tool designed to handle complex travel planning queries. It integrates with APIs like Booking.com and Google Maps to provide real-time flight and hotel information. This server is ideal for users who need assistance with travel logistics, such as finding the latest flight to reach a destination or locating reasonably priced hotels near popular landmarks.

๐Ÿ”ง Supported Functions

๐Ÿ›ซ search-flights

Searches for available flights between two airports using Booking.com's API.

๐Ÿ“… today

Provides the current date to ensure the Large Language Model (LLM) has up-to-date temporal context.

๐Ÿจ search-hotels

Searches for available hotels and accommodations based on user preferences.

๐Ÿ”ฎ Features to Come

๐Ÿš— search-car-rentals

Find car rental options at your destination.

โญ hotel-reviews

Access reviews for hotels and accommodations.

๐Ÿš• search-taxis

Find taxi and transfer services at your destination.

๐Ÿ“ฆ Installation

Pre-requisites

  1. Obtain a Booking.com API key from RapidAPI.
  2. Obtain a Google Maps API key from Google Cloud.

Use with Claude Desktop

To integrate with Claude Desktop, configure the claude_desktop_config.json as follows:

{
  "mcpServers": {
    "travel": {
      "command": "npx",
      "args": ["travel-mcp-server"],
      "env": {
        "BOOKING_COM_API_KEY": "<YOUR_BOOKING_DOT_COM_API_KEY>"
      }
    },
    "google-maps": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GOOGLE_MAPS_API_KEY",
        "mcp/google-maps"
      ],
      "env": {
        "GOOGLE_MAPS_API_KEY": "<YOUR_GOOGLE_MAPS_API_KEY>"
      }
    }
  }
}

Programmatic Use

Hereโ€™s a code snippet for programmatic use:

class TravelClient {
  private flightsClient: Client;
  private mapsClient: Client;
  private toolDefinitions: any[] = [];

  constructor() {
    this.flightsClient = new Client(
      { name: "FlightsApp", version: "1.0.0" },
      { capabilities: { tools: {}, resources: {}, prompts: {} } }
    );
    this.mapsClient = new Client(
      { name: "MapsApp", version: "1.0.0" },
      { capabilities: { tools: {}, resources: {}, prompts: {} } }
    );
  }

  async initialize() {
    console.log("Initializing MCP clients...");
    try {
      const flightsTransport = new StdioClientTransport({
        command: "node",
        args: ["../../node_modules/travel-mcp-server/build/index.js"],
      });

      console.log("GOOGLE MAPS API KEY", process.env.GOOGLE_MAPS_API_KEY);
      const mapsTransport = new StdioClientTransport({
        command: process.execPath,
        args: [
          "../../node_modules/@modelcontextprotocol/server-google-maps/dist/index.js",
        ],
        env: {
          GOOGLE_MAPS_API_KEY: process.env.GOOGLE_MAPS_API_KEY || "",
        },
      });

      await Promise.all([
        this.flightsClient.connect(flightsTransport),
        this.mapsClient.connect(mapsTransport),
      ]);

      // Discover tools from both servers
      console.log("Discovering tools...");
      const [flightsTools, mapsTools] = await Promise.all([
        this.flightsClient.listTools(),
        this.mapsClient.listTools(),
      ]);

      // Combine tools from both servers
      this.toolDefinitions = [
        ...flightsTools.tools.map((tool) => ({
          name: tool.name,
          description: tool.description || `Tool: ${tool.name}`,
          input_schema: tool.inputSchema,
        })),
        ...mapsTools.tools.map((tool) => ({
          name: tool.name,
          description: tool.description || `Tool: ${tool.name}`,
          input_schema: tool.inputSchema,
        })),
      ];

      console.log(`Discovered ${this.toolDefinitions.length} tools`);
      return this;
    } catch (error) {
      console.error("Error initializing MCP clients:", error);
      throw error;
    }
  }

  async callTool(toolName: string, parameters: any) {
    const tool = this.toolDefinitions.find((t) => t.name === toolName);
    if (!tool) {
      throw new Error(`Tool ${toolName} not found`);
    }

    // Determine which client to use based on the tool name
    const client = toolName.includes("maps")
      ? this.mapsClient
      : this.flightsClient;

    const toolRequest = {
      name: toolName,
      arguments: parameters,
    };

    const result = await client.callTool(toolRequest);
    return result;
  }

  async getToolDefinitions() {
    return this.toolDefinitions;
  }
}

export default TravelClient;

๐ŸŒŸ About

This project is designed to simplify travel planning by integrating multiple APIs and providing a seamless experience for users. No additional description, website, or topics are provided at this time.

Resources

Stars

3 stars

Watchers

1 watching

Forks

0 forks

Report repository

Releases

No releases published.

Packages 0

No packages published.

Languages

  • JavaScript 71.1%
  • TypeScript 28.9%

Features & Capabilities

Categories
mcp_server model_context_protocol javascript typescript travel_planning api_integration claude

Implementation Details

Stats

0 Views
0 Likes
3 GitHub Stars

Repository Info

prakashsanker Organization

Similar Servers

continuedev_continue by continuedev
0
0
0