航空航天MCP-飞行计划API和MCP服务器
      
全面的航空航天研究和飞行计划服务,提供HTTP API和模型上下文协议(MCP)集成。建于 FastMCP 用于简化MCP服务器开发。具有智能机场分辨率、大圆航线计算、飞机性能估计、大气建模、坐标系变换、气动分析、螺旋桨性能建模、火箭轨迹优化、轨道力学计算和航空航天运行的航天器轨迹规划等功能。
⚠️ 安全免责声明
此软件仅用于教育、研究和开发目的
- 不适用于真正的导航:不用于实际飞行计划或导航
- 未认证:该系统未经任何航空当局认证
- 仅估算:性能计算是理论估计
- 无天气数据:不考虑天气、航行通告或空域限制
- 无责任:作者对使用的任何后果不承担任何责任
对于真正的飞行计划,始终使用经过认证的航空软件,并咨询官方来源,包括航行通告、天气预报和空中交通管制。
🚀 快速开始
选项1:紫外线(推荐)
# Install UV (fast Python package manager)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and setup
git clone https://github.com/cheesejaguar/aerospace-mcp.git
cd aerospace-mcp
uv venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
uv sync
# Copy env and configure (optional but recommended)
cp .env.example .env
# Edit .env as needed (host/port/log level, optional LLM tools)
# Run HTTP server (package entrypoint)
uv run aerospace-mcp-http
# Alternatively (developer style)
uvicorn main:app --reload --host 0.0.0.0 --port 8080
# Test the API
curl "http://localhost:8080/health"选项2:Docker
git clone https://github.com/cheesejaguar/aerospace-mcp.git
cd aerospace-mcp
docker build -t aerospace-mcp .
docker run -p 8080:8080 aerospace-mcp
# Test the API
curl "http://localhost:8080/health"选项3:MCP客户端(克劳德桌面)
添加到您的Claude Desktop配置中:
{
"mcpServers": {
"aerospace-mcp": {
"command": "uv",
"args": ["run", "aerospace-mcp"],
"cwd": "/path/to/aerospace-mcp",
"env": {
"LLM_TOOLS_ENABLED": "true",
"OPENAI_API_KEY": "your-openai-api-key-here"
}
}
}
}备注:The env 部分是可选的,只有当您想启用AI驱动的代理工具以增强用户体验时才需要。
MCP通过CLI
# Start the MCP server (stdio)
uv run aerospace-mcp
# Start in SSE mode (optional)
uv run aerospace-mcp sse 0.0.0.0 8001📋 目录
✨ 特性
核心能力
- 机场决议:智能城市到机场地图,全球28000多个机场
- 路线规划:具有测地线精度的大圆距离计算
- 性能估计:通过OpenAP计算飞机特定燃料和时间
- 大气建模:ISA大气剖面图,可选增强精度
- 坐标变换:ECEF、ECI、用于航空航天分析的大地坐标系转换
- 多个接口:HTTP REST API和模型上下文协议(MCP)支持
- 实时处理:飞行计划请求的响应时间低于秒
空间和轨道力学能力
- 🛰️ 轨道元素和状态向量:开普勒元素和笛卡尔状态向量之间的转换
- 🌍 轨道传播:使用RK4方法对J2扰动进行数值积分
- 🗺️ 地面轨迹计算:计算卫星地面轨迹,用于任务规划
- 🔄 霍曼转让:计算最佳双脉冲轨道转移
- 🤝 轨道交会:规划多机动交会序列
- 🎯 轨迹优化:遗传算法和粒子群优化
- 📊 不确定性分析:用于轨道鲁棒性评估的蒙特卡洛抽样
- 🚀 朗伯问题:给定飞行时间的两体轨迹确定
支持的操作
- ✅ 按城市名称或IATA代码搜索机场
- ✅ 基于折线生成的飞行路线规划
- ✅ 飞机性能评估(190+种飞机类型)
- ✅ 燃油消耗和飞行时间计算
- ✅ 大圆距离计算
- ✅ 多段行程规划
- ✅ 飞机对比分析
- ✅ 大气剖面计算(ISA标准大气)
- ✅ 风廓线建模(对数/幂律)
- ✅ 坐标系变换(ECEF、ECI、大地测量)
- ✅ 机翼空气动力学分析(VLM,升力线理论)
- ✅ 翼型极性生成和数据库访问
- ✅ 飞机稳定性导数计算
- ✅ 螺旋桨性能分析(BEMT)
- ✅ 无人机能量优化与续航能力估算
- ✅ 电机螺旋桨匹配分析
- ✅ 大气一体化三维自由度火箭弹道仿真
- ✅ 用于任务规划的火箭尺寸估算
- ✅ 优化发射角度以获得最佳性能
- ✅ 利用梯度下降法优化推力剖面
- ✅ 设计研究的轨迹灵敏度分析
- ✅ 系统能力发现和状态报告
- ✅ 轨道力学计算 (开普勒元素、状态向量、传播)
- ✅ 地面轨迹计算 用于卫星跟踪和可视化
- ✅ 霍曼转移计划 用于轨道机动和任务设计
- ✅ 轨道交会规划 用于航天器近距离运行
- ✅ 轨迹优化 利用遗传算法和粒子群优化
- ✅ 蒙特卡罗不确定性分析 用于弹道鲁棒性评估
- ✅ 兰伯特问题解决 用于确定两体轨迹
- ✅ 猪排地块生成 行星际转移机会分析
- ✅ 可选SPICE集成 回退到简化星历模型
- ✅ 密度高度计算 用于绩效规划
- ✅ 空速转换 (IAS/CAS/EAS/TAS/Mach)
- ✅ 失速速度计算 适用于不同的配置
- ✅ 重量和平衡 CG极限计算
- ✅ 起飞/着陆性能 距离和V速度
- ✅ 燃料储备计算 根据FAR/IICAO规定
- ✅ 卡尔曼滤波器状态估计 用于传感器融合
- ✅ LQR控制器设计 用于最优控制
技术特性
- 🚀 快速:用于微秒级查找的内存中机场数据库
- 🔧 灵活的:可插拔后端系统(目前为OpenAP)
- 📊 准确的:使用WGS84测地线计算
- 🌐 标准:遵循国际民航组织飞机代码和国际航空运输协会机场代码
- 🔒 可靠的:全面的错误处理和优雅的降级
- 📚 有据可查的:完整的API文档及示例
- ⚡ 硬件优化:支持CuPy GPU加速的NumPy矢量化
- 🔄 批处理:矢量化运算,实现高效批量计算
- 🔍 工具发现:动态工具搜索,从44+个可用工具中查找相关工具
💾 安装
系统要求
- python:3.11+(建议使用3.12+以获得最佳性能)
- 记忆:最低512MB RAM(建议1GB以上)
- 存储:200MB可用空间
- 网络:用于初始设置的Internet连接
方法1:UV包管理器(推荐)
UV是最快的Python包管理器,提供了出色的依赖解析:
# Install UV
curl -LsSf https://astral.sh/uv/install.sh | sh # Linux/macOS
# Or: powershell -c "irm https://astral.sh/uv/install.ps1 | iex" # Windows
# Clone repository
git clone https://github.com/cheesejaguar/aerospace-mcp.git
cd aerospace-mcp
# Create virtual environment
uv venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
# Install dependencies
uv add fastapi uvicorn[standard] airportsdata geographiclib pydantic python-dotenv
uv add openap # Optional: for performance estimates
uv add mcp # Optional: for MCP server functionality
# Install optional aerospace analysis dependencies
uv add --optional-dependencies atmosphere # Ambiance for enhanced ISA
uv add --optional-dependencies space # Astropy for coordinate frames
uv add --optional-dependencies all # All optional dependencies
# Install development dependencies (optional)
uv add --dev pytest httpx black isort mypy pre-commit
# Verify installation
python -c "import main; print('✅ Installation successful')"方法2:Pip(传统)
# Clone repository
git clone https://github.com/cheesejaguar/aerospace-mcp.git
cd aerospace-mcp
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
# Upgrade pip
pip install --upgrade pip
# Install core dependencies
pip install fastapi uvicorn[standard] airportsdata geographiclib pydantic python-dotenv
# Install optional dependencies
pip install openap # For performance estimates
pip install mcp # For MCP server
pip install python-dotenv # For loading .env in local/dev
# Install from pyproject.toml
pip install -e .
# Verify installation
python -c "import main; print('✅ Installation successful')"方法三:Docker
# Clone repository
git clone https://github.com/cheesejaguar/aerospace-mcp.git
cd aerospace-mcp
# Build image
docker build -t aerospace-mcp .
# Run container
docker run -d -p 8080:8080 --name aerospace-mcp aerospace-mcp
# Health check
curl http://localhost:8080/health
# View logs
docker logs aerospace-mcp
# Stop container
docker stop aerospace-mcp方法4:康达/曼巴
# Create conda environment
conda create -n aerospace-mcp python=3.11
conda activate aerospace-mcp
# Clone repository
git clone https://github.com/cheesejaguar/aerospace-mcp.git
cd aerospace-mcp
# Install dependencies
conda install fastapi uvicorn pydantic
pip install airportsdata geographiclib openap mcp
# Verify installation
python -c "import main; print('✅ Installation successful')"安装故障排除
常见问题
OpenAP安装问题:
# Try these alternatives if OpenAP fails to install
pip install openap --no-cache-dir
pip install openap --force-reinstall
# Or install without OpenAP (performance estimates will be unavailable)GeographicLib问题:
# Install system dependencies (Ubuntu/Debian)
sudo apt-get install libproj-dev proj-data proj-bin
# Install system dependencies (macOS)
brew install proj
# Install system dependencies (Windows)
# Download from: https://proj.org/download.html导入错误:
# Verify your Python environment
python --version # Should be 3.11+
pip list | grep -E "(fastapi|openap|airportsdata)"
# Test individual imports
python -c "import fastapi; print('FastAPI OK')"
python -c "import airportsdata; print('AirportsData OK')"
python -c "import openap; print('OpenAP OK')" || echo "OpenAP not available (optional)"🎯 使用示例
HTTP API示例
基本飞行计划
# Plan a simple flight
curl -X POST "http://localhost:8080/plan" \
-H "Content-Type: application/json" \
-d '{
"depart_city": "San Francisco",
"arrive_city": "New York",
"ac_type": "A320",
"cruise_alt_ft": 37000,
"backend": "openap"
}'机场搜索
# Find airports by city
curl "http://localhost:8080/airports/by_city?city=Tokyo"
# Filter by country
curl "http://localhost:8080/airports/by_city?city=London&country=GB"
# Multiple results
curl "http://localhost:8080/airports/by_city?city=Paris"高级飞行计划
# Specify exact airports and aircraft mass
curl -X POST "http://localhost:8080/plan" \
-H "Content-Type: application/json" \
-d '{
"depart_city": "Los Angeles",
"arrive_city": "Tokyo",
"prefer_depart_iata": "LAX",
"prefer_arrive_iata": "NRT",
"ac_type": "B777",
"cruise_alt_ft": 39000,
"mass_kg": 220000,
"route_step_km": 100.0,
"backend": "openap"
}'Python客户端示例
普通客户端
import requests
import json
class AerospaceClient:
def __init__(self, base_url="http://localhost:8080"):
self.base_url = base_url
def plan_flight(self, departure, arrival, aircraft="A320", altitude=35000):
"""Plan a flight between two cities."""
response = requests.post(f"{self.base_url}/plan", json={
"depart_city": departure,
"arrive_city": arrival,
"ac_type": aircraft,
"cruise_alt_ft": altitude,
"backend": "openap"
})
return response.json()
def find_airports(self, city, country=None):
"""Find airports in a city."""
params = {"city": city}
if country:
params["country"] = country
response = requests.get(f"{self.base_url}/airports/by_city", params=params)
return response.json()
# Usage
client = AerospaceClient()
# Find airports
airports = client.find_airports("Sydney", "AU")
print(f"Sydney has {len(airports)} airports")
# Plan flight
plan = client.plan_flight("Sydney", "Melbourne", "B737")
print(f"Flight distance: {plan['distance_nm']:.0f} NM")
print(f"Flight time: {plan['estimates']['block']['time_min']:.0f} minutes")批处理
import asyncio
import aiohttp
from typing import List, Dict
async def plan_multiple_flights(flights: List[Dict]) -> List[Dict]:
"""Plan multiple flights concurrently."""
async with aiohttp.ClientSession() as session:
tasks = []
for flight in flights:
task = plan_single_flight(session, flight)
tasks.append(task)
results = await asyncio.gather(*tasks, return_exceptions=True)
return results
async def plan_single_flight(session, flight_data):
"""Plan a single flight."""
async with session.post(
"http://localhost:8080/plan",
json=flight_data
) as response:
return await response.json()
# Example usage
flights_to_plan = [
{"depart_city": "New York", "arrive_city": "London", "ac_type": "A330"},
{"depart_city": "London", "arrive_city": "Dubai", "ac_type": "B777"},
{"depart_city": "Dubai", "arrive_city": "Singapore", "ac_type": "A350"}
]
# Run the batch planning
results = asyncio.run(plan_multiple_flights(flights_to_plan))
for i, result in enumerate(results):
if not isinstance(result, Exception):
print(f"Flight {i+1}: {result['distance_nm']:.0f} NM, {result['estimates']['block']['time_min']:.0f} min")轨道力学示例
Python示例
import requests
class OrbitalMechanicsClient:
def __init__(self, base_url="http://localhost:8080"):
self.base_url = base_url
def plan_hohmann_transfer(self, r1_km, r2_km):
"""Calculate Hohmann transfer between two circular orbits."""
response = requests.post(f"{self.base_url}/hohmann_transfer", json={
"r1_m": r1_km * 1000, # Convert to meters
"r2_m": r2_km * 1000
})
return response.json()
def propagate_satellite_orbit(self, elements, duration_hours):
"""Propagate satellite orbit with J2 perturbations."""
response = requests.post(f"{self.base_url}/propagate_orbit_j2", json={
"initial_state": elements,
"time_span_s": duration_hours * 3600,
"time_step_s": 300 # 5-minute steps
})
return response.json()
# Example usage
client = OrbitalMechanicsClient()
# Plan a GTO to GEO transfer
gto_alt = 200 # km (perigee)
geo_alt = 35786 # km (GEO altitude)
transfer = client.plan_hohmann_transfer(
6378 + gto_alt, # Earth radius + altitude
6378 + geo_alt
)
print(f"Transfer Delta-V: {transfer['delta_v_total_ms']/1000:.2f} km/s")
print(f"Transfer Time: {transfer['transfer_time_h']:.1f} hours")
# Propagate ISS orbit for one day
iss_elements = {
"semi_major_axis_m": 6793000, # ~415 km altitude
"eccentricity": 0.0001,
"inclination_deg": 51.6,
"raan_deg": 0.0,
"arg_periapsis_deg": 0.0,
"true_anomaly_deg": 0.0,
"epoch_utc": "2024-01-01T12:00:00"
}
orbit_states = client.propagate_satellite_orbit(iss_elements, 24)
print(f"Propagated {len(orbit_states)} orbital states over 24 hours")轨迹优化示例
# Optimize a lunar transfer trajectory
def optimize_lunar_transfer():
initial_trajectory = [
{
"time_s": 0,
"position_m": [6700000, 0, 0], # LEO
"velocity_ms": [0, 7500, 0]
},
{
"time_s": 86400 * 3, # 3 days
"position_m": [384400000, 0, 0], # Moon distance
"velocity_ms": [0, 1000, 0]
}
]
response = requests.post("http://localhost:8080/genetic_algorithm_optimization", json={
"initial_trajectory": initial_trajectory,
"objective": "minimize_delta_v",
"constraints": {
"max_thrust_n": 50000,
"max_acceleration_ms2": 10
}
})
result = response.json()
print(f"Optimized Delta-V: {result['total_delta_v_ms']/1000:.2f} km/s")
print(f"Flight Time: {result['flight_time_s']/86400:.1f} days")
return result
optimized_trajectory = optimize_lunar_transfer()
# Generate porkchop plot for Mars mission planning
def plan_mars_mission():
response = requests.post("http://localhost:8080/porkchop_plot_analysis", json={
"departure_body": "Earth",
"arrival_body": "Mars",
"min_tof_days": 200,
"max_tof_days": 300
})
analysis = response.json()
if analysis["summary_statistics"]["feasible_transfers"] > 0:
optimal = analysis["optimal_transfer"]
print(f"Optimal Mars Transfer:")
print(f" Launch: {optimal['departure_date']}")
print(f" Arrival: {optimal['arrival_date']}")
print(f" C3: {optimal['c3_km2_s2']:.2f} km²/s²")
print(f" Flight Time: {optimal['time_of_flight_days']:.0f} days")
else:
print("No feasible transfers found in date range")
plan_mars_mission()JavaScript/TypeScript示例
interface FlightPlan {
depart_city: string;
arrive_city: string;
ac_type: string;
cruise_alt_ft?: number;
backend: "openap";
}
class AerospaceAPI {
constructor(private baseUrl: string = "http://localhost:8080") {}
async planFlight(request: FlightPlan) {
const response = await fetch(`${this.baseUrl}/plan`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(request),
});
if (!response.ok) {
throw new Error(`API Error: ${response.statusText}`);
}
return await response.json();
}
async findAirports(city: string, country?: string) {
const params = new URLSearchParams({ city });
if (country) params.append("country", country);
const response = await fetch(`${this.baseUrl}/airports/by_city?${params}`);
return await response.json();
}
}
// Usage
const api = new AerospaceAPI();
try {
const plan = await api.planFlight({
depart_city: "Boston",
arrive_city: "Seattle",
ac_type: "B737",
cruise_alt_ft: 36000,
backend: "openap"
});
console.log(`Flight planned: ${plan.distance_nm} NM`);
console.log(`Estimated time: ${plan.estimates.block.time_min} minutes`);
} catch (error) {
console.error("Flight planning failed:", error);
}🏗️ 建筑
系统概述
graph TB
Users[Users/Clients] --> API[FastAPI REST API]
Users --> MCP[MCP Server]
API --> Core[Core Services]
MCP --> Core
subgraph "Core Services"
Airport[Airport Resolution]
Route[Route Calculation]
Perf[Performance Estimation]
end
subgraph "Data Sources"
AirportDB[Airport Database
28,000+ airports]
OpenAP[OpenAP Models
190+ aircraft]
Geodesic[GeographicLib
WGS84 calculations]
end
Airport --> AirportDB
Route --> Geodesic
Perf --> OpenAP关键组件
- FastAPI应用程序 (
main.py)
- HTTP客户端的RESTful端点 - 自动生成的OpenAPI文档 - 使用Pydantic进行请求/响应验证
- MCP服务器 (
aerospace_mcp/fastmcp_server.py)
- 通过FastMCP实现模型上下文协议 - 基于工具的AI助手界面 - 异步请求处理
- 核心服务
- 机场决议城市→ 智能选择机场地图 - 路线计算:具有折线生成功能的大圆路径 - 性能估计:基于OpenAP的燃料和时间计算
- 数据层
- 内存中的机场数据库:启动时已装载28000多个机场 - OpenAP集成:飞机性能模型 - GeographicLib:精确的测地线计算
设计原则
- 性能优先:用于亚毫秒查找的内存数据结构
- 故障弱化:在没有可选依赖关系的情况下工作
- 类型安全:完整的类型提示和Pydantic验证
- 可扩展:新后端的插件架构
- 遵从标准:国际民航组织、国际航空运输协会和OpenAP标准
- 硬件不可知:NumPy/CuPy抽象,实现CPU/GPU灵活性
🚀 快速MCP迁移
该项目已经 从传统的MCP SDK迁移到FastMCP,显著改善了开发人员体验和代码可维护性。
什么是FastMCP?
FastMCP 是一个用于构建模型上下文协议服务器的高级Python框架。它大大减少了样板代码,同时保持了完全的MCP兼容性。
移民福利
✅ 代码减少70%:工具定义从冗长的JSON模式变成了简单的Python装饰器 ✅ 更好的类型安全性:根据类型提示自动生成架构 ✅ 更清洁的建筑:跨逻辑域的模块化工具组织 ✅ 提高可维护性:更易于阅读和扩展的Python代码 ✅ 完全兼容:相同的MCP协议,适用于所有现有客户端
之前vs之后
之前(传统MCP SDK):
Tool(
name="search_airports",
description="Search for airports by IATA code or city name",
inputSchema={
"type": "object",
"properties": {
"query": {"type": "string", "description": "IATA code or city name"},
"country": {"type": "string", "description": "Optional country filter"},
"query_type": {"type": "string", "enum": ["iata", "city", "auto"]}
},
"required": ["query"]
}
)
@server.call_tool()
async def handle_call_tool(name: str, arguments: dict):
if name == "search_airports":
return await _handle_search_airports(arguments)
# ... 40+ more tool handlers之后(FastMCP):
@mcp.tool
def search_airports(
query: str,
country: str | None = None,
query_type: Literal["iata", "city", "auto"] = "auto"
) -> str:
"""Search for airports by IATA code or city name."""
# Implementation here架构改进
FastMCP重构引入了 模块化架构 使用按领域组织的工具:
tools/core.py-核心飞行计划(搜索、计划、距离、性能)tools/atmosphere.py-大气建模和风分析tools/frames.py-坐标系变换tools/aerodynamics.py-机翼分析和翼型极性tools/propellers.py-螺旋桨BEMT和无人机能量分析tools/rockets.py-火箭轨迹和尺寸tools/orbits.py-轨道力学与传播tools/optimization.py-轨迹优化算法
集成模块 使用NumPy矢量化:
integrations/_array_backend.py-用于GPU支持的NumPy/CuPy抽象层integrations/atmosphere.py-矢量化ISA大气计算integrations/aero.py-矢量化空气动力学计算integrations/rockets.py-矢量化轨迹集成integrations/frames.py-矢量坐标变换
兼容性说明
- 入口点:现在使用
aerospace_mcp.fastmcp_server:run - 依赖项:包括
fastmcp>=2.11.3而不是生的mcp - 服务器名称:仍然
aerospace-mcp为了客户端兼容性 - 所有工具:所有44个工具都保持完全相同的名称和参数
⚙️ 配置(.env)
HTTP服务器和MCP服务器都会自动从本地加载环境变量 .env (通过 python-dotenv).
AEROSPACE_MCP_MODE:http或mcp(Docker入口点开关)AEROSPACE_MCP_HOST:绑定HTTP主机(默认0.0.0.0)AEROSPACE_MCP_PORT:HTTP端口(默认8080)AEROSPACE_MCP_LOG_LEVEL:debug|info|warning|error(默认值info)AEROSPACE_MCP_ENV:development|production(控件重新加载)LLM_TOOLS_ENABLED:true|false启用AI代理工具(默认false)OPENAI_API_KEY:如果启用了LLM工具,则需要
示例 .env:
AEROSPACE_MCP_MODE=http
AEROSPACE_MCP_HOST=0.0.0.0
AEROSPACE_MCP_PORT=8080
AEROSPACE_MCP_LOG_LEVEL=debug
LLM_TOOLS_ENABLED=false
# OPENAI_API_KEY=sk-...⚡ 演出
基准测试
| 操作 | 响应时间 | 吞吐量 | 内存使用情况 |
|---|---|---|---|
| 健康检查 | \<1ms | 10000+请求/秒 | ~5MB |
| 机场搜索 | 1-5ms | 1000+要求/秒 | ~50MB |
| 飞行计划 | 200-500ms | 5-10req/sec | ~100MB |
| 距离计算 | 10-50ms | 100+要求/秒 | ~50MB |
优化提示
- 路线解析:使用较大的
route_step_km更快处理的值 - 缓存:为重复请求实现客户端缓存
- 批处理:对多个并发请求使用异步客户端
- 记忆:增加可用RAM以提高OpenAP性能
缩放注意事项
- 水平扩展:无状态设计允许多个实例
- 负载均衡:标准HTTP负载平衡器工作良好
- 数据库:考虑大规模的机场数据外部数据库
- 缓存:为跨实例的共享缓存添加Redis
GPU加速(CuPy)
使用NumPy的矢量化操作优化了航空航天计算,并在支持CUDA的硬件上添加了CuPy后端,用于GPU加速。
启用GPU加速
# In your code, before using aerospace functions:
from aerospace_mcp.integrations._array_backend import set_backend, get_backend_info
# Check available backends
print(get_backend_info())
# {'current_backend': 'numpy', 'numpy_available': True, 'cupy_available': True, ...}
# Switch to GPU (requires CuPy and CUDA)
set_backend('cupy')
# Switch back to CPU
set_backend('numpy')安装CuPy
# For CUDA 11.x
pip install cupy-cuda11x
# For CUDA 12.x
pip install cupy-cuda12x
# Auto-detect CUDA version
pip install cupy支持GPU的模块
以下集成模块通过阵列后端支持GPU加速:
| 模块 | 操作 | 加速(GPU与CPU) |
|---|---|---|
atmosphere.py | ISA计算,风廓线 | 大批量为10-50x |
aero.py | 机翼分析,翼型极 | α扫掠为5-20x |
rockets.py | 轨迹集成、性能分析 | 3-10x |
frames.py | 坐标转换(批处理) | 20-100x用于大型数据集 |
备注:GPU加速为1000多个数据点的批处理操作提供了最大的好处。对于单次计算,由于GPU传输开销,CPU(NumPy)通常更快。
📖 API 文档
交互式文档
运行服务器时,API综合文档可在以下位置获得:
- Swagger用户界面: http://localhost:8080/docs
- ReDoc: http://localhost:8080/redoc
- OpenAPI架构: http://localhost:8080/openapi.json
核心终点
GET/健康
健康检查和系统状态。
响应:
{
"status": "ok",
"openap": true,
"airports_count": 28756
}GET/机场/城市
按城市名称搜索机场。
参数:
city(必填):要搜索的城市名称country(可选):ISO国家代码过滤器
示例: GET /airports/by_city?city=London&country=GB
POST/计划
生成完整的飞行计划。
请求正文:
{
"depart_city": "San Francisco",
"arrive_city": "New York",
"ac_type": "A320",
"cruise_alt_ft": 37000,
"mass_kg": 65000,
"route_step_km": 25.0,
"backend": "openap"
}响应:完整的飞行计划,包括路线折线和性能估计。
错误处理
所有端点都返回标准HTTP状态代码:
200:成功400:请求错误(参数无效)404:未找到(未找到机场/城市)501:未实现(后端不可用)
错误响应包括详细消息:
{
"detail": "departure: IATA 'XYZ' not found."
}🤖 MCP集成
支持的MCP客户端
- 克劳德桌面:本地集成
- VS代码继续:插件支持
- 自定义客户端:标准MCP协议
可用工具
| 工具 | 说明 | 参数 |
|---|---|---|
search_airports | 按IATA或城市查找机场 | query, country, query_type |
plan_flight | 完整的飞行计划 | departure, arrival, aircraft, route_options |
calculate_distance | 大圆距离 | origin, destination, step_km |
get_aircraft_performance | 性能估计 | aircraft_type, distance_km, cruise_altitude |
get_atmosphere_profile | ISA大气条件 | altitudes_m, model_type |
wind_model_simple | 风廓线计算 | altitudes_m, surface_wind_mps, model |
transform_frames | 坐标变换 | xyz, from_frame, to_frame, epoch_iso |
geodetic_to_ecef | Lat/lon到ECEF的转换 | latitude_deg, longitude_deg, altitude_m |
ecef_to_geodetic | ECEF到lat/lon转换 | x, y, z |
wing_vlm_analysis | 机翼空气动力学分析(VLM) | geometry, alpha_deg_list, mach |
airfoil_polar_analysis | 翼型极性发电 | airfoil_name, alpha_deg_list, reynolds, mach |
calculate_stability_derivatives | 稳定性导数计算 | geometry, alpha_deg, mach |
propeller_bemt_analysis | 螺旋桨性能(BEMT) | geometry, rpm_list, velocity_ms, altitude_m |
uav_energy_estimate | 无人机续航能力和能量分析 | uav_config, battery_config, mission_profile |
get_airfoil_database | 可用翼型系数 | 无 |
get_propeller_database | 可用螺旋桨数据 | 无 |
rocket_3dof_trajectory | 3自由度火箭弹道仿真 | geometry, dt_s, max_time_s, launch_angle_deg |
estimate_rocket_sizing | 根据任务要求确定火箭尺寸 | target_altitude_m, payload_mass_kg, propellant_type |
optimize_launch_angle | 发射角度优化 | geometry, objective, angle_bounds |
optimize_thrust_profile | 推力剖面优化 | geometry, burn_time_s, total_impulse_target, n_segments, objective |
trajectory_sensitivity_analysis | 参数敏感性分析 | base_geometry, parameter_variations, objective |
get_system_status | 系统运行状况和功能 | 无 |
elements_to_state_vector | 将轨道元素转换为状态向量 | elements |
state_vector_to_elements | 将状态向量转换为轨道元素 | state_vector |
propagate_orbit_j2 | J2扰动下的传播轨道 | initial_state, time_span_s, time_step_s |
calculate_ground_track | 计算卫星地面轨迹 | orbit_states, time_step_s |
hohmann_transfer | 计算霍曼转移轨道 | r1_m, r2_m |
orbital_rendezvous_planning | 计划轨道交会机动 | chaser_elements, target_elements |
genetic_algorithm_optimization | 基于遗传算法的轨迹优化 | initial_trajectory, objective, constraints |
particle_swarm_optimization | 基于粒子群算法的轨迹优化 | initial_trajectory, objective, constraints |
monte_carlo_uncertainty_analysis | 蒙特卡罗轨迹不确定性分析 | trajectory, uncertainty_params, num_samples |
porkchop_plot_analysis | 生成行星际转移的porkchop图 | departure_body, arrival_body, departure_dates, arrival_dates, min_tof_days, max_tof_days |
search_aerospace_tools | 按名称、描述或功能搜索工具 | query, search_type, max_results, category |
list_tool_categories | 列出所有可用的工具类别及其计数 | 无 |
lambert_problem_solver | 解决朗伯轨道转移问题 | r1_m, r2_m, tof_s, direction, central_body |
density_altitude_calculator | 根据压力高度和温度计算密度高度 | pressure_altitude_ft, temperature_c |
true_airspeed_converter | 在IAS/CAS/EAS/TAS/Mach之间转换 | speed_value, speed_type, altitude_ft, temperature_c |
stall_speed_calculator | 计算不同配置的失速速度 | weight_kg, wing_area_m2, cl_max_clean, cl_max_landing |
weight_and_balance | 计算飞机重量和重心位置 | basic_empty_weight_kg, fuel_kg, payload_items |
takeoff_performance | 计算起飞距离和V速度 | weight_kg, pressure_altitude_ft, temperature_c, wind_kts |
landing_performance | 计算着陆距离和进场速度 | weight_kg, pressure_altitude_ft, temperature_c, runway_condition |
fuel_reserve_calculator | 根据规定计算所需的燃料储备 | regulation, trip_fuel_kg, cruise_fuel_flow_kg_hr |
kalman_filter_state_estimation | 基于卡尔曼滤波器的状态估计 | initial_state, measurements, process_noise |
lqr_controller_design | 设计LQR最优控制器 | A_matrix, B_matrix, Q_matrix, R_matrix |
Claude桌面设置
- 打开克劳德桌面设置
- 添加服务器配置:
{
"mcpServers": {
"aerospace-mcp": {
"command": "uv",
"args": ["run", "aerospace-mcp"],
"cwd": "/path/to/aerospace-mcp"
}
}
}- 重新启动克劳德桌面
- 测试:“搜索东京机场”
工具发现
MCP服务器提供44多种航空航天工具,包括 工具搜索工具 跟随 Anthropic指南 对于动态工具发现:
# Search by natural language
search_aerospace_tools("atmospheric pressure altitude")
# Returns: get_atmosphere_profile, wind_model_simple, ...
# Search by regex pattern
search_aerospace_tools("(?i)orbit", search_type="regex")
# Returns: propagate_orbit_j2, elements_to_state_vector, hohmann_transfer, ...
# Filter by category
search_aerospace_tools("calculate", category="orbits")
# Returns only orbital mechanics tools matching "calculate"
# List all categories
list_tool_categories()
# Returns: core, atmosphere, frames, aerodynamics, propellers, rockets, orbits, gnc, performance, optimization, agents可用类别:
- 核心:飞行计划、机场、距离、飞机性能
- 氛围:ISA剖面图、风建模
- 帧:坐标变换(ECEF、ECI、大地测量)
- 空气动力学:机翼分析、翼型极性、稳定性导数
- 螺旋桨:BEMT分析、无人机能量估算
- 火箭:3自由度弹道、尺寸、发射优化
- 轨道:轨道要素、传播、转移、交会、朗伯求解器
- 优化:遗传算法、粒子群优化、蒙特卡洛、猪肉店图
- 健安喜:卡尔曼滤波器状态估计,LQR控制器设计
- 演出:密度高度、空速转换、失速速度、W&B、起飞/着陆
- 代理:LLM电动工具选择和数据格式化
延迟工具加载
对于具有许多工具的应用程序,航空航天mcp支持 延迟工具加载 以保持上下文窗口的效率。在MCP中使用Anthropic API时,配置 mcp_toolset 推迟加载除发现工具之外的所有工具:
{
"tools": [
{
"type": "tool_search_tool_regex_20251119",
"name": "tool_search_tool_regex"
},
{
"type": "mcp_toolset",
"mcp_server_name": "aerospace-mcp",
"default_config": {
"defer_loading": true
},
"configs": {
"search_aerospace_tools": { "defer_loading": false },
"list_tool_categories": { "defer_loading": false }
}
}
]
}此配置:
- 立即加载发现工具 (
search_aerospace_tools,list_tool_categories) - 推迟所有其他工具 直到克劳德找到他们
- 自动扩展
tool_reference从搜索结果到完整定义的块
当克劳德需要一个特定的工具时,它会使用 search_aerospace_tools 返回 tool_reference 阻碍:
{
"tool_references": [
{ "type": "tool_reference", "tool_name": "hohmann_transfer" },
{ "type": "tool_reference", "tool_name": "propagate_orbit_j2" }
]
}API自动将这些引用扩展为完整的工具定义,在提供对所有44+工具的访问的同时保持上下文高效。
VS代码继续安装
添加到您的 config.json:
{
"mcpServers": [
{
"name": "aerospace-mcp",
"command": "uv",
"args": ["run", "aerospace-mcp"],
"workingDirectory": "/path/to/aerospace-mcp"
}
]
}🛠️ 发展
开发设置
# Clone and setup
git clone https://github.com/cheesejaguar/aerospace-mcp.git
cd aerospace-mcp
# Create development environment
uv venv
source .venv/bin/activate
uv add --dev pytest httpx black isort mypy pre-commit
# Install pre-commit hooks
pre-commit install
# Run development server
uvicorn main:app --reload --log-level debug测试
# Run all tests
pytest
# Run with coverage
pytest --cov=. --cov-report=html
# Run specific test file
pytest tests/test_main.py -v
# Performance testing
pytest tests/test_performance.py -v代码质量
# Format code
black . && isort .
# Type checking
mypy main.py aerospace_mcp/
# Linting
ruff check .
# Pre-commit (runs all checks)
pre-commit run --all-files项目结构
aerospace-mcp/
├── main.py # FastAPI application
├── aerospace_mcp/ # MCP server implementation
│ ├── __init__.py
│ ├── server.py # Legacy MCP server (deprecated)
│ ├── fastmcp_server.py # FastMCP server entry point (primary)
│ ├── core.py # Shared business logic
│ ├── tools/ # MCP tool definitions
│ │ ├── core.py # Flight planning tools
│ │ ├── atmosphere.py # Atmospheric modeling tools
│ │ ├── aerodynamics.py # Wing & airfoil analysis
│ │ ├── frames.py # Coordinate transformations
│ │ ├── rockets.py # Rocket trajectory tools
│ │ ├── orbits.py # Orbital mechanics tools
│ │ ├── propellers.py # Propeller analysis tools
│ │ ├── optimization.py # Trajectory optimization
│ │ ├── gnc.py # GNC tools (Kalman filter, LQR)
│ │ ├── performance.py # Aircraft performance tools
│ │ ├── agents.py # LLM-powered agent tools
│ │ └── tool_search.py # Tool discovery and search
│ └── integrations/ # Backend computation modules
│ ├── _array_backend.py # NumPy/CuPy abstraction (GPU support)
│ ├── atmosphere.py # Vectorized ISA calculations
│ ├── aero.py # Vectorized aerodynamics
│ ├── frames.py # Vectorized coordinate transforms
│ ├── rockets.py # Vectorized trajectory integration
│ ├── orbits.py # Orbital mechanics computations
│ └── propellers.py # Propeller BEMT analysis
├── app/ # Alternative FastAPI structure
│ ├── __init__.py
│ └── main.py
├── tests/ # Test suite (412 tests)
│ ├── conftest.py
│ ├── test_main.py
│ ├── test_airports.py
│ ├── test_plan.py
│ ├── test_mcp.py
│ ├── test_integrations_*.py # Integration module tests
│ └── tools/ # Tool-specific tests
│ ├── test_tools_performance.py # Performance tools tests
│ ├── test_tools_gnc.py # GNC tools tests
│ └── test_tools_lambert.py # Lambert solver tests
├── docs/ # Documentation
│ ├── API.md
│ ├── ARCHITECTURE.md
│ ├── INTEGRATION.md
│ ├── QUICKSTART.md
│ ├── DEPLOYMENT.md
│ └── MCP_INTEGRATION.md
├── pyproject.toml # Project configuration
├── requirements.txt # Dependencies
├── Dockerfile # Docker configuration
├── docker-compose.yml # Multi-service setup
└── README.md # This file🤝 贡献
我们欢迎捐款!请参阅 贡献.md 详细指南。
快速贡献指南
- 分叉与克隆
git clone https://github.com/yourusername/aerospace-mcp.git
cd aerospace-mcp- 设置开发环境
uv venv && source .venv/bin/activate
uv add --dev pytest httpx black isort mypy- 进行更改
- 添加功能或修复错误 - 为新功能编写测试 - 根据需要更新文档
- 测试和格式
pytest
black . && isort .
mypy main.py- 提交拉取请求
- 清晰的标题和描述 - 参考任何相关问题 - 确保CI/CD检查通过
贡献领域
- 新飞机支持:为OpenAP添加更多飞机类型
- 天气集成:添加天气数据源
- 路线优化:实施航路点优化
- UI/前端:飞行计划Web界面
- 数据库后端:PostgreSQL/MongoDB集成
- 演出:优化和缓存改进
- GPU优化:将CuPy支持扩展到其他模块
- 向量化:提高NumPy矢量化覆盖率
📚 文档
完整的文件
- 快速入门指南 -5分钟后起床跑步
- API 参考 -完整的REST API文档
- MCP集成 -模型上下文协议设置
- 架构指南 -系统设计和组件
- 部署指导 -生产部署策略
- 贡献指南 -发展和贡献指南
- 集成指南 -客户端集成示例
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
第三方确认
- OpenAP:飞机性能建模- 代尔夫特 大学
- 机场数据:机场数据库- mborsetti
- GeographicLib:测地线计算- 查尔斯·卡尼
- 快速API:现代web框架- 塞巴斯蒂安·拉米雷斯
🆘 支持与社区
获取帮助
- GitHub 问题:Bug报告和功能请求
- GitHub讨论:问题和社区支持
- 文档:综合指南
/docs - 例子:代码示例和教程
社区
- Discord 的中文翻译是“不和谐”或“纷争”。:WIP用于实时聊天
专业支持
对于企业支持、咨询或定制开发:
- 电子邮件:hello@aeroastro.org
- 网站:https://aeroastro.org
______________________________________________________________________
⭐ 如果你觉得这个存储库有用,请为其加星!
建于❤️ 航空和软件开发社区。
