Skip to main content

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.

Metadata

Release files for mcp-flight-search 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-flight-search 0.2.1
File Size Uploaded
mcp_flight_search-0.2.1.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-flight-search 0.2.1
File Interpreter ABI Platform
mcp_flight_search-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.1 kB

Release files / mcp_flight_search-0.2.1.tar.gz

Download URL mcp_flight_search-0.2.1.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9bc3d93f15b6c05c54cbf3be4ba06ac7904b2b8fd8504ab700053d73f0c22cc7
BLAKE2b-256 checksum
How to use checksums
5e2ef2e2505b6a006a4597487261b57b247c2afea432e16b8b7b590a11efe7b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / mcp_flight_search-0.2.1-py3-none-any.whl

Download URL mcp_flight_search-0.2.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e002f98e7bb234deef967d958b007405cebc44753605e66cb42f14daf83bc5a6
BLAKE2b-256 checksum
How to use checksums
3a475abfc09a268140cd1a482dba64f89c072ee6c424a7fdabf99478c64c1491
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page