Skip to content

ppiova/TravelMCP

Repository files navigation

Travel MCP Server

A Model Context Protocol (MCP) server built with .NET that provides travel information including flights and hotels data.

Features

  • GetFlights: Search available flights with optional filtering by destination (IATA code)
  • GetHotels: Search available hotels with optional filtering by city
  • Case-insensitive filtering using Contains
  • Data loaded from embedded JSON files
  • Strongly typed with C# records
  • Custom MCP protocol implementation over stdio (JSON-RPC 2.0)
  • Zero external dependencies (except System.Text.Json)

Technologies

  • .NET 8.0: Modern C# with minimal APIs
  • System.Text.Json: Fast JSON serialization
  • MCP Protocol: Custom implementation of Model Context Protocol over stdio
  • JSON-RPC 2.0: Standard protocol for client-server communication

Prerequisites

  • .NET 8.0 SDK or higher
  • Visual Studio Code with GitHub Copilot extension

Setup

  1. Clone or navigate to the project directory

    cd TravelMCP
  2. Restore dependencies

    dotnet restore
  3. Build the project

    dotnet build

Visual Studio Code Configuration

Configure MCP in VS Code

The project includes a pre-configured .vscode/mcp.json file. To use it:

  1. Open the project in VS Code:

    code .
  2. Reload VS Code: Press Ctrl+Shift+P Developer: Reload Window

  3. Open Copilot Chat: Press Ctrl+Alt+I

  4. Verify tools are available: Type @workspace /tools in the chat

Using the MCP Server with GitHub Copilot

Once configured, you can interact with the server through GitHub Copilot Chat in VS Code:

Example prompts:

  • "Show me all available flights"
  • "Find flights to Las Vegas"
  • "What hotels are available in San Francisco?"
  • "Show me all hotels"

The MCP server will provide the data through the integrated tools.

Available Tools

GetFlights

Search for available flights with optional destination filtering.

Parameters:

  • to (optional): IATA destination code (e.g., "LAS", "SFO", "EZE")

Example usage in Copilot:

Show me flights to Las Vegas
Find flights with destination SFO

GetHotels

Search for available hotels with optional city filtering.

Parameters:

  • city (optional): City name (e.g., "Las Vegas", "San Francisco", "Buenos Aires")

Example usage in Copilot:

Show me hotels in San Francisco
Find hotels in Buenos Aires

Data Format

Flight Data

{
  "flight_number": "AA1456",
  "airline": "American Airlines",
  "from": "Miami (MIA)",
  "to": "Las Vegas (LAS)",
  "departure_time": "2025-11-05T09:45:00",
  "arrival_time": "2025-11-05T12:10:00",
  "duration": "5h 25m",
  "price_usd": 289.99
}

Hotel Data

{
  "city": "Las Vegas",
  "hotel_name": "The Venetian Resort",
  "rating": 4.8,
  "price_per_night_usd": 289.00,
  "address": "3355 S Las Vegas Blvd, Las Vegas, NV 89109, USA",
  "amenities": ["Pool", "Casino", "Spa", "Free WiFi"]
}

Project Structure

TravelMCP/
 Data/
    flights.json      # Sample flight data
    hotels.json       # Sample hotel data
 Mcp/
    McpServer.cs      # MCP server implementation
    Protocol.cs       # JSON-RPC protocol types
 Models/
    Flight.cs         # Flight data model
    Hotel.cs          # Hotel data model
 Program.cs            # Application entry point
 TravelServer.cs       # Business logic and tool handlers
 TravelMCP.csproj      # Project configuration

Testing

Test with PowerShell Script

.\test-server.ps1

This will send sample MCP requests to the server and display the responses.

Test with Automated Tests

cd Tests
dotnet run

This runs automated tests verifying:

  • Retrieving all flights
  • Filtering by IATA code
  • Case-insensitive partial search
  • Filtering hotels by city

Key Implementation Details

  1. Immutable records: Uses C# record types for data models
  2. Strong typing: All data is strongly typed with JSON deserialization
  3. Flexible filtering: Uses Contains for partial searches
  4. Case-insensitive: Searches without case distinction
  5. XML documentation: Code comments for IntelliSense
  6. Complete MCP protocol: Custom implementation without external dependencies
  7. Safe null handling: Optional parameters with default values
  8. JSON Schema: Input schema definitions for tools
  9. Error handling: Proper error responses per JSON-RPC 2.0

Future Improvements

Functionality

  • Add date validation to filter future flights
  • Implement sorting by price, rating, duration
  • Add combined GetTravelPackage(destination) tool to search flight+hotel
  • Additional filters: airline, price range, specific amenities
  • Add seat/room availability
  • Implement booking (mock)

Technical

  • Connect to real flight/hotel APIs
  • Data caching with temporal invalidation
  • Structured logging (Serilog, NLog)
  • Unit tests with xUnit/NUnit
  • Integration tests for MCP protocol
  • Metrics and telemetry
  • IATA code validation against official list
  • Multi-language support (i18n)

Architecture

  • Separate into layers (Data, Business, MCP)
  • Dependency injection
  • External configuration (appsettings.json)
  • Containerization with Docker
  • Health checks
  • Rate limiting to prevent abuse

Contributing

This is a demonstration project. Suggestions and improvements are welcome!

Resources

License

MIT


Built with using .NET and MCP

About

MCP Server for travel services - flights and hotels search

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published