@apify/actors-mcp-server 0.1.23 → 0.1.24-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +58 -2
  2. package/dist/actor/const.d.ts +12 -0
  3. package/dist/actor/const.d.ts.map +1 -0
  4. package/dist/actor/const.js +18 -0
  5. package/dist/actor/const.js.map +1 -0
  6. package/dist/actor/server.d.ts +4 -0
  7. package/dist/actor/server.d.ts.map +1 -0
  8. package/dist/actor/server.js +158 -0
  9. package/dist/actor/server.js.map +1 -0
  10. package/dist/actor/types.d.ts +23 -0
  11. package/dist/actor/types.d.ts.map +1 -0
  12. package/dist/actor/types.js +2 -0
  13. package/dist/actor/types.js.map +1 -0
  14. package/dist/actor/utils.d.ts +3 -0
  15. package/dist/actor/utils.d.ts.map +1 -0
  16. package/dist/actor/utils.js +26 -0
  17. package/dist/actor/utils.js.map +1 -0
  18. package/dist/apify-client.d.ts +7 -0
  19. package/dist/apify-client.d.ts.map +1 -0
  20. package/dist/apify-client.js +30 -0
  21. package/dist/apify-client.js.map +1 -0
  22. package/dist/const.d.ts +15 -19
  23. package/dist/const.d.ts.map +1 -1
  24. package/dist/const.js +23 -23
  25. package/dist/const.js.map +1 -1
  26. package/dist/examples/clientSse.d.ts +11 -1
  27. package/dist/examples/clientSse.d.ts.map +1 -1
  28. package/dist/examples/clientSse.js +13 -10
  29. package/dist/examples/clientSse.js.map +1 -1
  30. package/dist/examples/clientStdio.js +6 -6
  31. package/dist/examples/clientStdio.js.map +1 -1
  32. package/dist/examples/clientStdioChat.js +31 -16
  33. package/dist/examples/clientStdioChat.js.map +1 -1
  34. package/dist/examples/clientStreamableHttp.d.ts +2 -0
  35. package/dist/examples/clientStreamableHttp.d.ts.map +1 -0
  36. package/dist/examples/clientStreamableHttp.js +93 -0
  37. package/dist/examples/clientStreamableHttp.js.map +1 -0
  38. package/dist/index.d.ts +2 -14
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +6 -51
  41. package/dist/index.js.map +1 -1
  42. package/dist/input.d.ts +1 -1
  43. package/dist/input.d.ts.map +1 -1
  44. package/dist/input.js +15 -7
  45. package/dist/input.js.map +1 -1
  46. package/dist/main.d.ts +4 -0
  47. package/dist/main.d.ts.map +1 -1
  48. package/dist/main.js +22 -125
  49. package/dist/main.js.map +1 -1
  50. package/dist/mcp/actors.d.ts +22 -0
  51. package/dist/mcp/actors.d.ts.map +1 -0
  52. package/dist/mcp/actors.js +76 -0
  53. package/dist/mcp/actors.js.map +1 -0
  54. package/dist/mcp/client.d.ts +6 -0
  55. package/dist/mcp/client.d.ts.map +1 -0
  56. package/dist/mcp/client.js +33 -0
  57. package/dist/mcp/client.js.map +1 -0
  58. package/dist/mcp/const.d.ts +3 -0
  59. package/dist/mcp/const.d.ts.map +1 -0
  60. package/dist/mcp/const.js +3 -0
  61. package/dist/mcp/const.js.map +1 -0
  62. package/dist/mcp/proxy.d.ts +4 -0
  63. package/dist/mcp/proxy.d.ts.map +1 -0
  64. package/dist/mcp/proxy.js +29 -0
  65. package/dist/mcp/proxy.js.map +1 -0
  66. package/dist/mcp/server.d.ts +41 -0
  67. package/dist/mcp/server.d.ts.map +1 -0
  68. package/dist/mcp/server.js +187 -0
  69. package/dist/mcp/server.js.map +1 -0
  70. package/dist/mcp/utils.d.ts +26 -0
  71. package/dist/mcp/utils.d.ts.map +1 -0
  72. package/dist/mcp/utils.js +53 -0
  73. package/dist/mcp/utils.js.map +1 -0
  74. package/dist/stdio.d.ts +15 -0
  75. package/dist/stdio.d.ts.map +1 -0
  76. package/dist/stdio.js +57 -0
  77. package/dist/stdio.js.map +1 -0
  78. package/dist/tools/actor.d.ts +40 -0
  79. package/dist/tools/actor.d.ts.map +1 -0
  80. package/dist/tools/actor.js +138 -0
  81. package/dist/tools/actor.js.map +1 -0
  82. package/dist/tools/build.d.ts +13 -0
  83. package/dist/tools/build.d.ts.map +1 -0
  84. package/dist/tools/build.js +122 -0
  85. package/dist/tools/build.js.map +1 -0
  86. package/dist/tools/helpers.d.ts +19 -0
  87. package/dist/tools/helpers.d.ts.map +1 -0
  88. package/dist/tools/helpers.js +62 -0
  89. package/dist/tools/helpers.js.map +1 -0
  90. package/dist/tools/index.d.ts +6 -0
  91. package/dist/tools/index.d.ts.map +1 -0
  92. package/dist/tools/index.js +8 -0
  93. package/dist/tools/index.js.map +1 -0
  94. package/dist/tools/store_collection.d.ts +21 -0
  95. package/dist/tools/store_collection.d.ts.map +1 -0
  96. package/dist/tools/store_collection.js +82 -0
  97. package/dist/tools/store_collection.js.map +1 -0
  98. package/dist/tools/utils.d.ts +77 -0
  99. package/dist/tools/utils.d.ts.map +1 -0
  100. package/dist/tools/utils.js +202 -0
  101. package/dist/tools/utils.js.map +1 -0
  102. package/dist/tsconfig.tsbuildinfo +1 -1
  103. package/dist/types.d.ts +97 -10
  104. package/dist/types.d.ts.map +1 -1
  105. package/package.json +17 -14
  106. package/dist/actors.d.ts +0 -74
  107. package/dist/actors.d.ts.map +0 -1
  108. package/dist/actors.js +0 -327
  109. package/dist/actors.js.map +0 -1
  110. package/dist/logger.d.ts +0 -3
  111. package/dist/logger.d.ts.map +0 -1
  112. package/dist/logger.js +0 -4
  113. package/dist/logger.js.map +0 -1
  114. package/dist/server.d.ts +0 -43
  115. package/dist/server.d.ts.map +0 -1
  116. package/dist/server.js +0 -178
  117. package/dist/server.js.map +0 -1
  118. package/dist/tools.d.ts +0 -46
  119. package/dist/tools.d.ts.map +0 -1
  120. package/dist/tools.js +0 -128
  121. package/dist/tools.js.map +0 -1
