@apify/actors-mcp-server 0.10.10 → 0.10.11-beta.1
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/dist/apify_client.js +1 -4
- package/dist/apify_client.js.map +1 -1
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +9 -17
- package/dist/const.js.map +1 -1
- package/dist/dev_server.d.ts.map +1 -1
- package/dist/dev_server.js +10 -8
- package/dist/dev_server.js.map +1 -1
- package/dist/errors.js +1 -4
- package/dist/errors.js.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/index_internals.d.ts.map +1 -1
- package/dist/index_internals.js +2 -5
- package/dist/index_internals.js.map +1 -1
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +6 -8
- package/dist/input.js.map +1 -1
- package/dist/instrument.js +4 -7
- package/dist/instrument.js.map +1 -1
- package/dist/mcp/actors.d.ts +4 -4
- package/dist/mcp/actors.d.ts.map +1 -1
- package/dist/mcp/actors.js +7 -9
- package/dist/mcp/actors.js.map +1 -1
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +2 -8
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/const.js +1 -4
- package/dist/mcp/const.js.map +1 -1
- package/dist/mcp/proxy.d.ts.map +1 -1
- package/dist/mcp/proxy.js +1 -4
- package/dist/mcp/proxy.js.map +1 -1
- package/dist/mcp/server.d.ts +17 -17
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +90 -55
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/utils.js +1 -4
- package/dist/mcp/utils.js.map +1 -1
- package/dist/payments/const.js +1 -4
- package/dist/payments/const.js.map +1 -1
- package/dist/payments/helpers.d.ts.map +1 -1
- package/dist/payments/helpers.js +1 -4
- package/dist/payments/helpers.js.map +1 -1
- package/dist/payments/index.js +1 -4
- package/dist/payments/index.js.map +1 -1
- package/dist/payments/resolve.d.ts.map +1 -1
- package/dist/payments/resolve.js +1 -4
- package/dist/payments/resolve.js.map +1 -1
- package/dist/payments/skyfire.js +1 -4
- package/dist/payments/skyfire.js.map +1 -1
- package/dist/payments/types.d.ts.map +1 -1
- package/dist/payments/types.js +1 -4
- package/dist/payments/types.js.map +1 -1
- package/dist/payments/x402.d.ts.map +1 -1
- package/dist/payments/x402.js +6 -6
- package/dist/payments/x402.js.map +1 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +2 -7
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/latest_news_on_topic.d.ts.map +1 -1
- package/dist/prompts/latest_news_on_topic.js +6 -6
- package/dist/prompts/latest_news_on_topic.js.map +1 -1
- package/dist/resources/resource_service.d.ts.map +1 -1
- package/dist/resources/resource_service.js +19 -14
- package/dist/resources/resource_service.js.map +1 -1
- package/dist/resources/widgets.d.ts.map +1 -1
- package/dist/resources/widgets.js +1 -4
- package/dist/resources/widgets.js.map +1 -1
- package/dist/server_card.js +1 -4
- package/dist/server_card.js.map +1 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +1 -4
- package/dist/state.js.map +1 -1
- package/dist/stdio.js +5 -8
- package/dist/stdio.js.map +1 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +2 -5
- package/dist/telemetry.js.map +1 -1
- package/dist/tools/actor_executor.d.ts.map +1 -1
- package/dist/tools/actor_executor.js +1 -4
- package/dist/tools/actor_executor.js.map +1 -1
- package/dist/tools/apps/call_actor.js +1 -4
- package/dist/tools/apps/call_actor.js.map +1 -1
- package/dist/tools/apps/call_actor_widget.d.ts.map +1 -1
- package/dist/tools/apps/call_actor_widget.js +15 -11
- package/dist/tools/apps/call_actor_widget.js.map +1 -1
- package/dist/tools/apps/fetch_actor_details_widget.d.ts.map +1 -1
- package/dist/tools/apps/fetch_actor_details_widget.js +17 -12
- package/dist/tools/apps/fetch_actor_details_widget.js.map +1 -1
- package/dist/tools/apps/get_actor_run_widget.d.ts.map +1 -1
- package/dist/tools/apps/get_actor_run_widget.js +7 -10
- package/dist/tools/apps/get_actor_run_widget.js.map +1 -1
- package/dist/tools/apps/search_actors_widget.d.ts.map +1 -1
- package/dist/tools/apps/search_actors_widget.js +6 -7
- package/dist/tools/apps/search_actors_widget.js.map +1 -1
- package/dist/tools/build.d.ts.map +1 -1
- package/dist/tools/build.js +5 -8
- package/dist/tools/build.js.map +1 -1
- package/dist/tools/categories.d.ts.map +1 -1
- package/dist/tools/categories.js +5 -21
- package/dist/tools/categories.js.map +1 -1
- package/dist/tools/common/abort_actor_run.d.ts.map +1 -1
- package/dist/tools/common/abort_actor_run.js +6 -8
- package/dist/tools/common/abort_actor_run.js.map +1 -1
- package/dist/tools/common/add_actor.d.ts.map +1 -1
- package/dist/tools/common/add_actor.js +4 -6
- package/dist/tools/common/add_actor.js.map +1 -1
- package/dist/tools/common/dataset_collection.d.ts.map +1 -1
- package/dist/tools/common/dataset_collection.js +9 -8
- package/dist/tools/common/dataset_collection.js.map +1 -1
- package/dist/tools/common/fetch_apify_docs.d.ts.map +1 -1
- package/dist/tools/common/fetch_apify_docs.js +18 -10
- package/dist/tools/common/fetch_apify_docs.js.map +1 -1
- package/dist/tools/common/get_actor_output.d.ts.map +1 -1
- package/dist/tools/common/get_actor_output.js +10 -22
- package/dist/tools/common/get_actor_output.js.map +1 -1
- package/dist/tools/common/get_actor_run_log.d.ts.map +1 -1
- package/dist/tools/common/get_actor_run_log.js +3 -9
- package/dist/tools/common/get_actor_run_log.js.map +1 -1
- package/dist/tools/common/get_dataset.d.ts.map +1 -1
- package/dist/tools/common/get_dataset.js +2 -7
- package/dist/tools/common/get_dataset.js.map +1 -1
- package/dist/tools/common/get_dataset_items.d.ts.map +1 -1
- package/dist/tools/common/get_dataset_items.js +25 -25
- package/dist/tools/common/get_dataset_items.js.map +1 -1
- package/dist/tools/common/get_dataset_schema.d.ts.map +1 -1
- package/dist/tools/common/get_dataset_schema.js +8 -9
- package/dist/tools/common/get_dataset_schema.js.map +1 -1
- package/dist/tools/common/get_key_value_store.d.ts.map +1 -1
- package/dist/tools/common/get_key_value_store.js +2 -7
- package/dist/tools/common/get_key_value_store.js.map +1 -1
- package/dist/tools/common/get_key_value_store_keys.d.ts.map +1 -1
- package/dist/tools/common/get_key_value_store_keys.js +5 -12
- package/dist/tools/common/get_key_value_store_keys.js.map +1 -1
- package/dist/tools/common/get_key_value_store_record.d.ts.map +1 -1
- package/dist/tools/common/get_key_value_store_record.js +3 -10
- package/dist/tools/common/get_key_value_store_record.js.map +1 -1
- package/dist/tools/common/key_value_store_collection.d.ts.map +1 -1
- package/dist/tools/common/key_value_store_collection.js +9 -8
- package/dist/tools/common/key_value_store_collection.js.map +1 -1
- package/dist/tools/common/run_collection.d.ts.map +1 -1
- package/dist/tools/common/run_collection.js +12 -9
- package/dist/tools/common/run_collection.js.map +1 -1
- package/dist/tools/common/search_apify_docs.d.ts.map +1 -1
- package/dist/tools/common/search_apify_docs.js +13 -15
- package/dist/tools/common/search_apify_docs.js.map +1 -1
- package/dist/tools/core/actor_run_response.d.ts.map +1 -1
- package/dist/tools/core/actor_run_response.js +38 -12
- package/dist/tools/core/actor_run_response.js.map +1 -1
- package/dist/tools/core/actor_tools_factory.d.ts.map +1 -1
- package/dist/tools/core/actor_tools_factory.js +14 -14
- package/dist/tools/core/actor_tools_factory.js.map +1 -1
- package/dist/tools/core/call_actor_common.d.ts.map +1 -1
- package/dist/tools/core/call_actor_common.js +34 -38
- package/dist/tools/core/call_actor_common.js.map +1 -1
- package/dist/tools/core/fetch_actor_details_common.d.ts.map +1 -1
- package/dist/tools/core/fetch_actor_details_common.js +23 -22
- package/dist/tools/core/fetch_actor_details_common.js.map +1 -1
- package/dist/tools/core/get_actor_run_common.d.ts.map +1 -1
- package/dist/tools/core/get_actor_run_common.js +8 -20
- package/dist/tools/core/get_actor_run_common.js.map +1 -1
- package/dist/tools/core/search_actors_common.d.ts.map +1 -1
- package/dist/tools/core/search_actors_common.js +9 -14
- package/dist/tools/core/search_actors_common.js.map +1 -1
- package/dist/tools/default/call_actor.js +1 -4
- package/dist/tools/default/call_actor.js.map +1 -1
- package/dist/tools/default/fetch_actor_details.d.ts.map +1 -1
- package/dist/tools/default/fetch_actor_details.js +2 -5
- package/dist/tools/default/fetch_actor_details.js.map +1 -1
- package/dist/tools/default/get_actor_run.js +1 -4
- package/dist/tools/default/get_actor_run.js.map +1 -1
- package/dist/tools/default/search_actors.js +1 -4
- package/dist/tools/default/search_actors.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -5
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/structured_output_schemas.d.ts.map +1 -1
- package/dist/tools/structured_output_schemas.js +48 -23
- package/dist/tools/structured_output_schemas.js.map +1 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +7 -10
- package/dist/tools/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/actor.d.ts.map +1 -1
- package/dist/utils/actor.js +5 -8
- package/dist/utils/actor.js.map +1 -1
- package/dist/utils/actor_card.d.ts.map +1 -1
- package/dist/utils/actor_card.js +9 -17
- package/dist/utils/actor_card.js.map +1 -1
- package/dist/utils/actor_details.d.ts.map +1 -1
- package/dist/utils/actor_details.js +1 -4
- package/dist/utils/actor_details.js.map +1 -1
- package/dist/utils/actor_search.d.ts.map +1 -1
- package/dist/utils/actor_search.js +1 -4
- package/dist/utils/actor_search.js.map +1 -1
- package/dist/utils/ajv.d.ts.map +1 -1
- package/dist/utils/ajv.js +1 -4
- package/dist/utils/ajv.js.map +1 -1
- package/dist/utils/apify_docs.d.ts.map +1 -1
- package/dist/utils/apify_docs.js +1 -4
- package/dist/utils/apify_docs.js.map +1 -1
- package/dist/utils/apify_properties.d.ts.map +1 -1
- package/dist/utils/apify_properties.js +7 -47
- package/dist/utils/apify_properties.js.map +1 -1
- package/dist/utils/auth.js +1 -4
- package/dist/utils/auth.js.map +1 -1
- package/dist/utils/generic.d.ts.map +1 -1
- package/dist/utils/generic.js +8 -8
- package/dist/utils/generic.js.map +1 -1
- package/dist/utils/logging.js +1 -4
- package/dist/utils/logging.js.map +1 -1
- package/dist/utils/mcp.js +1 -4
- package/dist/utils/mcp.js.map +1 -1
- package/dist/utils/mcp_clients.js +1 -4
- package/dist/utils/mcp_clients.js.map +1 -1
- package/dist/utils/payment_errors.d.ts.map +1 -1
- package/dist/utils/payment_errors.js +2 -8
- package/dist/utils/payment_errors.js.map +1 -1
- package/dist/utils/pricing_info.d.ts +1 -1
- package/dist/utils/pricing_info.d.ts.map +1 -1
- package/dist/utils/pricing_info.js +17 -26
- package/dist/utils/pricing_info.js.map +1 -1
- package/dist/utils/progress.d.ts.map +1 -1
- package/dist/utils/progress.js +2 -7
- package/dist/utils/progress.js.map +1 -1
- package/dist/utils/schema_generation.d.ts.map +1 -1
- package/dist/utils/schema_generation.js +2 -7
- package/dist/utils/schema_generation.js.map +1 -1
- package/dist/utils/server-instructions/index.d.ts.map +1 -1
- package/dist/utils/server-instructions/index.js +9 -8
- package/dist/utils/server-instructions/index.js.map +1 -1
- package/dist/utils/server_mode.d.ts.map +1 -1
- package/dist/utils/server_mode.js +1 -4
- package/dist/utils/server_mode.js.map +1 -1
- package/dist/utils/tool_categories_helpers.d.ts.map +1 -1
- package/dist/utils/tool_categories_helpers.js +2 -6
- package/dist/utils/tool_categories_helpers.js.map +1 -1
- package/dist/utils/tool_status.d.ts.map +1 -1
- package/dist/utils/tool_status.js +4 -5
- package/dist/utils/tool_status.js.map +1 -1
- package/dist/utils/tools.d.ts.map +1 -1
- package/dist/utils/tools.js +10 -14
- package/dist/utils/tools.js.map +1 -1
- package/dist/utils/tools_loader.d.ts.map +1 -1
- package/dist/utils/tools_loader.js +1 -4
- package/dist/utils/tools_loader.js.map +1 -1
- package/dist/utils/ttl_lru.js +1 -4
- package/dist/utils/ttl_lru.js.map +1 -1
- package/dist/utils/userid_cache.d.ts.map +1 -1
- package/dist/utils/userid_cache.js +1 -4
- package/dist/utils/userid_cache.js.map +1 -1
- package/dist/utils/version.js +1 -4
- package/dist/utils/version.js.map +1 -1
- package/dist/web/dist/actor-detail-widget.js +357 -359
- package/dist/web/dist/actor-run-widget.js +51 -53
- package/dist/web/dist/search-actors-widget.js +453 -455
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +1 -1
package/dist/mcp/server.d.ts
CHANGED
|
@@ -71,18 +71,18 @@ export declare class ActorsMcpServer {
|
|
|
71
71
|
*/
|
|
72
72
|
listToolNames(): string[];
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
* Register handler to get notified when tools change.
|
|
75
|
+
* The handler receives an array of tool names that the server has after the change.
|
|
76
|
+
* This is primarily used to store the tools in shared state (e.g., Redis) for recovery
|
|
77
|
+
* when the server loses local state.
|
|
78
|
+
* @throws {Error} - If a handler is already registered.
|
|
79
|
+
* @param handler - The handler function to be called when tools change.
|
|
80
|
+
*/
|
|
81
81
|
registerToolsChangedHandler(handler: (toolNames: string[]) => void): void;
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
* Unregister the handler for tools changed event.
|
|
84
|
+
* @throws {Error} - If no handler is currently registered.
|
|
85
|
+
*/
|
|
86
86
|
unregisterToolsChangedHandler(): void;
|
|
87
87
|
/**
|
|
88
88
|
* Returns the list of all internal tool names
|
|
@@ -105,11 +105,11 @@ export declare class ActorsMcpServer {
|
|
|
105
105
|
*/
|
|
106
106
|
listAllToolNames(): string[];
|
|
107
107
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
* Loads missing toolNames from a provided list of tool names.
|
|
109
|
+
* Skips toolNames that are already loaded and loads only the missing ones.
|
|
110
|
+
* @param toolNames - Array of tool names to ensure are loaded
|
|
111
|
+
* @param apifyClient
|
|
112
|
+
*/
|
|
113
113
|
loadToolsByName(toolNames: string[], apifyClient: ApifyClient): Promise<void>;
|
|
114
114
|
/**
|
|
115
115
|
* Load Actors as tools, upsert successes into the server, and return both the tool
|
|
@@ -151,8 +151,8 @@ export declare class ActorsMcpServer {
|
|
|
151
151
|
*/
|
|
152
152
|
private setupPromptHandlers;
|
|
153
153
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
* Sets up MCP request handlers for long-running tasks.
|
|
155
|
+
*/
|
|
156
156
|
private setupTaskHandlers;
|
|
157
157
|
private setupToolHandlers;
|
|
158
158
|
/**
|
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;AASH,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;AAkC/E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAyBjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EACR,sBAAsB,EACtB,UAAU,EAGV,KAAK,EAIL,SAAS,EAEZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4DAA4D,CAAC;AAE5F,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,KAAK,EAAE,SA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A4FzB,OAAO,CAAC,iBAAiB;IAijBzB;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAoC/B;;;;;;;;;;;OAWG;YAEW,wBAAwB;YA+WxB,oBAAoB;IAmClC;;OAEG;YACW,cAAc;IA4CtB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAoB/B"}
|
package/dist/mcp/server.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Model Context Protocol (MCP) server for Apify Actors
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
!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]="0a4792fc-b93c-5742-850a-5be858a8b8fc")}catch(e){}}();
|
|
6
4
|
import { randomUUID } from 'node:crypto';
|
|
7
5
|
// The ext-apps package exposes `./server` via conditional exports only (no `./server/index.js`
|
|
8
6
|
// wildcard), so we can't satisfy the `import/extensions` rule on this subpath.
|
|
@@ -30,11 +28,11 @@ import { getHttpStatusCode, logHttpError } from '../utils/logging.js';
|
|
|
30
28
|
import { buildMCPResponse, computeToolResponseSizeBytes, getToolCallErrorUserText } from '../utils/mcp.js';
|
|
31
29
|
import { buildPaymentRequiredResponse } from '../utils/payment_errors.js';
|
|
32
30
|
import { createProgressTracker } from '../utils/progress.js';
|
|
33
|
-
import { parseServerMode, resolveServerMode } from '../utils/server_mode.js';
|
|
34
31
|
import { getServerInstructions } from '../utils/server-instructions/index.js';
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
32
|
+
import { parseServerMode, resolveServerMode } from '../utils/server_mode.js';
|
|
33
|
+
import { classifyFailureCategory, extractAjvErrorDetails, extractToolTelemetry, getToolStatusFromError, } from '../utils/tool_status.js';
|
|
34
|
+
import { buildActorFields, extractActorId, extractActorName, getToolFullName, getToolPublicFieldOnly, } from '../utils/tools.js';
|
|
35
|
+
import { getActors, getToolsForServerMode, toolNamesToInput } from '../utils/tools_loader.js';
|
|
38
36
|
import { getUserInfoCached } from '../utils/userid_cache.js';
|
|
39
37
|
import { getPackageVersion } from '../utils/version.js';
|
|
40
38
|
import { connectMCPClient } from './client.js';
|
|
@@ -220,9 +218,8 @@ export class ActorsMcpServer {
|
|
|
220
218
|
// consumers have migrated (see apify-mcp-server-internal#454).
|
|
221
219
|
const legacyUiMode = options.uiMode;
|
|
222
220
|
const rawServerMode = options.serverMode;
|
|
223
|
-
this.serverModeOption =
|
|
224
|
-
? parseServerMode(rawServerMode)
|
|
225
|
-
: parseServerMode(legacyUiMode);
|
|
221
|
+
this.serverModeOption =
|
|
222
|
+
rawServerMode !== undefined ? parseServerMode(rawServerMode) : parseServerMode(legacyUiMode);
|
|
226
223
|
// Preliminary resolution — re-resolved inside the initialize handler once
|
|
227
224
|
// client capabilities are known (only for 'auto').
|
|
228
225
|
this.serverMode = resolveServerMode(this.serverModeOption, false);
|
|
@@ -353,13 +350,13 @@ export class ActorsMcpServer {
|
|
|
353
350
|
return Array.from(this.tools.keys());
|
|
354
351
|
}
|
|
355
352
|
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
353
|
+
* Register handler to get notified when tools change.
|
|
354
|
+
* The handler receives an array of tool names that the server has after the change.
|
|
355
|
+
* This is primarily used to store the tools in shared state (e.g., Redis) for recovery
|
|
356
|
+
* when the server loses local state.
|
|
357
|
+
* @throws {Error} - If a handler is already registered.
|
|
358
|
+
* @param handler - The handler function to be called when tools change.
|
|
359
|
+
*/
|
|
363
360
|
registerToolsChangedHandler(handler) {
|
|
364
361
|
if (this.toolsChangedHandler) {
|
|
365
362
|
throw new Error('Tools changed handler is already registered.');
|
|
@@ -367,9 +364,9 @@ export class ActorsMcpServer {
|
|
|
367
364
|
this.toolsChangedHandler = handler;
|
|
368
365
|
}
|
|
369
366
|
/**
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
367
|
+
* Unregister the handler for tools changed event.
|
|
368
|
+
* @throws {Error} - If no handler is currently registered.
|
|
369
|
+
*/
|
|
373
370
|
unregisterToolsChangedHandler() {
|
|
374
371
|
if (!this.toolsChangedHandler) {
|
|
375
372
|
throw new Error('Tools changed handler is not registered.');
|
|
@@ -413,11 +410,11 @@ export class ActorsMcpServer {
|
|
|
413
410
|
return [...this.listInternalToolNames(), ...this.listActorToolNames(), ...this.listActorMcpServerToolIds()];
|
|
414
411
|
}
|
|
415
412
|
/**
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
413
|
+
* Loads missing toolNames from a provided list of tool names.
|
|
414
|
+
* Skips toolNames that are already loaded and loads only the missing ones.
|
|
415
|
+
* @param toolNames - Array of tool names to ensure are loaded
|
|
416
|
+
* @param apifyClient
|
|
417
|
+
*/
|
|
421
418
|
async loadToolsByName(toolNames, apifyClient) {
|
|
422
419
|
const loadedTools = new Set(this.listAllToolNames());
|
|
423
420
|
const missingToolNames = toolNames.filter((toolName) => !loadedTools.has(toolName));
|
|
@@ -663,8 +660,8 @@ export class ActorsMcpServer {
|
|
|
663
660
|
});
|
|
664
661
|
}
|
|
665
662
|
/**
|
|
666
|
-
|
|
667
|
-
|
|
663
|
+
* Sets up MCP request handlers for long-running tasks.
|
|
664
|
+
*/
|
|
668
665
|
setupTaskHandlers() {
|
|
669
666
|
// List tasks
|
|
670
667
|
this.server.setRequestHandler(ListTasksRequestSchema, async (request) => {
|
|
@@ -824,7 +821,9 @@ export class ActorsMcpServer {
|
|
|
824
821
|
let actorId;
|
|
825
822
|
try {
|
|
826
823
|
// Validate token
|
|
827
|
-
if (!apifyToken &&
|
|
824
|
+
if (!apifyToken &&
|
|
825
|
+
!((_a = this.options.paymentProvider) === null || _a === void 0 ? void 0 : _a.allowsUnauthenticated) &&
|
|
826
|
+
!this.options.allowUnauthMode) {
|
|
828
827
|
await failInvalidParams(dedent `
|
|
829
828
|
Apify API token is required but was not provided.
|
|
830
829
|
Please set the APIFY_TOKEN environment variable or pass it as a parameter in the request header as Authorization Bearer <token>.
|
|
@@ -836,8 +835,7 @@ export class ActorsMcpServer {
|
|
|
836
835
|
// TODO - if connection is /mcp client will not receive notification on tool change
|
|
837
836
|
// Find tool by name, actor full name, or legacy tool name (e.g. apify-slash-rag-web-browser → apify--rag-web-browser)
|
|
838
837
|
const newName = (_b = legacyToolNameToNew(name)) !== null && _b !== void 0 ? _b : name;
|
|
839
|
-
const toolEntry = Array.from(this.tools.values())
|
|
840
|
-
.find((t) => t.name === newName || getToolFullName(t) === newName);
|
|
838
|
+
const toolEntry = Array.from(this.tools.values()).find((t) => t.name === newName || getToolFullName(t) === newName);
|
|
841
839
|
if (!toolEntry) {
|
|
842
840
|
const availableTools = this.listToolNames();
|
|
843
841
|
await failInvalidParams(dedent `
|
|
@@ -873,7 +871,7 @@ export class ActorsMcpServer {
|
|
|
873
871
|
args = decodeDotPropertyNames(args);
|
|
874
872
|
// Centralize all payment processing: validate, strip payment fields, create client.
|
|
875
873
|
// Must run before AJV validation so toolArgsWithoutPayment doesn't contain provider-specific fields.
|
|
876
|
-
const { toolArgsWithoutPayment: toolArgs, toolArgsRedacted: logSafeArgs, apifyClient, paymentRequiredResult } = prepareToolCallContext({
|
|
874
|
+
const { toolArgsWithoutPayment: toolArgs, toolArgsRedacted: logSafeArgs, apifyClient, paymentRequiredResult, } = prepareToolCallContext({
|
|
877
875
|
provider: this.options.paymentProvider,
|
|
878
876
|
tool,
|
|
879
877
|
args: args,
|
|
@@ -885,7 +883,9 @@ export class ActorsMcpServer {
|
|
|
885
883
|
if (!tool.ajvValidate(toolArgs)) {
|
|
886
884
|
const errors = tool.ajvValidate.errors || [];
|
|
887
885
|
const ajvErrorDetails = extractAjvErrorDetails(errors);
|
|
888
|
-
const errorMessages = errors
|
|
886
|
+
const errorMessages = errors
|
|
887
|
+
.map((e) => `${e.instancePath || 'root'}: ${e.message || 'validation error'}`)
|
|
888
|
+
.join('; ');
|
|
889
889
|
await failInvalidParams(dedent `
|
|
890
890
|
Invalid arguments for tool "${tool.name}".
|
|
891
891
|
Validation errors: ${errorMessages}.
|
|
@@ -931,7 +931,11 @@ export class ActorsMcpServer {
|
|
|
931
931
|
const task = await this.taskStore.createTask({
|
|
932
932
|
ttl: request.params.task.ttl,
|
|
933
933
|
}, `call-tool-${name}-${randomUUID()}`, request, mcpSessionId);
|
|
934
|
-
log.debug('Created task for tool execution', {
|
|
934
|
+
log.debug('Created task for tool execution', {
|
|
935
|
+
taskId: task.taskId,
|
|
936
|
+
toolName: tool.name,
|
|
937
|
+
mcpSessionId,
|
|
938
|
+
});
|
|
935
939
|
// Execute the tool asynchronously and update task status
|
|
936
940
|
setImmediate(() => {
|
|
937
941
|
this.executeToolAndUpdateTask({
|
|
@@ -979,14 +983,13 @@ export class ActorsMcpServer {
|
|
|
979
983
|
if (tool.type === 'internal') {
|
|
980
984
|
// Tools that may emit notifications/progress during a sync wait must be opted in here.
|
|
981
985
|
// call-actor: emits during start+waitForFinish. get-actor-run: emits when waitSecs > 0.
|
|
982
|
-
const progressTrackerOptIn = tool.name === HelperTools.ACTOR_CALL
|
|
983
|
-
|| tool.name === HelperTools.ACTOR_RUNS_GET;
|
|
986
|
+
const progressTrackerOptIn = tool.name === HelperTools.ACTOR_CALL || tool.name === HelperTools.ACTOR_RUNS_GET;
|
|
984
987
|
const progressTracker = progressTrackerOptIn
|
|
985
988
|
? createProgressTracker(progressToken, extra.sendNotification)
|
|
986
989
|
: null;
|
|
987
990
|
try {
|
|
988
991
|
log.info('Calling internal tool', { toolName: tool.name, mcpSessionId, input: logSafeArgs });
|
|
989
|
-
const res = await tool.call({
|
|
992
|
+
const res = (await tool.call({
|
|
990
993
|
args: toolArgs,
|
|
991
994
|
extra,
|
|
992
995
|
apifyMcpServer: this,
|
|
@@ -996,7 +999,7 @@ export class ActorsMcpServer {
|
|
|
996
999
|
userRentedActorIds,
|
|
997
1000
|
progressTracker,
|
|
998
1001
|
mcpSessionId,
|
|
999
|
-
});
|
|
1002
|
+
}));
|
|
1000
1003
|
// Extract diagnostics and strip internal fields from res before returning to client.
|
|
1001
1004
|
const diag = extractToolTelemetry(res, actorName, actorId);
|
|
1002
1005
|
toolStatus = diag.toolStatus;
|
|
@@ -1058,7 +1061,10 @@ export class ActorsMcpServer {
|
|
|
1058
1061
|
// actor-mcp gets deeper telemetry treatment.
|
|
1059
1062
|
if ('isError' in res && res.isError) {
|
|
1060
1063
|
toolStatus = TOOL_STATUS.SOFT_FAIL;
|
|
1061
|
-
callDiagnostics = {
|
|
1064
|
+
callDiagnostics = {
|
|
1065
|
+
failure_category: FAILURE_CATEGORY.INTERNAL_ERROR,
|
|
1066
|
+
...buildActorFields(actorName, actorId),
|
|
1067
|
+
};
|
|
1062
1068
|
}
|
|
1063
1069
|
return captureResult({ ...res });
|
|
1064
1070
|
}
|
|
@@ -1076,7 +1082,9 @@ export class ActorsMcpServer {
|
|
|
1076
1082
|
failureCategory: callDiagnostics.failure_category,
|
|
1077
1083
|
});
|
|
1078
1084
|
return captureResult(buildMCPResponse({
|
|
1079
|
-
texts: [
|
|
1085
|
+
texts: [
|
|
1086
|
+
`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.`,
|
|
1087
|
+
],
|
|
1080
1088
|
isError: true,
|
|
1081
1089
|
}));
|
|
1082
1090
|
}
|
|
@@ -1089,7 +1097,12 @@ export class ActorsMcpServer {
|
|
|
1089
1097
|
if (tool.type === 'actor') {
|
|
1090
1098
|
const progressTracker = createProgressTracker(progressToken, extra.sendNotification);
|
|
1091
1099
|
try {
|
|
1092
|
-
log.info('Calling Actor', {
|
|
1100
|
+
log.info('Calling Actor', {
|
|
1101
|
+
toolName: tool.name,
|
|
1102
|
+
actorName: tool.actorFullName,
|
|
1103
|
+
mcpSessionId,
|
|
1104
|
+
input: logSafeArgs,
|
|
1105
|
+
});
|
|
1093
1106
|
const executorResult = await actorExecutor.executeActorTool({
|
|
1094
1107
|
actorFullName: tool.actorFullName,
|
|
1095
1108
|
input: toolArgs,
|
|
@@ -1137,7 +1150,10 @@ export class ActorsMcpServer {
|
|
|
1137
1150
|
failure_http_status: error.statusCode,
|
|
1138
1151
|
...buildActorFields(actorName, actorId),
|
|
1139
1152
|
};
|
|
1140
|
-
logHttpError(error, 'Permission approval required while calling tool', {
|
|
1153
|
+
logHttpError(error, 'Permission approval required while calling tool', {
|
|
1154
|
+
toolName: name,
|
|
1155
|
+
mcpSessionId,
|
|
1156
|
+
});
|
|
1141
1157
|
return captureResult(buildPermissionApprovalResponse(error));
|
|
1142
1158
|
}
|
|
1143
1159
|
// Re-throw MCP protocol errors (e.g. from failInvalidParams) so the SDK
|
|
@@ -1305,7 +1321,9 @@ export class ActorsMcpServer {
|
|
|
1305
1321
|
await this.taskStore.updateTaskStatus(taskId, 'working', undefined, mcpSessionId);
|
|
1306
1322
|
}
|
|
1307
1323
|
catch (err) {
|
|
1308
|
-
if (await skipIfTaskCancelled(' before execution started, skipping', TOOL_STATUS.ABORTED, {
|
|
1324
|
+
if (await skipIfTaskCancelled(' before execution started, skipping', TOOL_STATUS.ABORTED, {
|
|
1325
|
+
...buildActorFields(actorName, actorId),
|
|
1326
|
+
}))
|
|
1309
1327
|
return;
|
|
1310
1328
|
throw err;
|
|
1311
1329
|
}
|
|
@@ -1342,8 +1360,13 @@ export class ActorsMcpServer {
|
|
|
1342
1360
|
if (toolStatus === TOOL_STATUS.SUCCEEDED && tool.type === 'internal') {
|
|
1343
1361
|
const progressTracker = createProgressTracker(progressToken, extra.sendNotification, taskId, onStatusMessage);
|
|
1344
1362
|
try {
|
|
1345
|
-
log.info('Calling internal tool for task', {
|
|
1346
|
-
|
|
1363
|
+
log.info('Calling internal tool for task', {
|
|
1364
|
+
taskId,
|
|
1365
|
+
toolName: tool.name,
|
|
1366
|
+
mcpSessionId,
|
|
1367
|
+
input: logSafeArgs,
|
|
1368
|
+
});
|
|
1369
|
+
const res = (await tool.call({
|
|
1347
1370
|
args: toolArgs,
|
|
1348
1371
|
extra: taskExtra,
|
|
1349
1372
|
apifyMcpServer: this,
|
|
@@ -1354,7 +1377,7 @@ export class ActorsMcpServer {
|
|
|
1354
1377
|
progressTracker,
|
|
1355
1378
|
mcpSessionId,
|
|
1356
1379
|
taskMode: true,
|
|
1357
|
-
});
|
|
1380
|
+
}));
|
|
1358
1381
|
const diag = extractToolTelemetry(res, actorName, actorId);
|
|
1359
1382
|
toolStatus = diag.toolStatus;
|
|
1360
1383
|
callDiagnostics = { ...callDiagnostics, ...diag.callDiagnostics };
|
|
@@ -1370,7 +1393,13 @@ export class ActorsMcpServer {
|
|
|
1370
1393
|
if (toolStatus === TOOL_STATUS.SUCCEEDED && tool.type === 'actor') {
|
|
1371
1394
|
const progressTracker = createProgressTracker(progressToken, extra.sendNotification, taskId, onStatusMessage);
|
|
1372
1395
|
try {
|
|
1373
|
-
log.info('Calling Actor for task', {
|
|
1396
|
+
log.info('Calling Actor for task', {
|
|
1397
|
+
taskId,
|
|
1398
|
+
toolName: tool.name,
|
|
1399
|
+
actorName: tool.actorFullName,
|
|
1400
|
+
mcpSessionId,
|
|
1401
|
+
input: logSafeArgs,
|
|
1402
|
+
});
|
|
1374
1403
|
const executorResult = await actorExecutor.executeActorTool({
|
|
1375
1404
|
actorFullName: tool.actorFullName,
|
|
1376
1405
|
input: toolArgs,
|
|
@@ -1418,7 +1447,9 @@ export class ActorsMcpServer {
|
|
|
1418
1447
|
logHttpError(error, 'Payment required while calling tool (task mode)', { toolName: tool.name });
|
|
1419
1448
|
// Per MCP tasks spec: once a task is cancelled it MUST remain cancelled,
|
|
1420
1449
|
// so guard storeTaskResult against a cancel that raced with this 402.
|
|
1421
|
-
if (await skipIfTaskCancelled(', skipping 402 result storage', TOOL_STATUS.ABORTED, {
|
|
1450
|
+
if (await skipIfTaskCancelled(', skipping 402 result storage', TOOL_STATUS.ABORTED, {
|
|
1451
|
+
...buildActorFields(actorName, actorId),
|
|
1452
|
+
}))
|
|
1422
1453
|
return;
|
|
1423
1454
|
const paymentResponse = buildPaymentRequiredResponse(error);
|
|
1424
1455
|
await this.taskStore.storeTaskResult(taskId, 'completed', paymentResponse, mcpSessionId);
|
|
@@ -1431,10 +1462,14 @@ export class ActorsMcpServer {
|
|
|
1431
1462
|
return;
|
|
1432
1463
|
}
|
|
1433
1464
|
if (isPermissionApprovalError(error)) {
|
|
1434
|
-
logHttpError(error, 'Permission approval required while calling tool (task mode)', {
|
|
1465
|
+
logHttpError(error, 'Permission approval required while calling tool (task mode)', {
|
|
1466
|
+
toolName: tool.name,
|
|
1467
|
+
});
|
|
1435
1468
|
// Per MCP tasks spec: once a task is cancelled it MUST remain cancelled,
|
|
1436
1469
|
// so guard storeTaskResult against a cancel that raced with this approval error.
|
|
1437
|
-
if (await skipIfTaskCancelled(', skipping permission-approval result storage', TOOL_STATUS.ABORTED, {
|
|
1470
|
+
if (await skipIfTaskCancelled(', skipping permission-approval result storage', TOOL_STATUS.ABORTED, {
|
|
1471
|
+
...buildActorFields(actorName, actorId),
|
|
1472
|
+
}))
|
|
1438
1473
|
return;
|
|
1439
1474
|
const approvalResponse = buildPermissionApprovalResponse(error);
|
|
1440
1475
|
await this.taskStore.storeTaskResult(taskId, 'completed', approvalResponse, mcpSessionId);
|
|
@@ -1459,8 +1494,7 @@ export class ActorsMcpServer {
|
|
|
1459
1494
|
// FAILED/ABORTED/other → error
|
|
1460
1495
|
if (toolStatus === TOOL_STATUS.SOFT_FAIL) {
|
|
1461
1496
|
// Mezmo promotes on "error" in message/keys — use errMessage key, sanitized.
|
|
1462
|
-
const errMessage = (error instanceof Error ? error.message : String(error))
|
|
1463
|
-
.replace(/ error:/gi, ' failure:');
|
|
1497
|
+
const errMessage = (error instanceof Error ? error.message : String(error)).replace(/ error:/gi, ' failure:');
|
|
1464
1498
|
log.softFail('Tool execution soft-failed for task', {
|
|
1465
1499
|
taskId,
|
|
1466
1500
|
toolName: tool.name,
|
|
@@ -1493,10 +1527,12 @@ export class ActorsMcpServer {
|
|
|
1493
1527
|
mcpSessionId,
|
|
1494
1528
|
});
|
|
1495
1529
|
const failedResult = {
|
|
1496
|
-
content: [
|
|
1530
|
+
content: [
|
|
1531
|
+
{
|
|
1497
1532
|
type: 'text',
|
|
1498
1533
|
text: userText,
|
|
1499
|
-
}
|
|
1534
|
+
},
|
|
1535
|
+
],
|
|
1500
1536
|
isError: true,
|
|
1501
1537
|
internalToolStatus: toolStatus,
|
|
1502
1538
|
};
|
|
@@ -1510,7 +1546,7 @@ export class ActorsMcpServer {
|
|
|
1510
1546
|
}
|
|
1511
1547
|
/*
|
|
1512
1548
|
* Creates telemetry data for a tool call.
|
|
1513
|
-
|
|
1549
|
+
*/
|
|
1514
1550
|
async prepareTelemetryData(toolName, mcpSessionId, apifyToken) {
|
|
1515
1551
|
var _a, _b, _c, _d, _e;
|
|
1516
1552
|
if (!this.telemetryEnabled) {
|
|
@@ -1606,5 +1642,4 @@ export class ActorsMcpServer {
|
|
|
1606
1642
|
await this.server.close();
|
|
1607
1643
|
}
|
|
1608
1644
|
}
|
|
1609
|
-
//# sourceMappingURL=server.js.map
|
|
1610
|
-
//# debugId=0a4792fc-b93c-5742-850a-5be858a8b8fc
|
|
1645
|
+
//# sourceMappingURL=server.js.map
|