@apify/actors-mcp-server 0.13.0 → 0.14.0

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.
Files changed (75) hide show
  1. package/dist/const.d.ts +6 -5
  2. package/dist/const.d.ts.map +1 -1
  3. package/dist/const.js +8 -7
  4. package/dist/const.js.map +1 -1
  5. package/dist/dev_server.d.ts +18 -6
  6. package/dist/dev_server.d.ts.map +1 -1
  7. package/dist/dev_server.js +141 -16
  8. package/dist/dev_server.js.map +1 -1
  9. package/dist/index.d.ts +2 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +6 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/mcp/legacy_server.d.ts +75 -0
  14. package/dist/mcp/legacy_server.d.ts.map +1 -0
  15. package/dist/mcp/legacy_server.js +563 -0
  16. package/dist/mcp/legacy_server.js.map +1 -0
  17. package/dist/mcp/server.d.ts +110 -86
  18. package/dist/mcp/server.d.ts.map +1 -1
  19. package/dist/mcp/server.js +275 -670
  20. package/dist/mcp/server.js.map +1 -1
  21. package/dist/mcp/stateless_server.d.ts +58 -0
  22. package/dist/mcp/stateless_server.d.ts.map +1 -0
  23. package/dist/mcp/stateless_server.js +335 -0
  24. package/dist/mcp/stateless_server.js.map +1 -0
  25. package/dist/mcp/task_execution.d.ts +15 -8
  26. package/dist/mcp/task_execution.d.ts.map +1 -1
  27. package/dist/mcp/task_execution.js +31 -24
  28. package/dist/mcp/task_execution.js.map +1 -1
  29. package/dist/mcp/tool_call_engine.d.ts +23 -10
  30. package/dist/mcp/tool_call_engine.d.ts.map +1 -1
  31. package/dist/mcp/tool_call_engine.js +37 -28
  32. package/dist/mcp/tool_call_engine.js.map +1 -1
  33. package/dist/mcp/tool_call_telemetry.d.ts +4 -4
  34. package/dist/mcp/tool_call_telemetry.d.ts.map +1 -1
  35. package/dist/mcp/tool_call_telemetry.js +7 -7
  36. package/dist/mcp/tool_call_telemetry.js.map +1 -1
  37. package/dist/mcp/tool_dispatch.d.ts +19 -15
  38. package/dist/mcp/tool_dispatch.d.ts.map +1 -1
  39. package/dist/mcp/tool_dispatch.js +21 -19
  40. package/dist/mcp/tool_dispatch.js.map +1 -1
  41. package/dist/tools/actors/call_actor.js +3 -3
  42. package/dist/tools/actors/call_actor.js.map +1 -1
  43. package/dist/tools/actors/fetch_actor_details.d.ts.map +1 -1
  44. package/dist/tools/actors/fetch_actor_details.js +6 -6
  45. package/dist/tools/actors/fetch_actor_details.js.map +1 -1
  46. package/dist/tools/actors/search_actors.js +4 -4
  47. package/dist/tools/actors/search_actors.js.map +1 -1
  48. package/dist/tools/dev/report_problem.d.ts.map +1 -1
  49. package/dist/tools/dev/report_problem.js +4 -2
  50. package/dist/tools/dev/report_problem.js.map +1 -1
  51. package/dist/tools/runs/get_actor_run.js +4 -4
  52. package/dist/tools/runs/get_actor_run.js.map +1 -1
  53. package/dist/tools/runs/get_actor_run_log.d.ts.map +1 -1
  54. package/dist/tools/runs/get_actor_run_log.js +4 -2
  55. package/dist/tools/runs/get_actor_run_log.js.map +1 -1
  56. package/dist/tools/storage/get_dataset_items.js +4 -4
  57. package/dist/tools/storage/get_dataset_items.js.map +1 -1
  58. package/dist/tools/storage/storage_helpers.d.ts +1 -1
  59. package/dist/tools/storage/storage_helpers.d.ts.map +1 -1
  60. package/dist/tools/storage/storage_helpers.js +2 -2
  61. package/dist/tools/storage/storage_helpers.js.map +1 -1
  62. package/dist/tools/widgets/search_actors_widget.js +4 -4
  63. package/dist/tools/widgets/search_actors_widget.js.map +1 -1
  64. package/dist/tsconfig.tsbuildinfo +1 -1
  65. package/dist/types.d.ts +16 -20
  66. package/dist/types.d.ts.map +1 -1
  67. package/dist/types.js +2 -2
  68. package/dist/types.js.map +1 -1
  69. package/dist/utils/tool_status.d.ts +6 -0
  70. package/dist/utils/tool_status.d.ts.map +1 -1
  71. package/dist/utils/tool_status.js +9 -2
  72. package/dist/utils/tool_status.js.map +1 -1
  73. package/manifest.json +1 -1
  74. package/package.json +10 -2
  75. package/server.json +1 -1
