@apify/actors-mcp-server 0.11.7-beta.0 → 0.11.7-beta.10

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 (118) hide show
  1. package/dist/const.d.ts +5 -5
  2. package/dist/const.d.ts.map +1 -1
  3. package/dist/const.js +5 -5
  4. package/dist/const.js.map +1 -1
  5. package/dist/index_internals.d.ts +7 -12
  6. package/dist/index_internals.d.ts.map +1 -1
  7. package/dist/index_internals.js +6 -11
  8. package/dist/index_internals.js.map +1 -1
  9. package/dist/mcp/actors.d.ts +0 -4
  10. package/dist/mcp/actors.d.ts.map +1 -1
  11. package/dist/mcp/actors.js +0 -13
  12. package/dist/mcp/actors.js.map +1 -1
  13. package/dist/mcp/server.d.ts +16 -17
  14. package/dist/mcp/server.d.ts.map +1 -1
  15. package/dist/mcp/server.js +204 -442
  16. package/dist/mcp/server.js.map +1 -1
  17. package/dist/mcp/tool_call_error_mapper.d.ts +45 -0
  18. package/dist/mcp/tool_call_error_mapper.d.ts.map +1 -0
  19. package/dist/mcp/tool_call_error_mapper.js +59 -0
  20. package/dist/mcp/tool_call_error_mapper.js.map +1 -0
  21. package/dist/mcp/tool_call_telemetry.d.ts +37 -0
  22. package/dist/mcp/tool_call_telemetry.d.ts.map +1 -0
  23. package/dist/mcp/tool_call_telemetry.js +85 -0
  24. package/dist/mcp/tool_call_telemetry.js.map +1 -0
  25. package/dist/mcp/tool_dispatch.d.ts +49 -0
  26. package/dist/mcp/tool_dispatch.d.ts.map +1 -0
  27. package/dist/mcp/tool_dispatch.js +208 -0
  28. package/dist/mcp/tool_dispatch.js.map +1 -0
  29. package/dist/payments/const.d.ts +1 -0
  30. package/dist/payments/const.d.ts.map +1 -1
  31. package/dist/payments/const.js +1 -0
  32. package/dist/payments/const.js.map +1 -1
  33. package/dist/payments/skyfire.d.ts.map +1 -1
  34. package/dist/payments/skyfire.js +5 -6
  35. package/dist/payments/skyfire.js.map +1 -1
  36. package/dist/resources/api_resources.d.ts +37 -0
  37. package/dist/resources/api_resources.d.ts.map +1 -0
  38. package/dist/resources/api_resources.js +255 -0
  39. package/dist/resources/api_resources.js.map +1 -0
  40. package/dist/resources/resource_service.d.ts +4 -3
  41. package/dist/resources/resource_service.d.ts.map +1 -1
  42. package/dist/resources/resource_service.js +52 -7
  43. package/dist/resources/resource_service.js.map +1 -1
  44. package/dist/tools/actors/call_actor.d.ts +0 -3
  45. package/dist/tools/actors/call_actor.d.ts.map +1 -1
  46. package/dist/tools/actors/call_actor.js +2 -11
  47. package/dist/tools/actors/call_actor.js.map +1 -1
  48. package/dist/tools/actors/fetch_actor_details.d.ts +1 -7
  49. package/dist/tools/actors/fetch_actor_details.d.ts.map +1 -1
  50. package/dist/tools/actors/fetch_actor_details.js +14 -22
  51. package/dist/tools/actors/fetch_actor_details.js.map +1 -1
  52. package/dist/tools/actors/search_actors.d.ts +1 -6
  53. package/dist/tools/actors/search_actors.d.ts.map +1 -1
  54. package/dist/tools/actors/search_actors.js +17 -24
  55. package/dist/tools/actors/search_actors.js.map +1 -1
  56. package/dist/tools/dev/report_problem.d.ts +13 -0
  57. package/dist/tools/dev/report_problem.d.ts.map +1 -1
  58. package/dist/tools/dev/report_problem.js +14 -0
  59. package/dist/tools/dev/report_problem.js.map +1 -1
  60. package/dist/tools/docs/search_apify_docs.d.ts.map +1 -1
  61. package/dist/tools/docs/search_apify_docs.js +1 -0
  62. package/dist/tools/docs/search_apify_docs.js.map +1 -1
  63. package/dist/tools/runs/get_actor_run.d.ts +1 -6
  64. package/dist/tools/runs/get_actor_run.d.ts.map +1 -1
  65. package/dist/tools/runs/get_actor_run.js +17 -24
  66. package/dist/tools/runs/get_actor_run.js.map +1 -1
  67. package/dist/tools/storage/get_dataset.d.ts.map +1 -1
  68. package/dist/tools/storage/get_dataset.js +6 -5
  69. package/dist/tools/storage/get_dataset.js.map +1 -1
  70. package/dist/tools/storage/get_dataset_items.d.ts.map +1 -1
  71. package/dist/tools/storage/get_dataset_items.js +6 -8
  72. package/dist/tools/storage/get_dataset_items.js.map +1 -1
  73. package/dist/tools/storage/get_dataset_list.d.ts.map +1 -1
  74. package/dist/tools/storage/get_dataset_list.js +8 -9
  75. package/dist/tools/storage/get_dataset_list.js.map +1 -1
  76. package/dist/tools/storage/get_dataset_schema.d.ts.map +1 -1
  77. package/dist/tools/storage/get_dataset_schema.js +6 -4
  78. package/dist/tools/storage/get_dataset_schema.js.map +1 -1
  79. package/dist/tools/storage/get_key_value_store.js +3 -3
  80. package/dist/tools/storage/get_key_value_store.js.map +1 -1
  81. package/dist/tools/storage/get_key_value_store_keys.js +4 -4
  82. package/dist/tools/storage/get_key_value_store_keys.js.map +1 -1
  83. package/dist/tools/storage/get_key_value_store_list.d.ts.map +1 -1
  84. package/dist/tools/storage/get_key_value_store_list.js +8 -9
  85. package/dist/tools/storage/get_key_value_store_list.js.map +1 -1
  86. package/dist/tools/storage/get_key_value_store_record.d.ts.map +1 -1
  87. package/dist/tools/storage/get_key_value_store_record.js +12 -9
  88. package/dist/tools/storage/get_key_value_store_record.js.map +1 -1
  89. package/dist/tools/storage/storage_helpers.d.ts +27 -0
  90. package/dist/tools/storage/storage_helpers.d.ts.map +1 -1
  91. package/dist/tools/storage/storage_helpers.js +21 -1
  92. package/dist/tools/storage/storage_helpers.js.map +1 -1
  93. package/dist/tsconfig.tsbuildinfo +1 -1
  94. package/dist/types.d.ts +0 -11
  95. package/dist/types.d.ts.map +1 -1
  96. package/dist/types.js.map +1 -1
  97. package/dist/utils/actor_details.d.ts.map +1 -1
  98. package/dist/utils/actor_details.js +10 -3
  99. package/dist/utils/actor_details.js.map +1 -1
  100. package/dist/utils/logging.d.ts +2 -0
  101. package/dist/utils/logging.d.ts.map +1 -1
  102. package/dist/utils/logging.js +45 -1
  103. package/dist/utils/logging.js.map +1 -1
  104. package/dist/utils/mcp.d.ts +6 -0
  105. package/dist/utils/mcp.d.ts.map +1 -1
  106. package/dist/utils/mcp.js +15 -8
  107. package/dist/utils/mcp.js.map +1 -1
  108. package/dist/utils/payment_errors.d.ts +7 -1
  109. package/dist/utils/payment_errors.d.ts.map +1 -1
  110. package/dist/utils/payment_errors.js +10 -0
  111. package/dist/utils/payment_errors.js.map +1 -1
  112. package/dist/utils/server-instructions/index.d.ts.map +1 -1
  113. package/dist/utils/server-instructions/index.js +10 -0
  114. package/dist/utils/server-instructions/index.js.map +1 -1
  115. package/dist/web/dist/actor-run-widget.js +0 -3
  116. package/dist/web/dist/search-actors-widget.js +0 -3
  117. package/package.json +2 -2
  118. package/dist/web/dist/actor-detail-widget.js +0 -4551
