@iflow-mcp/flightradar24-mcp-server 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example ADDED
@@ -0,0 +1,6 @@
1
+ # Flightradar24 API Configuration
2
+ FR24_API_KEY=your-api-key-here
3
+ # Flightradar24 API URL, shouldn't need to change this
4
+ FR24_API_URL=https://fr24api.flightradar24.com
5
+ # Server Configuration
6
+ PORT=3000
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 sunsetcoder
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # Flightradar24 MCP Server đŸ›Šī¸
2
+
3
+ A Claude Desktop MCP server that helps you track flights in real-time using Flightradar24 data. Perfect for aviation enthusiasts, travel planners, or anyone curious about flights overhead!
4
+
5
+ ## What Can This Do? ✨
6
+
7
+ - 🔍 Track any flight in real-time
8
+ - ⏰ Get arrival and departure times for specific flights
9
+ - 🌉 View the status of flights at an airport
10
+ - 🚨 Monitor emergency flights
11
+
12
+ <img width="1466" alt="Anthropic Claude MCP Hackathon - FlightRadar24 MCP server" src="https://github.com/user-attachments/assets/719444ae-2c8b-4441-84f8-5150337d871f" />
13
+
14
+ ## Setup Guide 🚀
15
+
16
+ ### 1. Prerequisites
17
+ - [Claude Desktop](https://claude.ai/desktop) installed on your computer
18
+ - A Flightradar24 API key (get one from [Flightradar24's website](https://www.flightradar24.com/premium))*
19
+
20
+ ### 2. Installation
21
+
22
+ 1. Clone this repository somewhere on your computer:
23
+ ```bash
24
+ git clone https://github.com/sunsetcoder/flightradar24-mcp-server.git
25
+ ```
26
+
27
+ 2. Install dependencies & build the project:
28
+ ```bash
29
+ cd flightradar24-mcp-server
30
+ npm install
31
+ npm run build
32
+ ```
33
+
34
+ ### 3. Integration with Claude Desktop
35
+
36
+ 1. Open your Claude Desktop configuration file:
37
+ ```
38
+ # On Mac:
39
+ ~/Library/Application Support/Claude/claude_desktop_config.json
40
+
41
+ # On Windows:
42
+ %APPDATA%/Claude/claude_desktop_config.json
43
+ ```
44
+
45
+ 2. Add the following to the `mcpServers` object in your config:
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "flightradar24-server": {
50
+ "command": "node",
51
+ "args": [
52
+ "/Users/<username>/<FULL_PATH...>/flightradar24-mcp-server/dist/index.js"
53
+ ],
54
+ "env": {
55
+ "FR24_API_KEY": "your_api_key_here",
56
+ "FR24_API_URL": "https://fr24api.flightradar24.com"
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ 3. Important Steps:
64
+ - Replace `/FULL/PATH/TO/flightradar24-mcp-server` with the actual full path to where you cloned the repository
65
+ - Add your Flightradar24 API key in the `env` section
66
+ - Make sure to use forward slashes (`/`) in the path, even on Windows
67
+
68
+ 4. Restart Claude Desktop for the changes to take effect
69
+
70
+ ## Environment Setup
71
+
72
+ 1. Copy `.env.example` to `.env`:
73
+ ```bash
74
+ cp .env.example .env
75
+ ```
76
+
77
+ 2. Update the `.env` file with your actual Flightradar24 API key:
78
+ ```env
79
+ FR24_API_KEY=your_actual_api_key_here
80
+ ```
81
+
82
+ Note: Never commit your actual API key to version control. The `.env` file is ignored by git for security reasons.
83
+
84
+ ## Let's Try It Out! 🎮
85
+
86
+ Once the server is configured, you can ask Claude questions like:
87
+
88
+ 1. "What's the ETA for United Airlines flight UA123?"
89
+ 2. "Show me all flights currently at SFO"
90
+ 3. "Are there any emergency flights in the area?"
91
+ 4. "Show me all international flights arriving at SFO in the next 2 hours"
92
+ 5. "How many commercial flights are currently over the Pacific Ocean?"
93
+ 6. "Identify any flights that have declared an emergency in the California region"
94
+
95
+ Example conversation with Claude:
96
+ ```
97
+ You: What's the status of flight UA123?
98
+ Claude: Let me check that for you...
99
+ [Claude will use the MCP server to fetch real-time flight information]
100
+ ```
101
+
102
+ ## Common Questions & Troubleshooting 🤔
103
+
104
+ ### "Claude can't connect to the server"
105
+ - Check if the path in `claude_desktop_config.json` is correct
106
+ - Make sure you're using the full absolute path
107
+ - Verify your API key is correct
108
+ - Try restarting Claude Desktop
109
+
110
+ ### "The server isn't responding"
111
+ - Make sure your Flightradar24 API key is valid
112
+ - Check if the API URL is correct
113
+ - Look for any error messages in server logs
114
+
115
+ ### FlightRadar API Access
116
+ - Note: Using Flightradar24's API requires a [subscription](https://fr24api.flightradar24.com/subscriptions-and-credits)
117
+
118
+ ## Need More Help? 🆘
119
+
120
+ 1. Make sure Claude Desktop is properly installed
121
+ 2. Verify your Flightradar24 API key is active
122
+ 3. Check the path in your configuration file is correct
123
+ 4. Look for error messages in MCP server logs
124
+
125
+ ## License 📄
126
+
127
+ MIT
128
+
129
+ ---
130
+
131
+ Made with â¤ī¸ for aviation enthusiasts
package/dist/config.js ADDED
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ import dotenv from 'dotenv';
3
+ // Load environment variables
4
+ dotenv.config();
5
+ /**
6
+ * Environment variable schema validation
7
+ */
8
+ const envSchema = z.object({
9
+ FR24_API_KEY: z.string({
10
+ required_error: "FR24_API_KEY is required in environment variables",
11
+ invalid_type_error: "FR24_API_KEY must be a string"
12
+ }).min(1, { message: "FR24_API_KEY cannot be empty" }).default("test_api_key_for_demo"),
13
+ FR24_API_URL: z.string({
14
+ required_error: "FR24_API_URL is required in environment variables",
15
+ invalid_type_error: "FR24_API_URL must be a string"
16
+ }).url({ message: "FR24_API_URL must be a valid URL" }).default("https://fr24api.flightradar24.com")
17
+ });
18
+ /**
19
+ * Validate and extract environment variables
20
+ * @throws {Error} If validation fails
21
+ */
22
+ export const env = envSchema.parse(process.env);
package/dist/index.js ADDED
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { ListToolsRequestSchema, CallToolRequestSchema, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
5
+ import axios from 'axios';
6
+ import { isValidFlightTrackingParams } from './types.js';
7
+ import { env } from './config.js';
8
+ // API client configuration
9
+ const fr24Client = axios.create({
10
+ baseURL: env.FR24_API_URL,
11
+ headers: {
12
+ 'Accept': 'application/json',
13
+ 'Accept-Version': 'v1',
14
+ 'Authorization': `Bearer ${env.FR24_API_KEY}`
15
+ }
16
+ });
17
+ /**
18
+ * MCP Server implementation for Flightradar24 API
19
+ * Provides tools for tracking flights and monitoring air traffic
20
+ */
21
+ class FlightTrackingServer {
22
+ server;
23
+ constructor() {
24
+ this.server = new Server({ name: 'flightradar24-server', version: '1.0.0' }, {
25
+ capabilities: {
26
+ tools: {},
27
+ jsonrpc: true // Add this to enable JSON-RPC support
28
+ }
29
+ });
30
+ this.setupHandlers();
31
+ this.setupErrorHandling();
32
+ }
33
+ setupErrorHandling() {
34
+ this.server.onerror = (error) => {
35
+ console.error('[MCP Error]', error);
36
+ };
37
+ process.on('SIGINT', async () => {
38
+ await this.server.close();
39
+ process.exit(0);
40
+ });
41
+ }
42
+ setupHandlers() {
43
+ this.setupToolHandlers();
44
+ }
45
+ /**
46
+ * Configure available tools and their handlers
47
+ */
48
+ setupToolHandlers() {
49
+ this.server.setRequestHandler(ListToolsRequestSchema, async (request) => ({
50
+ tools: [
51
+ {
52
+ name: 'get_flight_positions',
53
+ description: 'Get real-time flight positions with various filtering options',
54
+ inputSchema: {
55
+ type: 'object',
56
+ properties: {
57
+ airports: { type: 'string', description: 'Comma-separated list of airport ICAO codes' },
58
+ bounds: { type: 'string', description: 'Geographical bounds (lat1,lon1,lat2,lon2)' },
59
+ categories: { type: 'string', description: 'Aircraft categories (P,C,J)' },
60
+ limit: { type: 'number', description: 'Maximum number of results' }
61
+ }
62
+ }
63
+ },
64
+ {
65
+ name: 'get_flight_eta',
66
+ description: 'Get estimated arrival time for a specific flight',
67
+ inputSchema: {
68
+ type: 'object',
69
+ properties: {
70
+ flightNumber: {
71
+ type: 'string',
72
+ description: 'Flight number (e.g., UA123)',
73
+ pattern: '^[A-Z0-9]{2,8}$'
74
+ }
75
+ },
76
+ required: ['flightNumber']
77
+ }
78
+ }
79
+ ]
80
+ }));
81
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
82
+ try {
83
+ const toolName = request.params.name;
84
+ const toolArgs = request.params.arguments;
85
+ switch (toolName) {
86
+ case 'get_flight_positions': {
87
+ const params = {
88
+ ...toolArgs,
89
+ limit: toolArgs?.limit ? parseInt(toolArgs.limit) : undefined
90
+ };
91
+ if (!isValidFlightTrackingParams(params)) {
92
+ throw new McpError(ErrorCode.InvalidParams, 'Invalid or missing query parameters. At least one valid parameter is required.');
93
+ }
94
+ const response = await fr24Client.get('/api/live/flight-positions/light', { params });
95
+ return {
96
+ content: [{
97
+ type: "text",
98
+ text: JSON.stringify(response.data, null, 2)
99
+ }]
100
+ };
101
+ }
102
+ case 'get_flight_eta': {
103
+ const { flightNumber } = toolArgs || {};
104
+ const flightNumberStr = String(flightNumber || '');
105
+ if (!flightNumberStr || !/^[A-Z0-9]{2,8}$/.test(flightNumberStr)) {
106
+ throw new McpError(ErrorCode.InvalidParams, 'Invalid flight number format');
107
+ }
108
+ const response = await fr24Client.get('/api/flights/detail', {
109
+ params: {
110
+ flight: flightNumberStr,
111
+ format: 'eta'
112
+ }
113
+ });
114
+ return {
115
+ content: [{
116
+ type: "text",
117
+ text: JSON.stringify(response.data, null, 2)
118
+ }]
119
+ };
120
+ }
121
+ default:
122
+ throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${toolName}`);
123
+ }
124
+ }
125
+ catch (error) {
126
+ if (axios.isAxiosError(error)) {
127
+ return {
128
+ isError: true,
129
+ content: [{
130
+ type: "text",
131
+ text: `Flightradar24 API error: ${error.response?.data?.message || error.message || 'Unknown error'}`
132
+ }]
133
+ };
134
+ }
135
+ throw error;
136
+ }
137
+ });
138
+ }
139
+ /**
140
+ * Start the MCP server using stdio transport
141
+ */
142
+ async run() {
143
+ const transport = new StdioServerTransport();
144
+ await this.server.connect(transport);
145
+ }
146
+ }
147
+ // Create and start the server
148
+ const server = new FlightTrackingServer();
149
+ server.run().catch(console.error);
150
+ //console.log(env.FR24_API_KEY)
151
+ //console.log(env.FR24_API_URL)
package/dist/test.js ADDED
@@ -0,0 +1,40 @@
1
+ // Test requests
2
+ const requests = [
3
+ // List tools request
4
+ {
5
+ jsonrpc: "2.0",
6
+ id: "1",
7
+ method: "list_tools",
8
+ params: {}
9
+ },
10
+ // Test flight positions request
11
+ {
12
+ jsonrpc: "2.0",
13
+ id: "2",
14
+ method: "call_tool",
15
+ params: {
16
+ name: "get_flight_positions",
17
+ arguments: {
18
+ airports: "KJFK,KLAX",
19
+ limit: "5"
20
+ }
21
+ }
22
+ },
23
+ // Test flight ETA request
24
+ {
25
+ jsonrpc: "2.0",
26
+ id: "3",
27
+ method: "call_tool",
28
+ params: {
29
+ name: "get_flight_eta",
30
+ arguments: {
31
+ flightNumber: "UA123"
32
+ }
33
+ }
34
+ }
35
+ ];
36
+ // Print each request with a delay
37
+ requests.forEach((request, index) => {
38
+ console.log(JSON.stringify(request));
39
+ });
40
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Validates flight tracking parameters
3
+ */
4
+ export function isValidFlightTrackingParams(params) {
5
+ if (!params || typeof params !== 'object') {
6
+ return false;
7
+ }
8
+ const typedParams = params;
9
+ // Check that at least one valid parameter is provided
10
+ const validParams = [
11
+ 'bounds', 'flights', 'callsigns', 'registrations', 'painted_as',
12
+ 'operating_as', 'airports', 'routes', 'aircraft', 'altitude_ranges',
13
+ 'squawks', 'categories', 'data_sources', 'airspaces', 'limit'
14
+ ];
15
+ const hasValidParam = validParams.some(param => {
16
+ const value = typedParams[param];
17
+ if (param === 'limit') {
18
+ return typeof value === 'number' && value > 0;
19
+ }
20
+ return typeof value === 'string' && value.length > 0;
21
+ });
22
+ return hasValidParam;
23
+ }
24
+ export var FlightCategory;
25
+ (function (FlightCategory) {
26
+ FlightCategory["PASSENGER"] = "P";
27
+ FlightCategory["CARGO"] = "C";
28
+ FlightCategory["MILITARY_AND_GOVERNMENT"] = "M";
29
+ FlightCategory["BUSINESS_JETS"] = "J";
30
+ FlightCategory["GENERAL_AVIATION"] = "T";
31
+ FlightCategory["HELICOPTERS"] = "H";
32
+ FlightCategory["LIGHTER_THAN_AIR"] = "B";
33
+ FlightCategory["GLIDERS"] = "G";
34
+ FlightCategory["DRONES"] = "D";
35
+ FlightCategory["GROUND_VEHICLES"] = "V";
36
+ FlightCategory["OTHER"] = "O";
37
+ FlightCategory["NON_CATEGORIZED"] = "N";
38
+ })(FlightCategory || (FlightCategory = {}));
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@iflow-mcp/flightradar24-mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "Model Context Protocol server for FlightRadar24 API",
5
+ "main": "build/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "flightradar24-mcp-server": "dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "start": "node dist/index.js",
13
+ "dev": "ts-node src/index.ts",
14
+ "test": "echo \"Error: no test specified\" && exit 1"
15
+ },
16
+ "keywords": [
17
+ "flightradar24",
18
+ "api",
19
+ "mcp",
20
+ "flight-tracking"
21
+ ],
22
+ "author": "",
23
+ "license": "MIT",
24
+ "dependencies": {
25
+ "@modelcontextprotocol/sdk": "latest",
26
+ "axios": "^1.6.0",
27
+ "dotenv": "^16.4.7",
28
+ "zod": "^3.22.4"
29
+ },
30
+ "devDependencies": {
31
+ "@types/express": "^4.17.21",
32
+ "@types/node": "^20.10.4",
33
+ "tsc-watch": "^6.0.4",
34
+ "typescript": "^5.3.3"
35
+ }
36
+ }
package/src/config.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod'
2
+ import dotenv from 'dotenv'
3
+
4
+ // Load environment variables
5
+ dotenv.config()
6
+
7
+ /**
8
+ * Environment variable schema validation
9
+ */
10
+ const envSchema = z.object({
11
+ FR24_API_KEY: z.string({
12
+ required_error: "FR24_API_KEY is required in environment variables",
13
+ invalid_type_error: "FR24_API_KEY must be a string"
14
+ }).min(1, { message: "FR24_API_KEY cannot be empty" }).default("test_api_key_for_demo"),
15
+ FR24_API_URL: z.string({
16
+ required_error: "FR24_API_URL is required in environment variables",
17
+ invalid_type_error: "FR24_API_URL must be a string"
18
+ }).url({ message: "FR24_API_URL must be a valid URL" }).default("https://fr24api.flightradar24.com")
19
+ })
20
+
21
+ /**
22
+ * Validate and extract environment variables
23
+ * @throws {Error} If validation fails
24
+ */
25
+ export const env = envSchema.parse(process.env)
package/src/index.ts ADDED
@@ -0,0 +1,200 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import {
5
+ ListToolsRequestSchema,
6
+ CallToolRequestSchema,
7
+ ErrorCode,
8
+ McpError,
9
+ ListToolsRequest,
10
+ CallToolRequest
11
+ } from '@modelcontextprotocol/sdk/types.js';
12
+ import axios from 'axios';
13
+ import {
14
+ FlightTrackingParams,
15
+ FlightPositionsResponse,
16
+ FlightETAResponse,
17
+ isValidFlightTrackingParams
18
+ } from './types.js';
19
+ import { env } from './config.js';
20
+
21
+ // API client configuration
22
+ const fr24Client = axios.create({
23
+ baseURL: env.FR24_API_URL,
24
+ headers: {
25
+ 'Accept': 'application/json',
26
+ 'Accept-Version': 'v1',
27
+ 'Authorization': `Bearer ${env.FR24_API_KEY}`
28
+ }
29
+ });
30
+
31
+ /**
32
+ * MCP Server implementation for Flightradar24 API
33
+ * Provides tools for tracking flights and monitoring air traffic
34
+ */
35
+ class FlightTrackingServer {
36
+ private server: Server;
37
+
38
+ constructor() {
39
+ this.server = new Server(
40
+ { name: 'flightradar24-server', version: '1.0.0' },
41
+ {
42
+ capabilities: {
43
+ tools: {},
44
+ jsonrpc: true // Add this to enable JSON-RPC support
45
+ }
46
+ }
47
+ );
48
+
49
+ this.setupHandlers();
50
+ this.setupErrorHandling();
51
+ }
52
+
53
+ private setupErrorHandling(): void {
54
+ this.server.onerror = (error) => {
55
+ console.error('[MCP Error]', error);
56
+ };
57
+
58
+ process.on('SIGINT', async () => {
59
+ await this.server.close();
60
+ process.exit(0);
61
+ });
62
+ }
63
+
64
+ private setupHandlers(): void {
65
+ this.setupToolHandlers();
66
+ }
67
+
68
+ /**
69
+ * Configure available tools and their handlers
70
+ */
71
+ private setupToolHandlers(): void {
72
+ this.server.setRequestHandler(ListToolsRequestSchema, async (request: ListToolsRequest) => ({
73
+ tools: [
74
+ {
75
+ name: 'get_flight_positions',
76
+ description: 'Get real-time flight positions with various filtering options',
77
+ inputSchema: {
78
+ type: 'object',
79
+ properties: {
80
+ airports: { type: 'string', description: 'Comma-separated list of airport ICAO codes' },
81
+ bounds: { type: 'string', description: 'Geographical bounds (lat1,lon1,lat2,lon2)' },
82
+ categories: { type: 'string', description: 'Aircraft categories (P,C,J)' },
83
+ limit: { type: 'number', description: 'Maximum number of results' }
84
+ }
85
+ }
86
+ },
87
+ {
88
+ name: 'get_flight_eta',
89
+ description: 'Get estimated arrival time for a specific flight',
90
+ inputSchema: {
91
+ type: 'object',
92
+ properties: {
93
+ flightNumber: {
94
+ type: 'string',
95
+ description: 'Flight number (e.g., UA123)',
96
+ pattern: '^[A-Z0-9]{2,8}$'
97
+ }
98
+ },
99
+ required: ['flightNumber']
100
+ }
101
+ }
102
+ ]
103
+ }));
104
+
105
+ this.server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest) => {
106
+ try {
107
+ const toolName = request.params.name;
108
+ const toolArgs = request.params.arguments;
109
+
110
+ switch (toolName) {
111
+ case 'get_flight_positions': {
112
+ const params: FlightTrackingParams = {
113
+ ...toolArgs,
114
+ limit: toolArgs?.limit ? parseInt(toolArgs.limit as string) : undefined
115
+ };
116
+
117
+ if (!isValidFlightTrackingParams(params)) {
118
+ throw new McpError(
119
+ ErrorCode.InvalidParams,
120
+ 'Invalid or missing query parameters. At least one valid parameter is required.'
121
+ );
122
+ }
123
+
124
+ const response = await fr24Client.get<FlightPositionsResponse>(
125
+ '/api/live/flight-positions/light',
126
+ { params }
127
+ );
128
+
129
+ return {
130
+ content: [{
131
+ type: "text",
132
+ text: JSON.stringify(response.data, null, 2)
133
+ }]
134
+ };
135
+ }
136
+
137
+ case 'get_flight_eta': {
138
+ const { flightNumber } = toolArgs || {};
139
+ const flightNumberStr = String(flightNumber || '');
140
+
141
+ if (!flightNumberStr || !/^[A-Z0-9]{2,8}$/.test(flightNumberStr)) {
142
+ throw new McpError(
143
+ ErrorCode.InvalidParams,
144
+ 'Invalid flight number format'
145
+ );
146
+ }
147
+
148
+ const response = await fr24Client.get<FlightETAResponse>(
149
+ '/api/flights/detail',
150
+ {
151
+ params: {
152
+ flight: flightNumberStr,
153
+ format: 'eta'
154
+ }
155
+ }
156
+ );
157
+
158
+ return {
159
+ content: [{
160
+ type: "text",
161
+ text: JSON.stringify(response.data, null, 2)
162
+ }]
163
+ };
164
+ }
165
+
166
+ default:
167
+ throw new McpError(
168
+ ErrorCode.MethodNotFound,
169
+ `Unknown tool: ${toolName}`
170
+ );
171
+ }
172
+ } catch (error) {
173
+ if (axios.isAxiosError(error)) {
174
+ return {
175
+ isError: true,
176
+ content: [{
177
+ type: "text",
178
+ text: `Flightradar24 API error: ${error.response?.data?.message || error.message || 'Unknown error'}`
179
+ }]
180
+ };
181
+ }
182
+ throw error;
183
+ }
184
+ });
185
+ }
186
+
187
+ /**
188
+ * Start the MCP server using stdio transport
189
+ */
190
+ async run(): Promise<void> {
191
+ const transport = new StdioServerTransport();
192
+ await this.server.connect(transport);
193
+ }
194
+ }
195
+
196
+ // Create and start the server
197
+ const server = new FlightTrackingServer();
198
+ server.run().catch(console.error);
199
+ //console.log(env.FR24_API_KEY)
200
+ //console.log(env.FR24_API_URL)
package/src/test.ts ADDED
@@ -0,0 +1,42 @@
1
+ // Test requests
2
+ const requests = [
3
+ // List tools request
4
+ {
5
+ jsonrpc: "2.0",
6
+ id: "1",
7
+ method: "list_tools",
8
+ params: {}
9
+ },
10
+
11
+ // Test flight positions request
12
+ {
13
+ jsonrpc: "2.0",
14
+ id: "2",
15
+ method: "call_tool",
16
+ params: {
17
+ name: "get_flight_positions",
18
+ arguments: {
19
+ airports: "KJFK,KLAX",
20
+ limit: "5"
21
+ }
22
+ }
23
+ },
24
+
25
+ // Test flight ETA request
26
+ {
27
+ jsonrpc: "2.0",
28
+ id: "3",
29
+ method: "call_tool",
30
+ params: {
31
+ name: "get_flight_eta",
32
+ arguments: {
33
+ flightNumber: "UA123"
34
+ }
35
+ }
36
+ }
37
+ ];
38
+
39
+ // Print each request with a delay
40
+ requests.forEach((request, index) => {
41
+ console.log(JSON.stringify(request));
42
+ });
@@ -0,0 +1,6 @@
1
+ declare namespace NodeJS {
2
+ interface ProcessEnv {
3
+ FR24_API_KEY: string;
4
+ FR24_API_URL: string;
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ declare module '@modelcontextprotocol/sdk' {
2
+ export class MCPServer {
3
+ constructor(config: { apiKey: string });
4
+ }
5
+ }
package/src/types.ts ADDED
@@ -0,0 +1,123 @@
1
+ export interface Coordinate {
2
+ lat: number;
3
+ lng: number;
4
+ }
5
+
6
+ export interface ApiResponse {
7
+ contents: {
8
+ uri: string;
9
+ mimeType: string;
10
+ text: string;
11
+ }[];
12
+ }
13
+
14
+ /**
15
+ * Flightradar24 API Types
16
+ */
17
+
18
+ export interface FlightPosition {
19
+ fr24_id: string;
20
+ hex: string;
21
+ callsign: string;
22
+ lat: number;
23
+ lon: number;
24
+ track: number;
25
+ alt: number;
26
+ gspeed: number;
27
+ vspeed: number;
28
+ squawk: string;
29
+ timestamp: string;
30
+ source: 'ADSB' | 'MLAT' | 'ESTIMATED';
31
+ }
32
+
33
+ export interface FlightPositionsResponse {
34
+ data: FlightPosition[];
35
+ }
36
+
37
+ export interface FlightETA {
38
+ flight_number: string;
39
+ departure: {
40
+ airport: string;
41
+ scheduled: string;
42
+ actual: string;
43
+ delay?: number;
44
+ };
45
+ arrival: {
46
+ airport: string;
47
+ scheduled: string;
48
+ estimated: string;
49
+ delay?: number;
50
+ };
51
+ status: 'scheduled' | 'active' | 'landed' | 'cancelled';
52
+ }
53
+
54
+ export interface FlightETAResponse {
55
+ data: FlightETA;
56
+ }
57
+
58
+ export interface FlightTrackingParams {
59
+ bounds?: string;
60
+ flights?: string;
61
+ callsigns?: string;
62
+ registrations?: string;
63
+ painted_as?: string;
64
+ operating_as?: string;
65
+ airports?: string;
66
+ routes?: string;
67
+ aircraft?: string;
68
+ altitude_ranges?: string;
69
+ squawks?: string;
70
+ categories?: string;
71
+ data_sources?: string;
72
+ airspaces?: string;
73
+ limit?: number;
74
+ }
75
+
76
+ /**
77
+ * Validates flight tracking parameters
78
+ */
79
+ export function isValidFlightTrackingParams(params: unknown): params is FlightTrackingParams {
80
+ if (!params || typeof params !== 'object') {
81
+ return false;
82
+ }
83
+
84
+ const typedParams = params as Record<string, unknown>;
85
+
86
+ // Check that at least one valid parameter is provided
87
+ const validParams = [
88
+ 'bounds', 'flights', 'callsigns', 'registrations', 'painted_as',
89
+ 'operating_as', 'airports', 'routes', 'aircraft', 'altitude_ranges',
90
+ 'squawks', 'categories', 'data_sources', 'airspaces', 'limit'
91
+ ];
92
+
93
+ const hasValidParam = validParams.some(param => {
94
+ const value = typedParams[param];
95
+ if (param === 'limit') {
96
+ return typeof value === 'number' && value > 0;
97
+ }
98
+ return typeof value === 'string' && value.length > 0;
99
+ });
100
+
101
+ return hasValidParam;
102
+ }
103
+
104
+ export enum FlightCategory {
105
+ PASSENGER = 'P',
106
+ CARGO = 'C',
107
+ MILITARY_AND_GOVERNMENT = 'M',
108
+ BUSINESS_JETS = 'J',
109
+ GENERAL_AVIATION = 'T',
110
+ HELICOPTERS = 'H',
111
+ LIGHTER_THAN_AIR = 'B',
112
+ GLIDERS = 'G',
113
+ DRONES = 'D',
114
+ GROUND_VEHICLES = 'V',
115
+ OTHER = 'O',
116
+ NON_CATEGORIZED = 'N'
117
+ }
118
+
119
+ export interface ApiError {
120
+ code: string;
121
+ message: string;
122
+ details?: any;
123
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "Node16",
5
+ "moduleResolution": "Node16",
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true
13
+ },
14
+ "include": [
15
+ "src/**/*"
16
+ ],
17
+ "exclude": [
18
+ "node_modules"
19
+ ]
20
+ }