@mcp-consultant-tools/rest-api 27.0.0 → 28.0.0-beta.13
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/cli/commands/index.d.ts +8 -0
- package/build/cli/commands/index.d.ts.map +1 -0
- package/build/cli/commands/index.js +9 -0
- package/build/cli/commands/index.js.map +1 -0
- package/build/cli/commands/rest-commands.d.ts +7 -0
- package/build/cli/commands/rest-commands.d.ts.map +1 -0
- package/build/cli/commands/rest-commands.js +212 -0
- package/build/cli/commands/rest-commands.js.map +1 -0
- package/build/cli/output.d.ts +11 -0
- package/build/cli/output.d.ts.map +1 -0
- package/build/cli/output.js +10 -0
- package/build/cli/output.js.map +1 -0
- package/build/cli.d.ts +9 -0
- package/build/cli.d.ts.map +1 -0
- package/build/cli.js +27 -0
- package/build/cli.js.map +1 -0
- package/build/context-factory.d.ts +10 -0
- package/build/context-factory.d.ts.map +1 -0
- package/build/context-factory.js +108 -0
- package/build/context-factory.js.map +1 -0
- package/build/index.d.ts +6 -18
- package/build/index.d.ts.map +1 -1
- package/build/index.js +21 -376
- package/build/index.js.map +1 -1
- package/build/models/api-types.d.ts +133 -0
- package/build/models/api-types.d.ts.map +1 -0
- package/build/models/api-types.js +5 -0
- package/build/models/api-types.js.map +1 -0
- package/build/models/index.d.ts +5 -0
- package/build/models/index.d.ts.map +1 -0
- package/build/models/index.js +2 -0
- package/build/models/index.js.map +1 -0
- package/build/prompts/index.d.ts +2 -0
- package/build/prompts/index.d.ts.map +1 -0
- package/build/prompts/index.js +24 -0
- package/build/prompts/index.js.map +1 -0
- package/build/prompts/templates.d.ts +6 -0
- package/build/prompts/templates.d.ts.map +1 -0
- package/build/prompts/templates.js +169 -0
- package/build/prompts/templates.js.map +1 -0
- package/build/services/index.d.ts +5 -0
- package/build/services/index.d.ts.map +1 -0
- package/build/services/index.js +5 -0
- package/build/services/index.js.map +1 -0
- package/build/services/openapi-parser.d.ts +69 -0
- package/build/services/openapi-parser.d.ts.map +1 -0
- package/build/services/openapi-parser.js +151 -0
- package/build/services/openapi-parser.js.map +1 -0
- package/build/services/rest-api-service.d.ts +90 -0
- package/build/services/rest-api-service.d.ts.map +1 -0
- package/build/services/rest-api-service.js +403 -0
- package/build/services/rest-api-service.js.map +1 -0
- package/build/tool-examples.d.ts +38 -0
- package/build/tool-examples.d.ts.map +1 -0
- package/build/tool-examples.js +69 -0
- package/build/tool-examples.js.map +1 -0
- package/build/tools/index.d.ts +7 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +6 -0
- package/build/tools/index.js.map +1 -0
- package/build/tools/rest-tools.d.ts +3 -0
- package/build/tools/rest-tools.d.ts.map +1 -0
- package/build/tools/rest-tools.js +166 -0
- package/build/tools/rest-tools.js.map +1 -0
- package/build/types.d.ts +9 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST API Service
|
|
3
|
+
*
|
|
4
|
+
* Provides HTTP request functionality with multiple authentication methods:
|
|
5
|
+
* - Static Bearer Token
|
|
6
|
+
* - Basic Authentication
|
|
7
|
+
* - API Key (custom header)
|
|
8
|
+
* - OAuth2 Client Credentials Flow (JWT generation)
|
|
9
|
+
*/
|
|
10
|
+
import https from "https";
|
|
11
|
+
import { parseOpenApiSpec } from './openapi-parser.js';
|
|
12
|
+
export class RestApiService {
|
|
13
|
+
config;
|
|
14
|
+
cachedToken = null;
|
|
15
|
+
httpsAgent;
|
|
16
|
+
cachedOpenApi = null;
|
|
17
|
+
openApiFetchPromise = null;
|
|
18
|
+
/** OpenAPI cache TTL in milliseconds (default: 5 minutes) */
|
|
19
|
+
static OPENAPI_CACHE_TTL = 5 * 60 * 1000;
|
|
20
|
+
constructor(config) {
|
|
21
|
+
this.config = {
|
|
22
|
+
responseSizeLimit: 10000,
|
|
23
|
+
enableSslVerify: true,
|
|
24
|
+
timeout: 30000,
|
|
25
|
+
...config,
|
|
26
|
+
};
|
|
27
|
+
// Normalize base URL (remove trailing slashes)
|
|
28
|
+
this.config.baseUrl = this.config.baseUrl.replace(/\/+$/, "");
|
|
29
|
+
// Create HTTPS agent if SSL verification is disabled
|
|
30
|
+
if (!this.config.enableSslVerify) {
|
|
31
|
+
this.httpsAgent = new https.Agent({ rejectUnauthorized: false });
|
|
32
|
+
}
|
|
33
|
+
// Validate mutually exclusive auth methods
|
|
34
|
+
const authMethods = [
|
|
35
|
+
this.config.bearerToken ? "bearer" : null,
|
|
36
|
+
this.config.basicAuth ? "basic" : null,
|
|
37
|
+
this.config.oauth2 ? "oauth2" : null,
|
|
38
|
+
this.config.apiKey ? "apikey" : null,
|
|
39
|
+
].filter(Boolean);
|
|
40
|
+
if (authMethods.length > 1) {
|
|
41
|
+
console.error(`Warning: Multiple auth methods configured (${authMethods.join(", ")}). Only one should be used.`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the current authentication method name
|
|
46
|
+
*/
|
|
47
|
+
getAuthMethod() {
|
|
48
|
+
if (this.config.oauth2)
|
|
49
|
+
return "oauth2";
|
|
50
|
+
if (this.config.bearerToken)
|
|
51
|
+
return "bearer";
|
|
52
|
+
if (this.config.basicAuth)
|
|
53
|
+
return "basic";
|
|
54
|
+
if (this.config.apiKey)
|
|
55
|
+
return "apikey";
|
|
56
|
+
return "none";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get OAuth2 access token using client credentials flow
|
|
60
|
+
* Caches token and refreshes when expired
|
|
61
|
+
*/
|
|
62
|
+
async getOAuth2Token() {
|
|
63
|
+
const oauth2 = this.config.oauth2;
|
|
64
|
+
if (!oauth2) {
|
|
65
|
+
throw new Error("OAuth2 configuration not provided");
|
|
66
|
+
}
|
|
67
|
+
// Check if we have a valid cached token (with 5 minute buffer)
|
|
68
|
+
const now = Date.now();
|
|
69
|
+
if (this.cachedToken && this.cachedToken.expiresAt > now + 5 * 60 * 1000) {
|
|
70
|
+
return this.cachedToken.accessToken;
|
|
71
|
+
}
|
|
72
|
+
console.error("Acquiring new OAuth2 token...");
|
|
73
|
+
const params = new URLSearchParams();
|
|
74
|
+
params.append("grant_type", oauth2.grantType || "client_credentials");
|
|
75
|
+
params.append("client_id", oauth2.clientId);
|
|
76
|
+
params.append("client_secret", oauth2.clientSecret);
|
|
77
|
+
params.append("scope", oauth2.scope);
|
|
78
|
+
if (oauth2.additionalParams) {
|
|
79
|
+
for (const [key, value] of Object.entries(oauth2.additionalParams)) {
|
|
80
|
+
params.append(key, value);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const response = await fetch(oauth2.tokenUrl, {
|
|
84
|
+
method: "POST",
|
|
85
|
+
headers: {
|
|
86
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
87
|
+
},
|
|
88
|
+
body: params.toString(),
|
|
89
|
+
});
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
const errorText = await response.text();
|
|
92
|
+
throw new Error(`OAuth2 token request failed: ${response.status} ${response.statusText} - ${errorText}`);
|
|
93
|
+
}
|
|
94
|
+
const tokenResponse = await response.json();
|
|
95
|
+
if (!tokenResponse.access_token) {
|
|
96
|
+
throw new Error("OAuth2 response missing access_token");
|
|
97
|
+
}
|
|
98
|
+
const expiresIn = tokenResponse.expires_in || 3600;
|
|
99
|
+
this.cachedToken = {
|
|
100
|
+
accessToken: tokenResponse.access_token,
|
|
101
|
+
expiresAt: now + expiresIn * 1000,
|
|
102
|
+
};
|
|
103
|
+
console.error(`OAuth2 token acquired, expires in ${Math.round(expiresIn / 60)} minutes`);
|
|
104
|
+
return this.cachedToken.accessToken;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the Authorization header value based on configured auth method
|
|
108
|
+
*/
|
|
109
|
+
async getAuthHeader() {
|
|
110
|
+
if (this.config.oauth2) {
|
|
111
|
+
const token = await this.getOAuth2Token();
|
|
112
|
+
return { name: "Authorization", value: `Bearer ${token}` };
|
|
113
|
+
}
|
|
114
|
+
if (this.config.bearerToken) {
|
|
115
|
+
return { name: "Authorization", value: `Bearer ${this.config.bearerToken}` };
|
|
116
|
+
}
|
|
117
|
+
if (this.config.basicAuth) {
|
|
118
|
+
const { username, password } = this.config.basicAuth;
|
|
119
|
+
const base64Credentials = Buffer.from(`${username}:${password}`).toString("base64");
|
|
120
|
+
return { name: "Authorization", value: `Basic ${base64Credentials}` };
|
|
121
|
+
}
|
|
122
|
+
if (this.config.apiKey) {
|
|
123
|
+
return { name: this.config.apiKey.headerName, value: this.config.apiKey.value };
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Sanitize headers for display (redact sensitive values)
|
|
129
|
+
*/
|
|
130
|
+
sanitizeHeaders(headers, isFromRequest = false) {
|
|
131
|
+
const sanitized = {};
|
|
132
|
+
const safeHeaders = new Set([
|
|
133
|
+
"accept",
|
|
134
|
+
"accept-language",
|
|
135
|
+
"content-type",
|
|
136
|
+
"user-agent",
|
|
137
|
+
"cache-control",
|
|
138
|
+
"if-match",
|
|
139
|
+
"if-none-match",
|
|
140
|
+
"if-modified-since",
|
|
141
|
+
"if-unmodified-since",
|
|
142
|
+
]);
|
|
143
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
144
|
+
const lowerKey = key.toLowerCase();
|
|
145
|
+
if (isFromRequest) {
|
|
146
|
+
sanitized[key] = value;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (lowerKey === "authorization") {
|
|
150
|
+
sanitized[key] = "[REDACTED]";
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (this.config.apiKey &&
|
|
154
|
+
lowerKey === this.config.apiKey.headerName.toLowerCase()) {
|
|
155
|
+
sanitized[key] = "[REDACTED]";
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (safeHeaders.has(lowerKey)) {
|
|
159
|
+
sanitized[key] = value;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
sanitized[key] = "[REDACTED]";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return sanitized;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Execute an HTTP request
|
|
169
|
+
*/
|
|
170
|
+
async request(options) {
|
|
171
|
+
const { method, endpoint, body, headers: requestHeaders, host } = options;
|
|
172
|
+
const normalizedEndpoint = `/${endpoint.replace(/^\/+|\/+$/g, "")}`;
|
|
173
|
+
const baseUrl = host ? host.replace(/\/+$/, "") : this.config.baseUrl;
|
|
174
|
+
const fullUrl = `${baseUrl}${normalizedEndpoint}`;
|
|
175
|
+
const headers = {
|
|
176
|
+
...this.config.customHeaders,
|
|
177
|
+
...requestHeaders,
|
|
178
|
+
};
|
|
179
|
+
if (body && !headers["Content-Type"] && !headers["content-type"]) {
|
|
180
|
+
headers["Content-Type"] = "application/json";
|
|
181
|
+
}
|
|
182
|
+
const authHeader = await this.getAuthHeader();
|
|
183
|
+
if (authHeader) {
|
|
184
|
+
headers[authHeader.name] = authHeader.value;
|
|
185
|
+
}
|
|
186
|
+
const fetchOptions = {
|
|
187
|
+
method,
|
|
188
|
+
headers,
|
|
189
|
+
};
|
|
190
|
+
if (["POST", "PUT", "PATCH"].includes(method) && body) {
|
|
191
|
+
fetchOptions.body =
|
|
192
|
+
typeof body === "string" ? body : JSON.stringify(body);
|
|
193
|
+
}
|
|
194
|
+
const controller = new AbortController();
|
|
195
|
+
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout || 30000);
|
|
196
|
+
fetchOptions.signal = controller.signal;
|
|
197
|
+
const startTime = Date.now();
|
|
198
|
+
try {
|
|
199
|
+
const response = await fetch(fullUrl, fetchOptions);
|
|
200
|
+
clearTimeout(timeoutId);
|
|
201
|
+
const endTime = Date.now();
|
|
202
|
+
const responseText = await response.text();
|
|
203
|
+
let responseBody;
|
|
204
|
+
try {
|
|
205
|
+
responseBody = JSON.parse(responseText);
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
responseBody = responseText;
|
|
209
|
+
}
|
|
210
|
+
const responseHeaders = {};
|
|
211
|
+
response.headers.forEach((value, key) => {
|
|
212
|
+
responseHeaders[key] = value;
|
|
213
|
+
});
|
|
214
|
+
const bodySize = Buffer.from(responseText).length;
|
|
215
|
+
const sizeLimit = this.config.responseSizeLimit || 10000;
|
|
216
|
+
const validation = {
|
|
217
|
+
isError: response.status >= 400,
|
|
218
|
+
messages: response.status >= 400
|
|
219
|
+
? [`Request failed with status ${response.status}`]
|
|
220
|
+
: ["Request completed successfully"],
|
|
221
|
+
};
|
|
222
|
+
if (bodySize > sizeLimit) {
|
|
223
|
+
responseBody =
|
|
224
|
+
typeof responseBody === "string"
|
|
225
|
+
? responseBody.slice(0, sizeLimit)
|
|
226
|
+
: JSON.stringify(responseBody).slice(0, sizeLimit);
|
|
227
|
+
validation.messages.push(`Response truncated: ${sizeLimit} of ${bodySize} bytes returned due to size limit`);
|
|
228
|
+
validation.truncated = {
|
|
229
|
+
originalSize: bodySize,
|
|
230
|
+
returnedSize: sizeLimit,
|
|
231
|
+
truncationPoint: sizeLimit,
|
|
232
|
+
sizeLimit,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
request: {
|
|
237
|
+
url: fullUrl,
|
|
238
|
+
method,
|
|
239
|
+
headers: {
|
|
240
|
+
...this.sanitizeHeaders(headers, false),
|
|
241
|
+
...this.sanitizeHeaders(requestHeaders || {}, true),
|
|
242
|
+
},
|
|
243
|
+
body,
|
|
244
|
+
authMethod: this.getAuthMethod(),
|
|
245
|
+
},
|
|
246
|
+
response: {
|
|
247
|
+
statusCode: response.status,
|
|
248
|
+
statusText: response.statusText,
|
|
249
|
+
timing: `${endTime - startTime}ms`,
|
|
250
|
+
headers: this.sanitizeHeaders(responseHeaders, false),
|
|
251
|
+
body: responseBody,
|
|
252
|
+
},
|
|
253
|
+
validation,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
clearTimeout(timeoutId);
|
|
258
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
259
|
+
throw new Error(`Request timeout after ${this.config.timeout}ms`);
|
|
260
|
+
}
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Force refresh the OAuth2 token (clears cache)
|
|
266
|
+
*/
|
|
267
|
+
clearTokenCache() {
|
|
268
|
+
this.cachedToken = null;
|
|
269
|
+
console.error("OAuth2 token cache cleared");
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Get configuration summary (safe to display)
|
|
273
|
+
*/
|
|
274
|
+
getConfigSummary() {
|
|
275
|
+
return {
|
|
276
|
+
baseUrl: this.config.baseUrl,
|
|
277
|
+
authMethod: this.getAuthMethod(),
|
|
278
|
+
sslVerification: this.config.enableSslVerify !== false,
|
|
279
|
+
responseSizeLimit: this.config.responseSizeLimit || 10000,
|
|
280
|
+
customHeaderCount: Object.keys(this.config.customHeaders || {}).length,
|
|
281
|
+
...(this.config.oauth2 && { oauth2TokenUrl: this.config.oauth2.tokenUrl }),
|
|
282
|
+
...(this.config.openApiUrl && { openApiUrl: this.config.openApiUrl }),
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Check if OpenAPI URL is configured
|
|
287
|
+
*/
|
|
288
|
+
hasOpenApiConfig() {
|
|
289
|
+
return !!this.config.openApiUrl;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Fetch and parse OpenAPI spec from configured URL
|
|
293
|
+
* Results are cached for OPENAPI_CACHE_TTL
|
|
294
|
+
*/
|
|
295
|
+
async fetchOpenApiSpec() {
|
|
296
|
+
if (!this.config.openApiUrl) {
|
|
297
|
+
throw new Error("OpenAPI URL not configured");
|
|
298
|
+
}
|
|
299
|
+
const now = Date.now();
|
|
300
|
+
if (this.cachedOpenApi &&
|
|
301
|
+
now - this.cachedOpenApi.fetchedAt < RestApiService.OPENAPI_CACHE_TTL) {
|
|
302
|
+
return this.cachedOpenApi;
|
|
303
|
+
}
|
|
304
|
+
if (this.openApiFetchPromise) {
|
|
305
|
+
return this.openApiFetchPromise;
|
|
306
|
+
}
|
|
307
|
+
this.openApiFetchPromise = this.doFetchOpenApiSpec();
|
|
308
|
+
try {
|
|
309
|
+
const result = await this.openApiFetchPromise;
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
313
|
+
this.openApiFetchPromise = null;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Actually fetch and parse the OpenAPI spec
|
|
318
|
+
*/
|
|
319
|
+
async doFetchOpenApiSpec() {
|
|
320
|
+
const url = this.config.openApiUrl;
|
|
321
|
+
console.error(`Fetching OpenAPI spec from ${url}...`);
|
|
322
|
+
const fetchOptions = {};
|
|
323
|
+
const controller = new AbortController();
|
|
324
|
+
const timeoutId = setTimeout(() => controller.abort(), 30000);
|
|
325
|
+
fetchOptions.signal = controller.signal;
|
|
326
|
+
try {
|
|
327
|
+
const response = await fetch(url, fetchOptions);
|
|
328
|
+
clearTimeout(timeoutId);
|
|
329
|
+
if (!response.ok) {
|
|
330
|
+
throw new Error(`Failed to fetch OpenAPI spec: ${response.status} ${response.statusText}`);
|
|
331
|
+
}
|
|
332
|
+
const spec = (await response.json());
|
|
333
|
+
const parsed = parseOpenApiSpec(spec);
|
|
334
|
+
this.cachedOpenApi = {
|
|
335
|
+
...parsed,
|
|
336
|
+
fetchedAt: Date.now(),
|
|
337
|
+
source: `OpenAPI spec from ${url}`,
|
|
338
|
+
};
|
|
339
|
+
console.error(`OpenAPI spec loaded: ${parsed.endpoints.length} endpoints, ${Object.keys(parsed.schemas).length} schemas`);
|
|
340
|
+
return this.cachedOpenApi;
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
clearTimeout(timeoutId);
|
|
344
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
345
|
+
throw new Error("OpenAPI fetch timeout after 30 seconds");
|
|
346
|
+
}
|
|
347
|
+
throw error;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Clear OpenAPI cache (forces re-fetch on next call)
|
|
352
|
+
*/
|
|
353
|
+
clearOpenApiCache() {
|
|
354
|
+
this.cachedOpenApi = null;
|
|
355
|
+
console.error("OpenAPI cache cleared");
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* List all available API endpoints from OpenAPI spec
|
|
359
|
+
* @param filter Optional filter to match endpoint paths (case-insensitive contains match)
|
|
360
|
+
*/
|
|
361
|
+
async listEndpointsAsync(filter) {
|
|
362
|
+
if (!this.config.openApiUrl) {
|
|
363
|
+
return {
|
|
364
|
+
baseUrl: this.config.baseUrl,
|
|
365
|
+
endpointCount: 0,
|
|
366
|
+
endpoints: [],
|
|
367
|
+
source: "No OpenAPI URL configured. Set REST_OPENAPI_URL environment variable.",
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
const openApiData = await this.fetchOpenApiSpec();
|
|
371
|
+
const endpoints = filter
|
|
372
|
+
? openApiData.endpoints.filter((ep) => ep.path.toLowerCase().includes(filter.toLowerCase()) ||
|
|
373
|
+
ep.entityName?.toLowerCase().includes(filter.toLowerCase()) ||
|
|
374
|
+
ep.description?.toLowerCase().includes(filter.toLowerCase()))
|
|
375
|
+
: openApiData.endpoints;
|
|
376
|
+
return {
|
|
377
|
+
baseUrl: this.config.baseUrl,
|
|
378
|
+
endpointCount: endpoints.length,
|
|
379
|
+
endpoints,
|
|
380
|
+
source: openApiData.source,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Get schema for a specific entity from OpenAPI spec
|
|
385
|
+
* @param entity Entity name (singular or plural)
|
|
386
|
+
*/
|
|
387
|
+
async getSchemaAsync(entity) {
|
|
388
|
+
if (!this.config.openApiUrl) {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
const openApiData = await this.fetchOpenApiSpec();
|
|
392
|
+
const normalizedEntity = entity.toLowerCase();
|
|
393
|
+
for (const [key, schema] of Object.entries(openApiData.schemas)) {
|
|
394
|
+
if (key.toLowerCase() === normalizedEntity ||
|
|
395
|
+
schema.entityName.toLowerCase() === normalizedEntity ||
|
|
396
|
+
schema.pluralName.toLowerCase() === normalizedEntity) {
|
|
397
|
+
return schema;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
//# sourceMappingURL=rest-api-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest-api-service.js","sourceRoot":"","sources":["../../src/services/rest-api-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAOvD,MAAM,OAAO,cAAc;IACjB,MAAM,CAAgB;IACtB,WAAW,GAAuB,IAAI,CAAC;IACvC,UAAU,CAA0B;IACpC,aAAa,GAA6B,IAAI,CAAC;IAC/C,mBAAmB,GAAsC,IAAI,CAAC;IAEtE,6DAA6D;IACrD,MAAM,CAAU,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IAE1D,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG;YACZ,iBAAiB,EAAE,KAAK;YACxB,eAAe,EAAE,IAAI;YACrB,OAAO,EAAE,KAAK;YACd,GAAG,MAAM;SACV,CAAC;QAEF,+CAA+C;QAC/C,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAE9D,qDAAqD;QACrD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;Y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O,CAAC,EAAE,CAAC;YAChE,IACE,GAAG,CAAC,WAAW,EAAE,KAAK,gBAAgB;gBACtC,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,gBAAgB;gBACpD,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,gBAAgB,EACpD,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Examples for REST API Tools
|
|
3
|
+
* Provides examples to improve LLM accuracy when using these tools
|
|
4
|
+
*/
|
|
5
|
+
export { descWithExamples } from '@mcp-consultant-tools/core';
|
|
6
|
+
export declare const ENDPOINT_EXAMPLES: {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[];
|
|
10
|
+
export declare const HEADER_EXAMPLES: {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[];
|
|
14
|
+
export declare const METHOD_EXAMPLES: {
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}[];
|
|
18
|
+
export declare const AUTH_TYPE_EXAMPLES: {
|
|
19
|
+
label: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
22
|
+
export declare const QUERY_PARAM_EXAMPLES: {
|
|
23
|
+
label: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}[];
|
|
26
|
+
export declare const HOST_OVERRIDE_EXAMPLES: {
|
|
27
|
+
label: string;
|
|
28
|
+
value: string;
|
|
29
|
+
}[];
|
|
30
|
+
export declare const ENTITY_EXAMPLES: {
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
}[];
|
|
34
|
+
export declare const ENDPOINT_FILTER_EXAMPLES: {
|
|
35
|
+
label: string;
|
|
36
|
+
value: string;
|
|
37
|
+
}[];
|
|
38
|
+
//# sourceMappingURL=tool-examples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-examples.d.ts","sourceRoot":"","sources":["../src/tool-examples.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAM9D,eAAO,MAAM,iBAAiB;;;GAI7B,CAAC;AAMF,eAAO,MAAM,eAAe;;;GAG3B,CAAC;AAMF,eAAO,MAAM,eAAe;;;GAM3B,CAAC;AAMF,eAAO,MAAM,kBAAkB;;;GAI9B,CAAC;AAMF,eAAO,MAAM,oBAAoB;;;GAGhC,CAAC;AAMF,eAAO,MAAM,sBAAsB;;;GAGlC,CAAC;AAMF,eAAO,MAAM,eAAe;;;GAI3B,CAAC;AAMF,eAAO,MAAM,wBAAwB;;;GAIpC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Examples for REST API Tools
|
|
3
|
+
* Provides examples to improve LLM accuracy when using these tools
|
|
4
|
+
*/
|
|
5
|
+
export { descWithExamples } from '@mcp-consultant-tools/core';
|
|
6
|
+
// ========================================
|
|
7
|
+
// Endpoint Examples
|
|
8
|
+
// ========================================
|
|
9
|
+
export const ENDPOINT_EXAMPLES = [
|
|
10
|
+
{ label: "List users", value: "/api/v1/users" },
|
|
11
|
+
{ label: "Get specific resource", value: "/api/v1/orders/12345" },
|
|
12
|
+
{ label: "Nested resource", value: "/api/v1/users/42/addresses" },
|
|
13
|
+
];
|
|
14
|
+
// ========================================
|
|
15
|
+
// Header Examples
|
|
16
|
+
// ========================================
|
|
17
|
+
export const HEADER_EXAMPLES = [
|
|
18
|
+
{ label: "JSON content type", value: '{"Content-Type":"application/json","Accept":"application/json"}' },
|
|
19
|
+
{ label: "Custom API version", value: '{"api-version":"2024-01-01"}' },
|
|
20
|
+
];
|
|
21
|
+
// ========================================
|
|
22
|
+
// Method Examples
|
|
23
|
+
// ========================================
|
|
24
|
+
export const METHOD_EXAMPLES = [
|
|
25
|
+
{ label: "Read data", value: "GET" },
|
|
26
|
+
{ label: "Create resource", value: "POST" },
|
|
27
|
+
{ label: "Full update", value: "PUT" },
|
|
28
|
+
{ label: "Partial update", value: "PATCH" },
|
|
29
|
+
{ label: "Remove resource", value: "DELETE" },
|
|
30
|
+
];
|
|
31
|
+
// ========================================
|
|
32
|
+
// Auth Type Examples
|
|
33
|
+
// ========================================
|
|
34
|
+
export const AUTH_TYPE_EXAMPLES = [
|
|
35
|
+
{ label: "OAuth2 bearer token", value: "bearer" },
|
|
36
|
+
{ label: "Basic credentials", value: "basic" },
|
|
37
|
+
{ label: "API key header", value: "api-key" },
|
|
38
|
+
];
|
|
39
|
+
// ========================================
|
|
40
|
+
// Query Parameter Examples
|
|
41
|
+
// ========================================
|
|
42
|
+
export const QUERY_PARAM_EXAMPLES = [
|
|
43
|
+
{ label: "OData filter", value: '{"$top":"10","$filter":"status eq \'active\'"}' },
|
|
44
|
+
{ label: "Pagination", value: '{"page":"1","pageSize":"25"}' },
|
|
45
|
+
];
|
|
46
|
+
// ========================================
|
|
47
|
+
// Host Override Examples
|
|
48
|
+
// ========================================
|
|
49
|
+
export const HOST_OVERRIDE_EXAMPLES = [
|
|
50
|
+
{ label: "Different API host", value: "https://other-api.example.com" },
|
|
51
|
+
{ label: "Staging environment", value: "https://staging-api.example.com" },
|
|
52
|
+
];
|
|
53
|
+
// ========================================
|
|
54
|
+
// Entity/Schema Examples
|
|
55
|
+
// ========================================
|
|
56
|
+
export const ENTITY_EXAMPLES = [
|
|
57
|
+
{ label: "User entity", value: "users" },
|
|
58
|
+
{ label: "Singular form", value: "contact" },
|
|
59
|
+
{ label: "Custom entity", value: "sic_exam" },
|
|
60
|
+
];
|
|
61
|
+
// ========================================
|
|
62
|
+
// Filter Examples (for list-endpoints)
|
|
63
|
+
// ========================================
|
|
64
|
+
export const ENDPOINT_FILTER_EXAMPLES = [
|
|
65
|
+
{ label: "Find exam endpoints", value: "exam" },
|
|
66
|
+
{ label: "Find user endpoints", value: "user" },
|
|
67
|
+
{ label: "Find auth endpoints", value: "auth" },
|
|
68
|
+
];
|
|
69
|
+
//# sourceMappingURL=tool-examples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-examples.js","sourceRoot":"","sources":["../src/tool-examples.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,2CAA2C;AAC3C,oBAAoB;AACpB,2CAA2C;AAE3C,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE;IAC/C,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,sBAAsB,EAAE;IACjE,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,4BAA4B,EAAE;CAClE,CAAC;AAEF,2CAA2C;AAC3C,kBAAkB;AAClB,2CAA2C;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,iEAAiE,EAAE;IACxG,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,8BAA8B,EAAE;CACvE,CAAC;AAEF,2CAA2C;AAC3C,kBAAkB;AAClB,2CAA2C;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE;IACpC,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE;IAC3C,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE;IACtC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE;IAC3C,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,EAAE;CAC9C,CAAC;AAEF,2CAA2C;AAC3C,qBAAqB;AACrB,2C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K,EAAE,MAAM,EAAE;CAChD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools barrel export + combined registration
|
|
3
|
+
*/
|
|
4
|
+
import type { ServiceContext } from '../types.js';
|
|
5
|
+
export declare function registerAllTools(server: any, ctx: ServiceContext): void;
|
|
6
|
+
export { registerRestTools } from './rest-tools.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAEvE;AAED,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,UAAU,gBAAgB,CAAC,MAAW,EAAE,GAAmB;IAC/D,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest-tools.d.ts","sourceRoot":"","sources":["../../src/tools/rest-tools.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAWlD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAgQxE"}
|