@apify/actors-mcp-server 0.1.21 → 0.1.22-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 (97) hide show
  1. package/README.md +1 -1
  2. package/dist/actor/const.d.ts +15 -0
  3. package/dist/actor/const.d.ts.map +1 -0
  4. package/dist/actor/const.js +20 -0
  5. package/dist/actor/const.js.map +1 -0
  6. package/dist/{input.d.ts → actor/input.d.ts} +1 -1
  7. package/dist/actor/input.d.ts.map +1 -0
  8. package/dist/{input.js → actor/input.js} +5 -1
  9. package/dist/actor/input.js.map +1 -0
  10. package/dist/actor/server.d.ts +4 -0
  11. package/dist/actor/server.d.ts.map +1 -0
  12. package/dist/actor/server.js +81 -0
  13. package/dist/actor/server.js.map +1 -0
  14. package/dist/actor/types.d.ts +30 -0
  15. package/dist/actor/types.d.ts.map +1 -0
  16. package/dist/actor/types.js +2 -0
  17. package/dist/actor/types.js.map +1 -0
  18. package/dist/actor/utils.d.ts +11 -0
  19. package/dist/actor/utils.d.ts.map +1 -0
  20. package/dist/actor/utils.js +50 -0
  21. package/dist/actor/utils.js.map +1 -0
  22. package/dist/const.d.ts +10 -20
  23. package/dist/const.d.ts.map +1 -1
  24. package/dist/const.js +17 -27
  25. package/dist/const.js.map +1 -1
  26. package/dist/examples/clientSse.d.ts +10 -1
  27. package/dist/examples/clientSse.d.ts.map +1 -1
  28. package/dist/examples/clientSse.js +7 -4
  29. package/dist/examples/clientSse.js.map +1 -1
  30. package/dist/examples/clientStdio.js +2 -2
  31. package/dist/examples/clientStdio.js.map +1 -1
  32. package/dist/examples/clientStdioChat.js +1 -1
  33. package/dist/index.d.ts +2 -14
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +6 -42
  36. package/dist/index.js.map +1 -1
  37. package/dist/main.d.ts +4 -0
  38. package/dist/main.d.ts.map +1 -1
  39. package/dist/main.js +21 -118
  40. package/dist/main.js.map +1 -1
  41. package/dist/mcp-server.d.ts +39 -0
  42. package/dist/mcp-server.d.ts.map +1 -0
  43. package/dist/mcp-server.js +155 -0
  44. package/dist/mcp-server.js.map +1 -0
  45. package/dist/stdio.d.ts +15 -0
  46. package/dist/stdio.d.ts.map +1 -0
  47. package/dist/stdio.js +46 -0
  48. package/dist/stdio.js.map +1 -0
  49. package/dist/tools/actor.d.ts +37 -0
  50. package/dist/tools/actor.d.ts.map +1 -0
  51. package/dist/tools/actor.js +89 -0
  52. package/dist/tools/actor.js.map +1 -0
  53. package/dist/tools/build.d.ts +12 -0
  54. package/dist/tools/build.d.ts.map +1 -0
  55. package/dist/tools/build.js +120 -0
  56. package/dist/tools/build.js.map +1 -0
  57. package/dist/tools/helpers.d.ts +19 -0
  58. package/dist/tools/helpers.d.ts.map +1 -0
  59. package/dist/tools/helpers.js +62 -0
  60. package/dist/tools/helpers.js.map +1 -0
  61. package/dist/tools/index.d.ts +6 -0
  62. package/dist/tools/index.d.ts.map +1 -0
  63. package/dist/tools/index.js +8 -0
  64. package/dist/tools/index.js.map +1 -0
  65. package/dist/tools/mcp-apify-client.d.ts +6 -0
  66. package/dist/tools/mcp-apify-client.d.ts.map +1 -0
  67. package/dist/tools/mcp-apify-client.js +22 -0
  68. package/dist/tools/mcp-apify-client.js.map +1 -0
  69. package/dist/tools/store_collection.d.ts +21 -0
  70. package/dist/tools/store_collection.d.ts.map +1 -0
  71. package/dist/tools/store_collection.js +80 -0
  72. package/dist/tools/store_collection.js.map +1 -0
  73. package/dist/tools/utils.d.ts +77 -0
  74. package/dist/tools/utils.d.ts.map +1 -0
  75. package/dist/{actors.js → tools/utils.js} +112 -241
  76. package/dist/tools/utils.js.map +1 -0
  77. package/dist/tsconfig.tsbuildinfo +1 -1
  78. package/dist/types.d.ts +70 -9
  79. package/dist/types.d.ts.map +1 -1
  80. package/package.json +17 -14
  81. package/dist/actors.d.ts +0 -74
  82. package/dist/actors.d.ts.map +0 -1
  83. package/dist/actors.js.map +0 -1
  84. package/dist/input.d.ts.map +0 -1
  85. package/dist/input.js.map +0 -1
  86. package/dist/logger.d.ts +0 -3
  87. package/dist/logger.d.ts.map +0 -1
  88. package/dist/logger.js +0 -4
  89. package/dist/logger.js.map +0 -1
  90. package/dist/server.d.ts +0 -43
  91. package/dist/server.d.ts.map +0 -1
  92. package/dist/server.js +0 -178
  93. package/dist/server.js.map +0 -1
  94. package/dist/tools.d.ts +0 -46
  95. package/dist/tools.d.ts.map +0 -1
  96. package/dist/tools.js +0 -128
  97. package/dist/tools.js.map +0 -1