@@ -0,0 +1,563 @@
1
+ /**
2
+ * Adapter for the 2025-era MCP protocol (https://modelcontextprotocol.io/specification/2025-11-25),
3
+ * served via the v1 SDK (`@modelcontextprotocol/sdk`): owns the SDK `Server`, request handlers,
4
+ * notifications, and transport lifecycle, reading shared Apify state through
5
+ * {@link LegacyMcpServerHost}. Sibling of `stateless_server.ts`, the 2026-07-28 adapter.
6
+ */
7
+
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="075c3e87-c2fb-5045-9a8c-5a25fbdafccf")}catch(e){}}();
9
+ import { randomUUID } from 'node:crypto';
10
+ import { InMemoryTaskStore } from '@modelcontextprotocol/sdk/experimental/tasks/stores/in-memory.js';
11
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
12
+ import { CallToolRequestSchema, CancelTaskRequestSchema, ErrorCode, GetPromptRequestSchema, GetTaskPayloadRequestSchema, GetTaskRequestSchema, InitializeRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ListTasksRequestSchema, ListToolsRequestSchema, McpError, ReadResourceRequestSchema, RELATED_TASK_META_KEY, SetLevelRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
13
+ import log from '@apify/log';
14
+ import { FAILURE_CATEGORY, TOOL_STATUS } from '../const.js';
15
+ import { getServerInfo } from '../server_card.js';
16
+ import { withReportProblemNudge } from '../tools/dev/report_problem.js';
17
+ import { isMcpClientFaultMessage, sanitizeMezmoMessage } from '../utils/logging.js';
18
+ import { getServerInstructions } from '../utils/server-instructions/index.js';
19
+ import { buildActorFields, getToolFullName, getToolPublicFieldOnly } from '../utils/tools.js';
20
+ import { LOG_LEVEL_MAP } from './const.js';
21
+ import { InternalError, InvalidParamsError } from './errors.js';
22
+ import { emitTaskStatusNotification, executeToolAndUpdateTask } from './task_execution.js';
23
+ import { buildPreflightFailureOutcome, classifyToolCallError, executeSyncToolCall, prepareToolCall, } from './tool_call_engine.js';
24
+ import { logToolCallAndTelemetry, prepareTelemetryData } from './tool_call_telemetry.js';
25
+ import { storeTaskResultOrSkipIfExpired } from './utils.js';
26
+ /**
27
+ * Legacy protocol boundary: project a service's domain error to its v1 `McpError`, copying `message`
28
+ * and `data` unchanged so the wire output (code, message, presence of `data`) is byte-identical.
29
+ * Non-domain errors pass through untouched.
30
+ */
31
+ function toLegacyMcpError(error) {
32
+ if (error instanceof InvalidParamsError)
33
+ return new McpError(ErrorCode.InvalidParams, error.message, error.data);
34
+ if (error instanceof InternalError)
35
+ return new McpError(ErrorCode.InternalError, error.message, error.data);
36
+ return error;
37
+ }
38
+ /**
39
+ * v1 SDK adapter. One per serving unit, constructed only by `ActorsMcpServer`.
40
+ */
41
+ export class LegacyMcpServer {
42
+ constructor(host) {
43
+ Object.defineProperty(this, "server", {
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true,
47
+ value: void 0
48
+ });
49
+ Object.defineProperty(this, "taskStore", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: void 0
54
+ });
55
+ Object.defineProperty(this, "host", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: void 0
60
+ });
61
+ Object.defineProperty(this, "sigintHandler", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: void 0
66
+ });
67
+ Object.defineProperty(this, "currentLogLevel", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: 'info'
72
+ });
73
+ this.host = host;
74
+ const { taskStore, transportType, setupSigintHandler = true } = host.options;
75
+ // for stdio use in memory task store if not provided, otherwise use provided task store
76
+ if (transportType === 'stdio' && !taskStore) {
77
+ this.taskStore = new InMemoryTaskStore();
78
+ }
79
+ else if (taskStore) {
80
+ this.taskStore = taskStore;
81
+ }
82
+ else {
83
+ throw new Error('Task store must be provided for non-stdio transport types');
84
+ }
85
+ this.server = new Server(getServerInfo(), {
86
+ capabilities: {
87
+ tools: {
88
+ listChanged: true,
89
+ },
90
+ // Declare long-running task support
91
+ tasks: {
92
+ list: {},
93
+ cancel: {},
94
+ requests: {
95
+ tools: {
96
+ call: {},
97
+ },
98
+ },
99
+ },
100
+ // Declared but unused — some clients (e.g. Claude Desktop) fail without it.
101
+ resources: {},
102
+ prompts: {},
103
+ logging: {},
104
+ },
105
+ instructions: getServerInstructions(),
106
+ });
107
+ this.setupInitializeHandler();
108
+ this.setupLoggingProxy();
109
+ this.setupErrorHandling(setupSigintHandler);
110
+ this.setupLoggingHandlers();
111
+ this.setupToolHandlers();
112
+ this.setupPromptHandlers();
113
+ // Handle resource requests so clients like Claude Desktop don't fail.
114
+ this.setupResourceHandlers();
115
+ this.setupTaskHandlers();
116
+ }
117
+ /**
118
+ * Override the SDK's `initialize` handler to run mode resolution and pending-source flush
119
+ * before `InitializeResult` is sent. `server.oninitialized` won't do: the SDK dispatches
120
+ * notification handlers fire-and-forget, so a follow-up `tools/list` could race past them.
121
+ */
122
+ setupInitializeHandler() {
123
+ // Private-field access, verified against @modelcontextprotocol/sdk ^1.25.x. On SDK bumps,
124
+ // re-check `shared/protocol.js` for a still-named, delegable `_oninitialize`. If it changed,
125
+ // rebuild the InitializeResult here (protocolVersion, serverInfo, capabilities, instructions)
126
+ // instead of delegating. Capability-gating unit tests are the canary.
127
+ // eslint-disable-next-line no-underscore-dangle
128
+ const sdkInitHandler = this.server._oninitialize.bind(this.server);
129
+ this.server.setRequestHandler(InitializeRequestSchema, async (request) => {
130
+ await this.host.applyInitialize(request);
131
+ const result = await sdkInitHandler(request);
132
+ // Tools are final here (applyInitialize flushed pending tools, applying the per-client
133
+ // blocklist), so tool presence is the ground truth for whether to advertise
134
+ // report-problem in the instructions.
135
+ result.instructions = this.host.getServerInstructions();
136
+ return result;
137
+ });
138
+ }
139
+ setupErrorHandling(setupSIGINTHandler = true) {
140
+ this.server.onerror = (error) => {
141
+ var _a;
142
+ // Known client faults are expected noise, not server bugs — softFail so they don't
143
+ // flood Mezmo error alerts. The fault patterns live in utils/logging.ts.
144
+ const message = (_a = error.message) !== null && _a !== void 0 ? _a : '';
145
+ if (isMcpClientFaultMessage(message)) {
146
+ // Sanitize the errMessage value to preserve the soft-fail level (Mezmo promotes
147
+ // entries whose message contains "error").
148
+ log.softFail('MCP client fault, request could not be handled', {
149
+ errMessage: sanitizeMezmoMessage(message),
150
+ });
151
+ }
152
+ else {
153
+ log.error('[MCP Error]', { error });
154
+ }
155
+ };
156
+ if (setupSIGINTHandler) {
157
+ const handler = async () => {
158
+ await this.server.close();
159
+ process.exit(0);
160
+ };
161
+ process.once('SIGINT', handler);
162
+ this.sigintHandler = handler;
163
+ }
164
+ }
165
+ setupLoggingProxy() {
166
+ const originalSendLoggingMessage = this.server.sendLoggingMessage.bind(this.server);
167
+ // Filter outgoing log messages below the client's requested level.
168
+ this.server.sendLoggingMessage = async (params) => {
169
+ var _a, _b;
170
+ const messageLevelValue = (_a = LOG_LEVEL_MAP[params.level]) !== null && _a !== void 0 ? _a : -1; // Unknown levels get -1, discard
171
+ const currentLevelValue = (_b = LOG_LEVEL_MAP[this.currentLogLevel]) !== null && _b !== void 0 ? _b : LOG_LEVEL_MAP.info; // Default to info if invalid
172
+ if (messageLevelValue >= currentLevelValue) {
173
+ await originalSendLoggingMessage(params);
174
+ }
175
+ };
176
+ }
177
+ setupLoggingHandlers() {
178
+ this.server.setRequestHandler(SetLevelRequestSchema, (request) => {
179
+ const { level } = request.params;
180
+ if (LOG_LEVEL_MAP[level] !== undefined) {
181
+ this.currentLogLevel = level;
182
+ }
183
+ // Sending empty result based on MCP spec
184
+ return {};
185
+ });
186
+ }
187
+ setupResourceHandlers() {
188
+ const { resourceService } = this.host;
189
+ this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
190
+ return await resourceService.listResources();
191
+ });
192
+ this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
193
+ try {
194
+ return await resourceService.readResource(request.params.uri, this.host.resolveApifyClient(request.params));
195
+ }
196
+ catch (error) {
197
+ throw toLegacyMcpError(error);
198
+ }
199
+ });
200
+ this.server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => {
201
+ return await resourceService.listResourceTemplates();
202
+ });
203
+ }
204
+ /**
205
+ * Sets up MCP request handlers for prompts. The prompt service throws domain errors; the
206
+ * boundary maps them to `McpError` so wire output is unchanged.
207
+ */
208
+ setupPromptHandlers() {
209
+ const { promptService } = this.host;
210
+ this.server.setRequestHandler(ListPromptsRequestSchema, () => promptService.listPrompts());
211
+ this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
212
+ try {
213
+ return promptService.getPrompt(request.params.name, request.params.arguments);
214
+ }
215
+ catch (error) {
216
+ throw toLegacyMcpError(error);
217
+ }
218
+ });
219
+ }
220
+ /**
221
+ * Fetches a task by ID, softFail-logging and throwing a client-facing McpError if it doesn't exist.
222
+ */
223
+ async getTaskOrThrow(taskId, mcpSessionId, logTag) {
224
+ const task = await this.taskStore.getTask(taskId, mcpSessionId);
225
+ if (!task) {
226
+ // Client error (invalid/unknown taskId) — softFail to avoid polluting error logs.
227
+ log.softFail(`[${logTag}] Task not found`, { taskId, mcpSessionId, statusCode: 404 });
228
+ throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found`);
229
+ }
230
+ return task;
231
+ }
232
+ /**
233
+ * Sets up MCP request handlers for long-running tasks.
234
+ * Each handler reads `_meta.mcpSessionId` (injected at the transport layer) to isolate
235
+ * per-session task stores.
236
+ */
237
+ setupTaskHandlers() {
238
+ // List tasks
239
+ this.server.setRequestHandler(ListTasksRequestSchema, async (request) => {
240
+ var _a;
241
+ const params = (request.params || {});
242
+ const { cursor } = params;
243
+ const mcpSessionId = (_a = params._meta) === null || _a === void 0 ? void 0 : _a.mcpSessionId;
244
+ log.debug('[ListTasksRequestSchema] Listing tasks', { mcpSessionId });
245
+ const result = await this.taskStore.listTasks(cursor, mcpSessionId);
246
+ return { tasks: result.tasks, nextCursor: result.nextCursor };
247
+ });
248
+ // Get task status
249
+ this.server.setRequestHandler(GetTaskRequestSchema, async (request) => {
250
+ var _a;
251
+ const params = (request.params || {});
252
+ const { taskId } = params;
253
+ const mcpSessionId = (_a = params._meta) === null || _a === void 0 ? void 0 : _a.mcpSessionId;
254
+ log.debug('[GetTaskRequestSchema] Getting task status', { taskId, mcpSessionId });
255
+ return await this.getTaskOrThrow(taskId, mcpSessionId, 'GetTaskRequestSchema');
256
+ });
257
+ // Get task result payload
258
+ this.server.setRequestHandler(GetTaskPayloadRequestSchema, async (request) => {
259
+ var _a;
260
+ const params = (request.params || {});
261
+ const { taskId } = params;
262
+ const mcpSessionId = (_a = params._meta) === null || _a === void 0 ? void 0 : _a.mcpSessionId;
263
+ log.debug('[GetTaskPayloadRequestSchema] Getting task result', { taskId, mcpSessionId });
264
+ const task = await this.getTaskOrThrow(taskId, mcpSessionId, 'GetTaskPayloadRequestSchema');
265
+ if (task.status !== 'completed' && task.status !== 'failed') {
266
+ throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" is not completed yet. Current status: ${task.status}`);
267
+ }
268
+ const result = await this.taskStore.getTaskResult(taskId, mcpSessionId);
269
+ // taskId is not in the result body — _meta.related-task lets clients correlate them
270
+ return {
271
+ ...result,
272
+ _meta: {
273
+ ...result._meta,
274
+ [RELATED_TASK_META_KEY]: { taskId },
275
+ },
276
+ };
277
+ });
278
+ // Cancel task
279
+ this.server.setRequestHandler(CancelTaskRequestSchema, async (request) => {
280
+ var _a;
281
+ const params = (request.params || {});
282
+ const { taskId } = params;
283
+ const mcpSessionId = (_a = params._meta) === null || _a === void 0 ? void 0 : _a.mcpSessionId;
284
+ log.debug('[CancelTaskRequestSchema] Cancelling task', { taskId, mcpSessionId });
285
+ const task = await this.getTaskOrThrow(taskId, mcpSessionId, 'CancelTaskRequestSchema');
286
+ if (task.status === 'completed' || task.status === 'failed' || task.status === 'cancelled') {
287
+ // Client error (cancel on terminal task) — softFail to avoid polluting error logs.
288
+ log.softFail('[CancelTaskRequestSchema] Task already in terminal state', {
289
+ taskId,
290
+ mcpSessionId,
291
+ status: task.status,
292
+ statusCode: 409,
293
+ });
294
+ throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task "${taskId}" with status "${task.status}"`);
295
+ }
296
+ await this.taskStore.updateTaskStatus(taskId, 'cancelled', 'Cancelled by client', mcpSessionId);
297
+ const updatedTask = await this.taskStore.getTask(taskId, mcpSessionId);
298
+ log.debug('[CancelTaskRequestSchema] Task cancelled successfully', { taskId, mcpSessionId });
299
+ await emitTaskStatusNotification(taskId, mcpSessionId, this.taskStore, this.server);
300
+ return updatedTask;
301
+ });
302
+ }
303
+ setupToolHandlers() {
304
+ // Handles the request to list tools.
305
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => {
306
+ const tools = Array.from(this.host.tools.values()).map((tool) => getToolPublicFieldOnly(tool, {
307
+ mode: this.host.serverMode,
308
+ filterWidgetMeta: true,
309
+ }));
310
+ return { tools };
311
+ });
312
+ /**
313
+ * Handles the request to call a tool. `extra` carries request-scoped helpers such as
314
+ * `sendNotification`. Throws {@link McpError} to mirror the MCP SDK's McpServer error codes.
315
+ */
316
+ this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
317
+ var _a, _b, _c;
318
+ const params = request.params;
319
+ // Keep telemetry on the decoded arguments.
320
+ const { name, arguments: initialArgs, _meta: meta } = params;
321
+ let args = initialArgs;
322
+ const progressToken = meta === null || meta === void 0 ? void 0 : meta.progressToken;
323
+ const apifyToken = this.host.resolveApifyToken(meta);
324
+ // Injected upstream; required for long-running tasks — the task store keys on it and
325
+ // there is no other channel to pass it.
326
+ const mcpSessionId = meta === null || meta === void 0 ? void 0 : meta.mcpSessionId;
327
+ if (!mcpSessionId) {
328
+ log.error('MCP Session ID is missing in tool call request. This should never happen.');
329
+ throw new Error('MCP Session ID is required for tool calls');
330
+ }
331
+ const startTime = Date.now();
332
+ let toolStatus = TOOL_STATUS.SUCCEEDED;
333
+ let callDiagnostics = {};
334
+ let shouldTrackTelemetry = true;
335
+ let resolvedToolName = name;
336
+ // Set only on the pre-flight task path — the one task-mode flow whose telemetry rides
337
+ // this handler's `finally` — so its `Tool call completed` log line keeps the taskId the
338
+ // async path logs via finishTaskTracking.
339
+ let preflightTaskId;
340
+ // The nudge must be included in the measured result.
341
+ let toolResult = null;
342
+ // Keep actor context available to the outer catch.
343
+ let actorName;
344
+ let actorId;
345
+ const { clientContext, actorStore } = this.host;
346
+ const { paymentProvider, allowUnauthMode } = this.host.options;
347
+ // Plain values pulled from the host/request, threaded into the shared engine.
348
+ const { signal, sendNotification } = extra;
349
+ const emitLog = async (msg) => this.server.sendLoggingMessage(msg);
350
+ // Start with the raw name so early failures still have telemetry.
351
+ const { telemetryData, userId } = await prepareTelemetryData({
352
+ toolName: name,
353
+ mcpSessionId,
354
+ apifyToken,
355
+ clientContext,
356
+ telemetryEnabled: this.host.telemetryEnabled,
357
+ transportType: this.host.options.transportType,
358
+ });
359
+ try {
360
+ const prepared = await prepareToolCall({
361
+ apifyToken,
362
+ name,
363
+ args,
364
+ meta,
365
+ requestHeaders: (_a = extra.requestInfo) === null || _a === void 0 ? void 0 : _a.headers,
366
+ isTaskRequest: Boolean(request.params.task),
367
+ mcpSessionId,
368
+ telemetryData,
369
+ clientContext,
370
+ tools: this.host.tools,
371
+ paymentProvider,
372
+ allowUnauthMode,
373
+ signal,
374
+ });
375
+ if ('result' in prepared) {
376
+ // The engine already classified this post-resolution failure.
377
+ resolvedToolName = prepared.resolvedToolName;
378
+ args = prepared.decodedArgs;
379
+ toolStatus = prepared.toolStatus;
380
+ callDiagnostics = prepared.callDiagnostics;
381
+ toolResult = prepared.result;
382
+ return prepared.result;
383
+ }
384
+ if ('message' in prepared) {
385
+ // Reproduce v1's invalid-params tail and preserve telemetry fields.
386
+ resolvedToolName = (_b = prepared.resolvedToolName) !== null && _b !== void 0 ? _b : resolvedToolName;
387
+ if (prepared.decodedArgs)
388
+ args = prepared.decodedArgs;
389
+ toolStatus = prepared.toolStatus;
390
+ callDiagnostics = prepared.callDiagnostics;
391
+ log.softFail(prepared.message, {
392
+ mcpSessionId,
393
+ failureCategory: prepared.callDiagnostics.failure_category,
394
+ actorName: prepared.callDiagnostics.actor_name,
395
+ validationKeyword: prepared.callDiagnostics.validation_keyword,
396
+ validationPath: prepared.callDiagnostics.validation_path,
397
+ validationMissingProperty: prepared.callDiagnostics.validation_missing_property,
398
+ validationAdditionalProperty: prepared.callDiagnostics.validation_additional_property,
399
+ ...prepared.logFields,
400
+ });
401
+ await this.server.sendLoggingMessage({ level: 'error', data: prepared.message });
402
+ throw new McpError(ErrorCode.InvalidParams, prepared.message);
403
+ }
404
+ const { tool, toolArgs, logSafeArgs, apifyClient, standbyRejection, paymentRequiredResult } = prepared;
405
+ actorName = prepared.actorName;
406
+ actorId = prepared.actorId;
407
+ resolvedToolName = getToolFullName(tool);
408
+ // Telemetry uses the decoded arguments.
409
+ args = prepared.decodedArgs;
410
+ // TODO: we should split this huge method into smaller parts as it is slowly getting out of hand
411
+ // Handle long-running task request
412
+ if (request.params.task) {
413
+ const task = await this.taskStore.createTask({
414
+ ttl: request.params.task.ttl,
415
+ }, `call-tool-${name}-${randomUUID()}`, request, mcpSessionId);
416
+ log.debug('Created task for tool execution', {
417
+ taskId: task.taskId,
418
+ toolName: tool.name,
419
+ mcpSessionId,
420
+ });
421
+ // Pre-flight failure is already known — resolve the task synchronously: store
422
+ // the failure as the terminal `completed` result and emit exactly one status
423
+ // notification. Standby rejection wins over payment-required, matching the sync
424
+ // path. Telemetry rides the handler's outer `finally`.
425
+ const preflightResult = standbyRejection !== null && standbyRejection !== void 0 ? standbyRejection : paymentRequiredResult;
426
+ if (preflightResult) {
427
+ const outcome = buildPreflightFailureOutcome(standbyRejection, paymentRequiredResult, actorName, actorId);
428
+ toolStatus = outcome.toolStatus;
429
+ callDiagnostics = outcome.callDiagnostics;
430
+ preflightTaskId = task.taskId;
431
+ try {
432
+ await storeTaskResultOrSkipIfExpired(this.taskStore, tool.name, task.taskId, 'completed', outcome.result, mcpSessionId);
433
+ }
434
+ catch (error) {
435
+ // A store failure (not expiry) must surface as a protocol error — the
436
+ // generic catch would return a task-less result the client rejects.
437
+ // Correct the stale pre-flight SOFT_FAIL to FAILED before throwing.
438
+ toolStatus = TOOL_STATUS.FAILED;
439
+ callDiagnostics = {
440
+ failure_category: FAILURE_CATEGORY.INTERNAL_ERROR,
441
+ ...buildActorFields(actorName, actorId),
442
+ };
443
+ throw new McpError(ErrorCode.InternalError, `Failed to store the pre-flight result for task "${task.taskId}": ${error instanceof Error ? error.message : String(error)}`);
444
+ }
445
+ // Defer so the client learns the taskId before the terminal status
446
+ // notification. emitTaskStatusNotification never throws.
447
+ setImmediate(() => {
448
+ void emitTaskStatusNotification(task.taskId, mcpSessionId, this.taskStore, this.server);
449
+ });
450
+ // Measure the nudged result without changing the stored result.
451
+ toolResult = withReportProblemNudge({
452
+ result: outcome.result,
453
+ tools: this.host.tools,
454
+ failingToolName: resolvedToolName,
455
+ failureCategory: callDiagnostics.failure_category,
456
+ failureHttpStatus: callDiagnostics.failure_http_status,
457
+ });
458
+ // Synthesize the terminal status instead of re-fetching: if the task expired
459
+ // before the result store, a re-fetch would fall back to a stale `working`.
460
+ return { task: { ...task, status: 'completed' } };
461
+ }
462
+ // Execute the tool asynchronously and update task status
463
+ setImmediate(() => {
464
+ executeToolAndUpdateTask({
465
+ taskId: task.taskId,
466
+ tool,
467
+ toolArgs,
468
+ logSafeArgs,
469
+ apifyClient,
470
+ apifyToken,
471
+ progressToken,
472
+ mcpSessionId,
473
+ actorName,
474
+ actorId,
475
+ clientContext,
476
+ taskStore: this.taskStore,
477
+ server: this.server,
478
+ tools: this.host.tools,
479
+ actorStore,
480
+ paymentProvider,
481
+ telemetryEnabled: this.host.telemetryEnabled,
482
+ telemetryEnv: this.host.telemetryEnv,
483
+ transportType: this.host.options.transportType,
484
+ sendNotification,
485
+ }).catch((error) =>
486
+ // Benign task-expiry is handled in-method (see the catch block and
487
+ // storeTaskResultOrSkipIfExpired); anything reaching here is genuinely unexpected.
488
+ log.error('executeToolAndUpdateTask failed unexpectedly', { taskId: task.taskId, error }));
489
+ });
490
+ // Return the task immediately; execution continues asynchronously
491
+ shouldTrackTelemetry = false;
492
+ return { task };
493
+ }
494
+ // Sync path: run the shared dispatch tail and project its neutral outcome by identity.
495
+ const outcome = await executeSyncToolCall(prepared, {
496
+ apifyToken,
497
+ toolName: name,
498
+ mcpSessionId,
499
+ progressToken,
500
+ tools: this.host.tools,
501
+ actorStore,
502
+ paymentProvider,
503
+ signal,
504
+ sendNotification,
505
+ emitLog,
506
+ });
507
+ toolStatus = outcome.toolStatus;
508
+ callDiagnostics = outcome.callDiagnostics;
509
+ toolResult = outcome.result;
510
+ return outcome.result;
511
+ }
512
+ catch (error) {
513
+ // Match v1: classify task-creation failures, but re-throw protocol errors as JSON-RPC.
514
+ if (error instanceof McpError) {
515
+ throw error;
516
+ }
517
+ const outcome = classifyToolCallError(error, {
518
+ tools: this.host.tools,
519
+ toolName: name,
520
+ failingToolName: resolvedToolName,
521
+ actorName,
522
+ actorId,
523
+ isAborted: Boolean((_c = extra.signal) === null || _c === void 0 ? void 0 : _c.aborted),
524
+ mcpSessionId,
525
+ });
526
+ toolStatus = outcome.toolStatus;
527
+ callDiagnostics = outcome.callDiagnostics;
528
+ toolResult = outcome.result;
529
+ return outcome.result;
530
+ }
531
+ finally {
532
+ if (shouldTrackTelemetry) {
533
+ logToolCallAndTelemetry({
534
+ toolName: resolvedToolName,
535
+ mcpSessionId,
536
+ toolStatus,
537
+ startTime,
538
+ telemetryData,
539
+ userId,
540
+ callDiagnostics,
541
+ args,
542
+ result: toolResult,
543
+ taskId: preflightTaskId,
544
+ telemetryEnv: this.host.telemetryEnv,
545
+ });
546
+ }
547
+ }
548
+ });
549
+ }
550
+ async connect(transport) {
551
+ await this.server.connect(transport);
552
+ }
553
+ async close() {
554
+ if (this.sigintHandler) {
555
+ process.removeListener('SIGINT', this.sigintHandler);
556
+ this.sigintHandler = undefined;
557
+ }
558
+ // Closing the server also removes its event handlers.
559
+ await this.server.close();
560
+ }
561
+ }
562
+ //# sourceMappingURL=legacy_server.js.map
563
+ //# debugId=075c3e87-c2fb-5045-9a8c-5a25fbdafccf
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy_server.js","sources":["../../src/mcp/legacy_server.ts"],"sourceRoot":"","names":[],"mappings":"AAAA;;;;;GAKG;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kEAAkE,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,EACH,qBAAqB,EACrB,uBAAuB,EACvB,SAAS,EACT,sBAAsB,EACtB,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,kCAAkC,EAClC,sBAAsB,EACtB,sBAAsB,EACtB,QAAQ,EACR,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,GACxB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,GAAG,MAAM,YAAY,CAAC;AAG7B,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAWxE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,a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