@j0hanz/fetch-url-mcp 1.12.0 → 1.12.2
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/README.md +34 -17
- package/dist/http/auth.d.ts.map +1 -1
- package/dist/http/auth.js +61 -20
- package/dist/http/helpers.d.ts +1 -1
- package/dist/http/helpers.d.ts.map +1 -1
- package/dist/http/helpers.js +7 -9
- package/dist/http/native.d.ts.map +1 -1
- package/dist/http/native.js +271 -54
- package/dist/http/rate-limit.d.ts.map +1 -1
- package/dist/http/rate-limit.js +2 -1
- package/dist/index.js +5 -4
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +8 -1
- package/dist/lib/core.d.ts +8 -4
- package/dist/lib/core.d.ts.map +1 -1
- package/dist/lib/core.js +240 -73
- package/dist/lib/fetch-pipeline.d.ts.map +1 -1
- package/dist/lib/fetch-pipeline.js +15 -2
- package/dist/lib/http.d.ts.map +1 -1
- package/dist/lib/http.js +1 -1
- package/dist/lib/mcp-interop.d.ts +15 -3
- package/dist/lib/mcp-interop.d.ts.map +1 -1
- package/dist/lib/mcp-interop.js +92 -23
- package/dist/lib/url.d.ts.map +1 -1
- package/dist/lib/url.js +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +2 -2
- package/dist/resources/index.d.ts +4 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +39 -4
- package/dist/schemas.d.ts +5 -5
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +7 -9
- package/dist/server.d.ts +3 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +20 -11
- package/dist/tasks/execution.d.ts +1 -1
- package/dist/tasks/execution.d.ts.map +1 -1
- package/dist/tasks/execution.js +72 -25
- package/dist/tasks/handlers.d.ts.map +1 -1
- package/dist/tasks/handlers.js +31 -24
- package/dist/tasks/manager.d.ts +5 -2
- package/dist/tasks/manager.d.ts.map +1 -1
- package/dist/tasks/manager.js +58 -19
- package/dist/tasks/owner.d.ts +5 -0
- package/dist/tasks/owner.d.ts.map +1 -1
- package/dist/tasks/owner.js +15 -7
- package/dist/tasks/registry.d.ts +10 -8
- package/dist/tasks/registry.d.ts.map +1 -1
- package/dist/tasks/registry.js +27 -15
- package/dist/tools/fetch-url.d.ts +2 -0
- package/dist/tools/fetch-url.d.ts.map +1 -1
- package/dist/tools/fetch-url.js +76 -21
- package/dist/transform/dom-prep.d.ts.map +1 -1
- package/dist/transform/dom-prep.js +6 -6
- package/dist/transform/transform.d.ts.map +1 -1
- package/dist/transform/transform.js +17 -14
- package/dist/transform/worker-pool.d.ts.map +1 -1
- package/dist/transform/worker-pool.js +43 -3
- package/package.json +2 -2
|
@@ -56,13 +56,21 @@ type ToolErrorResponse = CallToolResult & {
|
|
|
56
56
|
isError: true;
|
|
57
57
|
};
|
|
58
58
|
export declare function createToolErrorResponse(message: string, url: string, extra?: {
|
|
59
|
-
code?: string;
|
|
59
|
+
code?: string | number;
|
|
60
60
|
statusCode?: number;
|
|
61
61
|
details?: Record<string, unknown>;
|
|
62
|
+
data?: unknown;
|
|
62
63
|
}): ToolErrorResponse;
|
|
63
64
|
export declare function handleToolError(error: unknown, url: string, fallbackMessage?: string): ToolErrorResponse;
|
|
64
65
|
type CleanupCallback = () => void;
|
|
65
66
|
type RequestHandlerFn = (request: unknown, extra?: unknown) => Promise<unknown>;
|
|
67
|
+
interface ToolPresentation {
|
|
68
|
+
icons?: {
|
|
69
|
+
src: string;
|
|
70
|
+
mimeType?: string;
|
|
71
|
+
sizes?: string[];
|
|
72
|
+
}[];
|
|
73
|
+
}
|
|
66
74
|
export declare function registerServerLifecycleCleanup(server: McpServer, callback: CleanupCallback): void;
|
|
67
75
|
/**
|
|
68
76
|
* Retrieves the SDK's internal request-handler map.
|
|
@@ -78,6 +86,7 @@ export declare function getSdkCallToolHandler(server: McpServer): RequestHandler
|
|
|
78
86
|
* If the SDK changes this internal, the sdk-compat-guard.test.ts tests will fail.
|
|
79
87
|
*/
|
|
80
88
|
export declare function setTaskToolCallCapability(server: McpServer, enabled: boolean): void;
|
|
89
|
+
export declare function registerToolPresentation(server: McpServer, name: string, presentation: ToolPresentation): void;
|
|
81
90
|
type ProgressToken = string | number;
|
|
82
91
|
interface RequestMeta {
|
|
83
92
|
progressToken?: ProgressToken | undefined;
|
|
@@ -100,12 +109,15 @@ export interface ToolHandlerExtra {
|
|
|
100
109
|
sessionId?: unknown;
|
|
101
110
|
requestInfo?: unknown;
|
|
102
111
|
_meta?: RequestMeta;
|
|
112
|
+
progressState?: {
|
|
113
|
+
closed: boolean;
|
|
114
|
+
};
|
|
103
115
|
sendNotification?: (notification: ProgressNotification) => Promise<void>;
|
|
104
|
-
onProgress?: (progress: number, message: string) => void;
|
|
116
|
+
onProgress?: (progress: number, message: string, total?: number) => void;
|
|
105
117
|
canReportProgress?: () => boolean;
|
|
106
118
|
}
|
|
107
119
|
export interface ProgressReporter {
|
|
108
|
-
report: (progress: number, message: string) => void;
|
|
120
|
+
report: (progress: number, message: string, total?: number) => void;
|
|
109
121
|
}
|
|
110
122
|
export declare const createProgressReporter: (extra?: ToolHandlerExtra) => ProgressReporter;
|
|
111
123
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-interop.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-interop.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,
|
|
1
|
+
{"version":3,"file":"mcp-interop.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-interop.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB,MAAM,MAAM,SAAS,GA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AC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE,0BAA0B,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,aAAa,CAAC,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;IACpC,gBAAgB,CAAC,EAAE,CAAC,YAAY,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzE,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACrE;AAgND,eAAO,MAAM,sBAAsB,GACjC,QAAQ,gBAAgB,KACvB,gBAAsD,CAAC"}
|
package/dist/lib/mcp-interop.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setTimeout as setTimeoutPromise } from 'node:timers/promises';
|
|
2
|
-
import {} from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { ListToolsRequestSchema, ListToolsResultSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { logError, logWarn } from './core.js';
|
|
5
5
|
import { FetchError, getErrorMessage, isAbortError, isObject, isSystemError, } from './utils.js';
|
|
@@ -86,12 +86,13 @@ function sanitizeToolErrorDetails(details) {
|
|
|
86
86
|
export function createToolErrorResponse(message, url, extra) {
|
|
87
87
|
const errorContent = {
|
|
88
88
|
error: message,
|
|
89
|
-
...(extra?.code ? { code: extra.code } : {}),
|
|
89
|
+
...(extra?.code !== undefined ? { code: extra.code } : {}),
|
|
90
90
|
url,
|
|
91
91
|
...(extra?.statusCode !== undefined
|
|
92
92
|
? { statusCode: extra.statusCode }
|
|
93
93
|
: {}),
|
|
94
94
|
...(extra?.details ? { details: extra.details } : {}),
|
|
95
|
+
...(extra?.data !== undefined ? { data: extra.data } : {}),
|
|
95
96
|
};
|
|
96
97
|
return {
|
|
97
98
|
content: [{ type: 'text', text: JSON.stringify(errorContent) }],
|
|
@@ -156,7 +157,7 @@ function drainServerCleanupCallbacks(server) {
|
|
|
156
157
|
callback();
|
|
157
158
|
}
|
|
158
159
|
catch (error) {
|
|
159
|
-
logWarn('Server cleanup callback failed', { error });
|
|
160
|
+
logWarn('Server cleanup callback failed', { error }, 'mcp');
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
}
|
|
@@ -192,6 +193,13 @@ export function getSdkCallToolHandler(server) {
|
|
|
192
193
|
const handler = maybeHandlers.get('tools/call');
|
|
193
194
|
return typeof handler === 'function' ? handler : null;
|
|
194
195
|
}
|
|
196
|
+
function getSdkListToolsHandler(server) {
|
|
197
|
+
const maybeHandlers = Reflect.get(server.server, '_requestHandlers');
|
|
198
|
+
if (!(maybeHandlers instanceof Map))
|
|
199
|
+
return null;
|
|
200
|
+
const handler = maybeHandlers.get('tools/list');
|
|
201
|
+
return typeof handler === 'function' ? handler : null;
|
|
202
|
+
}
|
|
195
203
|
/**
|
|
196
204
|
* Patches the SDK's internal capabilities to enable/disable task-mode tool calls.
|
|
197
205
|
*
|
|
@@ -214,8 +222,52 @@ export function setTaskToolCallCapability(server, enabled) {
|
|
|
214
222
|
}
|
|
215
223
|
delete requests['tools'];
|
|
216
224
|
}
|
|
217
|
-
const
|
|
225
|
+
const toolPresentationByServer = new WeakMap();
|
|
226
|
+
const patchedToolListServers = new WeakSet();
|
|
227
|
+
function getServerToolPresentationMap(server) {
|
|
228
|
+
let toolMap = toolPresentationByServer.get(server);
|
|
229
|
+
if (toolMap)
|
|
230
|
+
return toolMap;
|
|
231
|
+
toolMap = new Map();
|
|
232
|
+
toolPresentationByServer.set(server, toolMap);
|
|
233
|
+
registerServerLifecycleCleanup(server, () => {
|
|
234
|
+
toolPresentationByServer.delete(server);
|
|
235
|
+
});
|
|
236
|
+
return toolMap;
|
|
237
|
+
}
|
|
238
|
+
function patchSdkToolListHandler(server) {
|
|
239
|
+
if (patchedToolListServers.has(server))
|
|
240
|
+
return;
|
|
241
|
+
const sdkListToolsHandler = getSdkListToolsHandler(server);
|
|
242
|
+
if (!sdkListToolsHandler)
|
|
243
|
+
return;
|
|
244
|
+
patchedToolListServers.add(server);
|
|
245
|
+
server.server.setRequestHandler(ListToolsRequestSchema, async (request, extra) => {
|
|
246
|
+
const parsed = ListToolsResultSchema.parse(await sdkListToolsHandler(request, extra));
|
|
247
|
+
const presentations = getServerToolPresentationMap(server);
|
|
248
|
+
return {
|
|
249
|
+
...parsed,
|
|
250
|
+
tools: parsed.tools.map((tool) => {
|
|
251
|
+
if (typeof tool.name !== 'string') {
|
|
252
|
+
return tool;
|
|
253
|
+
}
|
|
254
|
+
const presentation = presentations.get(tool.name);
|
|
255
|
+
if (!presentation?.icons?.length)
|
|
256
|
+
return tool;
|
|
257
|
+
return {
|
|
258
|
+
...tool,
|
|
259
|
+
icons: presentation.icons,
|
|
260
|
+
};
|
|
261
|
+
}),
|
|
262
|
+
};
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
export function registerToolPresentation(server, name, presentation) {
|
|
266
|
+
getServerToolPresentationMap(server).set(name, presentation);
|
|
267
|
+
patchSdkToolListHandler(server);
|
|
268
|
+
}
|
|
218
269
|
const PROGRESS_NOTIFICATION_TIMEOUT_MS = 5000;
|
|
270
|
+
const PROGRESS_NOTIFICATION_MIN_INTERVAL_MS = 100;
|
|
219
271
|
function resolveRelatedTaskMeta(meta) {
|
|
220
272
|
const related = meta?.['io.modelcontextprotocol/related-task'];
|
|
221
273
|
if (!isObject(related))
|
|
@@ -226,15 +278,18 @@ function resolveRelatedTaskMeta(meta) {
|
|
|
226
278
|
class ToolProgressReporter {
|
|
227
279
|
token;
|
|
228
280
|
handlers;
|
|
281
|
+
progressState;
|
|
229
282
|
taskMeta;
|
|
230
|
-
isTerminal = false;
|
|
231
283
|
lastProgress = -1;
|
|
232
284
|
lastMessage;
|
|
285
|
+
lastTotal;
|
|
233
286
|
pendingNotification;
|
|
234
287
|
isDispatching = false;
|
|
235
|
-
|
|
288
|
+
lastDispatchedAt = 0;
|
|
289
|
+
constructor(token, handlers, progressState, taskMeta) {
|
|
236
290
|
this.token = token;
|
|
237
291
|
this.handlers = handlers;
|
|
292
|
+
this.progressState = progressState;
|
|
238
293
|
this.taskMeta = taskMeta;
|
|
239
294
|
}
|
|
240
295
|
static create(extra = {}) {
|
|
@@ -247,7 +302,7 @@ class ToolProgressReporter {
|
|
|
247
302
|
send: extra.sendNotification,
|
|
248
303
|
onProgress,
|
|
249
304
|
canReport: extra.canReportProgress,
|
|
250
|
-
}, resolveRelatedTaskMeta(extra._meta));
|
|
305
|
+
}, extra.progressState, resolveRelatedTaskMeta(extra._meta));
|
|
251
306
|
}
|
|
252
307
|
/**
|
|
253
308
|
* Report progress toward completion. Steps are monotonic (never decrease)
|
|
@@ -255,32 +310,39 @@ class ToolProgressReporter {
|
|
|
255
310
|
* intermediate steps). Clients should treat progress as "at least this far"
|
|
256
311
|
* rather than expecting every step to fire sequentially.
|
|
257
312
|
*/
|
|
258
|
-
report(progress, message) {
|
|
259
|
-
if (this.
|
|
313
|
+
report(progress, message, total) {
|
|
314
|
+
if (this.progressState?.closed === true ||
|
|
315
|
+
this.handlers.canReport?.() === false) {
|
|
260
316
|
return;
|
|
317
|
+
}
|
|
261
318
|
const effectiveProgress = Math.max(progress, this.lastProgress);
|
|
319
|
+
const effectiveTotal = total === undefined ? this.lastTotal : Math.max(total, effectiveProgress);
|
|
262
320
|
const isIncreasing = effectiveProgress > this.lastProgress;
|
|
263
321
|
const isMessageChanged = message !== this.lastMessage;
|
|
322
|
+
const isTotalChanged = effectiveTotal !== this.lastTotal;
|
|
264
323
|
this.lastProgress = effectiveProgress;
|
|
265
324
|
this.lastMessage = message;
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
if (isIncreasing || isMessageChanged) {
|
|
325
|
+
this.lastTotal = effectiveTotal;
|
|
326
|
+
if (isIncreasing || isMessageChanged || isTotalChanged) {
|
|
270
327
|
try {
|
|
271
|
-
this.handlers.onProgress?.(effectiveProgress, message);
|
|
328
|
+
this.handlers.onProgress?.(effectiveProgress, message, effectiveTotal);
|
|
272
329
|
}
|
|
273
330
|
catch (error) {
|
|
274
331
|
logError('Progress callback failed', {
|
|
275
332
|
error: getErrorMessage(error),
|
|
276
333
|
progress: effectiveProgress,
|
|
277
334
|
message,
|
|
278
|
-
});
|
|
335
|
+
}, 'mcp');
|
|
279
336
|
}
|
|
280
337
|
}
|
|
281
338
|
if (!isIncreasing || this.token === null || !this.handlers.send)
|
|
282
339
|
return;
|
|
283
|
-
this.pendingNotification = this.createProgressNotification(
|
|
340
|
+
this.pendingNotification = this.createProgressNotification({
|
|
341
|
+
token: this.token,
|
|
342
|
+
progress: effectiveProgress,
|
|
343
|
+
message,
|
|
344
|
+
...(effectiveTotal !== undefined ? { total: effectiveTotal } : {}),
|
|
345
|
+
});
|
|
284
346
|
this.flushNotifications();
|
|
285
347
|
}
|
|
286
348
|
flushNotifications() {
|
|
@@ -294,9 +356,16 @@ class ToolProgressReporter {
|
|
|
294
356
|
this.pendingNotification = undefined;
|
|
295
357
|
return;
|
|
296
358
|
}
|
|
359
|
+
const remainingDelay = this.lastDispatchedAt +
|
|
360
|
+
PROGRESS_NOTIFICATION_MIN_INTERVAL_MS -
|
|
361
|
+
Date.now();
|
|
362
|
+
if (remainingDelay > 0) {
|
|
363
|
+
await setTimeoutPromise(remainingDelay, undefined, { ref: false });
|
|
364
|
+
}
|
|
297
365
|
const notification = this.pendingNotification;
|
|
298
366
|
this.pendingNotification = undefined;
|
|
299
367
|
await this.sendWithTimeout(notification);
|
|
368
|
+
this.lastDispatchedAt = Date.now();
|
|
300
369
|
}
|
|
301
370
|
}
|
|
302
371
|
finally {
|
|
@@ -325,7 +394,7 @@ class ToolProgressReporter {
|
|
|
325
394
|
logWarn('Progress notification timed out', {
|
|
326
395
|
progress: notification.params.progress,
|
|
327
396
|
message: notification.params.message,
|
|
328
|
-
});
|
|
397
|
+
}, 'mcp');
|
|
329
398
|
}
|
|
330
399
|
}
|
|
331
400
|
catch (error) {
|
|
@@ -333,17 +402,17 @@ class ToolProgressReporter {
|
|
|
333
402
|
error: getErrorMessage(error),
|
|
334
403
|
progress: notification.params.progress,
|
|
335
404
|
message: notification.params.message,
|
|
336
|
-
});
|
|
405
|
+
}, 'mcp');
|
|
337
406
|
}
|
|
338
407
|
}
|
|
339
|
-
createProgressNotification(
|
|
408
|
+
createProgressNotification(params) {
|
|
340
409
|
return {
|
|
341
410
|
method: 'notifications/progress',
|
|
342
411
|
params: {
|
|
343
|
-
progressToken: token,
|
|
344
|
-
progress,
|
|
345
|
-
total:
|
|
346
|
-
message,
|
|
412
|
+
progressToken: params.token,
|
|
413
|
+
progress: params.progress,
|
|
414
|
+
...(params.total !== undefined ? { total: params.total } : {}),
|
|
415
|
+
message: params.message,
|
|
347
416
|
...(this.taskMeta && {
|
|
348
417
|
_meta: {
|
|
349
418
|
'io.modelcontextprotocol/related-task': this.taskMeta,
|
package/dist/lib/url.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/lib/url.ts"],"names":[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C,QAAQ,CAAC,EAAE,QAAQ,GAClB;IAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAU/C"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -137,7 +137,7 @@ export function applyHttpServerTuning(server) {
|
|
|
137
137
|
maxConnections,
|
|
138
138
|
dropped: droppedSinceLastLog,
|
|
139
139
|
data,
|
|
140
|
-
});
|
|
140
|
+
}, 'http');
|
|
141
141
|
lastLoggedAt = now;
|
|
142
142
|
droppedSinceLastLog = 0;
|
|
143
143
|
};
|
|
@@ -148,7 +148,7 @@ export function applyHttpServerTuning(server) {
|
|
|
148
148
|
export function drainConnectionsOnShutdown(server) {
|
|
149
149
|
if (typeof server.closeIdleConnections === 'function') {
|
|
150
150
|
server.closeIdleConnections();
|
|
151
|
-
logDebug('Closed idle HTTP connections during shutdown');
|
|
151
|
+
logDebug('Closed idle HTTP connections during shutdown', undefined, 'http');
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
function createAbortSafeTimeoutPromise(timeoutMs, value, signal) {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { type IconInfo } from '../lib/utils.js';
|
|
3
3
|
export declare function registerInstructionResource(server: McpServer, instructions: string, iconInfo?: IconInfo): void;
|
|
4
|
+
export declare const HELP_TOPICS: readonly ["capabilities", "workflows", "constraints", "errors"];
|
|
5
|
+
export type HelpTopic = (typeof HELP_TOPICS)[number];
|
|
6
|
+
export declare function extractSection(instructions: string, topic: HelpTopic): string | undefined;
|
|
7
|
+
export declare function filterInstructions(instructions: string, topic?: string): string;
|
|
4
8
|
export declare function buildServerInstructions(): string;
|
|
5
9
|
export declare function registerGetHelpPrompt(server: McpServer, instructions: string, iconInfo?: IconInfo): void;
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQzE,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIpE,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,QAAQ,GAClB,IAAI,CAwBN;AAED,eAAO,MAAM,WAAW,iEAKd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,SAAS,GACf,MAAM,GAAG,SAAS,CAIpB;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,CAKR;AAED,wBAAgB,uBAAuB,IAAI,MAAM,CAgChD;AAiBD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,QAAQ,GAClB,IAAI,CA2BN"}
|
package/dist/resources/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { completable } from '@modelcontextprotocol/sdk/server/completable.js';
|
|
2
|
+
import { z } from 'zod';
|
|
1
3
|
import { config } from '../lib/core.js';
|
|
2
4
|
import { buildOptionalIcons } from '../lib/utils.js';
|
|
3
5
|
import { FETCH_URL_TOOL_NAME } from '../tools/fetch-url.js';
|
|
@@ -21,6 +23,25 @@ export function registerInstructionResource(server, instructions, iconInfo) {
|
|
|
21
23
|
],
|
|
22
24
|
}));
|
|
23
25
|
}
|
|
26
|
+
export const HELP_TOPICS = [
|
|
27
|
+
'capabilities',
|
|
28
|
+
'workflows',
|
|
29
|
+
'constraints',
|
|
30
|
+
'errors',
|
|
31
|
+
];
|
|
32
|
+
export function extractSection(instructions, topic) {
|
|
33
|
+
const sections = instructions.split(/\n(?=# )/g);
|
|
34
|
+
const match = sections.find((s) => s.toLowerCase().startsWith(`# ${topic}`));
|
|
35
|
+
return match?.trim();
|
|
36
|
+
}
|
|
37
|
+
export function filterInstructions(instructions, topic) {
|
|
38
|
+
if (!topic)
|
|
39
|
+
return instructions;
|
|
40
|
+
const normalized = topic.toLowerCase().trim();
|
|
41
|
+
if (!HELP_TOPICS.includes(normalized))
|
|
42
|
+
return instructions;
|
|
43
|
+
return extractSection(instructions, normalized) ?? instructions;
|
|
44
|
+
}
|
|
24
45
|
export function buildServerInstructions() {
|
|
25
46
|
const maxHtmlSizeMb = config.constants.maxHtmlBytes / 1024 / 1024;
|
|
26
47
|
return `# Fetch public webpages and return clean, readable Markdown.
|
|
@@ -28,11 +49,13 @@ export function buildServerInstructions() {
|
|
|
28
49
|
# Capabilities
|
|
29
50
|
- Tool: \`${FETCH_URL_TOOL_NAME}\` (fetch URL, return Markdown)
|
|
30
51
|
- Resource: \`internal://instructions\` (this document)
|
|
31
|
-
- Prompt: \`get-help\` (returns these instructions)
|
|
52
|
+
- Prompt: \`get-help\` (returns these instructions, optional \`topic\` filter with auto-completion)
|
|
53
|
+
- Completions: \`get-help\` prompt argument \`topic\` (${HELP_TOPICS.join(' | ')})
|
|
32
54
|
|
|
33
55
|
# Workflows
|
|
34
56
|
1. Standard: Call \`${FETCH_URL_TOOL_NAME}\` → read \`markdown\`. \`truncated: true\` means content was cut at server size limit.
|
|
35
|
-
2.
|
|
57
|
+
2. Progress: include \`_meta: { progressToken: "token" }\` (string or number) in \`tools/call\` to opt into \`notifications/progress\`.
|
|
58
|
+
3. Async: \`task: { ttl: <ms> }\` in \`tools/call\` → poll \`tasks/get\` for \`statusMessage\`, \`progress\`, and \`total\` → \`tasks/result\`. In HTTP mode, tasks are bound to the authenticated caller and can be resumed from a new MCP session with the same credentials. If a \`progressToken\` is supplied, the same token is reused for the task lifetime.
|
|
36
59
|
|
|
37
60
|
# Constraints
|
|
38
61
|
- Blocked URLs: localhost, private IPs (10.x, 172.16-31.x, 192.168.x), metadata (169.254.169.254), .local/.internal.
|
|
@@ -51,20 +74,32 @@ export function buildServerInstructions() {
|
|
|
51
74
|
- ABORTED: cancelled. Retry if needed.
|
|
52
75
|
- queue_full: worker pool busy. Wait and retry, or use task mode.`;
|
|
53
76
|
}
|
|
77
|
+
function buildTopicSchema() {
|
|
78
|
+
return completable(z
|
|
79
|
+
.string()
|
|
80
|
+
.optional()
|
|
81
|
+
.describe(`Filter help to a specific topic: ${HELP_TOPICS.join(', ')}.`), (value) => {
|
|
82
|
+
const partial = (value ?? '').toLowerCase();
|
|
83
|
+
return HELP_TOPICS.filter((t) => t.startsWith(partial));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
54
86
|
export function registerGetHelpPrompt(server, instructions, iconInfo) {
|
|
55
87
|
const description = 'Return Fetch URL server instructions: workflows, task mode, and error handling.';
|
|
56
88
|
server.registerPrompt('get-help', {
|
|
57
89
|
title: 'Get Help',
|
|
58
90
|
description,
|
|
91
|
+
argsSchema: {
|
|
92
|
+
topic: buildTopicSchema(),
|
|
93
|
+
},
|
|
59
94
|
...buildOptionalIcons(iconInfo),
|
|
60
|
-
}, () => ({
|
|
95
|
+
}, (args) => ({
|
|
61
96
|
description,
|
|
62
97
|
messages: [
|
|
63
98
|
{
|
|
64
99
|
role: 'user',
|
|
65
100
|
content: {
|
|
66
101
|
type: 'text',
|
|
67
|
-
text: instructions,
|
|
102
|
+
text: filterInstructions(instructions, args.topic),
|
|
68
103
|
},
|
|
69
104
|
},
|
|
70
105
|
],
|
package/dist/schemas.d.ts
CHANGED
|
@@ -8,14 +8,14 @@ export declare const fetchUrlInputSchema: z.ZodObject<{
|
|
|
8
8
|
}, z.core.$strict>;
|
|
9
9
|
export declare const fetchUrlOutputSchema: z.ZodObject<{
|
|
10
10
|
url: z.ZodURL;
|
|
11
|
-
inputUrl: z.
|
|
12
|
-
resolvedUrl: z.
|
|
11
|
+
inputUrl: z.ZodURL;
|
|
12
|
+
resolvedUrl: z.ZodURL;
|
|
13
13
|
finalUrl: z.ZodOptional<z.ZodURL>;
|
|
14
14
|
title: z.ZodOptional<z.ZodString>;
|
|
15
15
|
metadata: z.ZodOptional<z.ZodType<ExtractedMetadata, unknown, z.core.$ZodTypeInternals<ExtractedMetadata, unknown>>>;
|
|
16
|
-
markdown: z.
|
|
17
|
-
fetchedAt: z.
|
|
18
|
-
contentSize: z.
|
|
16
|
+
markdown: z.ZodString;
|
|
17
|
+
fetchedAt: z.ZodISODateTime;
|
|
18
|
+
contentSize: z.ZodNumber;
|
|
19
19
|
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
20
20
|
}, z.core.$strict>;
|
|
21
21
|
//# sourceMappingURL=schemas.d.ts.map
|
package/dist/schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAoD9D,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAG9D,CAAC;AAgBJ,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,iBAAiB,GAAG,SAAS,CAQ/B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAErE;AAED,eAAO,MAAM,mBAAmB;;kBAc/B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAoD9D,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAG9D,CAAC;AAgBJ,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,iBAAiB,GAAG,SAAS,CAQ/B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAErE;AAED,eAAO,MAAM,mBAAmB;;kBAc/B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;kBAkC/B,CAAC"}
|
package/dist/schemas.js
CHANGED
|
@@ -57,17 +57,18 @@ export const fetchUrlInputSchema = z.strictObject({
|
|
|
57
57
|
.describe(`Target URL. Max ${config.constants.maxUrlLength} chars. Example: https://example.com`),
|
|
58
58
|
}, 'Invalid input');
|
|
59
59
|
export const fetchUrlOutputSchema = z.strictObject({
|
|
60
|
-
url: z
|
|
60
|
+
url: z
|
|
61
|
+
.httpUrl()
|
|
62
|
+
.max(config.constants.maxUrlLength)
|
|
63
|
+
.describe('Normalized requested URL after validation.'),
|
|
61
64
|
inputUrl: z
|
|
62
65
|
.httpUrl()
|
|
63
66
|
.max(config.constants.maxUrlLength)
|
|
64
|
-
.optional()
|
|
65
67
|
.describe('Original requested URL.'),
|
|
66
68
|
resolvedUrl: z
|
|
67
69
|
.httpUrl()
|
|
68
70
|
.max(config.constants.maxUrlLength)
|
|
69
|
-
.
|
|
70
|
-
.describe('Final URL after raw-content transformations.'),
|
|
71
|
+
.describe('Resolved fetch URL after raw-content transformations.'),
|
|
71
72
|
finalUrl: z
|
|
72
73
|
.httpUrl()
|
|
73
74
|
.max(config.constants.maxUrlLength)
|
|
@@ -79,16 +80,13 @@ export const fetchUrlOutputSchema = z.strictObject({
|
|
|
79
80
|
.describe('Extracted page metadata.'),
|
|
80
81
|
markdown: (config.constants.maxInlineContentChars > 0
|
|
81
82
|
? z.string().max(config.constants.maxInlineContentChars)
|
|
82
|
-
: z.string())
|
|
83
|
-
|
|
84
|
-
.describe('Extracted Markdown. May be truncated (check truncated field).'),
|
|
85
|
-
fetchedAt: z.iso.datetime().optional().describe('ISO timestamp of fetch.'),
|
|
83
|
+
: z.string()).describe('Extracted Markdown. May be truncated (check truncated field).'),
|
|
84
|
+
fetchedAt: z.iso.datetime().describe('ISO timestamp of fetch.'),
|
|
86
85
|
contentSize: z
|
|
87
86
|
.number()
|
|
88
87
|
.int()
|
|
89
88
|
.min(0)
|
|
90
89
|
.max(config.constants.maxHtmlBytes * 4)
|
|
91
|
-
.optional()
|
|
92
90
|
.describe('Markdown fragment size before final inline truncation.'),
|
|
93
91
|
truncated: z.boolean().optional().describe('True if markdown was truncated.'),
|
|
94
92
|
});
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
export declare function createMcpServer(): Promise<McpServer>;
|
|
3
3
|
export declare function createMcpServerForHttpSession(): Promise<McpServer>;
|
|
4
|
-
export declare function startStdioServer(): Promise<
|
|
4
|
+
export declare function startStdioServer(): Promise<{
|
|
5
|
+
shutdown: (signal: string) => Promise<void>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA+GpE,wBAAsB,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAE1D;AAkDD,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,SAAS,CAAC,CAExE;AAgHD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC;IAChD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C,CAAC,CASD"}
|
package/dist/server.js
CHANGED
|
@@ -4,7 +4,7 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
4
4
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
5
|
import { SetLevelRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import { config } from './lib/core.js';
|
|
7
|
-
import { getSessionId, logError, logInfo, setLogLevel, setMcpServer, } from './lib/core.js';
|
|
7
|
+
import { getSessionId, logError, logInfo, logNotice, setLogLevel, setMcpServer, } from './lib/core.js';
|
|
8
8
|
import { setTaskToolCallCapability } from './lib/mcp-interop.js';
|
|
9
9
|
import { toError } from './lib/utils.js';
|
|
10
10
|
import { buildServerInstructions, registerGetHelpPrompt, registerInstructionResource, } from './resources/index.js';
|
|
@@ -109,13 +109,18 @@ export async function createMcpServerForHttpSession() {
|
|
|
109
109
|
}
|
|
110
110
|
function registerLoggingSetLevelHandler(server) {
|
|
111
111
|
server.server.setRequestHandler(SetLevelRequestSchema, (request) => {
|
|
112
|
-
|
|
112
|
+
const sessionId = getSessionId();
|
|
113
|
+
setLogLevel(request.params.level, sessionId);
|
|
114
|
+
logNotice('Logging level updated', {
|
|
115
|
+
level: request.params.level,
|
|
116
|
+
scope: sessionId ? 'session' : 'stdio',
|
|
117
|
+
}, 'logging');
|
|
113
118
|
return {};
|
|
114
119
|
});
|
|
115
120
|
}
|
|
116
121
|
function attachServerErrorHandler(server) {
|
|
117
122
|
server.server.onerror = (error) => {
|
|
118
|
-
logError('
|
|
123
|
+
logError('MCP server error', toError(error), 'server');
|
|
119
124
|
};
|
|
120
125
|
}
|
|
121
126
|
async function shutdownServer(server, signal) {
|
|
@@ -130,47 +135,49 @@ async function shutdownServer(server, signal) {
|
|
|
130
135
|
]);
|
|
131
136
|
for (const result of results) {
|
|
132
137
|
if (result.status === 'rejected') {
|
|
133
|
-
logError('Shutdown step failed', toError(result.reason));
|
|
138
|
+
logError('Shutdown step failed', toError(result.reason), 'server');
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
function createShutdownHandler(server) {
|
|
138
143
|
let shuttingDown = false;
|
|
139
144
|
let initialSignal = null;
|
|
145
|
+
let shutdownPromise = null;
|
|
140
146
|
return (signal) => {
|
|
141
147
|
if (shuttingDown) {
|
|
142
148
|
logInfo('Shutdown already in progress; ignoring signal', {
|
|
143
149
|
signal,
|
|
144
150
|
initialSignal,
|
|
145
|
-
});
|
|
146
|
-
return;
|
|
151
|
+
}, 'server');
|
|
152
|
+
return shutdownPromise ?? Promise.resolve();
|
|
147
153
|
}
|
|
148
154
|
shuttingDown = true;
|
|
149
155
|
initialSignal = signal;
|
|
150
|
-
Promise.resolve()
|
|
156
|
+
shutdownPromise = Promise.resolve()
|
|
151
157
|
.then(() => shutdownServer(server, signal))
|
|
152
158
|
.catch((err) => {
|
|
153
159
|
const error = toError(err);
|
|
154
|
-
logError('Error during shutdown', error);
|
|
160
|
+
logError('Error during shutdown', error, 'server');
|
|
155
161
|
process.exitCode = 1;
|
|
156
162
|
})
|
|
157
163
|
.finally(() => {
|
|
158
164
|
if (process.exitCode === undefined)
|
|
159
165
|
process.exitCode = 0;
|
|
160
166
|
});
|
|
167
|
+
return shutdownPromise;
|
|
161
168
|
};
|
|
162
169
|
}
|
|
163
170
|
function registerSignalHandlers(handler) {
|
|
164
171
|
for (const signal of SHUTDOWN_SIGNALS) {
|
|
165
172
|
process.once(signal, () => {
|
|
166
|
-
handler(signal);
|
|
173
|
+
void handler(signal);
|
|
167
174
|
});
|
|
168
175
|
}
|
|
169
176
|
}
|
|
170
177
|
async function connectStdioServer(server, transport) {
|
|
171
178
|
try {
|
|
172
179
|
await server.connect(transport);
|
|
173
|
-
logInfo('Fetch URL MCP server running on stdio');
|
|
180
|
+
logInfo('Fetch URL MCP server running on stdio', undefined, 'server');
|
|
174
181
|
}
|
|
175
182
|
catch (error) {
|
|
176
183
|
const err = toError(error);
|
|
@@ -182,6 +189,8 @@ async function connectStdioServer(server, transport) {
|
|
|
182
189
|
export async function startStdioServer() {
|
|
183
190
|
const server = await createMcpServer();
|
|
184
191
|
const transport = new StdioServerTransport();
|
|
185
|
-
|
|
192
|
+
const shutdown = createShutdownHandler(server);
|
|
193
|
+
registerSignalHandlers(shutdown);
|
|
186
194
|
await connectStdioServer(server, transport);
|
|
195
|
+
return { shutdown };
|
|
187
196
|
}
|
|
@@ -7,7 +7,7 @@ export declare function abortTaskExecution(taskId: string): void;
|
|
|
7
7
|
export declare function cancelTasksForOwner(ownerKey: string, statusMessage?: string): number;
|
|
8
8
|
export declare function abortAllTaskExecutions(): void;
|
|
9
9
|
type TaskSummary = CreateTaskResult['task'];
|
|
10
|
-
type TaskLifecycleProjection = Pick<TaskState, 'taskId' | 'status' | 'statusMessage' | 'createdAt' | 'lastUpdatedAt' | 'ttl' | 'pollInterval'>;
|
|
10
|
+
type TaskLifecycleProjection = Pick<TaskState, 'taskId' | 'status' | 'statusMessage' | 'progress' | 'total' | 'createdAt' | 'lastUpdatedAt' | 'ttl' | 'pollInterval'>;
|
|
11
11
|
export declare function toTaskSummary(task: TaskLifecycleProjection): TaskSummary;
|
|
12
12
|
export declare function emitTaskStatusNotification(server: McpServer, task: TaskState): void;
|
|
13
13
|
export declare function throwTaskNotFound(): never;
|