FlightAware MCP服务器
一个桥接服务器,将模型上下文协议(MCP)客户端连接到FlightAware的AeroAPI,以获取实时航空数据。
特性
- 航班信息:获取特定航班的实时信息
- 机场运营:在机场跟踪到达和离开的航班
- 飞机详细信息:按机尾号检索飞机信息
- 机场搜索:按地区、国家或自定义查询查找机场
- 详细跟踪:获取全面的航班运行详情
- 灵活的协议支持:适用于TCP和WebSocket连接
- 易于配置:通过环境变量或命令行进行简单设置
MCP工具
此服务器通过MCP接口提供以下工具:
getFlightByIdent
使用特定航班的标识符获取有关该航班的信息。
{
"id": "req123",
"method": "getFlightByIdent",
"params": {
"ident": "AAL100"
}
}getFlightsForAirport
列出抵达或离开特定机场的航班。
{
"id": "req124",
"method": "getFlightsForAirport",
"params": {
"airport_code": "KJFK",
"arrivals": true,
"departures": true,
"type": "all"
}
}getAircraftByTail
通过机尾号获取特定飞机的信息。
{
"id": "req125",
"method": "getAircraftByTail",
"params": {
"tail": "N12345"
}
}getAirportsByRegion
按国家、地区或自定义查询搜索机场。
{
"id": "req126",
"method": "getAirportsByRegion",
"params": {
"country": "US",
"region": "CA",
"query": "international"
}
}getFlightDetails
获取特定航班的详细信息。
{
"id": "req127",
"method": "getFlightDetails",
"params": {
"ident": "AAL100"
}
}配置
AeroAPI密钥
您需要一个FlightAware AeroAPI密钥才能使用此服务器。
- 注册地址: FlightAware AeroAPI 的
- 按照他们的说明获取API密钥
安装
使用NPX(无需安装)
直接使用npx运行:
npx flightaware-mcp --port 8080 --aeroapi-key YOUR_API_KEY全球安装
全局安装并从任何地方运行:
npm install -g flightaware-mcp
flightaware-mcp --port 8080 --aeroapi-key YOUR_API_KEY本地安装
在项目中本地安装:
npm install flightaware-mcp然后添加到您的 package.json 脚本:
"scripts": {
"start-mcp": "flightaware-mcp --port 8080"
}命令行选项
Usage: flightaware-mcp [options]
Options:
-V, --version output the version number
-p, --port Port to listen on (default: "8080")
-k, --aeroapi-key FlightAware AeroAPI key
-m, --mode Server mode (tcp or ws) (default: "tcp")
-t, --timeout Request timeout in milliseconds (default: "30000")
-d, --debug Enable debug mode with verbose logging
-h, --help display help for command
Notes:
- If you experience timeout errors (MCP error -32001), try increasing the timeout value.
- Debug mode will provide detailed logs about requests and timeouts.
- For n8n integrations, set a higher timeout value (60000 or more) if needed.环境变量
您可以使用环境变量而不是命令行参数:
AEROAPI_KEY=your_api_key
MCP_SERVER_PORT=8080
MCP_SERVER_MODE=tcp # or ws for WebSocket
MCP_REQUEST_TIMEOUT=60000 # timeout in milliseconds, increase if experiencing timeouts
DEBUG=true # enable debug mode with verbose logging
LOG_LEVEL=info # log level (error, warn, info, debug)使用示例
MCP客户端配置
对于支持服务器配置的MCP客户端,您可以使用以下配置:
{
"mcpServers": {
"flightaware": {
"command": "npx",
"args": [
"-y",
"flightaware-mcp"
],
"env": {
"AEROAPI_KEY": "YOUR_API_KEY_HERE"
}
}
}
}MCP客户端代码示例
const net = require('net');
const client = new net.Socket();
client.connect(8080, '127.0.0.1', () => {
console.log('Connected to MCP server');
// Request flight information
const request = {
id: 'req1',
method: 'getFlightByIdent',
params: {
ident: 'UAL123'
}
};
client.write(JSON.stringify(request) + '\n');
});
client.on('data', (data) => {
const response = JSON.parse(data.toString().trim());
console.log('Received response:', response);
client.end();
});
client.on('close', () => {
console.log('Connection closed');
});使用包含的客户端进行测试
此软件包包括一个测试客户端,便于测试:
# First, start the server
npm start
# In another terminal, run the test client
npm run client发展
从源头构建
# Clone the repository
git clone
cd flightaware-mcp
# Install dependencies
npm install
# Start development server
npm start运行测试
npm test代码检查
npm run lint故障排除
超时错误
如果您遇到超时错误(MCP error -32001: Request timed out),尝试以下解决方案:
- 增加超时值:
# With command line
flightaware-mcp --timeout 60000
# With environment variables
MCP_REQUEST_TIMEOUT=60000 flightaware-mcp- 启用调试模式以获取更多信息:
flightaware-mcp --debug- 检查您的网络连接:
- 确保您的服务器有稳定的互联网接入 - 检查是否有任何防火墙规则阻止出站请求
- 对于n8n集成:
- 设置更高的超时值(60000毫秒或更长) - 确保MCP服务器和n8n能够正常通信 - 尝试TCP和WebSocket模式(--mode ws 或 --mode tcp)
- 检查AeroAPI速率限制:
- FlightAware AeroAPI根据您的订阅设置了费率限制 - 启用调试模式以查看详细的API响应信息
许可证
麻省理工学院
