Skip to main content
Glama
ravinahp

Find Flights MCP Server

by ravinahp

查找航班 MCP 服务器选项 #1

铁匠徽章 MCP 服务器使用 Duffel API 搜索和检索航班信息。

工作原理

航班

Related MCP server: Flight + Stay Search MCP

视频演示

https://github.com/user-attachments/assets/c111aa4c-9559-4d74-a2f6-60e322c273d4

为什么这很有用

虽然像 Google Flights 这样的工具对于简单的行程来说已经很实用了,但这款工具在处理复杂的旅行计划时却更加出色。原因如下:

  • 上下文记忆:Claude 会记住您之前在聊天中搜索过的所有航班,因此您无需打开多个标签页来比较价格

  • 灵活的日期搜索:轻松搜索多天以找到最佳价格,无需手动检查每个日期

  • 复杂的行程:非常适合多城市旅行、单程航班,或者当您需要比较不同的路线选择时,您只需询问即可!

  • 自然对话:只需描述您要查找的内容 - 无需再点击日历界面或调整搜索参数来解析城市名称、日期和时间。

可以将其想象为在您的聊天中有一位旅行社代理,他能记住您讨论过的所有内容,并可以立即搜索日期和路线。

特征

  • 搜索多个目的地之间的航班

  • 支持单程、往返、多城市航班查询

  • 详细的航班优惠信息

  • 灵活的搜索参数(出发时间、舱位等级、乘客人数)

  • 自动处理航班转接

  • 搜索多日内的航班,找到最适合您行程的航班(速度较慢)

先决条件

  • Python 3.x

  • Duffel API 实时密钥

获取您的 Duffel API 密钥

Duffel 需要帐户验证和付款信息设置,但此 MCP 服务器仅使用 API 来搜索航班 - 不会向您的帐户进行实际预订或收费。

先试用 duffel_test 来体验一下这个工具的强大功能。如果您觉得好用,可以按照下面的验证流程使用正式版密钥。

首先测试模式(推荐)

您可以先使用测试 API 密钥( duffel_test )来尝试使用模拟数据的功能,然后再进行完整的验证过程:

  1. 访问Duffel 的注册页面

  2. 创建帐户(公司名称可以选择“个人使用”)

  3. 导航至“更多”>“开发者”以找到您的测试 API 密钥(已提供一个)

获取实时 API 密钥

要访问真实飞行数据,请按照以下步骤操作:

  1. 在 Duffel 仪表板中,关闭左上角的“测试模式”

  2. 验证过程需要多个步骤 - 您需要反复关闭测试模式:

    • 第一个切换:验证您的电子邮件地址

    • 再次切换:填写公司信息(个人使用即可)

    • 再次切换:添加付款信息(Duffel 要求,但此 MCP 服务器不会收取任何费用)

    • 再次切换:完成所有剩余的验证步骤

    • 最后切换:点击“同意并提交”后进入实时模式

  3. 完全验证后,转到更多>开发者>创建实时令牌

  4. 复制您的实时 API 密钥

💡 提示:每次完成验证步骤后,您都需要再次关闭测试模式才能继续下一步。请持续关闭测试模式,直到完成所有要求。

⚠️重要提示:

  • 您的付款信息由 Duffel 直接处理,MCP 服务器不会访问或存储

  • 此 MCP 服务器为只读服务器 - 它只能搜索航班,而不能预订航班

  • 通过此集成,您的付款方式不会收取任何费用

  • 所有敏感信息(包括 API 密钥)都保留在您的机器本地

  • 您可以从测试 API 密钥( duffel_test )开始评估功能

  • 验证过程可能需要一些时间 - 这是 Duffel 的标准要求

安全说明

此 MCP 服务器仅使用 Duffel 的搜索端点,无法进行预订或收费。您的付款信息仅用于 Duffel 的验证流程,MCP 服务器绝不会访问或与 Duffel 共享。

关于 API 使用限制的说明

  • 查看 Duffel 的当前价格和使用限制

  • 根据您的需求提供不同等级

  • 建议查看其网站上的当前价格

安装

通过 Smithery 安装

要通过Smithery自动安装 Claude Desktop 的 Find Flights:

npx -y @smithery/cli install @ravinahp/travel-mcp --client claude

手动安装

克隆存储库:

git clone https://github.com/ravinahp/flights-mcp
cd flights-mcp

使用 uv 安装依赖项:

uv sync

注意:由于该项目使用 pyproject.toml 进行依赖管理,因此我们使用 uv 而不是 pip。

配置为 MCP 服务器

要将此工具添加为 MCP 服务器,请修改您的 Claude 桌面配置文件。

配置文件位置:

  • MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%/Claude/claude_desktop_config.json

将以下配置添加到您的 JSON 文件:

{
    "flights-mcp": {
        "command": "uv",
        "args": [
            "--directory",
            "/Users/YOUR_USERNAME/Code/flights-mcp",
            "run",
            "flights-mcp"
        ],
        "env": {
            "DUFFEL_API_KEY_LIVE": "your_duffel_live_api_key_here"
        }
    }
}

⚠️重要提示:

  • 将YOUR_USERNAME替换为您的实际系统用户名

  • 将your_duffel_live_api_key_here替换为您的实际 Duffel Live API 密钥

  • 确保目录路径与本地安装匹配

部署

建筑

准备包裹:

# Sync dependencies and update lockfile
uv sync

# Build package
uv build

这将在dist/目录中创建分布。

调试

为了获得最佳调试体验,请使用 MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory /path/to/find-flights-mcp run find-flights-mcp

检查员提供:

  • 实时请求/响应监控

  • 输入/输出验证

  • 错误追踪

  • 性能指标

可用工具

1. 搜索航班

@mcp.tool()
async def search_flights(params: FlightSearch) -> str:
    """Search for flights based on parameters."""

支持三种航班类型:

  • 单程航班

  • 往返航班

  • 多城市航班

参数包括:

  • type :航班类型('单程','往返','多城市')

  • origin :出发机场代码

  • destination :目的地机场代码

  • departure_date :出发日期(YYYY-MM-DD)

  • 可选参数:

    • return_date :往返行程的返回日期

    • adults :成人乘客人数

    • cabin_class :首选舱位

    • departure_time :具体出发时间范围

    • arrival_time :具体到达时间范围

    • max_connections :最大连接数

2. 获取优惠详情

@mcp.tool()
async def get_offer_details(params: OfferDetails) -> str:
    """Get detailed information about a specific flight offer."""

使用其唯一 ID 检索特定航班优惠的全面详细信息。

3. 搜索多城市航班

@mcp.tool(name="search_multi_city")
async def search_multi_city(params: MultiCityRequest) -> str:
    """Search for multi-city flights."""

针对复杂的多城市航班行程的专用工具。

参数包括:

  • segments :航段列表

  • adults :成人乘客人数

  • cabin_class :首选舱位

  • max_connections :最大连接数

用例

一些例子(但请自己尝试一下!)

您可以使用这些工具来查找各种复杂程度的航班:

  • “查找 1 月 7 日从旧金山国际机场飞往纽约的 2 名成人商务舱单程航班”

  • “搜索 1 月 8 日从洛杉矶国际机场飞往伦敦的往返航班,1 月 15 日返回”

  • “计划 1 月 7 日从纽约飞往巴黎,1 月 10 日飞往罗马,1 月 15 日返回纽约”

  • “1 月 7 日至 1 月 15 日,从 旧金山 飞往 洛杉矶 的两名成人经济舱最便宜的航班是哪一班?”

  • 您甚至可以搜索多日内的航班,找到最适合您行程的航班。目前,我们建议仅通过这种方式搜索单程或往返航班。例如:“查找 1 月 7 日至 1 月 10 日从旧金山国际机场飞往洛杉矶国际机场,两位成人经济舱的最便宜航班。”

响应格式

该工具返回 JSON 格式的响应,内容如下:

  • 航班优惠详情

  • 定价信息

  • 切片(路线)详细信息

  • 承运商信息

  • 连接详细信息

错误处理

该服务包括针对以下方面的强大错误处理:

  • API 请求失败

  • 机场代码无效

  • API 密钥缺失或无效

  • 网络超时

  • 搜索参数无效

贡献

[如适用,请添加贡献指南]

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

演出说明

  • 单程/往返航班的搜索限制为 50 个

  • 多城市搜索限制为 10 个优惠

  • 根据搜索类型,供应商超时设置为 15-30 秒

舱位等级

可选舱位:

  • economy :标准经济舱

  • premium_economy :高级经济舱

  • business :商务舱

  • first :头等舱

含舱位等级的请求示例:

{
  "params": {
    "type": "one_way",
    "adults": 1,
    "origin": "SFO",
    "destination": "LAX",
    "departure_date": "2025-01-12",
    "cabin_class": "business"  // Specify desired cabin class
  }
}

Available Tools

3 tools
get_offer_detailsB

Get detailed information about a specific flight offer.

ParametersJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states it's a read operation ('Get'), implying it's non-destructive, but doesn't disclose behavioral traits like authentication requirements, rate limits, error handling, or what 'detailed information' entails beyond the input schema. This leaves significant gaps for an agent to understand how to use it effectively.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which likely defines the return structure), the description doesn't need to explain return values. However, with no annotations, 0% schema description coverage, and one parameter, the description is minimal. It covers the basic purpose but lacks usage guidelines and behavioral details, making it incomplete for optimal agent use despite the output schema's support.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions 'a specific flight offer', which aligns with the 'offer_id' parameter in the input schema. However, schema description coverage is 0%, so the schema provides no parameter descriptions. The description adds minimal semantics by implying the parameter identifies an offer, but doesn't explain format, source, or constraints, offering only basic compensation for the low coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'detailed information about a specific flight offer', making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'search_flights' or 'search_multi_city', which appear to be search operations rather than detail retrieval for a specific offer.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing an offer ID from a previous search, or clarify that it's for retrieving details of a single, pre-identified offer rather than searching for new ones.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_flightsD