package/dist/main.d.ts CHANGED
@@ -1,2 +1,6 @@
1
+ /**
2
+ * Serves as an Actor MCP SSE server entry point.
3
+ * This file needs to be named `main.ts` to be recognized by the Apify platform.
4
+ */
1
5
  export {};
2
6
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
package/dist/main.js CHANGED
@@ -1,131 +1,32 @@
1
- import { parse } from 'querystring';
2
- import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
1
+ /**
2
+ * Serves as an Actor MCP SSE server entry point.
3
+ * This file needs to be named `main.ts` to be recognized by the Apify platform.
4
+ */
3
5
  import { Actor } from 'apify';
4
- import express from 'express';
5
- import { HEADER_READINESS_PROBE, Routes } from './const.js';
6
- import { processInput } from './input.js';
7
- import { log } from './logger.js';
8
- import { ApifyMcpServer } from './server.js';
9
- import { getActorDiscoveryTools, getActorAutoLoadingTools } from './tools.js';
10
- await Actor.init();
6
+ import log from '@apify/log';
7
+ import { processInput } from './actor/input.js';
8
+ import { createExpressApp } from './actor/server.js';
9
+ import { ActorsMcpServer } from './mcp-server.js';
10
+ import { actorDefinitionTool, addTool, removeTool, searchTool, callActorGetDataset } from './tools/index.js';
11
11
  const STANDBY_MODE = Actor.getEnv().metaOrigin === 'STANDBY';
12
+ await Actor.init();
12
13
  const HOST = Actor.isAtHome() ? process.env.ACTOR_STANDBY_URL : 'http://localhost';
13
- const PORT = Actor.isAtHome() ? process.env.ACTOR_STANDBY_PORT : 3001;
14
+ const PORT = Actor.isAtHome() ? Number(process.env.ACTOR_STANDBY_PORT) : 3001;
14
15
  if (!process.env.APIFY_TOKEN) {
15
16
  log.error('APIFY_TOKEN is required but not set in the environment variables.');
16
17
  process.exit(1);
17
18
  }
