mcp-travelcode 1.0.3 → 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.
- package/build/client/api-client.d.ts +1 -1
- package/build/client/api-client.js +7 -8
- package/build/client/types.d.ts +23 -23
- package/build/formatters/flight-stats-formatter.d.ts +6 -0
- package/build/formatters/{aerodatabox-formatter.js → flight-stats-formatter.js} +1 -1
- package/build/http-server.js +1 -1
- package/build/index.js +0 -0
- package/build/server.js +1 -1
- package/build/tools/get-airport-delay-stats.js +2 -2
- package/build/tools/get-airport-flights.js +2 -2
- package/build/tools/get-flight-delay-stats.js +2 -2
- package/build/tools/get-flight-status.js +2 -2
- package/build/tools/get-hotel-offers.js +2 -2
- package/package.json +1 -1
- package/build/formatters/aerodatabox-formatter.d.ts +0 -6
|
@@ -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
|
-
|
|
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
|
|
77
|
+
async getFlightStats(subPath, params) {
|
|
78
78
|
await this.ensureValidToken();
|
|
79
|
-
// Build the
|
|
80
|
-
const pathUrl = new URL(`https://placeholder${
|
|
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
|
|
89
|
-
//
|
|
90
|
-
const
|
|
91
|
-
|
|
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(),
|
package/build/client/types.d.ts
CHANGED
|
@@ -128,11 +128,11 @@ export interface FlightSearchResultsResponse {
|
|
|
128
128
|
airports?: Record<string, DictionaryAirport>;
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
-
export interface
|
|
131
|
+
export interface FlightTime {
|
|
132
132
|
utc?: string;
|
|
133
133
|
local?: string;
|
|
134
134
|
}
|
|
135
|
-
export interface
|
|
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?:
|
|
149
|
-
revisedTime?:
|
|
150
|
-
predictedTime?:
|
|
151
|
-
actualTime?:
|
|
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
|
|
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
|
|
170
|
+
export interface FlightStatus {
|
|
171
171
|
type?: string;
|
|
172
172
|
status?: string;
|
|
173
|
-
departure:
|
|
174
|
-
arrival:
|
|
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?:
|
|
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
|
|
198
|
-
export interface
|
|
199
|
-
departure:
|
|
200
|
-
arrival:
|
|
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
|
|
216
|
-
departures?:
|
|
217
|
-
arrivals?:
|
|
215
|
+
export interface AirportBoardResponse {
|
|
216
|
+
departures?: BoardFlight[];
|
|
217
|
+
arrivals?: BoardFlight[];
|
|
218
218
|
}
|
|
219
|
-
export interface
|
|
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
|
|
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
|
|
241
|
+
export interface AirportDelayStats {
|
|
242
242
|
airport?: {
|
|
243
243
|
iata?: string;
|
|
244
244
|
name?: string;
|
|
245
245
|
};
|
|
246
246
|
date?: string;
|
|
247
|
-
departures?:
|
|
248
|
-
arrivals?:
|
|
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
|
package/build/http-server.js
CHANGED
|
@@ -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(
|
|
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
|
|
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/
|
|
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.
|
|
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/
|
|
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.
|
|
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/
|
|
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.
|
|
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/
|
|
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.
|
|
23
|
+
const flights = await client.getFlightStats(`/flights/number/${encodeURIComponent(normalized)}/${date}`, {
|
|
24
24
|
withAircraftImage: with_aircraft_image,
|
|
25
25
|
withLocation: with_location,
|
|
26
26
|
});
|
|
@@ -9,7 +9,7 @@ const guestSchema = z.object({
|
|
|
9
9
|
.describe("Array of child ages (0-17), required if children > 0"),
|
|
10
10
|
});
|
|
11
11
|
export const getHotelOffersSchema = {
|
|
12
|
-
id: z.number().int().describe("Hotel
|
|
12
|
+
id: z.number().int().describe("Hotel ID (from search_hotels results)"),
|
|
13
13
|
checkin: z.string().describe("Check-in date (YYYY-MM-DD)"),
|
|
14
14
|
checkout: z.string().describe("Check-out date (YYYY-MM-DD)"),
|
|
15
15
|
country_code: z.string().describe("Guest nationality ISO code (e.g. BY, RU, US)"),
|
|
@@ -21,7 +21,7 @@ export const getHotelOffersSchema = {
|
|
|
21
21
|
.describe("Location ID from prior search — enables cache reuse for faster results"),
|
|
22
22
|
};
|
|
23
23
|
export function registerGetHotelOffers(server, client) {
|
|
24
|
-
server.tool("get_hotel_offers", "Get all available rooms and rates for a specific hotel from all suppliers. Returns room types, prices, meal plans, and cancellation policies. The hotel
|
|
24
|
+
server.tool("get_hotel_offers", "Get all available rooms and rates for a specific hotel from all suppliers. Returns room types, prices, meal plans, and cancellation policies. The hotel ID comes from search_hotels results — do not explain this to the user, just chain the calls silently.", getHotelOffersSchema, async ({ id, checkin, checkout, country_code, guests, location }) => {
|
|
25
25
|
try {
|
|
26
26
|
const body = {
|
|
27
27
|
id,
|
package/package.json
CHANGED
|
@@ -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
|