travel-mcp-server

sivasiddamoorthy3-cpu/travel-mcp-server

3.2

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

The Travel MCP Server is a Golang-based server designed to handle travel operations such as booking, retrieving, and canceling tickets. It integrates seamlessly with AI agents like AssistAnt to provide a robust travel management solution.

Tools
3
Resources
0
Prompts
0

Travel MCP Server With GoLang

Here's a complete, production-ready example of a Golang MCP server for travel operations (booking, getting, and canceling tickets) with full VS Code integration and internal workflow explanations.

Step 1: Navigate to your project

cd /root/go/DCM/Siva-MCP-servers/travel-mcp-server/

Step 2: Clean and rebuild

go clean
go mod tidy
go build -o travel-mcp-server main.go

Step 3: Verify the executable

ls -la travel-mcp-server
chmod +x travel-mcp-server

Expected output:

-rwxr-xr-x 1 root root 15234567 Nov 16 12:50 travel-mcp-server

Step 4: VS Code Configuration

Create a file named mcp.json in your project root:

{
  "servers": {
    "travel-booking": {
      "type": "stdio",
      "command": "/absolute/path/to/travel-mcp-server",
      "env": {
        "LOG_LEVEL": "info"
      }
    }
  }
}

Alternatively, for VS Code's native MCP support via AssistAnt Extension, create .vscode/settings.json: ex: .vscode-server/data/User/globalStorage/assistant.assistant/settings/cline_mcp_settings.json Ex: /absolute/path/to/travel-mcp-server means ==> /root/go/DCM/Siva-MCP-servers/travel-mcp-server/travel-mcp-server

{
  "mcp.servers": {
    "travel-booking": {
      "command": "/absolute/path/to/travel-mcp-server",
      "type": "stdio"
    }
  }
}

How It Works Internally With Prompts

Scenario: User Prompt to AI Agent

User prompt to AssistAnt:

"I need to book a flight for John Smith from New York to Los Angeles on December 25, 2025, departing at 10:00 AM and arriving at 1:00 PM. The price is $450. After booking, show me all tickets for John Smith."

Internal Workflow Breakdown

Step 1: Prompt Analysis by AI Agent

AssistAnt receives the prompt and analyzes it:

  • Identifies entities: passenger name (John Smith), cities (New York → Los Angeles), times, price
  • Recognizes actions: "book" (requires book_ticket tool) and "show me all tickets" (requires list_tickets tool)
  • Determines MCP context: The agent consults the available tools from the MCP server
Step 2: MCP Server Context Discovery

The AI agent queries the MCP server's capability registry (automatically done through the protocol). The server responds with:

{
  "tools": [
    {
      "name": "book_ticket",
      "description": "Book a travel ticket for a passenger",
      "inputSchema": {
        "type": "object",
        "properties": {
          "passenger_name": {"type": "string"},
          "from": {"type": "string"},
          "to": {"type": "string"},
          "departure_time": {"type": "string", "description": "Format: YYYY-MM-DD HH:MM"},
          "arrival_time": {"type": "string"},
          "ticket_type": {"type": "string"},
          "price": {"type": "number"},
          "currency": {"type": "string"}
        }
      }
    },
    {
      "name": "list_tickets",
      "description": "List all tickets for a specific passenger",
      "inputSchema": {}
    }
  ]
}
Step 3: Tool Invocation (First Call)

AssistAnt formulates a JSON-RPC 2.0 request to invoke book_ticket:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "book_ticket",
    "arguments": {
      "passenger_name": "John Smith",
      "from": "New York",
      "to": "Los Angeles",
      "departure_time": "2025-12-25 10:00",
      "arrival_time": "2025-12-25 13:00",
      "ticket_type": "flight",
      "price": 450,
      "currency": "USD"
    }
  }
}
Step 4: MCP Server Processes Request
  • Parameter Validation: Server validates all required fields are present
  • Business Logic: handleBookTicket() executes:
    • Generates unique ticket ID using UUID
    • Creates Ticket object with all details
    • Stores in database (ticketDB map)
    • Generates seat number (e.g., "C23")
    • Records booking timestamp
    • Concurrency Management: Mutex locks ensure thread-safe database operations