18
- const app = express();
19
- const mcpServer = new ApifyMcpServer();
20
- let transport;
21
- const HELP_MESSAGE = `Connect to the server with GET request to ${HOST}/sse?token=YOUR-APIFY-TOKEN`
22
- + ` and then send POST requests to ${HOST}/message?token=YOUR-APIFY-TOKEN`;
23
- const actorRun = Actor.isAtHome() ? {
24
- id: process.env.ACTOR_RUN_ID,
25
- actId: process.env.ACTOR_ID,
26
- userId: process.env.APIFY_USER_ID,
27
- startedAt: process.env.ACTOR_STARTED_AT,
28
- finishedAt: null,
29
- status: 'RUNNING',
30
- meta: {
31
- origin: process.env.APIFY_META_ORIGIN,
32
- },
33
- options: {
34
- build: process.env.ACTOR_BUILD_NUMBER,
35
- memoryMbytes: process.env.ACTOR_MEMORY_MBYTES,
36
- },
37
- buildId: process.env.ACTOR_BUILD_ID,
38
- defaultKeyValueStoreId: process.env.ACTOR_DEFAULT_KEY_VALUE_STORE_ID,
39
- defaultDatasetId: process.env.ACTOR_DEFAULT_DATASET_ID,
40
- defaultRequestQueueId: process.env.ACTOR_DEFAULT_REQUEST_QUEUE_ID,
41
- buildNumber: process.env.ACTOR_BUILD_NUMBER,
42
- containerUrl: process.env.ACTOR_WEB_SERVER_URL,
43
- standbyUrl: process.env.ACTOR_STANDBY_URL,
44
- } : {};
45
- /**
46
- * Process input parameters and update tools
47
- * If URL contains query parameter actors, add tools from actors, otherwise add tools from default actors
48
- * @param url
49
- */
50
- async function processParamsAndUpdateTools(url) {
51
- const params = parse(url.split('?')[1] || '');
52
- delete params.token;
53
- log.debug(`Received input parameters: ${JSON.stringify(params)}`);
54
- const input = await processInput(params);
55
- if (input.actors) {
56
- await mcpServer.addToolsFromActors(input.actors);
57
- }
58
- if (input.enableActorAutoLoading) {
59
- mcpServer.updateTools(getActorAutoLoadingTools());
60
- }
61
- log.debug(`Server is running in STANDBY mode with the following Actors (tools): ${mcpServer.getToolNames()}.
62
- To use different Actors, provide them in query parameter "actors" or include them in the Actor Task input.`);
63
- }
64
- app.route(Routes.ROOT)
65
- .get(async (req, res) => {
66
- if (req.headers && req.get(HEADER_READINESS_PROBE) !== undefined) {
67
- log.debug('Received readiness probe');
68
- res.status(200).json({ message: 'Server is ready' }).end();
69
- return;
70
- }
71
- try {
72
- log.info(`Received GET message at: ${Routes.ROOT}`);
73
- await processParamsAndUpdateTools(req.url);
74
- res.status(200).json({ message: `Actor is using Model Context Protocol. ${HELP_MESSAGE}`, data: actorRun }).end();
75
- }
76
- catch (error) {
77
- log.error(`Error in GET ${Routes.ROOT} ${error}`);
78
- res.status(500).json({ message: 'Internal Server Error' }).end();
79
- }
80
- })
81
- .head((_req, res) => {
82
- res.status(200).end();
83
- });
84
- app.route(Routes.SSE)
85
- .get(async (req, res) => {
86
- try {
87
- log.info(`Received GET message at: ${Routes.SSE}`);
88
- await processParamsAndUpdateTools(req.url);
89
- transport = new SSEServerTransport(Routes.MESSAGE, res);
90
- await mcpServer.connect(transport);
91
- }
92
- catch (error) {
93
- log.error(`Error in GET ${Routes.SSE}: ${error}`);
94
- res.status(500).json({ message: 'Internal Server Error' }).end();
95
- }
96
- });
97
- app.route(Routes.MESSAGE)
98
- .post(async (req, res) => {
99
- try {
100
- log.info(`Received POST message at: ${Routes.MESSAGE}`);
101
- if (transport) {
102
- await transport.handlePostMessage(req, res);
103
- }
104
- else {
105
- res.status(400).json({
106
- message: 'Server is not connected to the client. '
107
- + 'Connect to the server with GET request to /sse endpoint',
108
- });
109
- }
110
- }
111
- catch (error) {
112
- log.error(`Error in POST ${Routes.MESSAGE}: ${error}`);
113
- res.status(500).json({ message: 'Internal Server Error' }).end();
114
- }
115
- });
116
- // Catch-all for undefined routes
117
- app.use((req, res) => {
118
- res.status(404).json({ message: `There is nothing at route ${req.method} ${req.originalUrl}. ${HELP_MESSAGE}` }).end();
119
- });
120
- const input = await processInput((await Actor.getInput()) ?? {});
19
+ const mcpServer = new ActorsMcpServer();
20
+ const input = processInput((await Actor.getInput()) ?? {});
121
21
  log.info(`Loaded input: ${JSON.stringify(input)} `);