package/README.md CHANGED
@@ -10,7 +10,6 @@ The server can be used in two ways:
10
10
  - **🇦 [MCP Server Actor](https://apify.com/apify/actors-mcp-server)** – HTTP server accessible via Server-Sent Events (SSE), see [guide](#-mcp-server-actor)
11
11
  - **⾕ MCP Server Stdio** – Local server available via standard input/output (stdio), see [guide](#-mcp-server-at-a-local-host)
12
12
 
13
-
14
13
  You can also interact with the MCP server using a chat-like UI with 💬 [Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client)
15
14
 
16
15
  # 🎯 What does Apify MCP server do?
@@ -337,6 +336,63 @@ If you want to specify which Actors to load, you can add the `--actors` argument
337
336
  }
338
337
  ```
339
338
 
339
+ #### VS Code
340
+
341
+ For one-click installation, click one of the install buttons below:
342
+
343
+ [![Install with NPX in VS Code](https://img.shields.io/badge/VS_Code-NPM-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=actors-mcp-server&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40apify%2Factors-mcp-server%22%5D%2C%22env%22%3A%7B%22APIFY_TOKEN%22%3A%22%24%7Binput%3Aapify_token%7D%22%7D%7D&inputs=%5B%7B%22type%22%3A%22promptString%22%2C%22id%22%3A%22apify_token%22%2C%22description%22%3A%22Apify+API+Token%22%2C%22password%22%3Atrue%7D%5D) [![Install with NPX in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-NPM-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=actors-mcp-server&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40apify%2Factors-mcp-server%22%5D%2C%22env%22%3A%7B%22APIFY_TOKEN%22%3A%22%24%7Binput%3Aapify_token%7D%22%7D%7D&inputs=%5B%7B%22type%22%3A%22promptString%22%2C%22id%22%3A%22apify_token%22%2C%22description%22%3A%22Apify+API+Token%22%2C%22password%22%3Atrue%7D%5D&quality=insiders)
344
+
345
+ ##### Manual installation
346
+
347
+ You can manually install the Apify MCP Server in VS Code. First, click one of the install buttons at the top of this section for a one-click installation.
348
+
349
+ Alternatively, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing `Ctrl + Shift + P` and typing `Preferences: Open User Settings (JSON)`.
350
+
351
+ ```json
352
+ {
353
+ "mcp": {
354
+ "inputs": [
355
+ {
356
+ "type": "promptString",
357
+ "id": "apify_token",
358
+ "description": "Apify API Token",
359
+ "password": true
360
+ }
361
+ ],
362
+ "servers": {
363
+ "actors-mcp-server": {
364
+ "command": "npx",
365
+ "args": ["-y", "@apify/actors-mcp-server"],
366
+ "env": {
367
+ "APIFY_TOKEN": "${input:apify_token}"
368
+ }
369
+ }
370
+ }
371
+ }
372
+ }
373
+ ```
374
+
375
+ Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace - just omit the top-level `mcp {}` key. This will allow you to share the configuration with others.
376
+
377
+ If you want to specify which Actors to load, you can add the `--actors` argument:
378
+
379
+ ```json
380
+ {
381
+ "servers": {
382
+ "actors-mcp-server": {
383
+ "command": "npx",
384
+ "args": [
385
+ "-y", "@apify/actors-mcp-server",
386
+ "--actors", "lukaskrivka/google-maps-with-contact-details,apify/instagram-scraper"
387
+ ],
388
+ "env": {
389
+ "APIFY_TOKEN": "${input:apify_token}"
390
+ }
391
+ }
392
+ }
393
+ }
394
+ ```
395
+
340
396
  #### Debugging NPM package @apify/actors-mcp-server with @modelcontextprotocol/inspector
341
397
 
342
398
  To debug the server, use the [MCP Inspector](https://github.com/modelcontextprotocol/inspector) tool:
@@ -408,7 +464,7 @@ You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-
408
464
 
409
465
  ```bash
410
466
  export APIFY_TOKEN=your-apify-token
411
- npx @modelcontextprotocol/inspector node ./dist/index.js
467
+ npx @modelcontextprotocol/inspector node ./dist/stdio.js
412
468
  ```
413
469
 
414
470
  Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Constants for the Actor.
3
+ */
4
+ export declare const HEADER_READINESS_PROBE = "x-apify-container-server-readiness-probe";
5
+ export declare enum Routes {
6
+ ROOT = "/",
7
+ MCP = "/mcp",
8
+ SSE = "/sse",
9
+ MESSAGE = "/message"
10
+ }
11
+ export declare const getHelpMessage: (host: string) => string;
12
+ //# sourceMappingURL=const.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../src/actor/const.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,sBAAsB,6CAA6C,CAAC;AAEjF,oBAAY,MAAM;IACd,IAAI,MAAM;IACV,GAAG,SAAS;IACZ,GAAG,SAAS;IACZ,OAAO,aAAa;CACvB;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,WAKW,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Constants for the Actor.
3
+ */
4
+ export const HEADER_READINESS_PROBE = 'x-apify-container-server-readiness-probe';
5
+ export var Routes;
6
+ (function (Routes) {
7
+ Routes["ROOT"] = "/";
8
+ Routes["MCP"] = "/mcp";
9
+ Routes["SSE"] = "/sse";
10
+ Routes["MESSAGE"] = "/message";
11
+ })(Routes || (Routes = {}));
12
+ export const getHelpMessage = (host) => `To interact with the server you can either:
13
+ - send request to ${host}${Routes.MCP}?token=YOUR-APIFY-TOKEN and receive a response
14
+ or
15
+ - connect for Server-Sent Events (SSE) via GET request to: ${host}${Routes.SSE}?token=YOUR-APIFY-TOKEN
16
+ - send messages via POST request to: ${host}${Routes.MESSAGE}?token=YOUR-APIFY-TOKEN
17
+ (Include your message content in the request body.)`;
18
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/actor/const.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,0CAA0C,CAAC;AAEjF,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IACd,oBAAU,CAAA;IACV,sBAAY,CAAA;IACZ,sBAAY,CAAA;IACZ,8BAAoB,CAAA;AACxB,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC;oBAC5B,IAAI,GAAG,MAAM,CAAC,GAAG;;6DAEwB,IAAI,GAAG,MAAM,CAAC,GAAG;uCACvC,IAAI,GAAG,MAAM,CAAC,OAAO;sDACN,CAAC"}
@@ -0,0 +1,4 @@
1
+ import express from 'express';
2
+ import { type ActorsMcpServer } from '../mcp/server.js';
3
+ export declare function createExpressApp(host: string, mcpServer: ActorsMcpServer): express.Express;
4
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/actor/server.ts"],"names":[],"mappings":"AASA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKxD,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,eAAe,GAC3B,OAAO,CAAC,OAAO,CAgJjB"}
@@ -0,0 +1,158 @@
1
+ /*
2
+ * Express server implementation used for standby Actor mode.
3
+ */
4
+ import { randomUUID } from 'node:crypto';
5
+ import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
6
+ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
7
+ import express from 'express';
8
+ import log from '@apify/log';
9
+ import { processParamsGetTools } from '../mcp/utils.js';
10
+ import { getHelpMessage, HEADER_READINESS_PROBE, Routes } from './const.js';
11
+ import { getActorRunData } from './utils.js';
12
+ export function createExpressApp(host, mcpServer) {
13
+ const app = express();
14
+ let transportSSE;
15
+ const transports = {};
16
+ function respondWithError(res, error, logMessage, statusCode = 500) {
17
+ log.error(`${logMessage}: ${error}`);
18
+ if (!res.headersSent) {
19
+ res.status(statusCode).json({
20
+ jsonrpc: '2.0',
21
+ error: {
22
+ code: statusCode === 500 ? -32603 : -32000,
23
+ message: statusCode === 500 ? 'Internal server error' : 'Bad Request',
24
+ },
25
+ id: null,
26
+ });
27
+ }
28
+ }
29
+ app.get(Routes.ROOT, async (req, res) => {
30
+ if (req.headers && req.get(HEADER_READINESS_PROBE) !== undefined) {
31
+ log.debug('Received readiness probe');
32
+ res.status(200).json({ message: 'Server is ready' }).end();
33
+ return;
34
+ }
35
+ try {
36
+ log.info(`Received GET message at: ${Routes.ROOT}`);
37
+ const tools = await processParamsGetTools(req.url, process.env.APIFY_TOKEN);
38
+ if (tools) {
39
+ mcpServer.updateTools(tools);
40
+ }
41
+ res.setHeader('Content-Type', 'text/event-stream');
42
+ res.setHeader('Cache-Control', 'no-cache');
43
+ res.setHeader('Connection', 'keep-alive');
44
+ res.status(200).json({ message: `Actor is using Model Context Protocol. ${getHelpMessage(host)}`, data: getActorRunData() }).end();
45
+ }
46
+ catch (error) {
47
+ respondWithError(res, error, `Error in GET ${Routes.ROOT}`);
48
+ }
49
+ });
50
+ app.head(Routes.ROOT, (_req, res) => {
51
+ res.status(200).end();
52
+ });
53
+ app.get(Routes.SSE, async (req, res) => {
54
+ try {
55
+ log.info(`Received GET message at: ${Routes.SSE}`);
56
+ const tools = await processParamsGetTools(req.url, process.env.APIFY_TOKEN);
57
+ if (tools.length > 0) {
58
+ mcpServer.updateTools(tools);
59
+ }
60
+ else {
61
+ // We are loading default Actors (if not specified otherwise), so that we don't have "empty" tools
62
+ await mcpServer.loadDefaultTools(process.env.APIFY_TOKEN);
63
+ }
64
+ transportSSE = new SSEServerTransport(Routes.MESSAGE, res);
65
+ await mcpServer.connect(transportSSE);
66
+ }
67
+ catch (error) {
68
+ respondWithError(res, error, `Error in GET ${Routes.SSE}`);
69
+ }
70
+ });
71
+ app.post(Routes.MESSAGE, async (req, res) => {
72
+ try {
73
+ log.info(`Received POST message at: ${Routes.MESSAGE}`);
74
+ if (transportSSE) {
75
+ await transportSSE.handlePostMessage(req, res);
76
+ }
77
+ else {
78
+ log.error('Server is not connected to the client.');
79
+ res.status(400).json({
80
+ jsonrpc: '2.0',
81
+ error: {
82
+ code: -32000,
83
+ message: 'Bad Request: Server is not connected to the client. '
84
+ + 'Connect to the server with GET request to /sse endpoint',
85
+ },
86
+ id: null,
87
+ });
88
+ }
89
+ }
90
+ catch (error) {
91
+ respondWithError(res, error, `Error in POST ${Routes.MESSAGE}`);
92
+ }
93
+ });
94
+ app.post(Routes.MCP, async (req, res) => {
95
+ log.info('Received MCP request:', req.body);
96
+ try {
97
+ // Check for existing session ID
98
+ const sessionId = req.headers['mcp-session-id'];
99
+ let transport;
100
+ if (sessionId && transports[sessionId]) {
101
+ // Reuse existing transport
102
+ transport = transports[sessionId];
103
+ }
104
+ else if (!sessionId && isInitializeRequest(req.body)) {
105
+ // New initialization request - use JSON response mode
106
+ transport = new StreamableHTTPServerTransport({
107
+ sessionIdGenerator: () => randomUUID(),
108
+ enableJsonResponse: true, // Enable JSON response mode
109
+ });
110
+ // Connect the transport to the MCP server BEFORE handling the request
111
+ await mcpServer.connect(transport);
112
+ // After handling the request, if we get a session ID back, store the transport
113
+ await transport.handleRequest(req, res, req.body);
114
+ // Store the transport by session ID for future requests
115
+ if (transport.sessionId) {
116
+ transports[transport.sessionId] = transport;
117
+ }
118
+ return; // Already handled
119
+ }
120
+ else {
121
+ // Invalid request - no session ID or not initialization request
122
+ res.status(400).json({
123
+ jsonrpc: '2.0',
124
+ error: {
125
+ code: -32000,
126
+ message: 'Bad Request: No valid session ID provided or not initialization request',
127
+ },
128
+ id: null,
129
+ });
130
+ return;
131
+ }
132
+ // Handle the request with existing transport - no need to reconnect
133
+ await transport.handleRequest(req, res, req.body);
134
+ }
135
+ catch (error) {
136
+ respondWithError(res, error, 'Error handling MCP request');
137
+ }
138
+ });
139
+ // Handle GET requests for SSE streams according to spec
140
+ app.get(Routes.MCP, async (_req, res) => {
141
+ // We don't support GET requests for this server
142
+ // The spec requires returning 405 Method Not Allowed in this case
143
+ res.status(405).set('Allow', 'POST').send('Method Not Allowed');
144
+ });
145
+ // Catch-all for undefined routes
146
+ app.use((req, res) => {
147
+ res.status(404).json({ message: `There is nothing at route ${req.method} ${req.originalUrl}. ${getHelpMessage(host)}` }).end();
148
+ });
149
+ return app;
150
+ }
151
+ // Helper function to detect initialize requests
152
+ function isInitializeRequest(body) {
153
+ if (Array.isArray(body)) {
154
+ return body.some((msg) => typeof msg === 'object' && msg !== null && 'method' in msg && msg.method === 'initialize');
155
+ }
156
+ return typeof body === 'object' && body !== null && 'method' in body && body.method === 'initialize';
157
+ }
158
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/actor/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,GAAG,MAAM,YAAY,CAAC;AAG7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,UAAU,gBAAgB,CAC5B,IAAY,EACZ,SAA0B;IAE1B,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,IAAI,YAAgC,CAAC;IACrC,MAAM,UAAU,GAA2D,EAAE,CAAC;IAE9E,SAAS,gBAAgB,CAAC,GAAa,EAAE,KAAc,EAAE,UAAkB,EAAE,UAAU,GAAG,GAAG;QACzF,GAAG,CAAC,KAAK,CAAC,GAAG,UAAU,KAAK,KAAK,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;YACnB,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;gBACxB,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACH,IAAI,EAAE,UAAU,KAAK,GAAG,CAAC,CAA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AM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,iCAAiC;IACjC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;QACpC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,6BAA6B,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,WAAW,KAAK,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;IACnI,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACf,CAAC;AAED,gDAAgD;AAChD,SAAS,mBAAmB,CAAC,IAAa;IACtC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,QAAQ,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC;IACzH,CAAC;IACD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,YAAY,CAAC;AACzG,CAAC"}
@@ -0,0 +1,23 @@
1
+ export interface ActorRunData {
2
+ id?: string;
3
+ actId?: string;
4
+ userId?: string;
5
+ startedAt?: string;
6
+ finishedAt: null;
7
+ status: 'RUNNING';
8
+ meta: {
9
+ origin?: string;
10
+ };
11
+ options: {
12
+ build?: string;
13
+ memoryMbytes?: string;
14
+ };
15
+ buildId?: string;
16
+ defaultKeyValueStoreId?: string;
17
+ defaultDatasetId?: string;
18
+ defaultRequestQueueId?: string;
19
+ buildNumber?: string;
20
+ containerUrl?: string;
21
+ standbyUrl?: string;
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/actor/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE;QACF,MAAM,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,OAAO,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/actor/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { ActorRunData } from './types.js';
2
+ export declare function getActorRunData(): ActorRunData | null;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/actor/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAuBrD"}
@@ -0,0 +1,26 @@
1
+ import { Actor } from 'apify';
2
+ export function getActorRunData() {
3
+ return Actor.isAtHome() ? {
4
+ id: process.env.ACTOR_RUN_ID,
5
+ actId: process.env.ACTOR_ID,
6
+ userId: process.env.APIFY_USER_ID,
7
+ startedAt: process.env.ACTOR_STARTED_AT,
8
+ finishedAt: null,
9
+ status: 'RUNNING',
10
+ meta: {
11
+ origin: process.env.APIFY_META_ORIGIN,
12
+ },
13
+ options: {
14
+ build: process.env.ACTOR_BUILD_NUMBER,
15
+ memoryMbytes: process.env.ACTOR_MEMORY_MBYTES,
16
+ },
17
+ buildId: process.env.ACTOR_BUILD_ID,
18
+ defaultKeyValueStoreId: process.env.ACTOR_DEFAULT_KEY_VALUE_STORE_ID,
19
+ defaultDatasetId: process.env.ACTOR_DEFAULT_DATASET_ID,
20
+ defaultRequestQueueId: process.env.ACTOR_DEFAULT_REQUEST_QUEUE_ID,
21
+ buildNumber: process.env.ACTOR_BUILD_NUMBER,
22
+ containerUrl: process.env.ACTOR_WEB_SERVER_URL,
23
+ standbyUrl: process.env.ACTOR_STANDBY_URL,
24
+ } : null;
25
+ }
26
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/actor/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAI9B,MAAM,UAAU,eAAe;IAC3B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACtB,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;QAC5B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;QAC3B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;QACjC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;QACvC,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;SACxC;QACD,OAAO,EAAE;YACL,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;YACrC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;SAChD;QACD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;QACnC,sBAAsB,EAAE,OAAO,CAAC,GAAG,CAAC,gCAAgC;QACpE,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB;QACtD,qBAAqB,EAAE,OAAO,CAAC,GAAG,CAAC,8BAA8B;QACjE,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;QAC3C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB;QAC9C,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;KAC5C,CAAC,CAAC,CAAC,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ApifyClientOptions } from 'apify';
2
+ import { ApifyClient as _ApifyClient } from 'apify-client';
3
+ export declare function getApifyAPIBaseUrl(): string;
4
+ export declare class ApifyClient extends _ApifyClient {
5
+ constructor(options: ApifyClientOptions);
6
+ }
7
+ //# sourceMappingURL=apify-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify-client.d.ts","sourceRoot":"","sources":["../src/apify-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,cAAc,CAAC;AAiB3D,wBAAgB,kBAAkB,IAAI,MAAM,CAI3C;AAED,qBAAa,WAAY,SAAQ,YAAY;gBAC7B,OAAO,EAAE,kBAAkB;CAO1C"}
@@ -0,0 +1,30 @@
1
+ import { ApifyClient as _ApifyClient } from 'apify-client';
2
+ import { USER_AGENT_ORIGIN } from './const.js';
3
+ /**
4
+ * Adds a User-Agent header to the request config.
5
+ * @param config
6
+ * @private
7
+ */
8
+ function addUserAgent(config) {
9
+ var _a, _b;
10
+ const updatedConfig = { ...config };
11
+ updatedConfig.headers = (_a = updatedConfig.headers) !== null && _a !== void 0 ? _a : {};
12
+ updatedConfig.headers['User-Agent'] = `${(_b = updatedConfig.headers['User-Agent']) !== null && _b !== void 0 ? _b : ''}; ${USER_AGENT_ORIGIN}`;
13
+ return updatedConfig;
14
+ }
15
+ export function getApifyAPIBaseUrl() {
16
+ // Workaround for Actor server where the platform APIFY_API_BASE_URL did not work with getActorDefinition from actors.ts
17
+ if (process.env.APIFY_IS_AT_HOME)
18
+ return 'https://api.apify.com';
19
+ return process.env.APIFY_API_BASE_URL || 'https://api.apify.com';
20
+ }
21
+ export class ApifyClient extends _ApifyClient {
22
+ constructor(options) {
23
+ super({
24
+ ...options,
25
+ baseUrl: getApifyAPIBaseUrl(),
26
+ requestInterceptors: [addUserAgent],
27
+ });
28
+ }
29
+ }
30
+ //# sourceMappingURL=apify-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify-client.js","sourceRoot":"","sources":["../src/apify-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,cAAc,CAAC;AAG3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;GAIG;AACH,SAAS,YAAY,CAAC,MAA0B;;IAC5C,MAAM,aAAa,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IACpC,aAAa,CAAC,OAAO,GAAG,MAAA,aAAa,CAAC,OAAO,mCAAI,EAAE,CAAC;IACpD,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,GAAG,MAAA,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,mCAAI,EAAE,KAAK,iBAAiB,EAAE,CAAC;IAC3G,OAAO,aAAa,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAC9B,wHAAwH;IACxH,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB;QAAE,OAAO,uBAAuB,CAAC;IACjE,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,uBAAuB,CAAC;AACrE,CAAC;AAED,MAAM,OAAO,WAAY,SAAQ,YAAY;IACzC,YAAY,OAA2B;QACnC,KAAK,CAAC;YACF,GAAG,OAAO;YACV,OAAO,EAAE,kBAAkB,EAAE;YAC7B,mBAAmB,EAAE,CAAC,YAAY,CAAC;SACtC,CAAC,CAAC;IACP,CAAC;CACJ"}
package/dist/const.d.ts CHANGED
@@ -1,27 +1,23 @@
1
+ export declare const ACTOR_README_MAX_LENGTH = 5000;
2
+ export declare const ACTOR_ENUM_MAX_LENGTH = 200;
3
+ export declare const ACTOR_MAX_DESCRIPTION_LENGTH = 500;
4
+ export declare const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 5000;
5
+ export declare const ACTOR_OUTPUT_TRUNCATED_MESSAGE: string;
6
+ export declare const ACTOR_ADDITIONAL_INSTRUCTIONS: string;
7
+ export declare const ACTOR_MAX_MEMORY_MBYTES = 4096;
1
8
  export declare const SERVER_NAME = "apify-mcp-server";
2
- export declare const SERVER_VERSION = "0.1.0";
3
- export declare const HEADER_READINESS_PROBE = "x-apify-container-server-readiness-probe";
4
- export declare const MAX_DESCRIPTION_LENGTH = 500;
9
+ export declare const SERVER_VERSION = "1.0.0";
5
10
  export declare const USER_AGENT_ORIGIN = "Origin/mcp-server";
11
+ export declare enum HelperTools {
12
+ SEARCH_ACTOR = "search-actor",
13
+ ADD_TOOL = "add-tool",
14
+ REMOVE_TOOL = "remove-tool",
15
+ GET_TOOL_DETAILS = "get-tool-details"
16
+ }
6
17
  export declare const defaults: {
7
18
  actors: string[];
8
19
  enableActorAutoLoading: boolean;
9
20
  maxMemoryMbytes: number;
10
21
  };
11
- export declare const ACTOR_README_MAX_LENGTH = 5000;
12
- export declare const ACTOR_ENUM_MAX_LENGTH = 200;
13
- export declare const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 5000;
14
- export declare const ACTOR_OUTPUT_TRUNCATED_MESSAGE: string;
15
- export declare const ACTOR_ADDITIONAL_INSTRUCTIONS: string;
16
- export declare enum InternalTools {
17
- DISCOVER_ACTORS = "discover-actors",
18
- ADD_ACTOR_TO_TOOLS = "add-actor-to-tools",
19
- REMOVE_ACTOR_FROM_TOOLS = "remove-actor-from-tools",
20
- GET_ACTOR_DETAILS = "get-actor-details"
21
- }
22
- export declare enum Routes {
23
- ROOT = "/",
24
- SSE = "/sse",
25
- MESSAGE = "/message"
26
- }
22
+ export declare const APIFY_USERNAME = "apify";
27
23
  //# sourceMappingURL=const.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAC9C,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,eAAO,MAAM,sBAAsB,6CAA6C,CAAC;AACjF,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,eAAO,MAAM,QAAQ;;;;CAQpB,CAAC;AAEF,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,+BAA+B,OAAQ,CAAC;AACrD,eAAO,MAAM,8BAA8B,QACQ,CAAC;AACpD,eAAO,MAAM,6BAA6B,QACuB,CAAC;AAElE,oBAAY,aAAa;IACrB,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;IACzC,uBAAuB,4BAA4B;IACnD,iBAAiB,sBAAsB;CAC1C;AAED,oBAAY,MAAM;IACd,IAAI,MAAM;IACV,GAAG,SAAS;IACZ,OAAO,aAAa;CACvB"}
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAGhD,eAAO,MAAM,+BAA+B,OAAQ,CAAC;AACrD,eAAO,MAAM,8BAA8B,QACQ,CAAC;AAEpD,eAAO,MAAM,6BAA6B,QACuB,CAAC;AAGlE,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAG7C,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAC9C,eAAO,MAAM,cAAc,UAAU,CAAC;AAGtC,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,oBAAY,WAAW;IACnB,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,gBAAgB,qBAAqB;CACxC;AAED,eAAO,MAAM,QAAQ;;;;CAQpB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAU,CAAC"}
package/dist/const.js CHANGED
@@ -1,8 +1,27 @@
1
+ // Actor input const
2
+ export const ACTOR_README_MAX_LENGTH = 5000;
3
+ export const ACTOR_ENUM_MAX_LENGTH = 200;
4
+ export const ACTOR_MAX_DESCRIPTION_LENGTH = 500;
5
+ // Actor output const
6
+ export const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 5000;
7
+ export const ACTOR_OUTPUT_TRUNCATED_MESSAGE = `Output was truncated because it will not fit into context.`
8
+ + `There is no reason to call this tool again!`;
9
+ export const ACTOR_ADDITIONAL_INSTRUCTIONS = 'Never call/execute tool/Actor unless confirmed by the user. '
10
+ + 'Always limit the number of results in the call arguments.';
11
+ // Actor run const
12
+ export const ACTOR_MAX_MEMORY_MBYTES = 4096; // If the Actor requires 8GB of memory, free users can't run actors-mcp-server and requested Actor
13
+ // MCP Server
1
14
  export const SERVER_NAME = 'apify-mcp-server';
2
- export const SERVER_VERSION = '0.1.0';
3
- export const HEADER_READINESS_PROBE = 'x-apify-container-server-readiness-probe';
4
- export const MAX_DESCRIPTION_LENGTH = 500;
15
+ export const SERVER_VERSION = '1.0.0';
16
+ // User agent headers
5
17
  export const USER_AGENT_ORIGIN = 'Origin/mcp-server';
18
+ export var HelperTools;
19
+ (function (HelperTools) {
20
+ HelperTools["SEARCH_ACTOR"] = "search-actor";
21
+ HelperTools["ADD_TOOL"] = "add-tool";
22
+ HelperTools["REMOVE_TOOL"] = "remove-tool";
23
+ HelperTools["GET_TOOL_DETAILS"] = "get-tool-details";
24
+ })(HelperTools || (HelperTools = {}));
6
25
  export const defaults = {
7
26
  actors: [
8
27
  'apify/instagram-scraper',
@@ -12,24 +31,5 @@ export const defaults = {
12
31
  enableActorAutoLoading: false,
13
32
  maxMemoryMbytes: 4096,
14
33
  };
15
- export const ACTOR_README_MAX_LENGTH = 5_000;
16
- export const ACTOR_ENUM_MAX_LENGTH = 200;
17
- export const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 5_000;
18
- export const ACTOR_OUTPUT_TRUNCATED_MESSAGE = `Output was truncated because it will not fit into context.`
19
- + `There is no reason to call this tool again!`;
20
- export const ACTOR_ADDITIONAL_INSTRUCTIONS = 'Never call/execute tool/Actor unless confirmed by the user. '
21
- + 'Always limit the number of results in the call arguments.';
22
- export var InternalTools;
23
- (function (InternalTools) {
24
- InternalTools["DISCOVER_ACTORS"] = "discover-actors";
25
- InternalTools["ADD_ACTOR_TO_TOOLS"] = "add-actor-to-tools";
26
- InternalTools["REMOVE_ACTOR_FROM_TOOLS"] = "remove-actor-from-tools";
27
- InternalTools["GET_ACTOR_DETAILS"] = "get-actor-details";
28
- })(InternalTools || (InternalTools = {}));
29
- export var Routes;
30
- (function (Routes) {
31
- Routes["ROOT"] = "/";
32
- Routes["SSE"] = "/sse";
33
- Routes["MESSAGE"] = "/message";
34
- })(Routes || (Routes = {}));
34
+ export const APIFY_USERNAME = 'apify';
35
35
  //# sourceMappingURL=const.js.map
package/dist/const.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,M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GAAG,CAAC;AAEhD,qBAAqB;AACrB,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAK,CAAC;AACrD,MAAM,CAAC,MAAM,8BAA8B,GAAG,4DAA4D;MACpG,6CAA6C,CAAC;AAEpD,MAAM,CAAC,MAAM,6BAA6B,GAAG,8DAA8D;MACrG,2DAA2D,CAAC;AAElE,kBAAkB;AAClB,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAK,CAAC,CAAC,kGAAkG;AAEhJ,aAAa;AACb,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,qBAAqB;AACrB,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAErD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACnB,4CAA6B,CAAA;IAC7B,oCAAqB,CAAA;IACrB,0CAA2B,CAAA;IAC3B,oDAAqC,CAAA;AACzC,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,MAAM,EAAE;QACJ,yBAAyB;QACzB,uBAAuB;QACvB,8CAA8C;KACjD;IACD,sBAAsB,EAAE,KAAK;IAC7B,eAAe,EAAE,IAAI;CACxB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC"}
@@ -4,5 +4,15 @@
4
4
  *
5
5
  * It requires the `APIFY_TOKEN` in the `.env` file.
6
6
  */
7
- export {};
7
+ import type { EventSourceInit } from 'eventsource';
8
+ import { EventSource } from 'eventsource';
9
+ declare global {
10
+ var EventSource: {
11
+ new (url: string, eventSourceInitDict?: EventSourceInit): EventSource;
12
+ prototype: EventSource;
13
+ CONNECTING: 0;
14
+ OPEN: 1;
15
+ CLOSED: 2;
16
+ };
17
+ }
8
18
  //# sourceMappingURL=clientSse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientSse.d.ts","sourceRoot":"","sources":["../../src/examples/clientSse.ts"],"names":[],"mappings":"AACA;;;;;GAKG"}
1
+ {"version":3,"file":"clientSse.d.ts","sourceRoot":"","sources":["../../src/examples/clientSse.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AASH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAsB1C,OAAO,CAAC,MAAM,CAAC;IAGX,IAAI,WAAW,EAAE;QACb,KAAI,GAAG,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,eAAe,GAAG,WAAW,CAAC;QACrE,SAAS,EAAE,WAAW,CAAC;QACvB,UAAU,EAAE,CAAC,CAAC;QACd,IAAI,EAAE,CAAC,CAAC;QACR,MAAM,EAAE,CAAC,CAAC;KACb,CAAC;CACL"}
@@ -5,22 +5,23 @@
5
5
  *
6
6
  * It requires the `APIFY_TOKEN` in the `.env` file.
7
7
  */
8
- import path from 'path';
9
- import { fileURLToPath } from 'url';
8
+ import path from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
10
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
11
11
  import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
12
12
  import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
13
- import dotenv from 'dotenv';
14
- import { EventSource } from 'eventsource';
15
- import { actorNameToToolName } from '../actors.js';
16
- const REQUEST_TIMEOUT = 120_000; // 2 minutes
13
+ import dotenv from 'dotenv'; // eslint-disable-line import/no-extraneous-dependencies
14
+ import { EventSource } from 'eventsource'; // eslint-disable-line import/no-extraneous-dependencies
15
+ import { actorNameToToolName } from '../tools/utils.js';
16
+ const REQUEST_TIMEOUT = 120000; // 2 minutes
17
17
  const filename = fileURLToPath(import.meta.url);
18
18
  const dirname = path.dirname(filename);
19
19
  dotenv.config({ path: path.resolve(dirname, '../../.env') });
20
- const SERVER_URL = 'https://actors-mcp-server.apify.actor/sse';
20
+ const SERVER_URL = process.env.MCP_SERVER_URL_BASE || 'https://actors-mcp-server.apify.actor/sse';
21
21
  // We need to change forward slash / to underscore -- in the tool name as Anthropic does not allow forward slashes in the tool name
22
22
  const SELECTED_TOOL = actorNameToToolName('apify/rag-web-browser');
23
- const QUERY = 'web browser for Anthropic';
23
+ // const QUERY = 'web browser for Anthropic';
24
+ const QUERY = 'apify';
24
25
  if (!process.env.APIFY_TOKEN) {
25
26
  console.error('APIFY_TOKEN is required but not set in the environment variables.');
26
27
  process.exit(1);
@@ -40,7 +41,7 @@ async function main() {
40
41
  // You can use this to set additional headers on the outgoing request.
41
42
  // Based on this example: https://github.com/modelcontextprotocol/typescript-sdk/issues/118
42
43
  async fetch(input, init) {
43
- const headers = new Headers(init?.headers || {});
44
+ const headers = new Headers((init === null || init === void 0 ? void 0 : init.headers) || {});
44
45
  headers.set('authorization', `Bearer ${process.env.APIFY_TOKEN}`);
45
46
  return fetch(input, { ...init, headers });
46
47
  },
@@ -71,12 +72,14 @@ async function main() {
71
72
  catch (error) {
72
73
  if (error instanceof Error) {
73
74
  console.error('Error:', error.message);
74
- console.error(error.stack);
75
75
  }
76
76
  else {
77
77
  console.error('An unknown error occurred:', error);
78
78
  }
79
79
  }
80
+ finally {
81
+ await client.close();
82
+ }
80
83
  }
81
84
  await main();
82
85
  //# sourceMappingURL=clientSse.js.map