Skip to main content

Flight search service implementing Model Context Protocol (MCP) tools

Project description

MCP Flight Search

A flight search service built with Model Context Protocol (MCP). This service demonstrates how to implement MCP tools for flight search capabilities.

What is Model Context Protocol?

The Model Context Protocol (MCP) is a standard developed by Anthropic that enables AI models to use tools by defining a structured format for tool descriptions, calls, and responses. This project implements MCP tools that can be used by Claude and other MCP-compatible models.

Installation

# Install from PyPI
pip install mcp-flight-search

# Or install from the project directory (development mode)
pip install -e .

Usage

Start the MCP server:

# Using the command-line entry point
mcp-flight-search --connection_type http

# Or run directly
python main.py --connection_type http

You can also specify a custom port:

python main.py --connection_type http --port 5000

Environment Variables

Set the SerpAPI key as an environment variable:

export SERP_API_KEY="your-api-key-here"

Features

  • MCP-compliant tools for flight search functionality
  • Integration with SerpAPI Google Flights
  • Support for one-way and round-trip flights
  • Rich logging with structured output
  • Modular, maintainable code structure

MCP Tools

This package provides the following Model Context Protocol tools:

  • search_flights_tool: Search for flights between airports with parameters:

    • origin: Departure airport code (e.g., ATL, JFK)
    • destination: Arrival airport code (e.g., LAX, ORD)
    • outbound_date: Departure date (YYYY-MM-DD)
    • return_date: Optional return date for round trips (YYYY-MM-DD)
  • server_status: Check if the MCP server is running

Project Structure

mcp-flight-search/
├── mcp_flight_search/
│   ├── __init__.py              # Package initialization and exports
│   ├── config.py                # Configuration variables (API keys)
│   ├── models/
│   │   ├── __init__.py          # Models package init
│   │   └── schemas.py           # Pydantic models (FlightInfo)
│   ├── services/
│   │   ├── __init__.py          # Services package init
│   │   ├── search_service.py    # Main flight search logic
│   │   └── serpapi_client.py    # SerpAPI client wrapper
│   ├── utils/
│   │   ├── __init__.py          # Utils package init
│   │   └── logging.py           # Logging configuration
│   └── server.py                # MCP server setup and tool registration
├── main.py                      # Main entry point
├── pyproject.toml               # Python packaging configuration
├── LICENSE                      # MIT License
└── README.md                    # Project documentation

Author

For more articles on AI/ML and Generative AI, follow me on Medium: https://medium.com/@arjun-prabhulal

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_mcp_flight_search-0.2.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_mcp_flight_search-0.2.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_mcp_flight_search-0.2.0.tar.gz.

File metadata

File hashes

Hashes for iflow_mcp_mcp_flight_search-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a738861c3336ef1b23748e4d5f6d3f2fbc531f1058fcd96a93cb0472e36588a9
MD5 357f18d6e8bb2c8587d9bd0c60e06154
BLAKE2b-256 f20da12da59c298dfc67a3072b1a8209786b9db62c1d10edfcde9796c2e1639b

See more details on using hashes here.

File details

Details for the file iflow_mcp_mcp_flight_search-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for iflow_mcp_mcp_flight_search-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0dd4ead2719e61122a40dbb9562ba9d9b26c93fe52b6acab23a27d6daabd8992
MD5 abb4f6fae99567bcda9218d55bba2fc0
BLAKE2b-256 8a72fc28b206f9ed84b7480ff9d3c2fa10d66a61ac3ff4891db1578cc22ba708

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page