@apify/actors-mcp-server 0.9.18-beta.1 → 0.9.18-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 (63) hide show
  1. package/README.md +124 -87
  2. package/dist/mcp/server.d.ts +3 -9
  3. package/dist/mcp/server.d.ts.map +1 -1
  4. package/dist/mcp/server.js +68 -47
  5. package/dist/mcp/server.js.map +1 -1
  6. package/dist/payments/helpers.d.ts +7 -7
  7. package/dist/payments/helpers.d.ts.map +1 -1
  8. package/dist/payments/helpers.js +9 -9
  9. package/dist/payments/helpers.js.map +1 -1
  10. package/dist/tools/core/actor_execution.d.ts.map +1 -1
  11. package/dist/tools/core/actor_execution.js +37 -13
  12. package/dist/tools/core/actor_execution.js.map +1 -1
  13. package/dist/tools/core/actor_tools_factory.d.ts +13 -0
  14. package/dist/tools/core/actor_tools_factory.d.ts.map +1 -1
  15. package/dist/tools/core/actor_tools_factory.js +52 -7
  16. package/dist/tools/core/actor_tools_factory.js.map +1 -1
  17. package/dist/tools/core/call_actor_common.d.ts +4 -0
  18. package/dist/tools/core/call_actor_common.d.ts.map +1 -1
  19. package/dist/tools/core/call_actor_common.js +8 -2
  20. package/dist/tools/core/call_actor_common.js.map +1 -1
  21. package/dist/tools/core/search_actors_common.d.ts +1 -1
  22. package/dist/tools/core/search_actors_common.d.ts.map +1 -1
  23. package/dist/tools/core/search_actors_common.js +18 -18
  24. package/dist/tools/core/search_actors_common.js.map +1 -1
  25. package/dist/tools/default/fetch_actor_details.d.ts.map +1 -1
  26. package/dist/tools/default/fetch_actor_details.js +8 -6
  27. package/dist/tools/default/fetch_actor_details.js.map +1 -1
  28. package/dist/tools/default/get_actor_run.d.ts.map +1 -1
  29. package/dist/tools/default/get_actor_run.js +1 -3
  30. package/dist/tools/default/get_actor_run.js.map +1 -1
  31. package/dist/tools/default/search_actors.d.ts +1 -1
  32. package/dist/tools/default/search_actors.d.ts.map +1 -1
  33. package/dist/tools/default/search_actors.js +30 -19
  34. package/dist/tools/default/search_actors.js.map +1 -1
  35. package/dist/tools/openai/fetch_actor_details.d.ts.map +1 -1
  36. package/dist/tools/openai/fetch_actor_details.js +7 -5
  37. package/dist/tools/openai/fetch_actor_details.js.map +1 -1
  38. package/dist/tools/openai/fetch_actor_details_internal.d.ts.map +1 -1
  39. package/dist/tools/openai/fetch_actor_details_internal.js +6 -4
  40. package/dist/tools/openai/fetch_actor_details_internal.js.map +1 -1
  41. package/dist/tools/openai/search_actors.d.ts.map +1 -1
  42. package/dist/tools/openai/search_actors.js +37 -17
  43. package/dist/tools/openai/search_actors.js.map +1 -1
  44. package/dist/tools/openai/search_actors_internal.d.ts.map +1 -1
  45. package/dist/tools/openai/search_actors_internal.js +11 -10
  46. package/dist/tools/openai/search_actors_internal.js.map +1 -1
  47. package/dist/tsconfig.tsbuildinfo +1 -1
  48. package/dist/utils/ajv.d.ts +10 -1
  49. package/dist/utils/ajv.d.ts.map +1 -1
  50. package/dist/utils/ajv.js +11 -2
  51. package/dist/utils/ajv.js.map +1 -1
  52. package/dist/utils/mcp.d.ts +2 -0
  53. package/dist/utils/mcp.d.ts.map +1 -1
  54. package/dist/utils/mcp.js +13 -0
  55. package/dist/utils/mcp.js.map +1 -1
  56. package/dist/utils/payment_errors.d.ts.map +1 -1
  57. package/dist/utils/payment_errors.js +9 -4
  58. package/dist/utils/payment_errors.js.map +1 -1
  59. package/dist/web/dist/actor-detail-widget.js +236 -236
  60. package/dist/web/dist/actor-run-widget.js +236 -236
  61. package/dist/web/dist/search-actors-widget.js +216 -216
  62. package/manifest.json +1 -1
  63. package/package.json +2 -1