@@ -0,0 +1,208 @@
1
+ import { CallToolResultSchema, ErrorCode, McpError, ServerNotificationSchema, } from '@modelcontextprotocol/sdk/types.js';
2
+ import dedent from 'dedent';
3
+ import log from '@apify/log';
4
+ import { FAILURE_CATEGORY, TOOL_STATUS } from '../const.js';
5
+ import { actorExecutor } from '../tools/actors/actor_executor.js';
6
+ import { TOOL_TYPE } from '../types.js';
7
+ import { remoteMcpFailureDetail } from '../utils/apify_errors.js';
8
+ import { logHttpError } from '../utils/logging.js';
9
+ import { respondErrorNoTelemetry } from '../utils/mcp.js';
10
+ import { applyToolTelemetry, classifyFailureCategory, getToolStatusFromError } from '../utils/tool_status.js';
11
+ import { buildActorFields } from '../utils/tools.js';
12
+ import { connectMCPClient } from './client.js';
13
+ import { EXTERNAL_TOOL_CALL_TIMEOUT_MSEC } from './const.js';
14
+ /**
15
+ * Runs a validated tool call through the single tool-type dispatch switch and returns the raw
16
+ * result plus derived telemetry. The exhaustive switch turns a future 4th TOOL_TYPE into a compile
17
+ * error (same `satisfies never` idiom as getToolFullName) instead of a silent runtime fall-through.
18
+ * Both the sync `CallToolRequestSchema` handler and `executeToolAndUpdateTask` call this after their
19
+ * own pre-dispatch validation and keep their own try/catch + buildToolCallErrorResult around it.
20
+ * INTERNAL and ACTOR execution errors propagate to the caller's catch; the ACTOR_MCP case keeps its
21
+ * own inner catch and returns a soft-fail result instead of throwing.
22
+ *
23
+ * `extractToolTelemetry` (via `applyToolTelemetry`) runs once here, in the INTERNAL and ACTOR
24
+ * cases, and strips `toolTelemetry` in place, so callers must not re-strip. ACTOR_MCP sets
25
+ * telemetry manually instead. The caller constructs `progressTracker`; dispatch consumes it and stops
26
+ * it in the branch `finally`. The abort source is `extra.signal`: the request signal for sync; the
27
+ * task caller passes a `taskExtra` whose `signal` is the cancel watcher's, so a client disconnect
28
+ * never cancels a task. `shouldForwardNotifications` gates only the ACTOR_MCP raw-notification
29
+ * forwarder (true for sync, false for task, whose originating request is already answered).
30
+ * `taskMode` is a passthrough to `tool.call` / `executeActorTool`, never a dispatch selector.
31
+ */
32
+ export async function dispatchToolCall(params) {
33
+ var _a, _b, _c, _d;
34
+ const { tool, toolArgs, logSafeArgs, apifyToken, apifyClient, apifyMcpServer, mcpSessionId, progressToken, progressTracker, shouldForwardNotifications, extra, actorName, actorId, taskMode, logContext, } = params;
35
+ let result = {};
36
+ let toolStatus = TOOL_STATUS.SUCCEEDED;
37
+ // Always populate actor fields so they're tracked on both success and failure paths.
38
+ let callDiagnostics = { ...buildActorFields(actorName, actorId) };
39
+ switch (tool.type) {
40
+ case TOOL_TYPE.INTERNAL: {
41
+ try {
42
+ log.info(`Calling internal tool${(_a = logContext === null || logContext === void 0 ? void 0 : logContext.messageSuffix) !== null && _a !== void 0 ? _a : ''}`, {
43
+ ...logContext === null || logContext === void 0 ? void 0 : logContext.fields,
44
+ toolName: tool.name,
45
+ mcpSessionId,
46
+ input: logSafeArgs,
47
+ });
48
+ const res = (await tool.call({
49
+ args: toolArgs,
50
+ extra,
51
+ apifyMcpServer,
52
+ mcpServer: apifyMcpServer.server,
53
+ apifyToken,
54
+ apifyClient,
55
+ progressTracker,
56
+ mcpSessionId,
57
+ taskMode,
58
+ }));
59
+ // Extract diagnostics and strip internal fields from res before returning to client.
60
+ ({ toolStatus, callDiagnostics } = applyToolTelemetry(res, actorName, actorId, callDiagnostics));
61
+ result = res;
62
+ }
63
+ finally {
64
+ progressTracker === null || progressTracker === void 0 ? void 0 : progressTracker.stop();
65
+ }
66
+ break;
67
+ }
68
+ case TOOL_TYPE.ACTOR_MCP: {
69
+ // This case never throws: connect/exec failures resolve to a soft-fail `result`
70
+ // (isError body) below instead. As a task, that means the outer completeTask
71
+ // stores it via the 'completed' path (isError body) — deliberately matching sync's
72
+ // own soft-fail semantics, unlike ACTOR/INTERNAL, whose thrown errors land in the
73
+ // task caller's 'failed' path.
74
+ let client = null;
75
+ try {
76
+ client = await connectMCPClient(tool.serverUrl, apifyToken, mcpSessionId);
77
+ if (!client) {
78
+ const msg = dedent `
79
+ Failed to connect to MCP server at "${tool.serverUrl}".
80
+ Please verify the server URL is correct and accessible, and ensure you have a valid Apify token with appropriate permissions.
81
+ `;
82
+ log.softFail(msg, { mcpSessionId, failureCategory: FAILURE_CATEGORY.INTERNAL_ERROR });
83
+ await apifyMcpServer.server.sendLoggingMessage({ level: 'error', data: msg });
84
+ toolStatus = TOOL_STATUS.SOFT_FAIL;
85
+ callDiagnostics = { ...callDiagnostics, failure_category: FAILURE_CATEGORY.INTERNAL_ERROR };
86
+ result = respondErrorNoTelemetry(msg);
87
+ break;
88
+ }
89
+ // Only set up notification handlers if progressToken is provided by the client.
90
+ // Gated off for tasks (shouldForwardNotifications=false): the originating request is
91
+ // already answered, so forwarding against its progressToken would misroute.
92
+ if (shouldForwardNotifications && progressToken !== undefined && progressToken !== null) {
93
+ // Set up notification handlers for the client
94
+ for (const schema of ServerNotificationSchema.options) {
95
+ const method = schema.shape.method.value;
96
+ // Forward notifications from the proxy client to the server
97
+ client.setNotificationHandler(schema, async (notification) => {
98
+ log.debug('Sending MCP notification', {
99
+ method,
100
+ mcpSessionId,
101
+ notification,
102
+ });
103
+ await extra.sendNotification(notification);
104
+ });
105
+ }
106
+ }
107
+ log.info(`Calling Actor-MCP${(_b = logContext === null || logContext === void 0 ? void 0 : logContext.messageSuffix) !== null && _b !== void 0 ? _b : ''}`, {
108
+ ...logContext === null || logContext === void 0 ? void 0 : logContext.fields,
109
+ toolName: tool.name,
110
+ actorMcpToolName: tool.originToolName,
111
+ actorId: tool.actorId,
112
+ mcpSessionId,
113
+ input: logSafeArgs,
114
+ });
115
+ const res = await client.callTool({
116
+ name: tool.originToolName,
117
+ arguments: toolArgs,
118
+ // Without forwarding there is no route back for remote progress — don't
119
+ // hand the remote a token nobody listens to.
120
+ ...(shouldForwardNotifications ? { _meta: { progressToken } } : {}),
121
+ }, CallToolResultSchema, {
122
+ timeout: EXTERNAL_TOOL_CALL_TIMEOUT_MSEC,
123
+ });
124
+ // TODO: actor-mcp responses are opaque — isError could be a user input problem
125
+ // (e.g. invalid query) or a genuine server failure. We can't distinguish without
126
+ // parsing the error text. Defaulting to INTERNAL_ERROR for now; revisit when
127
+ // actor-mcp gets deeper telemetry treatment.
128
+ if ('isError' in res && res.isError) {
129
+ toolStatus = TOOL_STATUS.SOFT_FAIL;
130
+ callDiagnostics = {
131
+ failure_category: FAILURE_CATEGORY.INTERNAL_ERROR,
132
+ ...buildActorFields(actorName, actorId),
133
+ };
134
+ }
135
+ result = { ...res };
136
+ }
137
+ catch (error) {
138
+ toolStatus = getToolStatusFromError(error, Boolean((_c = extra.signal) === null || _c === void 0 ? void 0 : _c.aborted));
139
+ const failureDetail = error instanceof Error ? error.message.slice(0, 200) : String(error).slice(0, 200);
140
+ callDiagnostics = {
141
+ failure_category: classifyFailureCategory(error),
142
+ failure_detail: failureDetail,
143
+ ...buildActorFields(actorName, actorId),
144
+ };
145
+ logHttpError(error, `Failed to call MCP tool '${tool.originToolName}' on Actor '${tool.actorId}'`, {
146
+ actorId: tool.actorId,
147
+ toolName: tool.originToolName,
148
+ failureCategory: callDiagnostics.failure_category,
149
+ });
150
+ result = respondErrorNoTelemetry(`Failed to call MCP tool '${tool.originToolName}' on Actor '${tool.actorId}': ${remoteMcpFailureDetail(error)}`);
151
+ }
152
+ finally {
153
+ if (client)
154
+ await client.close();
155
+ }
156
+ break;
157
+ }
158
+ case TOOL_TYPE.ACTOR: {
159
+ try {
160
+ log.info(`Calling Actor${(_d = logContext === null || logContext === void 0 ? void 0 : logContext.messageSuffix) !== null && _d !== void 0 ? _d : ''}`, {
161
+ ...logContext === null || logContext === void 0 ? void 0 : logContext.fields,
162
+ toolName: tool.name,
163
+ actorName: tool.actorFullName,
164
+ mcpSessionId,
165
+ input: logSafeArgs,
166
+ });
167
+ const executorResult = await actorExecutor.executeActorTool({
168
+ actorFullName: tool.actorFullName,
169
+ input: toolArgs,
170
+ apifyClient,
171
+ callOptions: { memory: tool.memoryMbytes },
172
+ progressTracker,
173
+ abortSignal: extra.signal,
174
+ mcpSessionId,
175
+ datasetItemsSchema: tool.datasetItemsSchema,
176
+ taskMode,
177
+ });
178
+ if (!executorResult) {
179
+ toolStatus = TOOL_STATUS.ABORTED;
180
+ // Receivers of cancellation notifications SHOULD NOT send a response for the cancelled request
181
+ // https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/cancellation#behavior-requirements
182
+ result = {};
183
+ break;
184
+ }
185
+ // Mirror the INTERNAL branch: read the telemetry the executor embedded on error
186
+ // results (e.g. respondUserError → SOFT_FAIL/INVALID_INPUT), strip it from the wire,
187
+ // and set failure_category so the report-problem nudge picks the softer variant.
188
+ ({ toolStatus, callDiagnostics } = applyToolTelemetry(executorResult, actorName, actorId, callDiagnostics));
189
+ result = executorResult;
190
+ }
191
+ finally {
192
+ if (progressTracker) {
193
+ progressTracker.stop();
194
+ }
195
+ }
196
+ break;
197
+ }
198
+ default:
199
+ // Exhaustiveness guard mirroring getToolFullName: a new TOOL_TYPE member makes `tool`
200
+ // non-`never` here and fails `satisfies never` at compile time. Unreachable at runtime —
201
+ // ToolEntry is a closed 3-way union. Unlike the pre-extraction fall-through (which also
202
+ // listed available tools, called log.softFail, and sent a logging message before
203
+ // throwing), this just throws InvalidParams with no side effects.
204
+ throw new McpError(ErrorCode.InvalidParams, `Unknown tool type "${tool.type}"`);
205
+ }
206
+ return { result, toolStatus, callDiagnostics };
207
+ }
208
+ //# sourceMappingURL=tool_dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool_dispatch.js","sourceRoot":"","sources":["../../src/mcp/tool_dispatch.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,oBAAoB,EACpB,SAAS,EACT,QAAQ,EACR,wBAAwB,GAC3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,GAAG,MAAM,YAAY,CAAC;AAG7B,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAC9G,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAG7D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAkBtC;;IACG,MAAM,EACF,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,UAAU,EACV,WAAW,EACX,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,EACf,0BAA0B,EAC1B,KAAK,EACL,SAAS,EACT,OAAO,EACP,QAAQ,EACR,UAAU,GACb,GAAG,MAAM,CAAC;IAEX,IAAI,MAAM,GAA4B,EAAE,CAAC;IACzC,IAAI,UAAU,GAAe,WAAW,CAAC,SA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,EAAE,IAAI,CAAC,aAAa;oBACjC,KAAK,EAAE,QAAQ;oBACf,WAAW;oBACX,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE;oBAC1C,eAAe;oBACf,WAAW,EAAE,KAAK,CAAC,MAAM;oBACzB,YAAY;oBACZ,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;oBAC3C,QAAQ;iBACX,CAAC,CAAC;gBAEH,IAAI,CAAC,cAAc,EAAE,CAAC;oBAClB,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC;oBACjC,+FAA+F;oBAC/F,8GAA8G;oBAC9G,MAAM,GAAG,EAAE,CAAC;oBACZ,MAAM;gBACV,CAAC;gBAED,gFAAgF;gBAChF,qFAAqF;gBACrF,iFAAiF;gBACjF,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,kBAAkB,CACjD,cAAyC,EACzC,SAAS,EACT,OAAO,EACP,eAAe,CAClB,CAAC,CAAC;gBACH,MAAM,GAAG,cAAc,CAAC;YAC5B,CAAC;oBAAS,CAAC;gBACP,IAAI,eAAe,EAAE,CAAC;oBAClB,eAAe,CAAC,IAAI,EAAE,CAAC;gBAC3B,CAAC;YACL,CAAC;YACD,MAAM;QACV,CAAC;QAED;YACI,sFAAsF;YACtF,yFAAyF;YACzF,wFAAwF;YACxF,iFAAiF;YACjF,kEAAkE;YAClE,MAAM,IAAI,QAAQ,CACd,SAAS,CAAC,aAAa,EACvB,sBAAuB,IAAkC,CAAC,IAAI,GAAG,CACpE,CAAC;IACV,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AACnD,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { type HelperToolName } from '../const.js';
2
2
  export declare const PAYMENT_PROTOCOL_HEADER = "x-apify-payment-protocol";
