MCPSample-Flight

TORU0239/MCPSample-Flight

3.1

If you are the rightful owner of MCPSample-Flight and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

MCPSample-Flight is a Model Context Protocol (MCP) server designed to facilitate flight search operations using Natural Language Processing (NLP) technology.

Conversational Flight Search

AI-powered flight search service with natural language processing, built with microservices architecture.

Overview

A two-tier system that enables users to search flights through natural conversation:

  • API Gateway - Handles chat interactions, understands natural language using LLM (OpenAI/Anthropic)
  • MCP Flight Server - Integrates with Amadeus GDS for real-time flight data

Architecture

User → [/chat] → API Gateway (:8787) → [MCP Protocol] → Flight Server (:8700) → Amadeus API
                       ↓                                         
                  OpenAI/Claude                              

Quick Start

Prerequisites

  • Node.js 18+
  • Amadeus API credentials (Register here)
  • OpenAI or Anthropic API key

Installation

  1. Clone and install dependencies
# Clone repository
git clone <your-repo-url>
cd <project-root>

# Install Flight Server
cd mcp-flight-server
npm install
cp .env.example .env  # Add Amadeus credentials

# Install API Gateway
cd ../api-gateway
npm install
cp .env.example .env  # Add LLM API keys
  1. Configure environment variables

mcp-flight-server/.env

AMADEUS_CLIENT_ID=your_amadeus_client_id
AMADEUS_CLIENT_SECRET=your_amadeus_client_secret
PORT=8700

api-gateway/.env

# Server
PORT=8787
FLIGHT_SERVER_URL=http://localhost:8700

# LLM Provider (choose one)
LLM_PROVIDER=openai  # or anthropic

# OpenAI
OPENAI_API_KEY=your_openai_key
OPENAI_MODEL=gpt-4o-mini

# OR Anthropic
ANTHROPIC_API_KEY=your_anthropic_key
ANTHROPIC_MODEL=claude-3-5-sonnet-20241022
  1. Start services
# Terminal 1: Start Flight Server
cd mcp-flight-server
npm run dev

# Terminal 2: Start API Gateway
cd api-gateway
npm run dev

Usage

Chat with the Assistant

POST http://localhost:8787/chat

curl -X POST http://localhost:8787/chat \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {
        "role": "user",
        "content": "Find me flights from Seoul to New York next Monday"
      }
    ]
  }'

Response:

{
  "message": "I found 15 flights from ICN to JFK. The cheapest option is $890 with one stop...",
  "flights": {
    "currency": "USD",
    "items": [...]
  },
  "cards": [
    {"title": "Local Food", "summary": "Must-try NYC dishes..."},
    {"title": "Top Attractions", "summary": "Empire State, Central Park..."},
    {"title": "Travel Tips", "summary": "NYC subway guide..."}
  ]
}

Direct Flight Search

POST http://localhost:8787/search-flights

{
  "origin": "ICN",
  "destination": "JFK",
  "departDate": "2025-03-15",
  "returnDate": "2025-03-22",
  "adults": 2,
  "currency": "USD"
}

API Endpoints

API Gateway (Port 8787)

EndpointMethodDescription
/chatPOSTNatural language flight search
/search-flightsPOSTDirect flight search
/locationsGETIATA code lookup
/healthGETService health check

Flight Server (Port 8700)

EndpointMethodDescription
/mcpPOSTMCP protocol handler
/api/search-flightsPOSTREST API (legacy)
/healthGETService health check

Tech Stack

ComponentTechnology
RuntimeNode.js 18+
FrameworkFastify 5
LanguageTypeScript 5.9
LLMOpenAI GPT-4 / Anthropic Claude 3.5
GDSAmadeus Test API
ValidationZod
ProtocolMCP (Message Communication Protocol)

Project Structure

.
ā”œā”€ā”€ api-gateway/
│   └── src/
│       ā”œā”€ā”€ index.ts        # Main gateway server
│       ā”œā”€ā”€ llm.ts          # LLM integration
│       ā”œā”€ā”€ mcpClient.ts    # MCP client
│       └── types.ts        # TypeScript types
│
└── mcp-flight-server/
    └── src/
        ā”œā”€ā”€ index.ts        # Flight server with Amadeus
        ā”œā”€ā”€ types.ts        # Type definitions
        └── schema.ts       # Zod schemas

Features

  • Natural Language Processing - Understands conversational queries
  • Smart Intent Detection - Extracts flight search parameters from text
  • Travel Recommendations - Generates destination info cards
  • OAuth Token Management - Automatic Amadeus token refresh
  • Rate Limiting - 100 requests/minute per client
  • Type Safety - Full TypeScript with runtime validation

Development

# Build for production
npm run build

# Start production server
npm start

# Type checking
npx tsc --noEmit

Troubleshooting

IssueSolution
"AMADEUS_CLIENT_ID not set"Add Amadeus credentials to .env
"LLM provider not configured"Set OpenAI or Anthropic API key
No flight resultsCheck IATA codes and date format (YYYY-MM-DD)
Connection refusedEnsure both servers are running

License

MIT

Author

Wonyoung Choi