package/README.md CHANGED
@@ -23,7 +23,7 @@ The Apify Model Context Protocol (MCP) server at [**mcp.apify.com**](https://mcp
23
23
  >
24
24
  > For the best experience, connect your AI assistant to our hosted server at **[`https://mcp.apify.com`](https://mcp.apify.com)**. The hosted server supports the latest features - including output schema inference for structured Actor results - that are not available when running locally via stdio.
25
25
 
26
- 💰 The server also supports [Skyfire agentic payments](#-skyfire-agentic-payments), allowing AI agents to pay for Actor runs without an API token.
26
+ 💰 The server also supports [agentic payments](#-agentic-payments) via [x402](#-x402) and [Skyfire](#-skyfire), allowing AI agents to pay for Actor runs without an API token.
27
27
 
28
28
  Apify MCP Server is compatible with `Claude Code, Claude.ai, Cursor, VS Code` and any client that adheres to the Model Context Protocol.
29
29
  Check out the [MCP clients section](#-mcp-clients) for more details or visit the [MCP configuration page](https://mcp.apify.com).
@@ -36,11 +36,16 @@ Check out the [MCP clients section](#-mcp-clients) for more details or visit the
36
36
  - [⚠️ SSE transport deprecation](#%EF%B8%8F-sse-transport-deprecation)
37
37
  - [🤖 MCP clients](#-mcp-clients)
38
38
  - [🪄 Try Apify MCP instantly](#-try-apify-mcp-instantly)
39
- - [💰 Skyfire agentic payments](#-skyfire-agentic-payments)
39
+ - [💰 Agentic payments](#-agentic-payments)
40
+ - [How agentic payments work](#how-agentic-payments-work)
41
+ - [💸 x402](#-x402)
42
+ - [🔥 Skyfire](#-skyfire)
40
43
  - [🛠️ Tools, resources, and prompts](#%EF%B8%8F-tools-resources-and-prompts)
41
44
  - [📊 Telemetry](#-telemetry)
42
- - [🐛 Troubleshooting (local MCP server)](#-troubleshooting-local-mcp-server)
45
+ - [💬 Usage examples](#-usage-examples)
46
+ - [🐛 Troubleshooting](#-troubleshooting)
43
47
  - [⚙️ Development](#%EF%B8%8F-development)
48
+ - [🔒 Privacy policy](#-privacy-policy)
44
49
  - [🤝 Contributing](#-contributing)
45
50
  - [📚 Learn more](#-learn-more)
46
51
 
@@ -89,18 +94,15 @@ Visit [mcp.apify.com](https://mcp.apify.com) to configure the server for your pr
89
94
 
90
95
  ![Apify-MCP-configuration-clients](https://raw.githubusercontent.com/apify/apify-mcp-server/refs/heads/master/docs/mcp-clients.png)
91
96
 
92
- ### Supported clients matrix
97
+ ### Tested clients
93
98
 
94
- The following table outlines the tested MCP clients and their level of support for key features.
95
-
96
- | Client | Dynamic Tool Discovery | Notes |
97
- |-----------------------------|------------------------|------------------------------------------------------|
98
- | **Claude.ai (web)** | 🟡 Partial | Tools may need to be reloaded manually in the client |
99
- | **Claude Desktop** | 🟡 Partial | Tools may need to be reloaded manually in the client |
100
- | **VS Code (Genie)** | Full | |
101
- | **Cursor** | ✅ Full | |
102
- | **Apify Tester MCP Client** | ✅ Full | Designed for testing Apify MCP servers |
103
- | **OpenCode** | ✅ Full | |
99
+ - [Claude Desktop](https://docs.apify.com/platform/integrations/claude-desktop)
100
+ - Claude.ai (web)
101
+ - [ChatGPT](https://docs.apify.com/platform/integrations/chatgpt)
102
+ - VS Code (Genie)
103
+ - Cursor
104
+ - OpenCode
105
+ - [Apify Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client) designed for testing Apify MCP servers
104
106
 
105
107
 
106
108
  **Smart tool selection based on client capabilities:**
@@ -118,21 +120,80 @@ Want to try Apify MCP without any setup?
118
120
  Check out [Apify Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client)
119
121
 
120
122
  This interactive, chat-like interface provides an easy way to explore the capabilities of Apify MCP without any local setup.
121
- Just sign in with your Apify account and start experimenting with web scraping, data extraction, and automation tools!
123
+ Sign in with your Apify account and start experimenting with web scraping, data extraction, and automation tools!
122
124
 
123
125
  Or use the MCP bundle file (formerly known as Anthropic Desktop extension file, or DXT) for one-click installation: [Apify MCP Server MCPB file](https://github.com/apify/apify-mcp-server/releases/latest/download/apify-mcp-server.mcpb)
124
126
 
125
- # 💰 Skyfire agentic payments
126
127
 
127
- The Apify MCP Server integrates with [Skyfire](https://www.skyfire.xyz/) to enable agentic payments - AI agents can autonomously pay for Actor runs without requiring an Apify API token. Instead of authenticating with `APIFY_TOKEN`, the agent uses Skyfire PAY tokens to cover billing for each tool call.
128
+ # 💰 Agentic payments
129
+
130
+ You can pay for Actor runs without an Apify API token using either **x402** or **Skyfire**.
131
+
132
+ - **x402** pays with USDC on [Base](https://base.org) and does not require a separate platform account. It is fully supported by [`mcpc`](https://github.com/apify/mcp-cli) (`npm install -g @apify/mcpc`). We use `mcpc` because it is one of the few MCP clients that supports the latest features and the x402 protocol natively.
133
+ - **Skyfire** pays with PAY tokens and requires a Skyfire account with a funded wallet. It does not require a special MCP client; the entire payment flow is handled directly through the MCP tool call parameters.
134
+
135
+ ## How agentic payments work
136
+
137
+ Actor run costs vary, so both payment methods use a prepaid balance model. The payment flow happens in four steps:
138
+
139
+ 1. **Discovery**: The agent discovers Actors with `search-actors` or `fetch-actor-details`. Those calls are free.
140
+ 2. **Prepayment**: Before running a paid Actor tool, the agent funds a prepaid balance.
141
+ - **x402**: `mcpc` automatically signs a $1.00 USDC transaction.
142
+ - **Skyfire**: The agent creates a PAY token (minimum $5.00) using Skyfire's `create-pay-token` tool.
143
+ 3. **Execution**: The agent calls the Actor tool.
144
+ - **x402**: Handled automatically by `mcpc` using the prepaid balance.
145
+ - **Skyfire**: The agent explicitly passes the PAY token in the `skyfire-pay-id` input property.
146
+ 4. **Resolution**: The tool returns the Actor results. Unused funds stay available for later runs.
147
+ - **x402**: After 60 minutes of inactivity, the server refunds any unused balance to the wallet on [Base](https://base.org).
148
+ - **Skyfire**: Skyfire returns unused funds when the token expires.
149
+
150
+ ## 💸 x402
151
+
152
+ The [x402 protocol](https://www.x402.org/) enables direct, machine-to-machine payments. Your MCP client can use it to pay for Actor runs with USDC on the [Base blockchain](https://base.org/), completely bypassing the need for an Apify API token.
153
+
154
+ ### Prerequisites
155
+
156
+ - A wallet with USDC on [Base](https://base.org) mainnet.
157
+
158
+ ### Setup
159
+
160
+ Create or import a wallet:
161
+
162
+ ```bash
163
+ # Create a new wallet
164
+ mcpc x402 init
165
+
166
+ # Import an existing wallet
167
+ mcpc x402 import <private-key>
168
+
169
+ # Show the wallet address so you can fund it with USDC on Base (https://base.org)
170
+ mcpc x402 info
171
+ ```
172
+
173
+ Connect to the server with x402 enabled:
174
+
175
+ ```bash
176
+ mcpc connect "mcp.apify.com?payment=x402" @apify --x402
177
+ ```
178
+
179
+ You can now call a paid tool:
180
+
181
+ ```bash
182
+ mcpc @apify tools-call call-actor actor:="apify/rag-web-browser" input:='{"query": "latest AI news"}'
183
+ ```
184
+
185
+ ## 🔥 Skyfire
128
186
 
129
- **Prerequisites:**
130
- - A [Skyfire account](https://www.skyfire.xyz/) with a funded wallet
131
- - An MCP client that supports multiple servers (e.g., Claude Desktop, OpenCode, VS Code)
187
+ [Skyfire](https://www.skyfire.xyz/) provides managed payment infrastructure for AI agents. Instead of authenticating with an Apify API token, your agent passes a Skyfire payment token to cover the cost of each tool call using PAY tokens.
132
188
 
133
- **Setup:**
189
+ ### Prerequisites
134
190
 
135
- Configure both the Skyfire MCP server and Apify MCP Server in your MCP client. Enable payment mode by adding the `payment=skyfire` query parameter to the Apify server URL:
191
+ - A [Skyfire account](https://www.skyfire.xyz/) with a funded wallet.
192
+ - An MCP client that supports multiple servers, such as Claude Desktop, OpenCode, or VS Code.
193
+
194
+ ### Setup
195
+
196
+ Configure the Skyfire MCP server and the Apify MCP Server in your client. Add `payment=skyfire` to the Apify server URL:
136
197
 
137
198
  ```json
138
199
  {
@@ -150,16 +211,7 @@ Configure both the Skyfire MCP server and Apify MCP Server in your MCP client. E
150
211
  }
151
212
  ```
152
213
 
153
- **How it works:**
154
-
155
- When Skyfire mode is enabled, the agent handles the full payment flow autonomously:
156
-
157
- 1. The agent discovers relevant Actors via `search-actors` or `fetch-actor-details` (these remain free).
158
- 2. Before executing an Actor, the agent creates a PAY token using the `create-pay-token` tool from the Skyfire MCP server (minimum $5.00 USD).
159
- 3. The agent passes the PAY token in the `skyfire-pay-id` input property when calling the Actor tool.
160
- 4. Results are returned as usual. Unused funds on the token remain available for future runs or are returned upon expiration.
161
-
162
- To learn more, see the [Skyfire integration documentation](https://docs.apify.com/platform/integrations/skyfire) and the [Agentic Payments with Skyfire](https://blog.apify.com/agentic-payments-skyfire/) blog post.
214
+ See the [Skyfire integration documentation](https://docs.apify.com/platform/integrations/skyfire) for setup details. The [Agentic Payments with Skyfire](https://blog.apify.com/agentic-payments-skyfire/) post provides additional background.
163
215
 
164
216
  # 🛠️ Tools, resources, and prompts
165
217
 
@@ -351,6 +403,34 @@ The server provides a set of predefined example prompts to help you get started
351
403
 
352
404
  The server does not yet provide any resources.
353
405
 
406
+ ## 💬 Usage examples
407
+
408
+ Below are realistic examples showing how an AI assistant uses the Apify MCP Server tools.
409
+
410
+ ### Example 1: Search the web using RAG Web Browser
411
+
412
+ **User prompt:**
413
+ > Find the latest news about autonomous AI agents and summarize the key developments.
414
+
415
+ The AI assistant calls the pre-configured `apify--rag-web-browser` Actor tool to search the web and return content from top results.
416
+ The tool returns markdown content from the top 3 search results, which the AI assistant then summarizes for the user.
417
+
418
+ ### Example 2: Discover and run an Actor from the Apify Store
419
+
420
+ **User prompt:**
421
+ > Scrape the top 10 restaurants in Prague from Google Maps with their contact details.
422
+
423
+ The AI assistant first searches for a suitable Actor, inspects its input schema, and then executes it.
424
+ The tool returns a preview of the scraped data including restaurant names, addresses, ratings, phone numbers, and websites.
425
+
426
+ ### Example 3: Retrieve and paginate through Actor run results
427
+
428
+ **User prompt:**
429
+ > Show me the next 10 results from that scraping run.
430
+
431
+ The AI assistant uses the dataset ID from the previous Actor run to fetch additional items.
432
+ Expected output: The tool returns the next page of structured data items from the Actor's output dataset.
433
+
354
434
  ## 📡 Telemetry
355
435
 
356
436
  The Apify MCP Server collects telemetry data about tool calls to help Apify understand usage patterns and improve the service.
@@ -434,7 +514,7 @@ Example: `https://mcp.apify.com?tools=search-actors`.
434
514
 
435
515
  ## 🐦 Canary PR releases
436
516
 
437
- Apify MCP is split across two repositories: this one for core MCP logic and the private `apify-mcp-server-internal` for the hosted server.
517
+ Apify MCP is split across two repositories: this repository for core MCP logic and the private `apify-mcp-server-internal` for the hosted server.
438
518
  Changes must be synchronized between both.
439
519
 
440
520
  To create a canary release, add the `beta` tag to your PR branch.
@@ -442,62 +522,11 @@ This publishes the package to [pkg.pr.new](https://pkg.pr.new/) for staging and
442
522
  See [the workflow file](.github/workflows/pre_release.yaml) for details.
443
523
 
444
524
  ## 🐋 Docker Hub integration
445
- The Apify MCP Server is also available on [Docker Hub](https://hub.docker.com/mcp/server/apify-mcp-server/overview), registered via the [mcp-registry](https://github.com/docker/mcp-registry) repository. The entry in `servers/apify-mcp-server/server.yaml` should be deployed automatically by the Docker Hub MCP registry (deployment frequency is unknown). **Before making major changes to the `stdio` server version, be sure to test it locally to ensure the Docker build passes.** To test, change the `source.branch` to your PR branch and run `task build -- apify-mcp-server`. For more details, see [CONTRIBUTING.md](https://github.com/docker/mcp-registry/blob/main/CONTRIBUTING.md).
446
-
447
- # 🐛 Troubleshooting (local MCP server)
448
-
449
- - Make sure you have `node` (v20 or higher) installed by running `node -v`.
450
- - Make sure the `APIFY_TOKEN` environment variable is set.
451
- - Always use the latest version of the MCP server by using `@apify/actors-mcp-server@latest`.
452
-
453
- ### Common issues
454
-
455
- #### "Unable to connect to extension server", "Cannot find module", or tools not loading
456
-
457
- This is most commonly caused by a **corrupted npx cache** — often left behind when Claude Desktop restarts the MCP server process mid-download. Fix it by clearing the cache:
458
-
459
- ```bash
460
- # macOS / Linux
461
- rm -rf ~/.npm/_npx
462
- npx -y @apify/actors-mcp-server@latest
463
-
464
- # Windows (PowerShell)
465
- Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"
466
- npx -y @apify/actors-mcp-server@latest
467
- ```
525
+ The Apify MCP Server is also available on [Docker Hub](https://hub.docker.com/mcp/server/apify-mcp-server/overview), registered via the [mcp-registry](https://github.com/docker/mcp-registry) repository. The entry in `servers/apify-mcp-server/server.yaml` should be deployed automatically by the Docker Hub MCP registry (deployment frequency is unknown). **Before making major changes to the `stdio` server version, test it locally to ensure the Docker build passes.** To test, change the `source.branch` to your PR branch and run `task build -- apify-mcp-server`. For more details, see [CONTRIBUTING.md](https://github.com/docker/mcp-registry/blob/main/CONTRIBUTING.md).
468
526
 
469
- After clearing the cache, restart Claude Desktop.
527
+ # 🐛 Troubleshooting
470
528
 
471
- #### Errors like "File is not defined" or "ReadableStream is not defined"
472
-
473
- You are running an **outdated version of Node.js**. The Apify MCP server requires Node.js **v20 or higher**:
474
-
475
- ```bash
476
- node -v # Check your version
477
- ```
478
-
479
- If your version is below 20, update Node.js from [nodejs.org](https://nodejs.org).
480
-
481
- #### Server works in Claude Desktop chat but not in cowork mode
482
-
483
- This is a known issue we are investigating. As a workaround, try using the hosted server at [mcp.apify.com](https://mcp.apify.com) instead of the local stdio server.
484
-
485
- ### Checking logs
486
-
487
- If you encounter issues, check the Claude Desktop logs for error details:
488
-
489
- - **macOS**: `~/Library/Logs/Claude/`
490
- - **Windows**: `%APPDATA%\Claude\logs\`
491
- - **Linux**: `~/.config/Claude/logs/`
492
-
493
- ### Debugging the NPM package
494
-
495
- To debug the server, use the [MCP Inspector](https://github.com/modelcontextprotocol/inspector) tool:
496
-
497
- ```shell
498
- export APIFY_TOKEN="your-apify-token"
499
- npx @modelcontextprotocol/inspector npx -y @apify/actors-mcp-server
500
- ```
529
+ For step-by-step troubleshooting, see the [Claude Desktop integration guide](https://docs.apify.com/platform/integrations/claude-desktop) in the Apify documentation.
501
530
 
502
531
  ## 💡 Limitations
503
532
 
@@ -510,6 +539,12 @@ The Actor input schema is processed to be compatible with most MCP clients while
510
539
  - **Enum values and examples** are added to property descriptions to ensure visibility, even if the client doesn't fully support the JSON schema.
511
540
  - **Rental Actors** are only available for use with the hosted MCP server at https://mcp.apify.com. When running the server locally via stdio, you can only access Actors that are already added to your local toolset. To dynamically search for and use any Actor from Apify Store—including rental Actors—connect to the hosted endpoint.
512
541
 
542
+ # 🔒 Privacy policy
543
+
544
+ When you use this server, your requests and Actor inputs are sent to the Apify API for execution.
545
+ Data is not shared with third parties beyond what is necessary to run the requested Actors.
546
+ For full details on data collection, usage, sharing, and retention, see [Apify Legal](https://docs.apify.com/legal).
547
+
513
548
  # 🤝 Contributing
514
549
 
515
550
  We welcome contributions to improve the Apify MCP Server! Here's how you can help:
@@ -530,3 +565,5 @@ For major changes, please open an issue first to discuss your proposal and ensur
530
565
  - [Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client)
531
566
  - [Webinar: Building and Monetizing MCP Servers on Apify](https://www.youtube.com/watch?v=w3AH3jIrXXo)
532
567
  - [How to build and monetize an AI agent on Apify](https://blog.apify.com/how-to-build-an-ai-agent/)
568
+ - [Connect Apify MCP with Claude Desktop](https://docs.apify.com/platform/integrations/claude-desktop)
569
+ - [Connect Apify MCP with ChatGPT](https://docs.apify.com/platform/integrations/chatgpt)
@@ -128,16 +128,10 @@ export declare class ActorsMcpServer {
128
128
  private setupTaskHandlers;
129
129
  private setupToolHandlers;
130
130
  /**
131
- * Finalizes and tracks telemetry for a tool call.
132
- * Calculates execution time, sets final status, and sends the telemetry event.
133
- *
134
- * @param telemetryData - Telemetry data to finalize and track (null if telemetry is disabled)
135
- * @param userId - Apify user ID (string or null if not available)
136
- * @param startTime - Timestamp when the tool call started
137
- * @param toolStatus - Final status of the tool call
138
- * @param callDiagnostics - Telemetry fields: always includes actor_name/actor_id when available; failure-specific fields only on non-success
131
+ * Logs tool call completion at INFO level and tracks telemetry.
132
+ * Computes duration once so both the log line and telemetry event use the same value.
139
133
  */
140
- private finalizeAndTrackTelemetry;
134
+ private logToolCallAndTelemetry;
141
135
  /**
142
136
  * Executes a tool asynchronously for a long-running task and updates task status.
143
137
  *
@@ -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,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAsBjD,OAAO,KAAK,EAER,sBAAsB,EACtB,UAAU,EAGV,UAAU,EAGV,SAAS,EAEZ,M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C,SAAS,EAAE,CAAC;IAQzG;;;;;;OAMG;IACU,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW;IAQnE;OACG;IACI,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,+BAA+B,UAAQ,GAAG,MAAM,EAAE;IAahG;;;;;OAKG;IACI,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,+BAA+B,UAAQ;IAS9E,OAAO,CAAC,yBAAyB;IAQjC,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,qBAAqB;IAoB7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAyC3B;;QAEI;IACJ,OAAO,CAAC,iBAAiB;IAuFzB,OAAO,CAAC,iBAAiB;IAubzB;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAiC/B;;;;;;;;;;;OAWG;YAEW,wBAAwB;YA2OxB,oBAAoB;IAiClC;;OAEG;YACW,cAAc;IA4CtB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAoB/B"}
@@ -20,7 +20,7 @@ import { getActorsAsTools, getCategoryTools, getDefaultTools } from '../tools/in
20
20
  import { openaiActorExecutor } from '../tools/openai/actor_executor.js';
21
21
  import { decodeDotPropertyNames, legacyToolNameToNew } from '../tools/utils.js';
22
22
  import { getHttpStatusCode, logHttpError } from '../utils/logging.js';
23
- import { buildMCPResponse } from '../utils/mcp.js';
23
+ import { buildMCPResponse, getToolCallErrorUserText } from '../utils/mcp.js';
24
24
  import { buildPaymentRequiredResponse } from '../utils/payment_errors.js';
25
25
  import { createProgressTracker } from '../utils/progress.js';
26
26
  import { getServerInstructions } from '../utils/server-instructions/index.js';
@@ -607,11 +607,10 @@ export class ActorsMcpServer {
607
607
  throw new Error('MCP Session ID is required for tool calls');
608
608
  }
609
609
  const startTime = Date.now();
610
- let telemetryData;
611
- let userId;
612
610
  let toolStatus = TOOL_STATUS.SUCCEEDED;
613
611
  let callDiagnostics = {};
614
612
  let shouldTrackTelemetry = true;
613
+ let resolvedToolName = name;
615
614
  const failInvalidParams = async (message, details, logFields) => {
616
615
  toolStatus = TOOL_STATUS.SOFT_FAIL;
617
616
  callDiagnostics = details;
@@ -628,9 +627,9 @@ export class ActorsMcpServer {
628
627
  await this.server.sendLoggingMessage({ level: 'error', data: message });
629
628
  throw new McpError(ErrorCode.InvalidParams, message);
630
629
  };
631
- // Initialize telemetry with raw tool name — may be overwritten below once the tool is resolved.
630
+ // Initialize telemetry with raw tool name — updated below once the tool is resolved.
632
631
  // This ensures telemetry is available even for early failures (missing token, tool not found).
633
- ({ telemetryData, userId } = await this.prepareTelemetryData(name, mcpSessionId, apifyToken));
632
+ const { telemetryData, userId } = await this.prepareTelemetryData(name, mcpSessionId, apifyToken);
634
633
  // actorName/actorId are declared here so they're available in the catch block for telemetry.
635
634
  // Set after tool resolution (inside the try block).
636
635
  let actorName;
@@ -662,8 +661,11 @@ export class ActorsMcpServer {
662
661
  });
663
662
  }
664
663
  const tool = toolEntry;
665
- // Re-initialize telemetry with the resolved tool (uses actorFullName for actor tools).
666
- ({ telemetryData, userId } = await this.prepareTelemetryData(getToolFullName(tool), mcpSessionId, apifyToken));
664
+ resolvedToolName = getToolFullName(tool);
665
+ // Update telemetry tool name now that we resolved the tool (uses actorFullName for actor tools).
666
+ if (telemetryData) {
667
+ telemetryData.tool_name = resolvedToolName;
668
+ }
667
669
  // Extract actor name/id for telemetry — available even when validation fails later.
668
670
  actorName = extractActorName(tool, args);
669
671
  actorId = extractActorId(tool);
@@ -682,8 +684,8 @@ export class ActorsMcpServer {
682
684
  // since validation expects the original, non-encoded property names.
683
685
  args = decodeDotPropertyNames(args);
684
686
  // Centralize all payment processing: validate, strip payment fields, create client.
685
- // Must run before ajv validation so toolArgs doesn't contain provider-specific fields.
686
- const { toolArgs, logSafeArgs, apifyClient, paymentRequiredResult } = prepareToolCallContext({
687
+ // Must run before AJV validation so toolArgsWithoutPayment doesn't contain provider-specific fields.
688
+ const { toolArgsWithoutPayment: toolArgs, toolArgsRedacted: logSafeArgs, apifyClient, paymentRequiredResult } = prepareToolCallContext({
687
689
  provider: this.options.paymentProvider,
688
690
  tool,
689
691
  args: args,
@@ -706,7 +708,7 @@ export class ActorsMcpServer {
706
708
  ...buildActorFields(actorName, actorId),
707
709
  });
708
710
  }
709
- // Check if tool call is a long running task and the tool supports that
711
+ // Check if tool call is a long-running task and the tool supports that
710
712
  // Cast to allowed task mode types ('optional' | 'required') for type-safe includes() check
711
713
  const taskSupport = (_d = tool.execution) === null || _d === void 0 ? void 0 : _d.taskSupport;
712
714
  if (request.params.task && !ALLOWED_TASK_TOOL_EXECUTION_MODES.includes(taskSupport)) {
@@ -764,7 +766,7 @@ export class ActorsMcpServer {
764
766
  ? createProgressTracker(progressToken, extra.sendNotification)
765
767
  : null;
766
768
  try {
767
- log.info('Calling internal tool', { name: tool.name, mcpSessionId, input: logSafeArgs });
769
+ log.info('Calling internal tool', { toolName: tool.name, mcpSessionId, input: logSafeArgs });
768
770
  const res = await tool.call({
769
771
  args: toolArgs,
770
772
  extra,
@@ -818,8 +820,9 @@ export class ActorsMcpServer {
818
820
  }
819
821
  }
820
822
  log.info('Calling Actor-MCP', {
823
+ toolName: tool.name,
824
+ actorMcpToolName: tool.originToolName,
821
825
  actorId: tool.actorId,
822
- toolName: tool.originToolName,
823
826
  mcpSessionId,
824
827
  input: logSafeArgs,
825
828
  });
@@ -867,7 +870,7 @@ export class ActorsMcpServer {
867
870
  if (tool.type === 'actor') {
868
871
  const progressTracker = createProgressTracker(progressToken, extra.sendNotification);
869
872
  try {
870
- log.info('Calling Actor', { actorName: tool.actorFullName, mcpSessionId, input: logSafeArgs });
873
+ log.info('Calling Actor', { toolName: tool.name, actorName: tool.actorFullName, mcpSessionId, input: logSafeArgs });
871
874
  const executorResult = await this.actorExecutor.executeActorTool({
872
875
  actorFullName: tool.actorFullName,
873
876
  input: toolArgs,
@@ -936,16 +939,23 @@ export class ActorsMcpServer {
936
939
  validationMissingProperty: callDiagnostics.validation_missing_property,
937
940
  validationAdditionalProperty: callDiagnostics.validation_additional_property,
938
941
  });
939
- const errorMessage = (error instanceof Error) ? error.message : 'Unknown error';
940
942
  return buildMCPResponse({
941
- texts: [`Error calling tool "${name}": ${errorMessage}. Please verify the tool name, input parameters, and ensure all required resources are available.`],
943
+ texts: [getToolCallErrorUserText(name, error)],
942
944
  isError: true,
943
945
  telemetry: { toolStatus },
944
946
  });
945
947
  }
946
948
  finally {
947
949
  if (shouldTrackTelemetry) {
948
- this.finalizeAndTrackTelemetry(telemetryData, userId, startTime, toolStatus, callDiagnostics);
950
+ this.logToolCallAndTelemetry({
951
+ toolName: resolvedToolName,
952
+ mcpSessionId,
953
+ toolStatus,
954
+ startTime,
955
+ telemetryData,
956
+ userId,
957
+ callDiagnostics,
958
+ });
949
959
  }
950
960
  }
951
961
  const availableTools = this.listToolNames();
@@ -963,28 +973,28 @@ export class ActorsMcpServer {
963
973
  });
964
974
  }
965
975
  /**
966
- * Finalizes and tracks telemetry for a tool call.
967
- * Calculates execution time, sets final status, and sends the telemetry event.
968
- *
969
- * @param telemetryData - Telemetry data to finalize and track (null if telemetry is disabled)
970
- * @param userId - Apify user ID (string or null if not available)
971
- * @param startTime - Timestamp when the tool call started
972
- * @param toolStatus - Final status of the tool call
973
- * @param callDiagnostics - Telemetry fields: always includes actor_name/actor_id when available; failure-specific fields only on non-success
976
+ * Logs tool call completion at INFO level and tracks telemetry.
977
+ * Computes duration once so both the log line and telemetry event use the same value.
974
978
  */
975
- finalizeAndTrackTelemetry(telemetryData, userId, startTime, toolStatus, callDiagnostics) {
976
- if (!telemetryData) {
977
- return;
979
+ logToolCallAndTelemetry(params) {
980
+ const durationMs = Date.now() - params.startTime;
981
+ log.info('Tool call completed', {
982
+ toolName: params.toolName,
983
+ mcpSessionId: params.mcpSessionId,
984
+ toolStatus: params.toolStatus,
985
+ durationMs,
986
+ ...(params.taskId !== undefined && { taskId: params.taskId }),
987
+ });
988
+ if (params.telemetryData) {
989
+ const finalizedTelemetryData = {
990
+ ...params.telemetryData,
991
+ tool_status: params.toolStatus,
992
+ tool_exec_time_ms: durationMs,
993
+ // Always include actor_name/actor_id; failure-specific fields are only present when callDiagnostics has them.
994
+ ...params.callDiagnostics,
995
+ };
996
+ trackToolCall(params.userId, this.telemetryEnv, finalizedTelemetryData);
978
997
  }
979
- const execTime = Date.now() - startTime;
980
- const finalizedTelemetryData = {
981
- ...telemetryData,
982
- tool_status: toolStatus,
983
- tool_exec_time_ms: execTime,
984
- // Always include actor_name/actor_id; failure-specific fields are only present when callDiagnostics has them.
985
- ...callDiagnostics,
986
- };
987
- trackToolCall(userId, this.telemetryEnv, finalizedTelemetryData);
988
998
  }
989
999
  // TODO: this function quite duplicates the main tool call login the CallToolRequestSchema handler, we should refactor
990
1000
  /**
@@ -1014,6 +1024,18 @@ export class ActorsMcpServer {
1014
1024
  // Prepare telemetry before try-catch so it's accessible to both paths.
1015
1025
  // This avoids re-fetching user data in the error handler.
1016
1026
  const { telemetryData, userId } = await this.prepareTelemetryData(getToolFullName(tool), mcpSessionId, apifyToken);
1027
+ const finishTaskTracking = (status, diagnostics) => {
1028
+ this.logToolCallAndTelemetry({
1029
+ toolName: tool.name,
1030
+ mcpSessionId,
1031
+ toolStatus: status,
1032
+ startTime,
1033
+ taskId,
1034
+ telemetryData,
1035
+ userId,
1036
+ callDiagnostics: diagnostics,
1037
+ });
1038
+ };
1017
1039
  try {
1018
1040
  // Check if task was already cancelled before we start execution.
1019
1041
  // Critical: if a client cancels the task immediately after creation (race condition),
@@ -1024,7 +1046,7 @@ export class ActorsMcpServer {
1024
1046
  taskId,
1025
1047
  mcpSessionId,
1026
1048
  });
1027
- this.finalizeAndTrackTelemetry(telemetryData, userId, startTime, TOOL_STATUS.ABORTED, {
1049
+ finishTaskTracking(TOOL_STATUS.ABORTED, {
1028
1050
  ...buildActorFields(actorName, actorId),
1029
1051
  });
1030
1052
  return;
@@ -1056,7 +1078,7 @@ export class ActorsMcpServer {
1056
1078
  if (toolStatus === TOOL_STATUS.SUCCEEDED && tool.type === 'internal') {
1057
1079
  const progressTracker = createProgressTracker(progressToken, extra.sendNotification, taskId, onStatusMessage);
1058
1080
  try {
1059
- log.info('Calling internal tool for task', { taskId, name: tool.name, mcpSessionId, input: logSafeArgs });
1081
+ log.info('Calling internal tool for task', { taskId, toolName: tool.name, mcpSessionId, input: logSafeArgs });
1060
1082
  const res = await tool.call({
1061
1083
  args: toolArgs,
1062
1084
  extra,
@@ -1083,7 +1105,7 @@ export class ActorsMcpServer {
1083
1105
  if (toolStatus === TOOL_STATUS.SUCCEEDED && tool.type === 'actor') {
1084
1106
  const progressTracker = createProgressTracker(progressToken, extra.sendNotification, taskId, onStatusMessage);
1085
1107
  try {
1086
- log.info('Calling Actor for task', { taskId, actorName: tool.actorFullName, mcpSessionId, input: logSafeArgs });
1108
+ log.info('Calling Actor for task', { taskId, toolName: tool.name, actorName: tool.actorFullName, mcpSessionId, input: logSafeArgs });
1087
1109
  const executorResult = await this.actorExecutor.executeActorTool({
1088
1110
  actorFullName: tool.actorFullName,
1089
1111
  input: toolArgs,
@@ -1115,7 +1137,7 @@ export class ActorsMcpServer {
1115
1137
  taskId,
1116
1138
  mcpSessionId,
1117
1139
  });
1118
- this.finalizeAndTrackTelemetry(telemetryData, userId, startTime, toolStatus);
1140
+ finishTaskTracking(toolStatus);
1119
1141
  return;
1120
1142
  }
1121
1143
  // Store the result in the task store
@@ -1125,7 +1147,7 @@ export class ActorsMcpServer {
1125
1147
  });
1126
1148
  await this.taskStore.storeTaskResult(taskId, 'completed', result, mcpSessionId);
1127
1149
  log.debug('Task completed successfully', { taskId, toolName: tool.name, mcpSessionId });
1128
- this.finalizeAndTrackTelemetry(telemetryData, userId, startTime, toolStatus, callDiagnostics);
1150
+ finishTaskTracking(toolStatus, callDiagnostics);
1129
1151
  }
1130
1152
  catch (error) {
1131
1153
  // Handle 402 Payment Required — return structured x402 result so clients can auto-pay
@@ -1133,7 +1155,7 @@ export class ActorsMcpServer {
1133
1155
  if (httpStatus === HTTP_PAYMENT_REQUIRED) {
1134
1156
  logHttpError(error, 'Payment required while calling tool (task mode)', { toolName: tool.name });
1135
1157
  await this.taskStore.storeTaskResult(taskId, 'completed', buildPaymentRequiredResponse(error), mcpSessionId);
1136
- this.finalizeAndTrackTelemetry(telemetryData, userId, startTime, TOOL_STATUS.SOFT_FAIL, {
1158
+ finishTaskTracking(TOOL_STATUS.SOFT_FAIL, {
1137
1159
  failure_category: FAILURE_CATEGORY.INVALID_INPUT,
1138
1160
  failure_http_status: 402,
1139
1161
  ...buildActorFields(actorName, actorId),
@@ -1158,7 +1180,7 @@ export class ActorsMcpServer {
1158
1180
  actorName: callDiagnostics.actor_name,
1159
1181
  error,
1160
1182
  });
1161
- const errorMessage = (error instanceof Error) ? error.message : 'Unknown error';
1183
+ const userText = getToolCallErrorUserText(tool.name, error);
1162
1184
  // Check if task was cancelled before storing result
1163
1185
  // TODO: In future, we should actually stop execution via AbortController,
1164
1186
  // but coordinating cancellation across distributed nodes would be complex
@@ -1167,23 +1189,22 @@ export class ActorsMcpServer {
1167
1189
  taskId,
1168
1190
  mcpSessionId,
1169
1191
  });
1170
- this.finalizeAndTrackTelemetry(telemetryData, userId, startTime, toolStatus, callDiagnostics);
1192
+ finishTaskTracking(toolStatus, callDiagnostics);
1171
1193
  return;
1172
1194
  }
1173
1195
  log.debug('[executeToolAndUpdateTask] Storing failed result', {
1174
1196
  taskId,
1175
1197
  mcpSessionId,
1176
- error: errorMessage,
1177
1198
  });
1178
1199
  await this.taskStore.storeTaskResult(taskId, 'failed', {
1179
1200
  content: [{
1180
1201
  type: 'text',
1181
- text: `Error calling tool: ${errorMessage}. Please verify the tool name, input parameters, and ensure all required resources are available.`,
1202
+ text: userText,
1182
1203
  }],
1183
1204
  isError: true,
1184
1205
  internalToolStatus: toolStatus,
1185
1206
  }, mcpSessionId);
1186
- this.finalizeAndTrackTelemetry(telemetryData, userId, startTime, toolStatus, callDiagnostics);
1207
+ finishTaskTracking(toolStatus, callDiagnostics);
1187
1208
  }
1188
1209
  }
1189
1210
  /*