3
+ export declare const SKYFIRE_PAY_ID_KEY = "skyfire-pay-id";
3
4
  export declare const SKYFIRE_TOOL_INSTRUCTIONS: string;
4
5
  export declare const SKYFIRE_PAY_ID_PROPERTY_DESCRIPTION = "Skyfire PAY JWT token used for billing purposes. This must be the JWT token string returned by the create-pay-token tool (starts with \"ey\"), NOT a token ID or UUID.";
5
6
  export declare const SKYFIRE_README_CONTENT: string;
@@ -1 +1 @@
1
- {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../src/payments/const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAEhE,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAKlE,eAAO,MAAM,yBAAyB,QAAi2B,CAAC;AAEx4B,eAAO,MAAM,mCAAmC,2KAAyK,CAAC;AAE1N,eAAO,MAAM,sBAAsB,QAAs8B,CAAC;AAE1+B;;;GAGG;AACH,eAAO,MAAM,qBAAqB,qBAWhC,CAAC"}
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../src/payments/const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAEhE,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAKlE,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AAEnD,eAAO,MAAM,yBAAyB,QAAi2B,CAAC;AAEx4B,eAAO,MAAM,mCAAmC,2KAAyK,CAAC;AAE1N,eAAO,MAAM,sBAAsB,QAAs8B,CAAC;AAE1+B;;;GAGG;AACH,eAAO,MAAM,qBAAqB,qBAWhC,CAAC"}
@@ -2,6 +2,7 @@ import { HELPER_TOOLS } from '../const.js';
2
2
  export const PAYMENT_PROTOCOL_HEADER = 'x-apify-payment-protocol';
3
3
  const SKYFIRE_MIN_CHARGE_USD = 5.0;
4
4
  const SKYFIRE_SELLER_ID = process.env.SKYFIRE_SELLER_SERVICE_ID;
5
+ export const SKYFIRE_PAY_ID_KEY = 'skyfire-pay-id';
5
6
  export const SKYFIRE_TOOL_INSTRUCTIONS = `To run the Actor, you need to provide a Skyfire PAY JWT token in the \`skyfire-pay-id\` input property. You first need to create the Skyfire PAY token by calling the \`create-pay-token\` tool from the Skyfire MCP server and then provide the created JWT token in the \`skyfire-pay-id\` input property when calling Actor tool. IMPORTANT: The value you pass to \`skyfire-pay-id\` must be the JWT token string itself (it starts with "ey"), NOT an ID or UUID. The Skyfire PAY token is used for billing purposes and needs to be charged with at least ${SKYFIRE_MIN_CHARGE_USD} USD.${SKYFIRE_SELLER_ID ? ` The Skyfire seller ID for Apify MCP server is "${SKYFIRE_SELLER_ID}".` : ''} When retrieving Actor output using the \`get-dataset-items\` tool, you also need to provide the same Skyfire PAY JWT token (starting with "ey") in the \`skyfire-pay-id\` input property.`;
6
7
  export const SKYFIRE_PAY_ID_PROPERTY_DESCRIPTION = `Skyfire PAY JWT token used for billing purposes. This must be the JWT token string returned by the create-pay-token tool (starts with "ey"), NOT a token ID or UUID.`;
7
8
  export const SKYFIRE_README_CONTENT = `The Apify MCP Server allows clients to interact with Apify Actors, storage, and documentation. Before running any Apify Actor, you need to set up a Skyfire PAY token for billing purposes. To set up the PAY token you need to use the create-pay-token tool from the Skyfire MCP server. The PAY token must be charged with a minimum of ${SKYFIRE_MIN_CHARGE_USD} USD to be valid.${SKYFIRE_SELLER_ID ? ` The Skyfire seller ID for Apify MCP server is "${SKYFIRE_SELLER_ID}".` : ''} When running an Actor using the call-actor tool, you must provide the Skyfire PAY JWT token in the \`skyfire-pay-id\` input property. IMPORTANT: The value for \`skyfire-pay-id\` must be the actual JWT token string (starting with "ey") returned by the create-pay-token tool, NOT a token ID or UUID. Similarly, when retrieving Actor output using the get-dataset-items tool, you must also provide the same Skyfire PAY JWT token (starting with "ey") in the \`skyfire-pay-id\` input property.`;
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/payments/const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,aAAa,CAAC;AAEhE,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAElE,MAAM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c;IAWhE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAK3E,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;CAO3C"}
1
+ {"version":3,"file":"skyfire.d.ts","sourceRoot":"","sources":["../../src/payments/skyfire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAU7C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAC1D,QAAQ,CAAC,EAAE,EAAG,SAAS,CAAU;IACjC,QAAQ,CAAC,qBAAqB,QAAQ;WAEzB,MAAM,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAItD,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS;IAwB9C,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI;IAO7D,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc;IAWhE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAK3E,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;CAO3C"}
@@ -1,7 +1,6 @@
1
1
  import { redactSkyfirePayId } from '../utils/logging.js';
2
2
  import { cloneToolEntry } from '../utils/tools.js';
3
- import { PAYMENT_PROTOCOL_HEADER, SKYFIRE_PAY_ID_PROPERTY_DESCRIPTION, SKYFIRE_README_CONTENT, SKYFIRE_TOOL_INSTRUCTIONS, } from './const.js';
4
- const SKYFIRE_PAY_ID_KEY = 'skyfire-pay-id';
3
+ import { PAYMENT_PROTOCOL_HEADER, SKYFIRE_PAY_ID_KEY, SKYFIRE_PAY_ID_PROPERTY_DESCRIPTION, SKYFIRE_README_CONTENT, SKYFIRE_TOOL_INSTRUCTIONS, } from './const.js';
5
4
  /**
6
5
  * Skyfire payment provider.
7
6
  *
@@ -70,10 +69,10 @@ export class SkyfirePaymentProvider {
70
69
  return SKYFIRE_README_CONTENT;
71
70
  }
72
71
  redactForLogging(args) {
73
- // TODO: redactSkyfirePayId is still exported and used directly by the internal MCP server repo.
74
- // Once the internal repo migrates to using `paymentProvider.redactForLogging()`, we should
75
- // remove the standalone function and centralize the redaction logic entirely inside this provider
76
- // to make it more maintainable.
72
+ // TODO: redactSkyfirePayId is still used directly by other in-repo callers
73
+ // (e.g. tools/actors/actor_executor.ts). Once those callers migrate to
74
+ // `paymentProvider.redactForLogging()`, remove the standalone function and
75
+ // centralize the redaction logic entirely inside this provider.
77
76
  return redactSkyfirePayId(args);
78
77
  }
79
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"skyfire.js","sourceRoot":"","sources":["../../src/payments/skyfire.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACH,uBAAuB,EACvB,mCAAmC,EACnC,sBAAsB,EACtB,yBAAyB,GAC5B,MAAM,YAAY,CAAC;AAGpB,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAAnC;QACa;;;;mBAAK,SAAkB;WAAC;QACxB;;;;mBAAwB,IAAI;WAAC;IAgE1C,CAAC;IA9DG,MAAM,CAAC,KAAK,CAAC,MAAM;QACf,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACxC,CAAC;IAED,kBAAkB,CAAC,IAAe;QAC9B,IAAI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AM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,UAAqC,CAAC;YACvE,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBAC7B,KAAK,CAAC,kBAAkB,CAAC,GAAG;oBACxB,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,mCAAmC;iBACnD,CAAC;YACN,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,eAAe,CAAC,IAA6B;QACzC,IAAI,IAAI,CAAC,kBAAkB,CAAC,KAAK,SAAS,EAAE,CAAC;YACzC,OAAO,qBAAqB,kBAAkB,yFAAyF,kBAAkB,IAAI,CAAC;QAClK,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,iBAAiB,CAAC,IAA6B;QAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO;gBACH,CAAC,kBAAkB,CAAC,EAAE,KAAK;gBAC3B,CAAC,uBAAuB,CAAC,EAAE,SAAS;aACvC,CAAC;QACN,CAAC;QACD,OAAO,EAAE,CAAC;IACd,CAAC;IAED,mBAAmB,CAAC,IAA6B;QAC7C,MAAM,EAAE,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QACzD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,aAAa;QACT,OAAO,sBAAsB,CAAC;IAClC,CAAC;IAED,gBAAgB,CAAC,IAAa;QAC1B,2EAA2E;QAC3E,uEAAuE;QACvE,2EAA2E;QAC3E,gEAAgE;QAChE,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACJ"}
@@ -0,0 +1,37 @@
1
+ import type { ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { ApifyClient } from '../apify_client.js';
3
+ /**
4
+ * True when the URI is an Apify API URL (same origin as the configured API base).
5
+ *
6
+ * This is the security gate for the generic read proxy: the apify-client attaches the
7
+ * session token as an `Authorization` header to every outbound request, so we must only
8
+ * hand it Apify API URLs — never an arbitrary host. Userinfo-bearing URLs
9
+ * (`user@api.apify.com`) are rejected even when the host is genuinely ours: axios drops
10
+ * the default `Authorization` header for credentials-bearing URLs, so the read would
11
+ * silently run unauthenticated.
12
+ */
13
+ export declare function isApifyApiUri(uri: string): boolean;
14
+ /**
15
+ * Read any Apify API GET endpoint as an MCP resource.
16
+ *
17
+ * A thin streaming proxy: the apify-client injects the session token (and the MCP-origin header),
18
+ * the body streams in verbatim and is returned by its declared Content-Type — textual types
19
+ * (text/*, JSON, XML) as `text`, anything else as a base64 `blob`. The body is never parsed, so
20
+ * JSON primitives, formatting, and bytes round-trip exactly.
21
+ *
22
+ * Genuine failures (no token, bad origin, a missing resource, a bad token, a 5xx, a network error)
23
+ * throw an `McpError` so the SDK returns a JSON-RPC error rather than success-shaped content for an
24
+ * unreadable resource (see SEP-2164). A body over `MAX_INLINE_BYTES` is NOT a failure — it is a
25
+ * successful read returning a download pointer.
26
+ *
27
+ * The request goes straight through `apifyClient.httpClient.axios` (the same axios instance
28
+ * apify-client builds internally, so token/origin headers still apply) instead of
29
+ * `httpClient.call()`: with `responseType: 'stream'`, a non-2xx reaches `call()` as an unconsumed
30
+ * stream — its `ApifyApiError` message degrades to junk and each retry attempt strands an unread
31
+ * socket. One attempt, no retries. `maxContentLength` is enforced by axios itself mid-consumption
32
+ * (verified in axios@1.16.1: the adapter wraps streamed responses in a byte-counting generator
33
+ * that throws `ERR_BAD_RESPONSE` when the decoded size crosses the limit), so an oversized body
34
+ * is aborted at ~`MAX_INLINE_BYTES`, never buffered whole.
35
+ */
36
+ export declare function readApiResource(uri: string, apifyClient?: ApifyClient): Promise<ReadResourceResult>;
37
+ //# sourceMappingURL=api_resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api_resources.d.ts","sourceRoot":"","sources":["../../src/resources/api_resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,kBAAkB,EAErB,MAAM,oCAAoC,CAAC;AAI5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA2CtD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQlD;AAkGD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA2FzG"}
@@ -0,0 +1,255 @@
1
+ import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
2
+ import { isAxiosError } from 'axios';
3
+ import { getApifyAPIBaseUrl } from '../apify_client.js';
4
+ import { MAX_INLINE_BYTES } from '../const.js';
5
+ import { parseBaseMimeType } from '../tools/storage/storage_helpers.js';
6
+ import { getHttpStatusCode, logHttpError } from '../utils/logging.js';
7
+ import { getHttpErrorHint } from '../utils/mcp.js';
8
+ const TEXT_MIME_TYPE = 'text/plain';
9
+ /** Textual base MIME types (returned as `text`); everything else becomes a base64 `blob`. */
10
+ function isTextualMimeType(baseMimeType) {
11
+ if (!baseMimeType)
12
+ return false;
13
+ return (baseMimeType.startsWith('text/') ||
14
+ baseMimeType === 'application/json' ||
15
+ baseMimeType.endsWith('+json') ||
16
+ baseMimeType === 'application/xml' ||
17
+ baseMimeType.endsWith('+xml') ||
18
+ baseMimeType === 'application/javascript');
19
+ }
20
+ /**
21
+ * Maps a failed read's HTTP status to a JSON-RPC error code:
22
+ * - 3xx/4xx except 429 → `InvalidParams` (the request/resource is the problem — bad URI, missing/invalid
23
+ * token, private resource, or a resource that does not exist; SEP-2164 remaps "nonexistent" here too).
24
+ * - 429, 5xx, or no status (network failure) → `InternalError` (transient or upstream).
25
+ */
26
+ function getErrorCodeForStatus(status) {
27
+ if (status !== undefined && status < 500 && status !== 429)
28
+ return ErrorCode.InvalidParams;
29
+ return ErrorCode.InternalError;
30
+ }
31
+ /** Throw the standard resources/read failure McpError. Callers log the error first — the log source differs by site. */
32
+ function throwReadFailure(uri, status, message) {
33
+ const hint = getHttpErrorHint(status);
34
+ throw new McpError(getErrorCodeForStatus(status), `Failed to read ${uri}: ${status ? `HTTP ${status}: ` : ''}${message}${hint ? `. ${hint}` : ''}`, { uri });
35
+ }
36
+ /**
37
+ * True when the URI is an Apify API URL (same origin as the configured API base).
38
+ *
39
+ * This is the security gate for the generic read proxy: the apify-client attaches the
40
+ * session token as an `Authorization` header to every outbound request, so we must only
41
+ * hand it Apify API URLs — never an arbitrary host. Userinfo-bearing URLs
42
+ * (`user@api.apify.com`) are rejected even when the host is genuinely ours: axios drops
43
+ * the default `Authorization` header for credentials-bearing URLs, so the read would
44
+ * silently run unauthenticated.
45
+ */
46
+ export function isApifyApiUri(uri) {
47
+ try {
48
+ const url = new URL(uri);
49
+ if (url.username || url.password)
50
+ return false;
51
+ return url.origin === new URL(getApifyAPIBaseUrl()).origin;
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ }
57
+ /**
58
+ * Matches an Apify key-value-store record path, capturing the store id and the record key.
59
+ * Both groups exclude `/?#` so a trailing query or fragment can't leak into the captured key.
60
+ */
61
+ const KV_RECORD_PATH_RE = /^\/v2\/key-value-stores\/([^/?#]+)\/records\/([^/?#]+)$/;
62
+ /** `decodeURIComponent` that returns the input unchanged on malformed percent-encoding instead of throwing. */
63
+ function safeDecodeURIComponent(segment) {
64
+ try {
65
+ return decodeURIComponent(segment);
66
+ }
67
+ catch {
68
+ return segment;
69
+ }
70
+ }
71
+ /**
72
+ * Download URL for a body too large to inline. For a key-value-store record URI, returns the
73
+ * store's signed `recordPublicUrl` — fetchable without an API token when the client can read the
74
+ * store's URL signing key. Falls back to the original API URL for any other endpoint, or if minting
75
+ * the signed URL fails (fetching that link then needs a token).
76
+ */
77
+ async function fetchRecordDownloadUrl(uri, apifyClient) {
78
+ let pathname;
79
+ try {
80
+ pathname = new URL(uri).pathname;
81
+ }
82
+ catch {
83
+ return uri;
84
+ }
85
+ const match = KV_RECORD_PATH_RE.exec(pathname);
86
+ if (!match)
87
+ return uri;
88
+ try {
89
+ const store = apifyClient.keyValueStore(safeDecodeURIComponent(match[1]));
90
+ return await store.getRecordPublicUrl(safeDecodeURIComponent(match[2]));
91
+ }
92
+ catch (err) {
93
+ logHttpError(err, `Failed to mint signed download URL for ${uri}; falling back to API URL`);
94
+ return uri;
95
+ }
96
+ }
97
+ /** Single text-contents result; pass `mimeType` to preserve a body's declared Content-Type. */
98
+ function buildTextResult(uri, text, mimeType = TEXT_MIME_TYPE) {
99
+ return { contents: [{ uri, mimeType, text }] };
100
+ }
101
+ /** True when the URI is a key-value-store record path (a single record, not a pageable list). */
102
+ function isKvRecordUri(uri) {
103
+ try {
104
+ return KV_RECORD_PATH_RE.test(new URL(uri).pathname);
105
+ }
106
+ catch {
107
+ return false;
108
+ }
109
+ }
110
+ /** Body too large to inline: a download-pointer text result. NOT a failure — the resource is readable, just not inline. */
111
+ async function buildLinkOutResult(uri, apifyClient) {
112
+ const downloadUrl = await fetchRecordDownloadUrl(uri, apifyClient);
113
+ // A KVS record is a single object with no paging; only a dataset/list can shrink via limit/offset.
114
+ const pagingHint = isKvRecordUri(uri) ? '' : ' For a dataset/list, re-read with a smaller limit/offset range.';
115
+ return buildTextResult(uri, `Response body exceeds the ${MAX_INLINE_BYTES}-byte inline limit. Download it from ${downloadUrl} ` +
116
+ `(may require your Apify API token).${pagingHint}`);
117
+ }
118
+ /** The mid-consumption abort axios raises when a streamed body crosses `maxContentLength`. */
119
+ function isMaxContentLengthAbort(err) {
120
+ return isAxiosError(err) && err.code === 'ERR_BAD_RESPONSE' && err.message.includes('maxContentLength');
121
+ }
122
+ /** `charset` parameter of a Content-Type header, lowercased; `undefined` when absent. */
123
+ function parseCharset(contentType) {
124
+ const match = /;\s*charset\s*=\s*"?([^";]+)"?/i.exec(contentType !== null && contentType !== void 0 ? contentType : '');
125
+ return match === null || match === void 0 ? void 0 : match[1].trim().toLowerCase();
126
+ }
127
+ /** Drain a response stream into one Buffer. Chunks are Buffers (`objectMode: false`). */
128
+ async function collectStream(data) {
129
+ const chunks = [];
130
+ for await (const chunk of data) {
131
+ chunks.push(Buffer.from(chunk));
132
+ }
133
+ return Buffer.concat(chunks);
134
+ }
135
+ /** `error.message` from an Apify API error body, or `undefined` when the body isn't that shape. */
136
+ function parseApiErrorMessage(body) {
137
+ var _a;
138
+ if (!body || body.length === 0)
139
+ return undefined;
140
+ try {
141
+ const parsed = JSON.parse(body.toString('utf-8'));
142
+ return typeof ((_a = parsed === null || parsed === void 0 ? void 0 : parsed.error) === null || _a === void 0 ? void 0 : _a.message) === 'string' ? parsed.error.message : undefined;
143
+ }
144
+ catch {
145
+ return undefined;
146
+ }
147
+ }
148
+ /**
149
+ * Read any Apify API GET endpoint as an MCP resource.
150
+ *
151
+ * A thin streaming proxy: the apify-client injects the session token (and the MCP-origin header),
152
+ * the body streams in verbatim and is returned by its declared Content-Type — textual types
153
+ * (text/*, JSON, XML) as `text`, anything else as a base64 `blob`. The body is never parsed, so
154
+ * JSON primitives, formatting, and bytes round-trip exactly.
155
+ *
156
+ * Genuine failures (no token, bad origin, a missing resource, a bad token, a 5xx, a network error)
157
+ * throw an `McpError` so the SDK returns a JSON-RPC error rather than success-shaped content for an
158
+ * unreadable resource (see SEP-2164). A body over `MAX_INLINE_BYTES` is NOT a failure — it is a
159
+ * successful read returning a download pointer.
160
+ *
161
+ * The request goes straight through `apifyClient.httpClient.axios` (the same axios instance
162
+ * apify-client builds internally, so token/origin headers still apply) instead of
163
+ * `httpClient.call()`: with `responseType: 'stream'`, a non-2xx reaches `call()` as an unconsumed
164
+ * stream — its `ApifyApiError` message degrades to junk and each retry attempt strands an unread
165
+ * socket. One attempt, no retries. `maxContentLength` is enforced by axios itself mid-consumption
166
+ * (verified in axios@1.16.1: the adapter wraps streamed responses in a byte-counting generator
167
+ * that throws `ERR_BAD_RESPONSE` when the decoded size crosses the limit), so an oversized body
168
+ * is aborted at ~`MAX_INLINE_BYTES`, never buffered whole.
169
+ */
170
+ export async function readApiResource(uri, apifyClient) {
171
+ var _a, _b;
172
+ if (!isApifyApiUri(uri)) {
173
+ throw new McpError(ErrorCode.InvalidParams, `Failed to read ${uri}: only Apify API URLs (${getApifyAPIBaseUrl()}) are readable as resources.`, { uri });
174
+ }
175
+ if (!apifyClient) {
176
+ throw new McpError(ErrorCode.InvalidParams, `Failed to read ${uri}: no Apify token in this session.`, {
177
+ uri,
178
+ });
179
+ }
180
+ let response;
181
+ try {
182
+ // The raw axios instance skips `httpClient.call()` → `ensureNodeInit()`, so reads do NOT honor
183
+ // `HTTPS_PROXY` (auth + MCP-origin headers are instance defaults and still apply — not a leak).
184
+ // Fine for direct egress; a proxy-mandatory deployment needs an apify-client init hook.
185
+ response = await apifyClient.httpClient.axios.request({
186
+ url: uri,
187
+ method: 'GET',
188
+ responseType: 'stream',
189
+ maxContentLength: MAX_INLINE_BYTES,
190
+ });
191
+ }
192
+ catch (err) {
193
+ logHttpError(err, `resources/read request failed`, { uri });
194
+ throwReadFailure(uri, getHttpStatusCode(err), err instanceof Error ? err.message : String(err));
195
+ }
196
+ let body;
197
+ let overLimit = false;
198
+ try {
199
+ body = await collectStream(response.data);
200
+ }
201
+ catch (err) {
202
+ if (isMaxContentLengthAbort(err)) {
203
+ overLimit = true;
204
+ }
205
+ else {
206
+ // A drop mid-body (reset, truncation, bad gzip). Never return partial content.
207
+ logHttpError(err, `resources/read response interrupted`, { uri });
208
+ const message = err instanceof Error ? err.message : String(err);
209
+ throw new McpError(ErrorCode.InternalError, `Failed to read ${uri}: response interrupted: ${message}`, {
210
+ uri,
211
+ });
212
+ }
213
+ }
214
+ // `validateStatus: null` on this axios instance resolves non-2xx responses instead of throwing,
215
+ // so a failed request is checked here. The error body was just collected above (Apify API error
216
+ // bodies are small JSON; if one somehow crossed the limit, fall back to the status text).
217
+ if (response.status >= 300) {
218
+ const message = (_a = parseApiErrorMessage(body)) !== null && _a !== void 0 ? _a : response.statusText;
219
+ logHttpError(Object.assign(new Error(message), { statusCode: response.status }), `resources/read failed`, {
220
+ uri,
221
+ });
222
+ throwReadFailure(uri, response.status, message);
223
+ }
224
+ // Second clause is runtime-redundant (undefined ⟺ overLimit) but narrows `body` to Buffer below.
225
+ if (overLimit || body === undefined) {
226
+ return buildLinkOutResult(uri, apifyClient);
227
+ }
228
+ const contentTypeHeader = response.headers['content-type'];
229
+ const contentType = typeof contentTypeHeader === 'string' ? contentTypeHeader : undefined;
230
+ // Empty body → empty text preserving the declared Content-Type, matching get-key-value-store-record
231
+ // (even for a binary type: an empty blob carries no bytes).
232
+ if (body.length === 0) {
233
+ return buildTextResult(uri, '', contentType);
234
+ }
235
+ const baseMimeType = parseBaseMimeType(contentType);
236
+ const charset = (_b = parseCharset(contentType)) !== null && _b !== void 0 ? _b : 'utf-8';
237
+ // Decode with the DECLARED charset, not hardcoded UTF-8 — latin1 bytes decoded as UTF-8 mangle
238
+ // irreversibly to U+FFFD. A charset Node cannot decode falls through to the blob branch (lossless
239
+ // base64 beats text in a wrong encoding), the same rule as apify-client's body_parser. The full
240
+ // Content-Type — charset included — rides along on the text result.
241
+ if (isTextualMimeType(baseMimeType) && Buffer.isEncoding(charset)) {
242
+ return buildTextResult(uri, body.toString(charset), contentType);
243
+ }
244
+ // Binary or undecodable text: base MIME type only (parameters are meaningless for a blob).
245
+ return {
246
+ contents: [
247
+ {
248
+ uri,
249
+ ...(baseMimeType && { mimeType: baseMimeType }),
250
+ blob: body.toString('base64'),
251
+ },
252
+ ],
253
+ };
254
+ }
255
+ //# sourceMappingURL=api_resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api_resources.js","sourceRoot":"","sources":["../../src/resources/api_resources.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,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MAAM,YAAY,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,MAAA,YAAY,CAAC,WAAW,CAAC,mCAAI,OAAO,CAAC;IACrD,+FAA+F;IAC/F,kGAAkG;IAClG,gGAAgG;IAChG,oEAAoE;IACpE,IAAI,iBAAiB,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAChE,OAAO,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC;IACrE,CAAC;IACD,2FAA2F;IAC3F,OAAO;QACH,QAAQ,EAAE;YACN;gBACI,GAAG;gBACH,GAAG,CAAC,YAAY,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;gBAC/C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;aACD;SACnC;KACJ,CAAC;AACN,CAAC"}
@@ -1,8 +1,9 @@
1
- import type { ListResourcesResult, ListResourceTemplatesResult, ReadResourceResult, TextResourceContents } from '@modelcontextprotocol/sdk/types.js';
1
+ import type { BlobResourceContents, ListResourcesResult, ListResourceTemplatesResult, ReadResourceResult, TextResourceContents } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { ApifyClient } from '../apify_client.js';
2
3
  import type { PaymentProvider } from '../payments/types.js';
3
4
  import { SERVER_MODE } from '../types.js';
4
5
  import type { AvailableWidget } from './widgets.js';
5
- type ExtendedResourceContents = TextResourceContents & {
6
+ type ExtendedResourceContents = (TextResourceContents | BlobResourceContents) & {
6
7
  html?: string;
7
8
  _meta?: AvailableWidget['meta'];
8
9
  };
@@ -11,7 +12,7 @@ type ExtendedReadResourceResult = Omit<ReadResourceResult, 'contents'> & {
11
12
  };
12
13
  type ResourceService = {
13
14
  listResources: () => Promise<ListResourcesResult>;
14
- readResource: (uri: string) => Promise<ExtendedReadResourceResult>;
15
+ readResource: (uri: string, apifyClient?: ApifyClient) => Promise<ExtendedReadResourceResult>;
15
16
  listResourceTemplates: () => Promise<ListResourceTemplatesResult>;
16
17
  };
17
18
  type ResourceServiceOptions = {