122
22
  if (STANDBY_MODE) {
23
+ const app = createExpressApp(HOST, mcpServer);
123
24
  log.info('Actor is running in the STANDBY mode.');
124
- await mcpServer.addToolsFromDefaultActors();
125
- mcpServer.updateTools(getActorDiscoveryTools());
25
+ const tools = [searchTool, actorDefinitionTool];
126
26
  if (input.enableActorAutoLoading) {
127
- mcpServer.updateTools(getActorAutoLoadingTools());
27
+ tools.push(addTool, removeTool);
128
28
  }
29
+ mcpServer.updateTools(tools);
129
30
  app.listen(PORT, () => {
130
31
  log.info(`The Actor web server is listening for user requests at ${HOST}`);
131
32
  });
@@ -133,10 +34,12 @@ if (STANDBY_MODE) {
133
34
  else {
134
35
  log.info('Actor is not designed to run in the NORMAL model (use this mode only for debugging purposes)');
135
36
  if (input && !input.debugActor && !input.debugActorInput) {
136
- await Actor.fail('If you need to debug a specific actor, please provide the debugActor and debugActorInput fields in the input');
37
+ await Actor.fail('If you need to debug a specific Actor, please provide the debugActor and debugActorInput fields in the input');
137
38
  }
138
39
  const options = { memory: input.maxActorMemoryBytes };
139
- await mcpServer.callActorGetDataset(input.debugActor, input.debugActorInput, options);
40
+ const items = await callActorGetDataset(input.debugActor, input.debugActorInput, process.env.APIFY_TOKEN, options);
41
+ await Actor.pushData(items);
42
+ log.info(`Pushed ${items.length} items to the dataset`);
140
43
  await Actor.exit();
141
44
  }
142
45
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"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C,CAAC;IAEzG,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QACvD,MAAM,KAAK,CAAC,IAAI,CAAC,8GAA8G,CAAC,CAAC;IACrI,CAAC;IACD,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,mBAAmB,EAAsB,CAAC;IAC1E,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,KAAK,CAAC,UAAW,EAAE,KAAK,CAAC,eAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAErH,MAAM,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5B,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,MAAM,uBAAuB,CAAC,CAAC;IACxD,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Model Context Protocol (MCP) server for Apify Actors
3
+ */
4
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
+ import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
6
+ import type { ToolWrap } from './types.js';
7
+ /**
8
+ * Create Apify MCP server
9
+ */
10
+ export declare class ActorsMcpServer {
11
+ server: Server;
12
+ tools: Map<string, ToolWrap>;
13
+ constructor();
14
+ /**
15
+ * Loads missing default tools.
16
+ */
17
+ loadDefaultTools(): Promise<void>;
18
+ /**
19
+ * Loads tools from URL params.
20
+ *
21
+ * Used primarily for SSE.
22
+ */
23
+ loadToolsFromUrl(url: string): Promise<void>;
24
+ /**
25
+ * Upsert new tools.
26
+ * @param tools - Array of tool wrappers.
27
+ * @returns Array of tool wrappers.
28
+ */
29
+ updateTools(tools: ToolWrap[]): ToolWrap[];
30
+ /**
31
+ * Returns an array of tool names.
32
+ * @returns {string[]} - An array of tool names.
33
+ */
34
+ getToolNames(): string[];
35
+ private setupErrorHandling;
36
+ private setupToolHandlers;
37
+ connect(transport: Transport): Promise<void>;
38
+ }
39
+ //# sourceMappingURL=mcp-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAa/E,OAAO,KAAK,EAAyB,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKlE;;GAEG;AACH,qBAAa,eAAe;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;;IAsBpC;;OAEG;IACU,gBAAgB;IAM7B;;;;OAIG;IACU,gBAAgB,CAAC,GAAG,EAAE,MAAM;IAKzC;;;;OAIG;IACI,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE;IAQpC;;;OAGG;IACI,YAAY,IAAI,MAAM,EAAE;IAI/B,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,iBAAiB;IAiFnB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrD"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Model Context Protocol (MCP) server for Apify Actors
3
+ */
4
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
+ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
6
+ import log from '@apify/log';
7
+ import { ACTOR_OUTPUT_MAX_CHARS_PER_ITEM, ACTOR_OUTPUT_TRUNCATED_MESSAGE, SERVER_NAME, SERVER_VERSION, } from './const.js';
8
+ import { actorDefinitionTool, callActorGetDataset, getActorsAsTools, searchTool } from './tools/index.js';
9
+ import { defaults } from './actor/const.js';
10
+ import { actorNameToToolName } from './tools/utils.js';
11
+ import { processParamsGetTools } from './actor/utils.js';
12
+ /**
13
+ * Create Apify MCP server
14
+ */
15
+ export class ActorsMcpServer {
16
+ server;
17
+ tools;
18
+ constructor() {
19
+ this.server = new Server({
20
+ name: SERVER_NAME,
21
+ version: SERVER_VERSION,
22
+ }, {
23
+ capabilities: {
24
+ tools: { listChanged: true },
25
+ },
26
+ });
27
+ this.tools = new Map();
28
+ this.setupErrorHandling();
29
+ this.setupToolHandlers();
30
+ // Add default tools
31
+ this.updateTools([searchTool, actorDefinitionTool]);
32
+ }
33
+ /**
34
+ * Loads missing default tools.
35
+ */
36
+ async loadDefaultTools() {
37
+ const missingDefaultTools = defaults.actors.filter(name => !this.tools.has(actorNameToToolName(name)));
38
+ const tools = await getActorsAsTools(missingDefaultTools);
39
+ if (tools.length > 0)
40
+ this.updateTools(tools);
41
+ }
42
+ /**
43
+ * Loads tools from URL params.
44
+ *
45
+ * Used primarily for SSE.
46
+ */
47
+ async loadToolsFromUrl(url) {
48
+ const tools = await processParamsGetTools(url);
49
+ if (tools.length > 0)
50
+ this.updateTools(tools);
51
+ }
52
+ /**
53
+ * Upsert new tools.
54
+ * @param tools - Array of tool wrappers.
55
+ * @returns Array of tool wrappers.
56
+ */
57
+ updateTools(tools) {
58
+ for (const wrap of tools) {
59
+ this.tools.set(wrap.tool.name, wrap);
60
+ log.info(`Added/updated tool: ${wrap.tool.name}`);
61
+ }
62
+ return tools;
63
+ }
64
+ /**
65
+ * Returns an array of tool names.
66
+ * @returns {string[]} - An array of tool names.
67
+ */
68
+ getToolNames() {
69
+ return Array.from(this.tools.keys());
70
+ }
71
+ setupErrorHandling() {
72
+ this.server.onerror = (error) => {
73
+ console.error('[MCP Error]', error); // eslint-disable-line no-console
74
+ };
75
+ process.on('SIGINT', async () => {
76
+ await this.server.close();
77
+ process.exit(0);
78
+ });
79
+ }
80
+ setupToolHandlers() {
81
+ /**
82
+ * Handles the request to list tools.
83
+ * @param {object} request - The request object.
84
+ * @returns {object} - The response object containing the tools.
85
+ */
86
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => {
87
+ // TODO if there is actor-mcp as a tool, also list the tools from that Actor
88
+ const tools = Array.from(this.tools.values()).map((tool) => (tool.tool));
89
+ return { tools };
90
+ });
91
+ /**
92
+ * Handles the request to call a tool.
93
+ * @param {object} request - The request object containing tool name and arguments.
94
+ * @throws {Error} - Throws an error if the tool is unknown or arguments are invalid.
95
+ */
96
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
97
+ const { name, arguments: args } = request.params;
98
+ const apifyToken = request.params.apifyToken || process.env.APIFY_TOKEN;
99
+ // Validate token
100
+ if (!apifyToken) {
101
+ throw new Error('APIFY_TOKEN is required but not set in the environment variables or passed as a parameter.');
102
+ }
103
+ // Find tool by name or actor full name
104
+ const tool = Array.from(this.tools.values())
105
+ .find((t) => t.tool.name === name || (t.type === 'actor' && t.tool.actorFullName === name));
106
+ if (!tool) {
107
+ // TODO: handle errors better, server.sendLoggingMessage ( )
108
+ throw new Error(`Unknown tool: ${name}`);
109
+ }
110
+ if (!args) {
111
+ throw new Error(`Missing arguments for tool: ${name}`);
112
+ }
113
+ log.info(`Validate arguments for tool: ${tool.tool.name} with arguments: ${JSON.stringify(args)}`);
114
+ if (!tool.tool.ajvValidate(args)) {
115
+ throw new Error(`Invalid arguments for tool ${tool.tool.name}: args: ${JSON.stringify(args)} error: ${JSON.stringify(tool?.tool.ajvValidate.errors)}`);
116
+ }
117
+ try {
118
+ // Handle internal tool
119
+ if (tool.type === 'internal') {
120
+ const internalTool = tool.tool;
121
+ const res = await internalTool.call({
122
+ args,
123
+ apifyMcpServer: this,
124
+ mcpServer: this.server,
125
+ });
126
+ return { ...res };
127
+ }
128
+ // Handle actor tool
129
+ if (tool.type === 'actor') {
130
+ const actorTool = tool.tool;
131
+ const callOptions = {
132
+ memory: actorTool.memoryMbytes,
133
+ };
134
+ const items = await callActorGetDataset(actorTool.actorFullName, args, apifyToken, callOptions);
135
+ const content = items.map((item) => {
136
+ const text = JSON.stringify(item).slice(0, ACTOR_OUTPUT_MAX_CHARS_PER_ITEM);
137
+ return text.length === ACTOR_OUTPUT_MAX_CHARS_PER_ITEM
138
+ ? { type: 'text', text: `${text} ... ${ACTOR_OUTPUT_TRUNCATED_MESSAGE}` }
139
+ : { type: 'text', text };
140
+ });
141
+ return { content };
142
+ }
143
+ }
144
+ catch (error) {
145
+ log.error(`Error calling tool: ${error}`);
146
+ throw new Error(`Error calling tool: ${error}`);
147
+ }
148
+ throw new Error(`Tool ${name} is not implemented`);
149
+ });
150
+ }
151
+ async connect(transport) {
152
+ await this.server.connect(transport);
153
+ }
154
+ }
155
+ //# sourceMappingURL=mcp-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAGnG,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EACH,+BAA+B,EAC/B,8BAA8B,EAC9B,WAAW,EACX,cAAc,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE1G,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,eAAe;IACjB,MAAM,CAAS;IACf,KAAK,CAAwB;IAEpC;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CACpB;YACI,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,cAAc;SAC1B,EACD;YACI,YAAY,EAAE;gBACV,KAAK,EAAE,EAAE,WAA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,CAAC,CAAC;IACzC,CAAC;CACJ"}
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * This script initializes and starts the Apify MCP server using the Stdio transport.
4
+ *
5
+ * Usage:
6
+ * node <script_name> --actors=<actor1,actor2,...>
7
+ *
8
+ * Command-line arguments:
9
+ * --actors - A comma-separated list of Actor full names to add to the server.
10
+ *
11
+ * Example:
12
+ * node stdio.js --actors=apify/google-search-scraper,apify/instagram-scraper
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=stdio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG"}
package/dist/stdio.js ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * This script initializes and starts the Apify MCP server using the Stdio transport.
4
+ *
5
+ * Usage:
6
+ * node <script_name> --actors=<actor1,actor2,...>
7
+ *
8
+ * Command-line arguments:
9
+ * --actors - A comma-separated list of Actor full names to add to the server.
10
+ *
11
+ * Example:
12
+ * node stdio.js --actors=apify/google-search-scraper,apify/instagram-scraper
13
+ */
14
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
15
+ import minimist from 'minimist';
16
+ import log from '@apify/log';
17
+ import { defaults } from './actor/const.js';
18
+ import { ActorsMcpServer } from './mcp-server.js';
19
+ import { addTool, removeTool, getActorsAsTools } from './tools/index.js';
20
+ // Configure logging, set to ERROR
21
+ log.setLevel(log.LEVELS.ERROR);
22
+ // Parse command line arguments
23
+ const { actors = '', enableActorAutoLoading = false } = minimist(process.argv.slice(2));
24
+ const actorList = actors ? actors.split(',').map((a) => a.trim()) : [];
25
+ // Validate environment
26
+ if (!process.env.APIFY_TOKEN) {
27
+ log.error('APIFY_TOKEN is required but not set in the environment variables.');
28
+ process.exit(1);
29
+ }
30
+ async function main() {
31
+ const mcpServer = new ActorsMcpServer();
32
+ // Initialize tools
33
+ const tools = await getActorsAsTools(actorList.length ? actorList : defaults.actors);
34
+ if (enableActorAutoLoading) {
35
+ tools.push(addTool, removeTool);
36
+ }
37
+ mcpServer.updateTools(tools);
38
+ // Start server
39
+ const transport = new StdioServerTransport();
40
+ await mcpServer.connect(transport);
41
+ }
42
+ main().catch((error) => {
43
+ log.error('Server error:', error);
44
+ process.exit(1);
45
+ });
46
+ //# sourceMappingURL=stdio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.js","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,kCAAkC;AAClC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAE/B,+BAA+B;AAC/B,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,sBAAsB,GAAG,KAAK,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACxF,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAE/E,uBAAuB;AACvB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;IAC3B,GAAG,CAAC,KAAK,CAAC,mEAAmE,CAAC,CAAC;IAC/E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,KAAK,UAAU,IAAI;IACf,MAAM,SAAS,GAAG,IAAI,eAAe,EAAE,CAAC;IACxC,mBAAmB;IACnB,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrF,IAAI,sBAAsB,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC;IACD,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAE7B,eAAe;IACf,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACnB,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { ActorCallOptions } from 'apify-client';
2
+ import type { ToolWrap } from '../types.js';
3
+ /**
4
+ * Calls an Apify actor and retrieves the dataset items.
5
+ *
6
+ *
7
+ * It requires the `APIFY_TOKEN` environment variable to be set.
8
+ * If the `APIFY_IS_AT_HOME` the dataset items are pushed to the Apify dataset.
9
+ *
10
+ * @param {string} actorName - The name of the actor to call.
11
+ * @param {ActorCallOptions} callOptions - The options to pass to the actor.
12
+ * @param {unknown} input - The input to pass to the actor.
13
+ * @param {string} apifyToken - The Apify token to use for authentication.
14
+ * @returns {Promise<object[]>} - A promise that resolves to an array of dataset items.
15
+ * @throws {Error} - Throws an error if the `APIFY_TOKEN` is not set
16
+ */
17
+ export declare function callActorGetDataset(actorName: string, input: unknown, apifyToken: string, callOptions?: ActorCallOptions | undefined): Promise<object[]>;
18
+ /**
19
+ * Fetches actor input schemas by Actor IDs or Actor full names and creates MCP tools.
20
+ *
21
+ * This function retrieves the input schemas for the specified actors and compiles them into MCP tools.
22
+ * It uses the AJV library to validate the input schemas.
23
+ *
24
+ * Tool name can't contain /, so it is replaced with _
25
+ *
26
+ * The input schema processing workflow:
27
+ * 1. Properties are marked as required using markInputPropertiesAsRequired() to add "REQUIRED" prefix to descriptions
28
+ * 2. Nested properties are built by analyzing editor type (proxy, requestListSources) using buildNestedProperties()
29
+ * 3. Properties are filtered using filterSchemaProperties()
30
+ * 4. Properties are shortened using shortenProperties()
31
+ * 5. Enums are added to descriptions with examples using addEnumsToDescriptionsWithExamples()
32
+ *
33
+ * @param {string[]} actors - An array of actor IDs or Actor full names.
34
+ * @returns {Promise<Tool[]>} - A promise that resolves to an array of MCP tools.
35
+ */
36
+ export declare function getActorsAsTools(actors: string[]): Promise<ToolWrap[]>;
37
+ //# sourceMappingURL=actor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../../src/tools/actor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAa5C;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CACrC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,EAClB,WAAW,GAAE,gBAAgB,GAAG,SAAqB,GACtD,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBnB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAgC5E"}
@@ -0,0 +1,89 @@
1
+ import { Ajv } from 'ajv';
2
+ import log from '@apify/log';
3
+ import { getActorDefinition } from './build.js';
4
+ import { ACTOR_ADDITIONAL_INSTRUCTIONS, ACTOR_MAX_MEMORY_MBYTES } from '../const.js';
5
+ import { ApifyClient } from './mcp-apify-client.js';
6
+ import { actorNameToToolName, addEnumsToDescriptionsWithExamples, buildNestedProperties, filterSchemaProperties, markInputPropertiesAsRequired, shortenProperties, } from './utils.js';
7
+ /**
8
+ * Calls an Apify actor and retrieves the dataset items.
9
+ *
10
+ *
11
+ * It requires the `APIFY_TOKEN` environment variable to be set.
12
+ * If the `APIFY_IS_AT_HOME` the dataset items are pushed to the Apify dataset.
13
+ *
14
+ * @param {string} actorName - The name of the actor to call.
15
+ * @param {ActorCallOptions} callOptions - The options to pass to the actor.
16
+ * @param {unknown} input - The input to pass to the actor.
17
+ * @param {string} apifyToken - The Apify token to use for authentication.
18
+ * @returns {Promise<object[]>} - A promise that resolves to an array of dataset items.
19
+ * @throws {Error} - Throws an error if the `APIFY_TOKEN` is not set
20
+ */
21
+ export async function callActorGetDataset(actorName, input, apifyToken, callOptions = undefined) {
22
+ const name = actorName;
23
+ try {
24
+ log.info(`Calling Actor ${name} with input: ${JSON.stringify(input)}`);
25
+ const client = new ApifyClient({ token: apifyToken });
26
+ const actorClient = client.actor(name);
27
+ const results = await actorClient.call(input, callOptions);
28
+ const dataset = await client.dataset(results.defaultDatasetId).listItems();
29
+ log.info(`Actor ${name} finished with ${dataset.items.length} items`);
30
+ return dataset.items;
31
+ }
32
+ catch (error) {
33
+ log.error(`Error calling actor: ${error}. Actor: ${name}, input: ${JSON.stringify(input)}`);
34
+ throw new Error(`Error calling Actor: ${error}`);
35
+ }
36
+ }
37
+ /**
38
+ * Fetches actor input schemas by Actor IDs or Actor full names and creates MCP tools.
39
+ *
40
+ * This function retrieves the input schemas for the specified actors and compiles them into MCP tools.
41
+ * It uses the AJV library to validate the input schemas.
42
+ *
43
+ * Tool name can't contain /, so it is replaced with _
44
+ *
45
+ * The input schema processing workflow:
46
+ * 1. Properties are marked as required using markInputPropertiesAsRequired() to add "REQUIRED" prefix to descriptions
47
+ * 2. Nested properties are built by analyzing editor type (proxy, requestListSources) using buildNestedProperties()
48
+ * 3. Properties are filtered using filterSchemaProperties()
49
+ * 4. Properties are shortened using shortenProperties()
50
+ * 5. Enums are added to descriptions with examples using addEnumsToDescriptionsWithExamples()
51
+ *
52
+ * @param {string[]} actors - An array of actor IDs or Actor full names.
53
+ * @returns {Promise<Tool[]>} - A promise that resolves to an array of MCP tools.
54
+ */
55
+ export async function getActorsAsTools(actors) {
56
+ const ajv = new Ajv({ coerceTypes: 'array', strict: false });
57
+ const results = await Promise.all(actors.map(getActorDefinition));
58
+ const tools = [];
59
+ for (const result of results) {
60
+ if (result) {
61
+ if (result.input && 'properties' in result.input && result.input) {
62
+ result.input.properties = markInputPropertiesAsRequired(result.input);
63
+ result.input.properties = buildNestedProperties(result.input.properties);
64
+ result.input.properties = filterSchemaProperties(result.input.properties);
65
+ result.input.properties = shortenProperties(result.input.properties);
66
+ result.input.properties = addEnumsToDescriptionsWithExamples(result.input.properties);
67
+ }
68
+ try {
69
+ const memoryMbytes = result.defaultRunOptions?.memoryMbytes || ACTOR_MAX_MEMORY_MBYTES;
70
+ tools.push({
71
+ type: 'actor',
72
+ tool: {
73
+ name: actorNameToToolName(result.actorFullName),
74
+ actorFullName: result.actorFullName,
75
+ description: `${result.description} Instructions: ${ACTOR_ADDITIONAL_INSTRUCTIONS}`,
76
+ inputSchema: result.input || {},
77
+ ajvValidate: ajv.compile(result.input || {}),
78
+ memoryMbytes: memoryMbytes > ACTOR_MAX_MEMORY_MBYTES ? ACTOR_MAX_MEMORY_MBYTES : memoryMbytes,
79
+ },
80
+ });
81
+ }
82
+ catch (validationError) {
83
+ log.error(`Failed to compile AJV schema for Actor: ${result.actorFullName}. Error: ${validationError}`);
84
+ }
85
+ }
86
+ }
87
+ return tools;
88
+ }
89
+ //# sourceMappingURL=actor.js.map
@@ -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C;YAC1F,CAAC;YACD,IAAI,CAAC;gBACD,MAAM,YAAY,GAAG,MAAM,CAAC,iBAAiB,EAAE,YAAY,IAAI,uBAAuB,CAAC;gBACvF,KAAK,CAAC,IAAI,CAAC;oBACP,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE;wBACF,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,aAAa,CAAC;wBAC/C,aAAa,EAAE,MAAM,CAAC,aAAa;wBACnC,WAAW,EAAE,GAAG,MAAM,CAAC,WAAW,kBAAkB,6BAA6B,EAAE;wBACnF,WAAW,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;wBAC/B,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;wBAC5C,YAAY,EAAE,YAAY,GAAG,uBAAuB,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,YAAY;qBAChG;iBACJ,CAAC,CAAC;YACP,CAAC;YAAC,OAAO,eAAe,EAAE,CAAC;gBACvB,GAAG,CAAC,KAAK,CAAC,2CAA2C,MAAM,CAAC,aAAa,YAAY,eAAe,EAAE,CAAC,CAAC;YAC5G,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ActorDefinitionPruned, ToolWrap } from '../types.js';
2
+ /**
3
+ * Get Actor input schema by Actor name.
4
+ * First, fetch the Actor details to get the default build tag and buildId.
5
+ * Then, fetch the build details and return actorName, description, and input schema.
6
+ * @param {string} actorIdOrName - Actor ID or Actor full name.
7
+ * @param {number} limit - Truncate the README to this limit.
8
+ * @returns {Promise<ActorDefinitionWithDesc | null>} - The actor definition with description or null if not found.
9
+ */
10
+ export declare function getActorDefinition(actorIdOrName: string, limit?: number): Promise<ActorDefinitionPruned | null>;
11
+ export declare const actorDefinitionTool: ToolWrap;
12
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/tools/build.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,qBAAqB,EAA4D,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK7H;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,GAAE,MAAgC,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAsC9I;AA6CD,eAAO,MAAM,mBAAmB,EAAE,QAuBjC,CAAC"}