Back to MCP directory
publicPublicdnsLocal runtime

gemini-function-calling-+-model-context-protocol(mcp)-flight-search

该项目展示了如何利用Google的Gemini 2.5 Pro模型通过函数调用功能与MCP协议下的航班搜索工具交互,实现自然语言查询航班信息并返回格式化结果。

article

README

🚀 天王星函数调用 + 模型上下文协议(MCP)飞行搜索

本项目借助 Google 的 Gemini 2.5 Pro 模型,结合功能调用能力,通过 Model Context Protocol (MCP) 与 mcp-flight-search 工具实现交互。可使用自然语言进行航班搜索,自动提取参数并执行搜索,最终展示格式化结果。

示例输出

架构图

🚀 快速开始

此项目展示了如何使用Google的Gemini 2.5 Pro模型结合功能调用 capabilities 来与 mcp-flight-search 工具通过Model Context Protocol (MCP)交互。该客户演示实现如下:

  1. 使用stdio通信连接到本地MCP服务器进程 (mcp-flight-search)
  2. 使用自然语言提示与Gemini 2.5 Pro进行航班搜索(例如,“查找2025年5月5日从亚特兰大到拉斯维加斯的航班”)
  3. 让Gemini自动从自然语言输入中确定正确的函数参数
  4. 执行MCP工具的飞行搜索
  5. 显示格式化的搜索结果

✨ 主要特性

  • 使用Gemini 2.5 Pro进行自然语言航班搜索
  • 自动提取功能参数
  • 集成 mcp-flight-search 工具通过stdio通信
  • 格式化JSON输出航班结果
  • 环境基配置的API密钥管理

📦 安装指南

先决条件

项目需要以下条件:

  • Python 3.7及以上版本
  • Google Gemini API密钥
  • SerpAPI密钥

💻 使用示例

基础用法

运行客户:

python client.py

脚本将执行以下操作:

  1. 启动MCP飞行搜索服务器进程
  2. 将您的航班搜索查询发送到Gemini 2.5 Pro
  3. 使用Gemini的功能调用来提取搜索参数
  4. 执行MCP工具的搜索
  5. 显示格式化结果

📚 详细文档

相关项目

此客户使用 mcp-flight-search 工具,可在以下位置找到:

作者

了解更多关于AI/ML和生成式AI的文章,请访问我的Medium:@arjun-prabhulal

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client