mcp-travelcode 1.0.4 → 1.0.5

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.
@@ -23,7 +23,7 @@ export declare class TravelCodeApiClient {
23
23
  private ensureValidToken;
24
24
  get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
25
25
  post<T>(path: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<T>;
26
- getAerodatabox<T>(aerodataboxPath: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
26
+ getFlightStats<T>(subPath: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
27
27
  /**
28
28
  * POST request that returns an SSE stream.
29
29
  * Collects events and returns them as an array of {event, data} objects.
@@ -74,10 +74,10 @@ export class TravelCodeApiClient {
74
74
  });
75
75
  return this.handleResponse(response);
76
76
  }
77
- async getAerodatabox(aerodataboxPath, params) {
77
+ async getFlightStats(subPath, params) {
78
78
  await this.ensureValidToken();
79
- // Build the AeroDataBox path with query params
80
- const pathUrl = new URL(`https://placeholder${aerodataboxPath}`);
79
+ // Build the inner path with query params
80
+ const pathUrl = new URL(`https://placeholder${subPath}`);
81
81
  if (params) {
82
82
  for (const [key, value] of Object.entries(params)) {
83
83
  if (value !== undefined) {
@@ -85,11 +85,10 @@ export class TravelCodeApiClient {
85
85
  }
86
86
  }
87
87
  }
88
- const fullAeroPath = pathUrl.pathname + pathUrl.search;
89
- // Proxy URL: strip /v1 from base URL, route through /flight/aerodatabox
90
- const proxyBaseUrl = this.baseUrl.replace(/\/v1\/?$/, "");
91
- const proxyUrl = new URL(`${proxyBaseUrl}/flight/aerodatabox`);
92
- proxyUrl.searchParams.set("path", fullAeroPath);
88
+ const fullPath = pathUrl.pathname + pathUrl.search;
89
+ // Route through the TravelCode flight stats proxy endpoint
90
+ const proxyUrl = new URL(`${this.baseUrl}/flight/aerostats`);
91
+ proxyUrl.searchParams.set("path", fullPath);
93
92
  const response = await fetch(proxyUrl.toString(), {
94
93
  method: "GET",
95
94
  headers: this.headers(),
@@ -128,11 +128,11 @@ export interface FlightSearchResultsResponse {
128
128
  airports?: Record<string, DictionaryAirport>;
129
129
  };
130
130
  }
131
- export interface AeroFlightTime {
131
+ export interface FlightTime {
132
132
  utc?: string;
133
133
  local?: string;
134
134
  }
135
- export interface AeroFlightEndpoint {
135
+ export interface FlightEndpoint {
136
136
  airport?: {
137
137
  icao?: string;
138
138
  iata?: string;
@@ -145,17 +145,17 @@ export interface AeroFlightEndpoint {
145
145
  };
146
146
  countryCode?: string;
147
147
  };
148
- scheduledTime?: AeroFlightTime;
149
- revisedTime?: AeroFlightTime;
150
- predictedTime?: AeroFlightTime;
151
- actualTime?: AeroFlightTime;
148
+ scheduledTime?: FlightTime;
149
+ revisedTime?: FlightTime;
150
+ predictedTime?: FlightTime;
151
+ actualTime?: FlightTime;
152
152
  terminal?: string;
153
153
  gate?: string;
154
154
  baggageBelt?: string;
155
155
  checkInDesk?: string;
156
156
  quality?: string[];
157
157
  }
158
- export interface AeroFlightAircraft {
158
+ export interface FlightAircraft {
159
159
  reg?: string;
160
160
  modeS?: string;
161
161
  model?: string;
@@ -167,11 +167,11 @@ export interface AeroFlightAircraft {
167
167
  description?: string;
168
168
  };
169
169
  }
170
- export interface AeroFlightStatus {
170
+ export interface FlightStatus {
171
171
  type?: string;
172
172
  status?: string;
173
- departure: AeroFlightEndpoint;
174
- arrival: AeroFlightEndpoint;
173
+ departure: FlightEndpoint;
174
+ arrival: FlightEndpoint;
175
175
  number?: string;
176
176
  callSign?: string;
177
177
  airline?: {
@@ -179,7 +179,7 @@ export interface AeroFlightStatus {
179
179
  iata?: string;
180
180
  icao?: string;
181
181
  };
182
- aircraft?: AeroFlightAircraft;
182
+ aircraft?: FlightAircraft;
183
183
  location?: {
184
184
  pressureAltFt?: number;
185
185
  gsKt?: number;
@@ -194,10 +194,10 @@ export interface AeroFlightStatus {
194
194
  mile?: number;
195
195
  };
196
196
  }
197
- export type AeroFlightStatusResponse = AeroFlightStatus[];
198
- export interface AeroBoardFlight {
199
- departure: AeroFlightEndpoint;
200
- arrival: AeroFlightEndpoint;
197
+ export type FlightStatusResponse = FlightStatus[];
198
+ export interface BoardFlight {
199
+ departure: FlightEndpoint;
200
+ arrival: FlightEndpoint;
201
201
  number?: string;
202
202
  status?: string;
203
203
  codeshareStatus?: string;
@@ -212,11 +212,11 @@ export interface AeroBoardFlight {
212
212
  reg?: string;
213
213
  };
214
214
  }
215
- export interface AeroAirportBoardResponse {
216
- departures?: AeroBoardFlight[];
217
- arrivals?: AeroBoardFlight[];
215
+ export interface AirportBoardResponse {
216
+ departures?: BoardFlight[];
217
+ arrivals?: BoardFlight[];
218
218
  }
219
- export interface AeroFlightDelayStats {
219
+ export interface FlightDelayStats {
220
220
  route?: {
221
221
  from?: string;
222
222
  to?: string;
@@ -231,21 +231,21 @@ export interface AeroFlightDelayStats {
231
231
  onTimePercentage?: number;
232
232
  observations?: number;
233
233
  }
234
- export interface AeroAirportDelayInfo {
234
+ export interface AirportDelayInfo {
235
235
  averageDelayMin?: number;
236
236
  delayIndex?: number;
237
237
  medianDelayMin?: number;
238
238
  cancellations?: number;
239
239
  totalFlights?: number;
240
240
  }
241
- export interface AeroAirportDelayStats {
241
+ export interface AirportDelayStats {
242
242
  airport?: {
243
243
  iata?: string;
244
244
  name?: string;
245
245
  };
246
246
  date?: string;
247
- departures?: AeroAirportDelayInfo;
248
- arrivals?: AeroAirportDelayInfo;
247
+ departures?: AirportDelayInfo;
248
+ arrivals?: AirportDelayInfo;
249
249
  }
250
250
  export interface OrderShort {
251
251
  orderId: number;
@@ -0,0 +1,6 @@
1
+ import { FlightStatus, BoardFlight, FlightDelayStats, AirportDelayStats } from "../client/types.js";
2
+ export declare function formatFlightStatus(flights: FlightStatus[], flightNumber: string, date: string): string;
3
+ export declare function formatAirportBoard(flights: BoardFlight[], airportCode: string, direction: string, fromTime: string, toTime: string): string;
4
+ export declare function formatFlightDelayStats(stats: FlightDelayStats, flightNumber: string): string;
5
+ export declare function formatAirportDelayStats(stats: AirportDelayStats, airportCode: string, date: string): string;
6
+ //# sourceMappingURL=flight-stats-formatter.d.ts.map
@@ -243,4 +243,4 @@ function assessDelay(avgDelayMin) {
243
243
  return "Moderate delays";
244
244
  return "Severe delays";
245
245
  }
246
- //# sourceMappingURL=aerodatabox-formatter.js.map
246
+ //# sourceMappingURL=flight-stats-formatter.js.map
@@ -59,7 +59,7 @@ app.use((_req, res, next) => {
59
59
  res.setHeader("Access-Control-Expose-Headers", "Mcp-Session-Id");
60
60
  next();
61
61
  });
62
- app.options("*", (_req, res) => {
62
+ app.options(/.*/, (_req, res) => {
63
63
  res.sendStatus(204);
64
64
  });
65
65
  // --- Protected Resource Metadata (RFC 9728) ---
package/build/index.js CHANGED
File without changes
package/build/server.js CHANGED
@@ -33,7 +33,7 @@ export function createServer(config) {
33
33
  // Flight search tools
34
34
  registerSearchFlights(server, client, config);
35
35
  registerGetFlightResults(server, client);
36
- // Flight statistics tools (AeroDataBox)
36
+ // Flight statistics tools
37
37
  registerGetFlightStatus(server, client);
38
38
  registerGetAirportFlights(server, client);
39
39
  registerGetFlightDelayStats(server, client);
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { formatAirportDelayStats } from "../formatters/aerodatabox-formatter.js";
2
+ import { formatAirportDelayStats } from "../formatters/flight-stats-formatter.js";
3
3
  export const getAirportDelayStatsSchema = {
4
4
  airport_code: z
5
5
  .string()
@@ -12,7 +12,7 @@ export function registerGetAirportDelayStats(server, client) {
12
12
  server.tool("get_airport_delay_stats", "Get current delay statistics for an airport on a specific date. Shows average departure/arrival delays and cancellation rates. Use this during weather events or disruptions to assess the situation at an airport.", getAirportDelayStatsSchema, async ({ airport_code, date }) => {
13
13
  try {
14
14
  const code = airport_code.toUpperCase();
15
- const stats = await client.getAerodatabox(`/airports/iata/${encodeURIComponent(code)}/delays/${date}`);
15
+ const stats = await client.getFlightStats(`/airports/iata/${encodeURIComponent(code)}/delays/${date}`);
16
16
  return {
17
17
  content: [{ type: "text", text: formatAirportDelayStats(stats, code, date) }],
18
18
  };
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { formatAirportBoard } from "../formatters/aerodatabox-formatter.js";
2
+ import { formatAirportBoard } from "../formatters/flight-stats-formatter.js";
3
3
  export const getAirportFlightsSchema = {
4
4
  airport_code: z
5
5
  .string()
@@ -49,7 +49,7 @@ export function registerGetAirportFlights(server, client) {
49
49
  };
50
50
  }
51
51
  const code = airport_code.toUpperCase();
52
- const board = await client.getAerodatabox(`/flights/airports/iata/${encodeURIComponent(code)}/${from_time}/${to_time}`, {
52
+ const board = await client.getFlightStats(`/flights/airports/iata/${encodeURIComponent(code)}/${from_time}/${to_time}`, {
53
53
  withCancellations: true,
54
54
  withCodeshares: include_codeshares,
55
55
  withCargo: include_cargo,
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { formatFlightDelayStats } from "../formatters/aerodatabox-formatter.js";
2
+ import { formatFlightDelayStats } from "../formatters/flight-stats-formatter.js";
3
3
  export const getFlightDelayStatsSchema = {
4
4
  flight_number: z
5
5
  .string()
@@ -9,7 +9,7 @@ export function registerGetFlightDelayStats(server, client) {
9
9
  server.tool("get_flight_delay_stats", "Get historical delay statistics for a specific flight number. Shows how often the flight is delayed, average delay duration, and reliability assessment. Use this to evaluate a flight's punctuality before booking.", getFlightDelayStatsSchema, async ({ flight_number }) => {
10
10
  try {
11
11
  const normalized = flight_number.replace(/\s+/g, "").toUpperCase();
12
- const stats = await client.getAerodatabox(`/flights/${encodeURIComponent(normalized)}/delays`);
12
+ const stats = await client.getFlightStats(`/flights/${encodeURIComponent(normalized)}/delays`);
13
13
  return {
14
14
  content: [{ type: "text", text: formatFlightDelayStats(stats, normalized) }],
15
15
  };
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { formatFlightStatus } from "../formatters/aerodatabox-formatter.js";
2
+ import { formatFlightStatus } from "../formatters/flight-stats-formatter.js";
3
3
  export const getFlightStatusSchema = {
4
4
  flight_number: z
5
5
  .string()
@@ -20,7 +20,7 @@ export function registerGetFlightStatus(server, client) {
20
20
  server.tool("get_flight_status", "Get real-time status of a specific flight by flight number and date. Returns departure/arrival times (scheduled, actual, estimated), terminals, gates, aircraft info, and delay information. Use this to check if a flight is on time, delayed, or cancelled.", getFlightStatusSchema, async ({ flight_number, date, with_aircraft_image, with_location }) => {
21
21
  try {
22
22
  const normalized = flight_number.replace(/\s+/g, "").toUpperCase();
23
- const flights = await client.getAerodatabox(`/flights/number/${encodeURIComponent(normalized)}/${date}`, {
23
+ const flights = await client.getFlightStats(`/flights/number/${encodeURIComponent(normalized)}/${date}`, {
24
24
  withAircraftImage: with_aircraft_image,
25
25
  withLocation: with_location,
26
26
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-travelcode",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "MCP server for TravelCode — flights, hotels, orders. Search flights & hotels, manage bookings via AI assistants.",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",
@@ -1,6 +0,0 @@
1
- import { AeroFlightStatus, AeroBoardFlight, AeroFlightDelayStats, AeroAirportDelayStats } from "../client/types.js";
2
- export declare function formatFlightStatus(flights: AeroFlightStatus[], flightNumber: string, date: string): string;
3
- export declare function formatAirportBoard(flights: AeroBoardFlight[], airportCode: string, direction: string, fromTime: string, toTime: string): string;
4
- export declare function formatFlightDelayStats(stats: AeroFlightDelayStats, flightNumber: string): string;
5
- export declare function formatAirportDelayStats(stats: AeroAirportDelayStats, airportCode: string, date: string): string;
6
- //# sourceMappingURL=aerodatabox-formatter.d.ts.map