@apify/actors-mcp-server 0.8.3 → 0.8.4
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 +54 -11
- package/dist/actor/const.js +4 -1
- package/dist/actor/const.js.map +1 -1
- package/dist/actor/server.js +9 -6
- package/dist/actor/server.js.map +1 -1
- package/dist/actor/types.js +4 -1
- package/dist/actor/types.js.map +1 -1
- package/dist/actor/utils.js +4 -1
- package/dist/actor/utils.js.map +1 -1
- package/dist/apify-client.js +4 -1
- package/dist/apify-client.js.map +1 -1
- package/dist/const.d.ts +3 -0
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +7 -1
- package/dist/const.js.map +1 -1
- package/dist/errors.js +4 -1
- package/dist/errors.js.map +1 -1
- package/dist/index-internals.d.ts +6 -4
- package/dist/index-internals.d.ts.map +1 -1
- package/dist/index-internals.js +9 -4
- package/dist/index-internals.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/input.js +4 -1
- package/dist/input.js.map +1 -1
- package/dist/instrument.d.ts +2 -0
- package/dist/instrument.d.ts.map +1 -0
- package/dist/instrument.js +27 -0
- package/dist/instrument.js.map +1 -0
- package/dist/main.js +5 -2
- package/dist/main.js.map +1 -1
- package/dist/mcp/actors.js +4 -1
- package/dist/mcp/actors.js.map +1 -1
- package/dist/mcp/client.d.ts +1 -1
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +9 -5
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/const.js +4 -1
- package/dist/mcp/const.js.map +1 -1
- package/dist/mcp/proxy.js +4 -1
- package/dist/mcp/proxy.js.map +1 -1
- package/dist/mcp/server.d.ts +2 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +63 -25
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/utils.d.ts +2 -2
- package/dist/mcp/utils.d.ts.map +1 -1
- package/dist/mcp/utils.js +6 -3
- package/dist/mcp/utils.js.map +1 -1
- package/dist/prompts/index.js +4 -1
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/latest-news-on-topic.js +4 -1
- package/dist/prompts/latest-news-on-topic.js.map +1 -1
- package/dist/resources/resource_service.js +4 -1
- package/dist/resources/resource_service.js.map +1 -1
- package/dist/resources/widgets.js +4 -1
- package/dist/resources/widgets.js.map +1 -1
- package/dist/server_card.d.ts +4 -0
- package/dist/server_card.d.ts.map +1 -0
- package/dist/server_card.js +36 -0
- package/dist/server_card.js.map +1 -0
- package/dist/state.js +4 -1
- package/dist/state.js.map +1 -1
- package/dist/stdio.d.ts +1 -14
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +20 -3
- package/dist/stdio.js.map +1 -1
- package/dist/telemetry.js +4 -1
- package/dist/telemetry.js.map +1 -1
- package/dist/tools/actor.d.ts +19 -7
- package/dist/tools/actor.d.ts.map +1 -1
- package/dist/tools/actor.js +77 -23
- package/dist/tools/actor.js.map +1 -1
- package/dist/tools/build.js +4 -1
- package/dist/tools/build.js.map +1 -1
- package/dist/tools/categories.d.ts +6 -0
- package/dist/tools/categories.d.ts.map +1 -1
- package/dist/tools/categories.js +6 -3
- package/dist/tools/categories.js.map +1 -1
- package/dist/tools/dataset.js +4 -1
- package/dist/tools/dataset.js.map +1 -1
- package/dist/tools/dataset_collection.js +4 -1
- package/dist/tools/dataset_collection.js.map +1 -1
- package/dist/tools/fetch-actor-details-internal.d.ts.map +1 -1
- package/dist/tools/fetch-actor-details-internal.js +11 -2
- package/dist/tools/fetch-actor-details-internal.js.map +1 -1
- package/dist/tools/fetch-actor-details.d.ts.map +1 -1
- package/dist/tools/fetch-actor-details.js +11 -2
- package/dist/tools/fetch-actor-details.js.map +1 -1
- package/dist/tools/fetch-apify-docs.js +4 -1
- package/dist/tools/fetch-apify-docs.js.map +1 -1
- package/dist/tools/get-actor-output.js +4 -1
- package/dist/tools/get-actor-output.js.map +1 -1
- package/dist/tools/get-html-skeleton.js +4 -1
- package/dist/tools/get-html-skeleton.js.map +1 -1
- package/dist/tools/helpers.js +4 -1
- package/dist/tools/helpers.js.map +1 -1
- package/dist/tools/index.js +4 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/key_value_store.js +4 -1
- package/dist/tools/key_value_store.js.map +1 -1
- package/dist/tools/key_value_store_collection.js +4 -1
- package/dist/tools/key_value_store_collection.js.map +1 -1
- package/dist/tools/run.js +7 -4
- package/dist/tools/run.js.map +1 -1
- package/dist/tools/run_collection.js +4 -1
- package/dist/tools/run_collection.js.map +1 -1
- package/dist/tools/search-actors-internal.js +4 -1
- package/dist/tools/search-actors-internal.js.map +1 -1
- package/dist/tools/search-apify-docs.js +4 -1
- package/dist/tools/search-apify-docs.js.map +1 -1
- package/dist/tools/store_collection.js +4 -1
- package/dist/tools/store_collection.js.map +1 -1
- package/dist/tools/structured-output-schemas.d.ts +9 -0
- package/dist/tools/structured-output-schemas.d.ts.map +1 -1
- package/dist/tools/structured-output-schemas.js +28 -1
- package/dist/tools/structured-output-schemas.js.map +1 -1
- package/dist/tools/utils.js +4 -1
- package/dist/tools/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +71 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/actor-card.js +4 -1
- package/dist/utils/actor-card.js.map +1 -1
- package/dist/utils/actor-details.d.ts +2 -1
- package/dist/utils/actor-details.d.ts.map +1 -1
- package/dist/utils/actor-details.js +12 -5
- package/dist/utils/actor-details.js.map +1 -1
- package/dist/utils/actor-response.js +4 -1
- package/dist/utils/actor-response.js.map +1 -1
- package/dist/utils/actor-search.js +4 -1
- package/dist/utils/actor-search.js.map +1 -1
- package/dist/utils/actor.js +4 -1
- package/dist/utils/actor.js.map +1 -1
- package/dist/utils/ajv.js +4 -1
- package/dist/utils/ajv.js.map +1 -1
- package/dist/utils/apify-docs.js +4 -1
- package/dist/utils/apify-docs.js.map +1 -1
- package/dist/utils/apify-properties.js +4 -1
- package/dist/utils/apify-properties.js.map +1 -1
- package/dist/utils/auth.d.ts +9 -0
- package/dist/utils/auth.d.ts.map +1 -0
- package/dist/utils/auth.js +39 -0
- package/dist/utils/auth.js.map +1 -0
- package/dist/utils/generic.d.ts +11 -0
- package/dist/utils/generic.d.ts.map +1 -1
- package/dist/utils/generic.js +21 -1
- package/dist/utils/generic.js.map +1 -1
- package/dist/utils/html-to-md.js +4 -1
- package/dist/utils/html-to-md.js.map +1 -1
- package/dist/utils/html.js +4 -1
- package/dist/utils/html.js.map +1 -1
- package/dist/utils/logging.d.ts +8 -0
- package/dist/utils/logging.d.ts.map +1 -1
- package/dist/utils/logging.js +25 -1
- package/dist/utils/logging.js.map +1 -1
- package/dist/utils/mcp-clients.js +4 -1
- package/dist/utils/mcp-clients.js.map +1 -1
- package/dist/utils/mcp.js +4 -1
- package/dist/utils/mcp.js.map +1 -1
- package/dist/utils/pricing-info.js +4 -1
- package/dist/utils/pricing-info.js.map +1 -1
- package/dist/utils/progress.js +4 -1
- package/dist/utils/progress.js.map +1 -1
- package/dist/utils/schema-generation.js +4 -1
- package/dist/utils/schema-generation.js.map +1 -1
- package/dist/utils/server-instructions.js +4 -1
- package/dist/utils/server-instructions.js.map +1 -1
- package/dist/utils/skyfire.js +4 -1
- package/dist/utils/skyfire.js.map +1 -1
- package/dist/utils/tool-categories-helpers.js +4 -1
- package/dist/utils/tool-categories-helpers.js.map +1 -1
- package/dist/utils/tool-status.js +4 -1
- package/dist/utils/tool-status.js.map +1 -1
- package/dist/utils/tools-loader.d.ts +2 -2
- package/dist/utils/tools-loader.d.ts.map +1 -1
- package/dist/utils/tools-loader.js +24 -13
- package/dist/utils/tools-loader.js.map +1 -1
- package/dist/utils/tools.js +4 -1
- package/dist/utils/tools.js.map +1 -1
- package/dist/utils/ttl-lru.js +4 -1
- package/dist/utils/ttl-lru.js.map +1 -1
- package/dist/utils/userid-cache.js +4 -1
- package/dist/utils/userid-cache.js.map +1 -1
- package/dist/utils/version.d.ts.map +1 -1
- package/dist/utils/version.js +6 -4
- package/dist/utils/version.js.map +1 -1
- package/dist/web/dist/actor-run-widget.js +2 -0
- package/dist/web/dist/search-actors-widget.js +2 -0
- package/manifest.json +1 -1
- package/package.json +3 -1
- package/server.json +1 -1
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","
|
|
1
|
+
{"version":3,"file":"main.js","sources":["../src/main.ts"],"sourceRoot":"","names":[],"mappings":"AAAA;;;GAGG;;;;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAG9B,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,UAAU,KAAK,SAAS,CAAC;AAE7D,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;AAEnB,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,iBAA2B,CAAC,CAAC,CAAC,kBAAkB,CAAC;AAC7F,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE9E,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;IAC3B,GAAG,CAAC,KAAK,CAAC,mEAAmE,CAAC,CAAC;IAC/E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CA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AG,CAAC,EAAE,CAAC;QACnD,MAAM,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QAC9C,GAAG,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IACvF,CAAC;IACD,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC;AAED,0BAA0B;AAC1B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;IAC5B,GAAG,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;IACzD,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC,CAAC,CAAC","debugId":"9985651f-f1cb-5f8a-8b1c-87e0af1d2b27"}
|
package/dist/mcp/actors.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
!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]="a493f85b-e828-5a85-8c6c-c866a1bbbf7b")}catch(e){}}();
|
|
1
3
|
import { ApifyClient } from '../apify-client.js';
|
|
2
4
|
import { MCP_STREAMABLE_ENDPOINT } from '../const.js';
|
|
3
5
|
import { parseCommaSeparatedList } from '../utils/generic.js';
|
|
@@ -53,4 +55,5 @@ export async function getRealActorID(actorIdOrName, apifyToken) {
|
|
|
53
55
|
export async function getActorStandbyURL(realActorId, standbyBaseUrl = 'apify.actor') {
|
|
54
56
|
return `https://${realActorId}.${standbyBaseUrl}`;
|
|
55
57
|
}
|
|
56
|
-
//# sourceMappingURL=actors.js.map
|
|
58
|
+
//# sourceMappingURL=actors.js.map
|
|
59
|
+
//# debugId=a493f85b-e828-5a85-8c6c-c866a1bbbf7b
|
package/dist/mcp/actors.js.map
CHANGED
|
@@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MAAM,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IACzE,OAAO,GAAG,UAAU,GAAG,aAAa,EAAE,CAAC;AAC3C,CAAC;AAED;;EAEE;AACF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,aAAqB,EAAE,UAAkB;IAC1E,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;IAE3D,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC;IAC/B,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,SAAS,aAAa,YAAY,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,CAAC,EAAE,CAAC;AACnB,CAAC;AAED;;EAEE;AACF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,WAAmB,EAAE,cAAc,GAAG,aAAa;IACxF,OAAO,WAAW,WAAW,IAAI,cAAc,EAAE,CAAC;AACtD,CAAC","debugId":"a493f85b-e828-5a85-8c6c-c866a1bbbf7b"}
|
package/dist/mcp/client.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
|
3
3
|
* Creates and connects a ModelContextProtocol client.
|
|
4
4
|
* First tries streamable HTTP transport, then falls back to SSE transport.
|
|
5
5
|
*/
|
|
6
|
-
export declare function connectMCPClient(url: string, token: string): Promise<Client | null>;
|
|
6
|
+
export declare function connectMCPClient(url: string, token: string, mcpSessionId?: string): Promise<Client | null>;
|
|
7
7
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/mcp/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAWnE;;;GAGG;AACH,wBAAsB,gBAAgB,CAClC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAWnE;;;GAGG;AACH,wBAAsB,gBAAgB,CAClC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAClD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA6BxB"}
|
package/dist/mcp/client.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
!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]="1c491ad2-8a77-5073-be64-28c9b7b8691e")}catch(e){}}();
|
|
1
3
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
4
|
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
3
5
|
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
@@ -10,7 +12,7 @@ import { getMCPServerID } from './utils.js';
|
|
|
10
12
|
* Creates and connects a ModelContextProtocol client.
|
|
11
13
|
* First tries streamable HTTP transport, then falls back to SSE transport.
|
|
12
14
|
*/
|
|
13
|
-
export async function connectMCPClient(url, token) {
|
|
15
|
+
export async function connectMCPClient(url, token, mcpSessionId) {
|
|
14
16
|
let client;
|
|
15
17
|
try {
|
|
16
18
|
client = await createMCPStreamableClient(url, token);
|
|
@@ -19,12 +21,13 @@ export async function connectMCPClient(url, token) {
|
|
|
19
21
|
catch (error) {
|
|
20
22
|
// If streamable HTTP transport fails on not timeout error, continue with SSE transport
|
|
21
23
|
if (error instanceof TimeoutError) {
|
|
22
|
-
log.warning('Connection to MCP server using streamable HTTP transport timed out', { url });
|
|
24
|
+
log.warning('Connection to MCP server using streamable HTTP transport timed out', { url, mcpSessionId });
|
|
23
25
|
return null;
|
|
24
26
|
}
|
|
25
27
|
// If streamable HTTP transport fails, fall back to SSE transport
|
|
26
28
|
log.debug('Streamable HTTP transport failed, falling back to SSE transport', {
|
|
27
29
|
url,
|
|
30
|
+
mcpSessionId,
|
|
28
31
|
});
|
|
29
32
|
}
|
|
30
33
|
try {
|
|
@@ -33,10 +36,10 @@ export async function connectMCPClient(url, token) {
|
|
|
33
36
|
}
|
|
34
37
|
catch (error) {
|
|
35
38
|
if (error instanceof TimeoutError) {
|
|
36
|
-
log.warning('Connection to MCP server using SSE transport timed out', { url });
|
|
39
|
+
log.warning('Connection to MCP server using SSE transport timed out', { url, mcpSessionId });
|
|
37
40
|
return null;
|
|
38
41
|
}
|
|
39
|
-
logHttpError(error, 'Failed to connect to MCP server using SSE transport', { url, cause: error });
|
|
42
|
+
logHttpError(error, 'Failed to connect to MCP server using SSE transport', { url, mcpSessionId, cause: error });
|
|
40
43
|
throw error;
|
|
41
44
|
}
|
|
42
45
|
}
|
|
@@ -101,4 +104,5 @@ async function createMCPStreamableClient(url, token) {
|
|
|
101
104
|
await withTimeout(ACTORIZED_MCP_CONNECTION_TIMEOUT_MSEC, client.connect(transport));
|
|
102
105
|
return client;
|
|
103
106
|
}
|
|
104
|
-
//# sourceMappingURL=client.js.map
|
|
107
|
+
//# sourceMappingURL=client.js.map
|
|
108
|
+
//# debugId=1c491ad2-8a77-5073-be64-28c9b7b8691e
|
package/dist/mcp/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../src/mcp/client.ts"],"sourceRoot":"","names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,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EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9C,CAAC;YACD,8DAA8D;SAC1D,EAAE,yDAAyD;KACtE,CAAC,CAAC;IAEP,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACtB,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC;QACzB,OAAO,EAAE,OAAO;KACnB,CAAC,CAAC;IAEH,MAAM,WAAW,CAAC,qCAAqC,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAEpF,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,yBAAyB,CACpC,GAAW,EAAE,KAAa;IAE1B,MAAM,SAAS,GAAG,IAAI,6BAA6B,CAC/C,IAAI,GAAG,CAAC,GAAG,CAAC,EACZ;QACI,WAAW,EAAE;YACT,OAAO,EAAE;gBACL,aAAa,EAAE,UAAU,KAAK,EAAE;aACnC;SACJ;KACJ,CAAC,CAAC;IAEP,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACtB,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC;QACzB,OAAO,EAAE,OAAO;KACnB,CAAC,CAAC;IAEH,MAAM,WAAW,CAAC,qCAAqC,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAEpF,OAAO,MAAM,CAAC;AAClB,CAAC","debugId":"1c491ad2-8a77-5073-be64-28c9b7b8691e"}
|
package/dist/mcp/const.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
!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]="7c5ef840-6cd3-5004-867f-cf4f3046bc28")}catch(e){}}();
|
|
1
3
|
export const MAX_TOOL_NAME_LENGTH = 64;
|
|
2
4
|
export const SERVER_ID_LENGTH = 8;
|
|
3
5
|
export const EXTERNAL_TOOL_CALL_TIMEOUT_MSEC = 120000; // 2 minutes
|
|
@@ -12,4 +14,5 @@ export const LOG_LEVEL_MAP = {
|
|
|
12
14
|
alert: 6,
|
|
13
15
|
emergency: 7,
|
|
14
16
|
};
|
|
15
|
-
//# sourceMappingURL=const.js.map
|
|
17
|
+
//# sourceMappingURL=const.js.map
|
|
18
|
+
//# debugId=7c5ef840-6cd3-5004-867f-cf4f3046bc28
|
package/dist/mcp/const.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","
|
|
1
|
+
{"version":3,"file":"const.js","sources":["../../src/mcp/const.ts"],"sourceRoot":"","names":[],"mappings":";;AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAO,CAAC,CAAC,YAAY;AACpE,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAM,CAAC,CAAC,aAAa;AAE1E,MAAM,CAAC,MAAM,aAAa,GAA2B;IACjD,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,CAAC;CACf,CAAC","debugId":"7c5ef840-6cd3-5004-867f-cf4f3046bc28"}
|
package/dist/mcp/proxy.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
!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]="20731836-5909-588b-be10-804393668984")}catch(e){}}();
|
|
1
3
|
import { fixedAjvCompile } from '../tools/utils.js';
|
|
2
4
|
import { ajv } from '../utils/ajv.js';
|
|
3
5
|
import { getMCPServerID, getProxyMCPServerToolName } from './utils.js';
|
|
@@ -25,4 +27,5 @@ serverUrl) {
|
|
|
25
27
|
}
|
|
26
28
|
return compiledTools;
|
|
27
29
|
}
|
|
28
|
-
//# sourceMappingURL=proxy.js.map
|
|
30
|
+
//# sourceMappingURL=proxy.js.map
|
|
31
|
+
//# debugId=20731836-5909-588b-be10-804393668984
|
package/dist/mcp/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","
|
|
1
|
+
{"version":3,"file":"proxy.js","sources":["../../src/mcp/proxy.ts"],"sourceRoot":"","names":[],"mappings":";;AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACnC,OAAe,EACf,MAAc;AACd,yBAAyB;AACzB,SAAiB;IAEjB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC;IACrC,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;IAEtB,MAAM,aAAa,GAAgB,EAAE,CAAC;IACtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,OAAO,GAAiB;YAC1B,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,OAAO;YAChB,QAAQ,EAAE,cAAc,CAAC,SAAS,CAAC;YACnC,SAAS;YACT,cAAc,EAAE,IAAI,CAAC,IAAI;YAEzB,IAAI,EAAE,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC;YACrD,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;YACnC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC;YACnD,6CAA6C;YAC7C,WAAW,EAAE,IAAI,CAAC,WAAW;SAChC,CAAC;QAEF,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,aAAa,CAAC;AACzB,CAAC","debugId":"20731836-5909-588b-be10-804393668984"}
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { TaskStore } from '@modelcontextprotocol/sdk/experimental/tasks/int
|
|
|
5
5
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
6
6
|
import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
7
7
|
import { ApifyClient } from '../apify-client.js';
|
|
8
|
-
import type { ActorsMcpServerOptions, ToolEntry } from '../types.js';
|
|
8
|
+
import type { ActorsMcpServerOptions, ActorStore, ToolEntry } from '../types.js';
|
|
9
9
|
/**
|
|
10
10
|
* Create Apify MCP server
|
|
11
11
|
*/
|
|
@@ -17,6 +17,7 @@ export declare class ActorsMcpServer {
|
|
|
17
17
|
private currentLogLevel;
|
|
18
18
|
readonly options: ActorsMcpServerOptions;
|
|
19
19
|
readonly taskStore: TaskStore;
|
|
20
|
+
readonly actorStore?: ActorStore;
|
|
20
21
|
private telemetryEnabled;
|
|
21
22
|
private telemetryEnv;
|
|
22
23
|
private availableWidgets;
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4DAA4D,CAAC;AAE5F,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AA0B/E,OAAO,EAAE,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+
!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]="edb6e5fc-9df1-507e-a4a2-43b635b00c39")}catch(e){}}();
|
|
4
6
|
import { randomUUID } from 'node:crypto';
|
|
5
7
|
import { InMemoryTaskStore } from '@modelcontextprotocol/sdk/experimental/tasks/stores/in-memory.js';
|
|
6
8
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
@@ -16,7 +18,7 @@ import { getTelemetryEnv, trackToolCall } from '../telemetry.js';
|
|
|
16
18
|
import { callActorGetDataset, defaultTools, getActorsAsTools, toolCategories } from '../tools/index.js';
|
|
17
19
|
import { decodeDotPropertyNames } from '../tools/utils.js';
|
|
18
20
|
import { buildActorResponseContent } from '../utils/actor-response.js';
|
|
19
|
-
import { logHttpError } from '../utils/logging.js';
|
|
21
|
+
import { logHttpError, redactSkyfirePayId } from '../utils/logging.js';
|
|
20
22
|
import { buildMCPResponse } from '../utils/mcp.js';
|
|
21
23
|
import { createProgressTracker } from '../utils/progress.js';
|
|
22
24
|
import { getServerInstructions } from '../utils/server-instructions.js';
|
|
@@ -75,6 +77,12 @@ export class ActorsMcpServer {
|
|
|
75
77
|
writable: true,
|
|
76
78
|
value: void 0
|
|
77
79
|
});
|
|
80
|
+
Object.defineProperty(this, "actorStore", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: void 0
|
|
85
|
+
});
|
|
78
86
|
// Telemetry configuration (resolved from options and env vars in setupTelemetry)
|
|
79
87
|
Object.defineProperty(this, "telemetryEnabled", {
|
|
80
88
|
enumerable: true,
|
|
@@ -106,6 +114,7 @@ export class ActorsMcpServer {
|
|
|
106
114
|
else {
|
|
107
115
|
throw new Error('Task store must be provided for non-stdio transport types');
|
|
108
116
|
}
|
|
117
|
+
this.actorStore = options.actorStore;
|
|
109
118
|
const { setupSigintHandler = true } = options;
|
|
110
119
|
this.server = new Server({
|
|
111
120
|
name: SERVER_NAME,
|
|
@@ -276,7 +285,7 @@ export class ActorsMcpServer {
|
|
|
276
285
|
* @returns Promise<ToolEntry[]> - Array of loaded tool entries
|
|
277
286
|
*/
|
|
278
287
|
async loadActorsAsTools(actorIdsOrNames, apifyClient) {
|
|
279
|
-
const actorTools = await getActorsAsTools(actorIdsOrNames, apifyClient);
|
|
288
|
+
const actorTools = await getActorsAsTools(actorIdsOrNames, apifyClient, { actorStore: this.actorStore });
|
|
280
289
|
if (actorTools.length > 0) {
|
|
281
290
|
this.upsertTools(actorTools, true);
|
|
282
291
|
}
|
|
@@ -290,7 +299,7 @@ export class ActorsMcpServer {
|
|
|
290
299
|
* Used primarily for SSE.
|
|
291
300
|
*/
|
|
292
301
|
async loadToolsFromUrl(url, apifyClient) {
|
|
293
|
-
const tools = await processParamsGetTools(url, apifyClient, this.options.uiMode);
|
|
302
|
+
const tools = await processParamsGetTools(url, apifyClient, this.options.uiMode, this.actorStore);
|
|
294
303
|
if (tools.length > 0) {
|
|
295
304
|
log.debug('Loading tools from query parameters');
|
|
296
305
|
this.upsertTools(tools, false);
|
|
@@ -564,7 +573,6 @@ export class ActorsMcpServer {
|
|
|
564
573
|
const metaApifyToken = meta === null || meta === void 0 ? void 0 : meta.apifyToken;
|
|
565
574
|
const apifyToken = (metaApifyToken || this.options.token || process.env.APIFY_TOKEN);
|
|
566
575
|
const userRentedActorIds = meta === null || meta === void 0 ? void 0 : meta.userRentedActorIds;
|
|
567
|
-
const actorOutputSchema = meta === null || meta === void 0 ? void 0 : meta.actorOutputSchema;
|
|
568
576
|
// mcpSessionId was injected upstream it is important and required for long running tasks as the store uses it and there is not other way to pass it
|
|
569
577
|
const mcpSessionId = meta === null || meta === void 0 ? void 0 : meta.mcpSessionId;
|
|
570
578
|
if (!mcpSessionId) {
|
|
@@ -576,7 +584,7 @@ export class ActorsMcpServer {
|
|
|
576
584
|
const msg = `Apify API token is required but was not provided.
|
|
577
585
|
Please set the APIFY_TOKEN environment variable or pass it as a parameter in the request header as Authorization Bearer <token>.
|
|
578
586
|
You can obtain your Apify token from https://console.apify.com/account/integrations.`;
|
|
579
|
-
log.softFail(msg, { statusCode: 400 });
|
|
587
|
+
log.softFail(msg, { mcpSessionId, statusCode: 400 });
|
|
580
588
|
await this.server.sendLoggingMessage({ level: 'error', data: msg });
|
|
581
589
|
throw new McpError(ErrorCode.InvalidParams, msg);
|
|
582
590
|
}
|
|
@@ -585,7 +593,7 @@ You can obtain your Apify token from https://console.apify.com/account/integrati
|
|
|
585
593
|
if (name.startsWith('local__')) {
|
|
586
594
|
// we split the name by '__' and take the last part, which is the actual Actor name
|
|
587
595
|
const parts = name.split('__');
|
|
588
|
-
log.debug('Tool name with prefix detected', { toolName: name, lastPart: parts[parts.length - 1] });
|
|
596
|
+
log.debug('Tool name with prefix detected', { toolName: name, lastPart: parts[parts.length - 1], mcpSessionId });
|
|
589
597
|
if (parts.length > 1) {
|
|
590
598
|
name = parts[parts.length - 1];
|
|
591
599
|
}
|
|
@@ -599,28 +607,28 @@ You can obtain your Apify token from https://console.apify.com/account/integrati
|
|
|
599
607
|
const msg = `Tool "${name}" was not found.
|
|
600
608
|
Available tools: ${availableTools.length > 0 ? availableTools.join(', ') : 'none'}.
|
|
601
609
|
Please verify the tool name is correct. You can list all available tools using the tools/list request.`;
|
|
602
|
-
log.softFail(msg, { statusCode: 404 });
|
|
610
|
+
log.softFail(msg, { mcpSessionId, statusCode: 404 });
|
|
603
611
|
await this.server.sendLoggingMessage({ level: 'error', data: msg });
|
|
604
612
|
throw new McpError(ErrorCode.InvalidParams, msg);
|
|
605
613
|
}
|
|
606
614
|
if (!args) {
|
|
607
615
|
const msg = `Missing arguments for tool "${name}".
|
|
608
616
|
Please provide the required arguments for this tool. Check the tool's input schema using ${HelperTools.ACTOR_GET_DETAILS} tool to see what parameters are required.`;
|
|
609
|
-
log.softFail(msg, { statusCode: 400 });
|
|
617
|
+
log.softFail(msg, { mcpSessionId, statusCode: 400 });
|
|
610
618
|
await this.server.sendLoggingMessage({ level: 'error', data: msg });
|
|
611
619
|
throw new McpError(ErrorCode.InvalidParams, msg);
|
|
612
620
|
}
|
|
613
621
|
// Decode dot property names in arguments before validation,
|
|
614
622
|
// since validation expects the original, non-encoded property names.
|
|
615
623
|
args = decodeDotPropertyNames(args);
|
|
616
|
-
log.debug('Validate arguments for tool', { toolName: tool.name, input: args });
|
|
624
|
+
log.debug('Validate arguments for tool', { toolName: tool.name, mcpSessionId, input: args });
|
|
617
625
|
if (!tool.ajvValidate(args)) {
|
|
618
626
|
const errors = (tool === null || tool === void 0 ? void 0 : tool.ajvValidate.errors) || [];
|
|
619
627
|
const errorMessages = errors.map((e) => `${e.instancePath || 'root'}: ${e.message || 'validation error'}`).join('; ');
|
|
620
628
|
const msg = `Invalid arguments for tool "${tool.name}".
|
|
621
629
|
Validation errors: ${errorMessages}.
|
|
622
630
|
Please check the tool's input schema using ${HelperTools.ACTOR_GET_DETAILS} tool and ensure all required parameters are provided with correct types and values.`;
|
|
623
|
-
log.softFail(msg, { statusCode: 400 });
|
|
631
|
+
log.softFail(msg, { mcpSessionId, statusCode: 400 });
|
|
624
632
|
await this.server.sendLoggingMessage({ level: 'error', data: msg });
|
|
625
633
|
throw new McpError(ErrorCode.InvalidParams, msg);
|
|
626
634
|
}
|
|
@@ -631,7 +639,7 @@ Please check the tool's input schema using ${HelperTools.ACTOR_GET_DETAILS} tool
|
|
|
631
639
|
if (request.params.task && !ALLOWED_TASK_TOOL_EXECUTION_MODES.includes(taskSupport)) {
|
|
632
640
|
const msg = `Tool "${tool.name}" does not support long running task calls.
|
|
633
641
|
Please remove the "task" parameter from the tool call request or use a different tool that supports long running tasks.`;
|
|
634
|
-
log.softFail(msg, { statusCode: 400 });
|
|
642
|
+
log.softFail(msg, { mcpSessionId, statusCode: 400 });
|
|
635
643
|
await this.server.sendLoggingMessage({ level: 'error', data: msg });
|
|
636
644
|
throw new McpError(ErrorCode.InvalidParams, msg);
|
|
637
645
|
}
|
|
@@ -640,7 +648,7 @@ Please remove the "task" parameter from the tool call request or use a different
|
|
|
640
648
|
const task = await this.taskStore.createTask({
|
|
641
649
|
ttl: request.params.task.ttl,
|
|
642
650
|
}, `call-tool-${name}-${randomUUID()}`, request);
|
|
643
|
-
log.debug('Created task for tool execution', { taskId: task.taskId, toolName: tool.name });
|
|
651
|
+
log.debug('Created task for tool execution', { taskId: task.taskId, toolName: tool.name, mcpSessionId });
|
|
644
652
|
// Execute the tool asynchronously and update task status
|
|
645
653
|
setImmediate(async () => {
|
|
646
654
|
await this.executeToolAndUpdateTask({
|
|
@@ -675,7 +683,7 @@ Please remove the "task" parameter from the tool call request or use a different
|
|
|
675
683
|
const progressTracker = tool.name === 'call-actor'
|
|
676
684
|
? createProgressTracker(progressToken, extra.sendNotification)
|
|
677
685
|
: null;
|
|
678
|
-
log.info('Calling internal tool', { name: tool.name, input: args });
|
|
686
|
+
log.info('Calling internal tool', { name: tool.name, mcpSessionId, input: redactSkyfirePayId(args) });
|
|
679
687
|
const res = await tool.call({
|
|
680
688
|
args,
|
|
681
689
|
extra,
|
|
@@ -683,8 +691,8 @@ Please remove the "task" parameter from the tool call request or use a different
|
|
|
683
691
|
mcpServer: this.server,
|
|
684
692
|
apifyToken,
|
|
685
693
|
userRentedActorIds,
|
|
686
|
-
actorOutputSchema,
|
|
687
694
|
progressTracker,
|
|
695
|
+
mcpSessionId,
|
|
688
696
|
});
|
|
689
697
|
if (progressTracker) {
|
|
690
698
|
progressTracker.stop();
|
|
@@ -706,11 +714,11 @@ Please remove the "task" parameter from the tool call request or use a different
|
|
|
706
714
|
if (tool.type === 'actor-mcp') {
|
|
707
715
|
let client = null;
|
|
708
716
|
try {
|
|
709
|
-
client = await connectMCPClient(tool.serverUrl, apifyToken);
|
|
717
|
+
client = await connectMCPClient(tool.serverUrl, apifyToken, mcpSessionId);
|
|
710
718
|
if (!client) {
|
|
711
719
|
const msg = `Failed to connect to MCP server at "${tool.serverUrl}".
|
|
712
720
|
Please verify the server URL is correct and accessible, and ensure you have a valid Apify token with appropriate permissions.`;
|
|
713
|
-
log.softFail(msg, { statusCode: 408 }); // 408 Request Timeout
|
|
721
|
+
log.softFail(msg, { mcpSessionId, statusCode: 408 }); // 408 Request Timeout
|
|
714
722
|
await this.server.sendLoggingMessage({ level: 'error', data: msg });
|
|
715
723
|
toolStatus = TOOL_STATUS.SOFT_FAIL;
|
|
716
724
|
return buildMCPResponse({ texts: [msg], isError: true });
|
|
@@ -724,13 +732,14 @@ Please verify the server URL is correct and accessible, and ensure you have a va
|
|
|
724
732
|
client.setNotificationHandler(schema, async (notification) => {
|
|
725
733
|
log.debug('Sending MCP notification', {
|
|
726
734
|
method,
|
|
735
|
+
mcpSessionId,
|
|
727
736
|
notification,
|
|
728
737
|
});
|
|
729
738
|
await extra.sendNotification(notification);
|
|
730
739
|
});
|
|
731
740
|
}
|
|
732
741
|
}
|
|
733
|
-
log.info('Calling Actor-MCP', { actorId: tool.actorId, toolName: tool.originToolName, input: args });
|
|
742
|
+
log.info('Calling Actor-MCP', { actorId: tool.actorId, toolName: tool.originToolName, mcpSessionId, input: redactSkyfirePayId(args) });
|
|
734
743
|
const res = await client.callTool({
|
|
735
744
|
name: tool.originToolName,
|
|
736
745
|
arguments: args,
|
|
@@ -744,6 +753,17 @@ Please verify the server URL is correct and accessible, and ensure you have a va
|
|
|
744
753
|
// We treat the call as succeeded at the telemetry layer unless an actual error is thrown.
|
|
745
754
|
return { ...res };
|
|
746
755
|
}
|
|
756
|
+
catch (error) {
|
|
757
|
+
logHttpError(error, `Failed to call MCP tool '${tool.originToolName}' on Actor '${tool.actorId}'`, {
|
|
758
|
+
actorId: tool.actorId,
|
|
759
|
+
toolName: tool.originToolName,
|
|
760
|
+
});
|
|
761
|
+
toolStatus = TOOL_STATUS.FAILED;
|
|
762
|
+
return buildMCPResponse({
|
|
763
|
+
texts: [`Failed to call MCP tool '${tool.originToolName}' on Actor '${tool.actorId}': ${error instanceof Error ? error.message : String(error)}. The MCP server may be temporarily unavailable.`],
|
|
764
|
+
isError: true,
|
|
765
|
+
});
|
|
766
|
+
}
|
|
747
767
|
finally {
|
|
748
768
|
if (client)
|
|
749
769
|
await client.close();
|
|
@@ -757,8 +777,16 @@ Please verify the server URL is correct and accessible, and ensure you have a va
|
|
|
757
777
|
const { 'skyfire-pay-id': _skyfirePayId, ...actorArgs } = args;
|
|
758
778
|
const apifyClient = createApifyClientWithSkyfireSupport(this, args, apifyToken);
|
|
759
779
|
try {
|
|
760
|
-
log.info('Calling Actor', { actorName: tool.actorFullName, input: actorArgs });
|
|
761
|
-
const callResult = await callActorGetDataset(
|
|
780
|
+
log.info('Calling Actor', { actorName: tool.actorFullName, mcpSessionId, input: redactSkyfirePayId(actorArgs) });
|
|
781
|
+
const callResult = await callActorGetDataset({
|
|
782
|
+
actorName: tool.actorFullName,
|
|
783
|
+
input: actorArgs,
|
|
784
|
+
apifyClient,
|
|
785
|
+
callOptions,
|
|
786
|
+
progressTracker,
|
|
787
|
+
abortSignal: extra.signal,
|
|
788
|
+
mcpSessionId,
|
|
789
|
+
});
|
|
762
790
|
if (!callResult) {
|
|
763
791
|
toolStatus = TOOL_STATUS.ABORTED;
|
|
764
792
|
// Receivers of cancellation notifications SHOULD NOT send a response for the cancelled request
|
|
@@ -794,7 +822,7 @@ Please verify the server URL is correct and accessible, and ensure you have a va
|
|
|
794
822
|
const msg = `Unknown tool type for "${name}".
|
|
795
823
|
Available tools: ${availableTools.length > 0 ? availableTools.join(', ') : 'none'}.
|
|
796
824
|
Please verify the tool name and ensure the tool is properly registered.`;
|
|
797
|
-
log.softFail(msg, { statusCode: 404 });
|
|
825
|
+
log.softFail(msg, { mcpSessionId, statusCode: 404 });
|
|
798
826
|
await this.server.sendLoggingMessage({
|
|
799
827
|
level: 'error',
|
|
800
828
|
data: msg,
|
|
@@ -880,7 +908,7 @@ Please verify the tool name and ensure the tool is properly registered.`;
|
|
|
880
908
|
// Handle internal tool execution in task mode
|
|
881
909
|
if (toolStatus === TOOL_STATUS.SUCCEEDED && tool.type === 'internal') {
|
|
882
910
|
const progressTracker = createProgressTracker(progressToken, extra.sendNotification, taskId);
|
|
883
|
-
log.info('Calling internal tool for task', { taskId, name: tool.name, input: args });
|
|
911
|
+
log.info('Calling internal tool for task', { taskId, name: tool.name, mcpSessionId, input: redactSkyfirePayId(args) });
|
|
884
912
|
const res = await tool.call({
|
|
885
913
|
args,
|
|
886
914
|
extra,
|
|
@@ -889,6 +917,7 @@ Please verify the tool name and ensure the tool is properly registered.`;
|
|
|
889
917
|
apifyToken,
|
|
890
918
|
userRentedActorIds,
|
|
891
919
|
progressTracker,
|
|
920
|
+
mcpSessionId,
|
|
892
921
|
});
|
|
893
922
|
if (progressTracker) {
|
|
894
923
|
progressTracker.stop();
|
|
@@ -912,8 +941,16 @@ Please verify the tool name and ensure the tool is properly registered.`;
|
|
|
912
941
|
const callOptions = { memory: tool.memoryMbytes };
|
|
913
942
|
const { 'skyfire-pay-id': _skyfirePayId, ...actorArgs } = args;
|
|
914
943
|
const apifyClient = createApifyClientWithSkyfireSupport(this, args, apifyToken);
|
|
915
|
-
log.info('Calling Actor for task', { taskId, actorName: tool.actorFullName, input: actorArgs });
|
|
916
|
-
const callResult = await callActorGetDataset(
|
|
944
|
+
log.info('Calling Actor for task', { taskId, actorName: tool.actorFullName, mcpSessionId, input: redactSkyfirePayId(actorArgs) });
|
|
945
|
+
const callResult = await callActorGetDataset({
|
|
946
|
+
actorName: tool.actorFullName,
|
|
947
|
+
input: actorArgs,
|
|
948
|
+
apifyClient,
|
|
949
|
+
callOptions,
|
|
950
|
+
progressTracker,
|
|
951
|
+
abortSignal: extra.signal,
|
|
952
|
+
mcpSessionId,
|
|
953
|
+
});
|
|
917
954
|
if (!callResult) {
|
|
918
955
|
toolStatus = TOOL_STATUS.ABORTED;
|
|
919
956
|
result = {};
|
|
@@ -989,7 +1026,7 @@ Please verify the tool name and ensure the tool is properly registered.`;
|
|
|
989
1026
|
if (apifyToken) {
|
|
990
1027
|
const apifyClient = new ApifyClient({ token: apifyToken });
|
|
991
1028
|
userId = await getUserIdFromTokenCached(apifyToken, apifyClient);
|
|
992
|
-
log.debug('Telemetry: fetched userId', { userId });
|
|
1029
|
+
log.debug('Telemetry: fetched userId', { userId, mcpSessionId });
|
|
993
1030
|
}
|
|
994
1031
|
const capabilities = (_b = (_a = this.options.initializeRequestData) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.capabilities;
|
|
995
1032
|
const params = (_c = this.options.initializeRequestData) === null || _c === void 0 ? void 0 : _c.params;
|
|
@@ -1074,4 +1111,5 @@ Please verify the tool name and ensure the tool is properly registered.`;
|
|
|
1074
1111
|
await this.server.close();
|
|
1075
1112
|
}
|
|
1076
1113
|
}
|
|
1077
|
-
//# sourceMappingURL=server.js.map
|
|
1114
|
+
//# sourceMappingURL=server.js.map
|
|
1115
|
+
//# debugId=edb6e5fc-9df1-507e-a4a2-43b635b00c39
|