flight-mcp
✈️ Flight MCP Server — SQLite Demo
一个功能完备的 Model Context Protocol (MCP) 演示服务器,提供模拟的航班搜索与预订能力。
[!WARNING] 仅供模拟: 本系统中所有航班、库存和预订均使用虚构/示例数据纯模拟生成。本项目不会集成任何真实航空公司 API,不会预订真实航班。
项目简介
本项目是一个简洁、模块化的 Python 应用,设计目的是帮助学习 Model Context Protocol (MCP) 的基础知识。它作为一个本地后端服务器,无缝连接到 Claude Desktop,让 AI 在安全可控的前提下访问本地 SQLite 数据库,用于浏览 Demo 航班并完成预订。
Related MCP server: SQLite MCP Server
什么是 MCP?
Model Context Protocol (MCP) 是一种开放标准,允许像 Claude 这样的 AI 模型安全地连接到本地或远程的数据源、工具和服务。MCP 让模型不再靠猜测或幻觉来捏造数据,而是可以查询一个确定性的后端系统。
架构
系统的整体架构采用清晰的分层方式:
Claude Desktop (Client)
↓ (stdio JSON-RPC)
Python Flight MCP Server
↓
Services Layer (Business Logic)
↓
SQLite Database (Data Store)技术栈
语言: Python 3.11+
包管理器:
uv框架: 官方 MCP Python SDK(
mcp)数据库: SQLite(本地文件)
客户端: Claude Desktop
六个可用工具
该服务器向 AI 暴露六个功能完整的 MCP 工具:
search_flights:按出发地、目的地和日期查找可用航班。get_flight:获取指定航班的完整详情与元数据。check_seats:查询航班的实时余座情况。book_flight:创建新的模拟预订(需要用户确认)。get_booking:通过 PNR 编号查看已有预订的详情。cancel_booking:取消预订并恢复座位库存。
SQLite Demo 数据库
系统使用本地 SQLite 数据库(data/flightmcp.db)存储航班库存和预订状态。
注意:实际的 .db 文件已被版本控制排除,避免陈旧状态问题。
如需用全新的演示数据初始化数据库,请运行:
uv run python scripts/seed_database.py安装与设置
请确保已安装 uv,然后同步依赖项:
uv sync运行测试
项目内置了一套稳健的 pytest 测试套件,用于后端验证。
uv run pytest运行 MCP 服务器
如需手动验证服务器能否正常启动(它会持续运行并等待 stdio 通信):
uv run flight-mcp(所有应用日志都会严格输出到 stderr,以保证 stdout 上 MCP 协议输出的干净整洁。)
配置 Claude Desktop
若要将此 MCP 服务器连接到 Claude Desktop,请编辑 Claude Desktop 的配置文件(在 macOS 上通常位于 ~/Library/Application Support/Claude/claude_desktop_config.json)。
Claude Desktop 配置示例:
{
"mcpServers": {
"flight-mcp": {
"command": "/opt/homebrew/bin/uv",
"args": [
"run",
"--directory",
"/Users/baratharjun/Desktop/medai",
"flight-mcp"
],
"cwd": "/Users/baratharjun/Desktop/medai"
}
}
}注意:请根据本地项目目录和 uv 安装路径修改绝对路径。
工具使用示例
连接到 Claude Desktop 之后,你可以用自然语言交互:
用户: “帮我找一班 2026-09-05 从 Chennai 到 Delhi 的航班。”
Claude 调用 search_flights 并读取 SQLite 数据库。
用户: “航班 1 还有多少个座位?”
Claude 调用 check_seats。
用户: “我要预订航班 1。我的名字是 Test User,邮箱是 [test@example.com](mailto:test@example.com),电话是 9999999999。”
Claude 确认请求并询问用户是否确认。
用户: “确认。”
Claude 调用 book_flight 并返回一个虚构的预订号(例如 FLM-XXXXXX)。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides Claude Desktop with secure access to multiple database connections, allowing users to query MySQL, PostgreSQL, SQLite, and SQL Server databases directly through natural language.
- AlicenseNot gradedqualityDmaintenanceEnables natural language interaction with local SQLite databases through Claude Desktop, translating plain English queries into SQL for data analysis and exploration.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables natural language querying of SAP flight data (airlines, flights, bookings) using Claude Code, with 19 tools for model introspection, SQL queries, and analytics.1The Unlicense
- FlicenseNot gradedqualityDmaintenanceEnables querying and managing a CRM database through natural language conversations with Claude Desktop.
Related MCP Connectors
Talk to your live-events CRM (campaigns, analytics, paid ads, segments) in Claude and ChatGPT.
GibsonAI MCP server: manage your databases with natural language
Search, read, and write your Apple Notes from ChatGPT/Claude via a local Mac agent + MCP relay.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/BarathArjun-B/travel_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server