Step 5: MCP Server Returns Response
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\n  \"status\": \"success\",\n  \"ticket_id\": \"a1b2c3d4-e5f6-7890-1234-567890abcdef\",\n  \"message\": \"✅ Ticket booked successfully for John Smith\",\n  \"ticket\": {\n    \"id\": \"a1b2c3d4-e5f6-7890-1234-567890abcdef\",\n    \"passenger_name\": \"John Smith\",\n    \"from\": \"New York\",\n    \"to\": \"Los Angeles\",\n    \"departure_time\": \"2025-12-25 10:00\",\n    \"arrival_time\": \"2025-12-25 13:00\",\n    \"price\": 450,\n    \"currency\": \"USD\",\n    \"status\": \"booked\",\n    \"booked_at\": \"2025-11-11T08:03:00Z\",\n    \"seat_number\": \"C23\",\n    \"ticket_type\": \"flight\"\n  }\n}"
      }
    ]
  }
}
Step 6: Tool Invocation (Second Call)

AssistAnt now calls list_tickets to show all bookings:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "list_tickets",
    "arguments": {
      "passenger_name": "John Smith"
    }
  }
}
Step 7: MCP Server Processes Second Request
  • Database Query: Server locks and iterates through ticketDB
  • Filtering: Returns only tickets matching "John Smith"
  • Response Formatting: Returns structured JSON with all matching tickets
Step 8: AI Agent Presents Result to User

AssistAnt synthesizes both responses and presents to the user:

Booking Confirmation:

✅ Successfully booked a flight for John Smith

  • Ticket ID: a1b2c3d4-e5f6-7890-1234-567890abcdef
  • Route: New York → Los Angeles
  • Departure: December 25, 2025 at 10:00 AM
  • Arrival: December 25, 2025 at 1:00 PM
  • Seat: C23
  • Price: $450.00
  • Status: Booked

All Tickets for John Smith:

  • The flight booking shown above (Status: Booked)

Second Example: Cancellation Workflow

User prompt:

"Cancel the ticket with ID a1b2c3d4-e5f6-7890-1234-567890abcdef because I need to reschedule."

Step 1: Prompt Recognition

AssistAnt identifies action: "Cancel" → cancel_ticket tool needed

Step 2: Tool Invocation
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "cancel_ticket",
    "arguments": {
      "ticket_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
      "reason": "User needs to reschedule"
    }
  }
}
Step 3: Server Processing
  • Finds ticket in database
  • Updates status to StatusCanceled
  • Records cancellation timestamp
  • Calculates refund (90% of $450 = $405)
  • Returns confirmation with refund details
Step 4: AI Response

✅ Ticket successfully canceled!

  • Ticket ID: a1b2c3d4-e5f6-7890-1234-567890abcdef
  • Refund Amount: $405.00
  • Cancellation Reason: User needs to reschedule
  • Canceled At: 2025-11-11 08:05:30 UTC

Step 5: Running the Complete System

Terminal 1: Start the MCP server

./travel-mcp-server

Output:

🚀 Starting Travel Booking MCP Server...
✅ MCP Server initialized. Waiting for connections...

Terminal 2 (or VS Code):

  • Open AssistAnt or VS Code with MCP integration
  • Paste the user prompts shown above
  • Watch as AssistAnt orchestrates multiple tool calls seamlessly

Internal Architecture Summary

ComponentRoleTechnology
Golang ServerExposes tools via JSON-RPC 2.0 protocolmark3labs/mcp-go SDK
Tool HandlersBusiness logic for each operationGo functions with context handling
Thread SafetyPrevents race conditions in shared databasesync.RWMutex
Protocol TransportCommunication between AssistAnt and serverSTDIO (standard input/output)
Persistence LayerIn-memory ticket storageGo map with UUID keys
Type SystemValidates arguments before executionGo structs + JSON schema

This implementation demonstrates how MCP servers act as a bridge between AI reasoning and real-world systems—AssistAnt handles the "what" and "why," while the MCP server handles the "how."