mcp-travelcode 1.0.4 → 1.0.6
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.d.ts +14 -6
- package/build/http-server.js +89 -30
- 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/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.d.ts
CHANGED
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
* HTTP entry point for the TravelCode MCP Server.
|
|
4
4
|
*
|
|
5
5
|
* Supports OAuth 2.1 via MCP spec:
|
|
6
|
-
* - Serves Protected Resource Metadata (RFC 9728) at
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* - Serves Protected Resource Metadata (RFC 9728) at the path-aware well-known
|
|
7
|
+
* URL (`/.well-known/oauth-protected-resource/mcp`) AND the legacy
|
|
8
|
+
* non-suffixed path for older clients.
|
|
9
|
+
* - Proxies Authorization Server Metadata (RFC 8414) at
|
|
10
|
+
* `/.well-known/oauth-authorization-server`. travel-code.com's nginx blocks
|
|
11
|
+
* `/.well-known/*` on its own origin, so MCP clients cannot discover AS
|
|
12
|
+
* metadata there directly. We advertise the sidecar itself as the AS in the
|
|
13
|
+
* Protected Resource Metadata document and serve the AS metadata here with
|
|
14
|
+
* the real upstream `authorization_endpoint` / `token_endpoint` /
|
|
15
|
+
* `registration_endpoint` / `revocation_endpoint` values. The browser and
|
|
16
|
+
* client hit those upstream URLs directly — only discovery is proxied.
|
|
17
|
+
* - Returns 401 with WWW-Authenticate on missing Bearer and on unknown session,
|
|
18
|
+
* so clients can restart the OAuth flow after a sidecar restart.
|
|
19
|
+
* - Creates per-session McpServer instances using the user's OAuth token.
|
|
12
20
|
*
|
|
13
21
|
* Stdio transport (src/index.ts) remains unchanged for backward compatibility.
|
|
14
22
|
*/
|
package/build/http-server.js
CHANGED
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
* HTTP entry point for the TravelCode MCP Server.
|
|
4
4
|
*
|
|
5
5
|
* Supports OAuth 2.1 via MCP spec:
|
|
6
|
-
* - Serves Protected Resource Metadata (RFC 9728) at
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* - Serves Protected Resource Metadata (RFC 9728) at the path-aware well-known
|
|
7
|
+
* URL (`/.well-known/oauth-protected-resource/mcp`) AND the legacy
|
|
8
|
+
* non-suffixed path for older clients.
|
|
9
|
+
* - Proxies Authorization Server Metadata (RFC 8414) at
|
|
10
|
+
* `/.well-known/oauth-authorization-server`. travel-code.com's nginx blocks
|
|
11
|
+
* `/.well-known/*` on its own origin, so MCP clients cannot discover AS
|
|
12
|
+
* metadata there directly. We advertise the sidecar itself as the AS in the
|
|
13
|
+
* Protected Resource Metadata document and serve the AS metadata here with
|
|
14
|
+
* the real upstream `authorization_endpoint` / `token_endpoint` /
|
|
15
|
+
* `registration_endpoint` / `revocation_endpoint` values. The browser and
|
|
16
|
+
* client hit those upstream URLs directly — only discovery is proxied.
|
|
17
|
+
* - Returns 401 with WWW-Authenticate on missing Bearer and on unknown session,
|
|
18
|
+
* so clients can restart the OAuth flow after a sidecar restart.
|
|
19
|
+
* - Creates per-session McpServer instances using the user's OAuth token.
|
|
12
20
|
*
|
|
13
21
|
* Stdio transport (src/index.ts) remains unchanged for backward compatibility.
|
|
14
22
|
*/
|
|
@@ -19,11 +27,21 @@ import { createServer } from "./server.js";
|
|
|
19
27
|
// --- Configuration ---
|
|
20
28
|
const PORT = parseInt(process.env.PORT || "3000", 10);
|
|
21
29
|
const API_BASE_URL = (process.env.TRAVELCODE_API_BASE_URL || "https://api.travel-code.com/v1").replace(/\/+$/, "");
|
|
22
|
-
|
|
23
|
-
//
|
|
30
|
+
// Upstream Authorization Server origin — where the real OAuth endpoints live.
|
|
31
|
+
// travel-code.com implements /oauth/authorize, /oauth/token, /oauth/register,
|
|
32
|
+
// /oauth/revoke but does NOT expose RFC 8414 metadata (nginx blocks
|
|
33
|
+
// /.well-known/*), so we proxy AS metadata from this sidecar.
|
|
34
|
+
const UPSTREAM_AS_ORIGIN = (process.env.OAUTH_ISSUER || "https://travel-code.com").replace(/\/+$/, "");
|
|
35
|
+
// Resource URI — the public URL of this MCP server (origin, no path).
|
|
24
36
|
// In production, set to the actual public URL (e.g. https://mcp.travel-code.com).
|
|
25
37
|
// Locally defaults to http://localhost:PORT.
|
|
26
|
-
const RESOURCE_URI = process.env.RESOURCE_URI || `http://localhost:${PORT}
|
|
38
|
+
const RESOURCE_URI = (process.env.RESOURCE_URI || `http://localhost:${PORT}`).replace(/\/+$/, "");
|
|
39
|
+
// MCP endpoint path — advertised as the canonical resource identifier in
|
|
40
|
+
// Protected Resource Metadata (RFC 9728) so audience binding (RFC 8707) works.
|
|
41
|
+
const MCP_PATH = "/mcp";
|
|
42
|
+
const MCP_RESOURCE_IDENTIFIER = `${RESOURCE_URI}${MCP_PATH}`;
|
|
43
|
+
// Path-aware PRM URL per RFC 9728 §3.1.
|
|
44
|
+
const PRM_URL = `${RESOURCE_URI}/.well-known/oauth-protected-resource${MCP_PATH}`;
|
|
27
45
|
const POLL_INTERVAL_MS = parseInt(process.env.TRAVELCODE_POLL_INTERVAL_MS || "2000", 10);
|
|
28
46
|
const POLL_TIMEOUT_MS = parseInt(process.env.TRAVELCODE_POLL_TIMEOUT_MS || "90000", 10);
|
|
29
47
|
const SCOPES_SUPPORTED = [
|
|
@@ -59,18 +77,59 @@ app.use((_req, res, next) => {
|
|
|
59
77
|
res.setHeader("Access-Control-Expose-Headers", "Mcp-Session-Id");
|
|
60
78
|
next();
|
|
61
79
|
});
|
|
62
|
-
app.options(
|
|
80
|
+
app.options(/.*/, (_req, res) => {
|
|
63
81
|
res.sendStatus(204);
|
|
64
82
|
});
|
|
65
83
|
// --- Protected Resource Metadata (RFC 9728) ---
|
|
84
|
+
//
|
|
85
|
+
// `resource` MUST match the URL the client is actually using (the MCP endpoint)
|
|
86
|
+
// so that audience binding / RFC 8707 resource indicators line up.
|
|
87
|
+
//
|
|
88
|
+
// `authorization_servers` points to the sidecar itself rather than the upstream
|
|
89
|
+
// travel-code.com origin, because the upstream blocks /.well-known/* at the
|
|
90
|
+
// edge. The client will discover AS metadata from us at
|
|
91
|
+
// `/.well-known/oauth-authorization-server` (served below), which in turn
|
|
92
|
+
// advertises the real upstream authorize/token/register/revoke endpoints.
|
|
93
|
+
const protectedResourceMetadata = {
|
|
94
|
+
resource: MCP_RESOURCE_IDENTIFIER,
|
|
95
|
+
authorization_servers: [RESOURCE_URI],
|
|
96
|
+
scopes_supported: SCOPES_SUPPORTED,
|
|
97
|
+
bearer_methods_supported: ["header"],
|
|
98
|
+
resource_name: "TravelCode MCP Server",
|
|
99
|
+
};
|
|
100
|
+
app.get("/.well-known/oauth-protected-resource/mcp", (_req, res) => {
|
|
101
|
+
res.json(protectedResourceMetadata);
|
|
102
|
+
});
|
|
103
|
+
// Legacy non-path-suffixed PRM for older clients that don't do
|
|
104
|
+
// path-aware discovery per RFC 9728 §3.1.
|
|
66
105
|
app.get("/.well-known/oauth-protected-resource", (_req, res) => {
|
|
67
|
-
res.json(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
106
|
+
res.json(protectedResourceMetadata);
|
|
107
|
+
});
|
|
108
|
+
// --- Authorization Server Metadata (RFC 8414) — proxied ---
|
|
109
|
+
//
|
|
110
|
+
// travel-code.com's nginx blocks /.well-known/oauth-authorization-server at
|
|
111
|
+
// the edge, so we host the document ourselves. `issuer` MUST match the URL at
|
|
112
|
+
// which this metadata was fetched (RFC 8414 §3.3) — that's RESOURCE_URI.
|
|
113
|
+
// The endpoints point to the real upstream OAuth server; the browser and
|
|
114
|
+
// token-endpoint calls go there directly.
|
|
115
|
+
const authorizationServerMetadata = {
|
|
116
|
+
issuer: RESOURCE_URI,
|
|
117
|
+
authorization_endpoint: `${UPSTREAM_AS_ORIGIN}/oauth/authorize`,
|
|
118
|
+
token_endpoint: `${UPSTREAM_AS_ORIGIN}/oauth/token`,
|
|
119
|
+
registration_endpoint: `${UPSTREAM_AS_ORIGIN}/oauth/register`,
|
|
120
|
+
revocation_endpoint: `${UPSTREAM_AS_ORIGIN}/oauth/revoke`,
|
|
121
|
+
scopes_supported: SCOPES_SUPPORTED,
|
|
122
|
+
response_types_supported: ["code"],
|
|
123
|
+
grant_types_supported: ["authorization_code", "refresh_token"],
|
|
124
|
+
token_endpoint_auth_methods_supported: ["none"],
|
|
125
|
+
code_challenge_methods_supported: ["S256"],
|
|
126
|
+
};
|
|
127
|
+
app.get("/.well-known/oauth-authorization-server", (_req, res) => {
|
|
128
|
+
res.json(authorizationServerMetadata);
|
|
129
|
+
});
|
|
130
|
+
// Some MCP clients also probe a path-suffixed variant.
|
|
131
|
+
app.get("/.well-known/oauth-authorization-server/mcp", (_req, res) => {
|
|
132
|
+
res.json(authorizationServerMetadata);
|
|
74
133
|
});
|
|
75
134
|
// --- Health check ---
|
|
76
135
|
app.get("/health", (_req, res) => {
|
|
@@ -81,11 +140,10 @@ app.get("/health", (_req, res) => {
|
|
|
81
140
|
});
|
|
82
141
|
});
|
|
83
142
|
// --- Helper: send 401 ---
|
|
84
|
-
function send401(res) {
|
|
85
|
-
const metadataUrl = `${RESOURCE_URI}/.well-known/oauth-protected-resource`;
|
|
143
|
+
function send401(res, description = "Bearer token required") {
|
|
86
144
|
res.status(401)
|
|
87
|
-
.set("WWW-Authenticate", `Bearer resource_metadata="${
|
|
88
|
-
.json({ error: "unauthorized", error_description:
|
|
145
|
+
.set("WWW-Authenticate", `Bearer resource_metadata="${PRM_URL}"`)
|
|
146
|
+
.json({ error: "unauthorized", error_description: description });
|
|
89
147
|
}
|
|
90
148
|
// --- MCP endpoint ---
|
|
91
149
|
app.all("/mcp", async (req, res) => {
|
|
@@ -105,10 +163,10 @@ app.all("/mcp", async (req, res) => {
|
|
|
105
163
|
if (sessionId) {
|
|
106
164
|
const session = sessions.get(sessionId);
|
|
107
165
|
if (!session) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
166
|
+
// Return 401 (not 404) so the client restarts the OAuth flow after a
|
|
167
|
+
// sidecar restart or TTL expiry, instead of giving up with a dead
|
|
168
|
+
// session ID.
|
|
169
|
+
send401(res, "Session not found or expired. Please re-authenticate.");
|
|
112
170
|
return;
|
|
113
171
|
}
|
|
114
172
|
await session.transport.handleRequest(req, res, req.body);
|
|
@@ -155,10 +213,11 @@ app.all("/mcp", async (req, res) => {
|
|
|
155
213
|
// --- Start ---
|
|
156
214
|
app.listen(PORT, () => {
|
|
157
215
|
console.log(`TravelCode MCP Server (HTTP) listening on port ${PORT}`);
|
|
158
|
-
console.log(`MCP endpoint:
|
|
159
|
-
console.log(`Resource
|
|
160
|
-
console.log(`
|
|
161
|
-
console.log(`
|
|
162
|
-
console.log(`
|
|
216
|
+
console.log(`MCP endpoint: ${MCP_RESOURCE_IDENTIFIER}`);
|
|
217
|
+
console.log(`Protected Resource: ${PRM_URL}`);
|
|
218
|
+
console.log(`AS metadata (proxy): ${RESOURCE_URI}/.well-known/oauth-authorization-server`);
|
|
219
|
+
console.log(`Upstream OAuth: ${UPSTREAM_AS_ORIGIN}/oauth/{authorize,token,register,revoke}`);
|
|
220
|
+
console.log(`API base URL: ${API_BASE_URL}`);
|
|
221
|
+
console.log(`Scopes: ${SCOPES_SUPPORTED.join(", ")}`);
|
|
163
222
|
});
|
|
164
223
|
//# sourceMappingURL=http-server.js.map
|
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
|
});
|
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
|