航班搜索预订服务

一个基于Duffel API的航班搜索和预订服务,提供完整的航班预订流程。

  • by modellers
  • JavaScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 modellers/mcp-duffel-travels

使用说明

MCP行李旅行

模型上下文协议(MCP)服务器,使用 API达菲.

特性

此MCP服务器使用以下工具实现完整的航班预订工作流程:

  1. 航班优惠请求 -根据出发地、目的地、日期和乘客搜索航班优惠
  2. 航班优惠 -获取特定航班优惠的详细信息
  3. 机票_预订_有效期_价格_优惠 -验证报价并确认当前定价
  4. 航班预订列表服务和地图 -查看可用服务和座位图
  5. 航班预订创建订单 -使用乘客详细信息创建预订订单
  6. 航班_预订_预订_订单 -处理已暂停订单的付款
  7. 航班_预订_订单_状态 -检索订单状态和电子机票

先决条件

  • Node.js 18或更高版本
  • Duffel API钥匙(在https://duffel.com)

安装

npm install
npm run build

配置

将Duffel API密钥设置为环境变量:

export DUFFEL_API_KEY=your_duffel_api_key_here

用法

运行服务器

node build/index.js

与Claude Desktop一起使用

将以下内容添加到您的Claude Desktop配置文件中:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json 视窗: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "duffel-travels": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-duffel-travels/build/index.js"],
      "env": {
        "DUFFEL_API_KEY": "your_duffel_api_key_here"
      }
    }
  }
}

航班预订工作流程

典型的航班预订流程遵循以下步骤:

1.搜索航班

使用 flight_offer_request 搜索可用航班:

{
  "origin": "JFK",
  "destination": "LAX",
  "departure_date": "2024-12-20",
  "return_date": "2024-12-27",
  "passengers": [
    { "type": "adult" }
  ],
  "cabin_class": "economy"
}

2.获取优惠详情

使用 flight_offers 要获取有关特定优惠的详细信息:

{
  "offer_id": "off_123abc..."
}

3.验证报价

使用 flight_booking_validate_or_price_offer 确认当前价格:

{
  "offer_id": "off_123abc..."
}

4.查看服务和座位(可选)

使用 flight_booking_list_services_and_seatmaps 查看可用的附加组件:

{
  "offer_id": "off_123abc..."
}

5.创建订单

使用 flight_booking_create_order 预订航班:

{
  "offer_id": "off_123abc...",
  "passengers": [
    {
      "id": "pas_0000...",
      "given_name": "John",
      "family_name": "Doe",
      "born_on": "1990-01-01",
      "email": "john.doe@example.com",
      "phone_number": "+1234567890"
    }
  ]
}

6.订单付款(如需要)

使用 flight_booking_pay_for_order 如果订单被搁置:

{
  "order_id": "ord_123abc...",
  "payment": {
    "type": "balance",
    "amount": "100.00",
    "currency": "USD"
  }
}

7.检查订单状态

使用 flight_booking_get_order_status 取回门票和确认:

{
  "order_id": "ord_123abc..."
}

发展

构建

npm run build

观看模式

npm run watch

API 文档

有关Duffel API的详细信息,请访问:

许可证

麻省理工学院