Search for flights based on parameters.

ParametersJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

D1.9/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but provides none. It doesn't indicate whether this is a read-only operation, whether it requires authentication, what rate limits might apply, what format results are returned in, or any other behavioral characteristics. For a search tool that likely interacts with external APIs, this lack of transparency is a significant gap that leaves the agent guessing about important operational aspects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is maximally concise at just 6 words. While this conciseness comes at the expense of completeness, every word earns its place - 'Search' indicates the action, 'for flights' specifies the resource, and 'based on parameters' acknowledges the input requirements. There's no wasted verbiage or redundant phrasing, making it efficiently front-loaded despite its brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of flight search (11 parameters with nested objects, multiple flight types, and sibling tools), the description is woefully incomplete. While the presence of an output schema means the description doesn't need to explain return values, it fails to provide context about the tool's scope, limitations, or relationship to other tools. With no annotations and minimal description, the agent lacks crucial information needed to use this tool effectively in context with 'search_multi_city' and 'get_offer_details'.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description states 'based on parameters' but provides zero information about what those parameters are or their semantics. With schema description coverage at 0% (the schema has descriptions but they're not counted in coverage), the description fails to compensate by explaining any of the 11 parameters documented in the schema. The agent must rely entirely on the schema to understand parameters like 'type', 'origin', 'destination', 'departure_date', etc., with no high-level guidance from the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Search for flights based on parameters' is tautological - it essentially restates the tool name 'search_flights' with minimal elaboration. While it indicates the general action (search) and resource (flights), it lacks specificity about what kind of search this performs or how it differs from sibling tools like 'search_multi_city'. The description doesn't provide meaningful differentiation from what the name already conveys.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides absolutely no guidance about when to use this tool versus alternatives. With sibling tools like 'search_multi_city' and 'get_offer_details' available, the agent receives no indication whether this is the primary search tool, whether it's for simple searches while 'search_multi_city' handles complex itineraries, or any prerequisites or constraints. The description offers zero contextual usage information.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_multi_cityC

Search for multi-city flights.

ParametersJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'search' but doesn't disclose behavioral traits like whether this is a read-only operation, if it requires authentication, rate limits, pagination, error handling, or what the search returns (e.g., flight options, prices). For a complex search tool with no annotations, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise with a single sentence ('Search for multi-city flights.'). It's front-loaded and wastes no words, though this conciseness comes at the cost of completeness. Every word earns its place by stating the core function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (multi-city flight search with 1 parameter containing nested objects), no annotations, and an output schema (which reduces need to describe returns), the description is incomplete. It lacks context on usage, behavior, and doesn't leverage the output schema to clarify purpose. For a search tool with rich schema but no annotations, more guidance is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the input schema has detailed descriptions for all parameters (e.g., 'Flight segments', 'Departure date (YYYY-MM-DD)'). The description adds no parameter information beyond the schema. Baseline 3 is appropriate as the schema does the heavy lifting, though the description doesn't compensate for the 0% coverage with any additional context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Search for multi-city flights' states the basic action (search) and resource (multi-city flights), but it's vague about scope and doesn't distinguish from sibling 'search_flights'. It doesn't specify what 'search' entails (e.g., finding available flights, prices, routes) or how multi-city differs from other flight types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus 'search_flights' or 'get_offer_details'. The description implies usage for multi-city flights but doesn't specify prerequisites, constraints (e.g., minimum segments), or alternatives. Without explicit when/when-not instructions, the agent lacks context for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv1.0.0
    • First observedget_offer_details
    • First observedsearch_flights
    • First observedsearch_multi_city

TDQS

C2.8/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: get_offer_details retrieves details for a specific offer, search_flights handles standard flight searches, and search_multi_city handles multi-city itineraries. There is no overlap or ambiguity between these functions.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern using snake_case: get_offer_details, search_flights, and search_multi_city. The naming is predictable and readable throughout.

Tool Count3/5

With only 3 tools, the set feels thin for a flight search domain. While the core search functions are covered, typical operations like booking, managing reservations, or checking availability are missing, making the scope borderline minimal.

Completeness2/5

The toolset is significantly incomplete for flight operations. It lacks essential actions such as booking flights, canceling reservations, checking seat availability, or managing user profiles, which are critical for a functional flight service. Agents will face dead ends in common workflows.

Maintenance

ActivityInactive
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers