@apify/actors-mcp-server 0.1.22-beta.13 → 0.1.22-beta.15

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 (115) hide show
  1. package/README.md +62 -64
  2. package/dist/actors.d.ts +74 -0
  3. package/dist/actors.d.ts.map +1 -0
  4. package/dist/{tools/utils.js → actors.js} +241 -112
  5. package/dist/actors.js.map +1 -0
  6. package/dist/const.d.ts +18 -14
  7. package/dist/const.d.ts.map +1 -1
  8. package/dist/const.js +22 -22
  9. package/dist/const.js.map +1 -1
  10. package/dist/examples/clientSse.d.ts +1 -10
  11. package/dist/examples/clientSse.d.ts.map +1 -1
  12. package/dist/examples/clientSse.js +4 -7
  13. package/dist/examples/clientSse.js.map +1 -1
  14. package/dist/examples/clientStdio.js +2 -2
  15. package/dist/examples/clientStdio.js.map +1 -1
  16. package/dist/examples/clientStdioChat.js +1 -1
  17. package/dist/index.d.ts +14 -2
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +51 -6
  20. package/dist/index.js.map +1 -1
  21. package/dist/input.d.ts +1 -1
  22. package/dist/input.d.ts.map +1 -1
  23. package/dist/input.js +8 -6
  24. package/dist/input.js.map +1 -1
  25. package/dist/logger.d.ts +3 -0
  26. package/dist/logger.d.ts.map +1 -0
  27. package/dist/logger.js +4 -0
  28. package/dist/logger.js.map +1 -0
  29. package/dist/main.d.ts +0 -4
  30. package/dist/main.d.ts.map +1 -1
  31. package/dist/main.js +122 -27
  32. package/dist/main.js.map +1 -1
  33. package/dist/server.d.ts +43 -0
  34. package/dist/server.d.ts.map +1 -0
  35. package/dist/server.js +178 -0
  36. package/dist/server.js.map +1 -0
  37. package/dist/tools.d.ts +46 -0
  38. package/dist/tools.d.ts.map +1 -0
  39. package/dist/tools.js +128 -0
  40. package/dist/tools.js.map +1 -0
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/dist/types.d.ts +10 -93
  43. package/dist/types.d.ts.map +1 -1
  44. package/package.json +16 -18
  45. package/dist/actor/const.d.ts +0 -10
  46. package/dist/actor/const.d.ts.map +0 -1
  47. package/dist/actor/const.js +0 -11
  48. package/dist/actor/const.js.map +0 -1
  49. package/dist/actor/server.d.ts +0 -4
  50. package/dist/actor/server.d.ts.map +0 -1
  51. package/dist/actor/server.js +0 -82
  52. package/dist/actor/server.js.map +0 -1
  53. package/dist/actor/types.d.ts +0 -23
  54. package/dist/actor/types.d.ts.map +0 -1
  55. package/dist/actor/types.js +0 -2
  56. package/dist/actor/types.js.map +0 -1
  57. package/dist/actor/utils.d.ts +0 -3
  58. package/dist/actor/utils.d.ts.map +0 -1
  59. package/dist/actor/utils.js +0 -26
  60. package/dist/actor/utils.js.map +0 -1
  61. package/dist/apify-client.d.ts +0 -6
  62. package/dist/apify-client.d.ts.map +0 -1
  63. package/dist/apify-client.js +0 -23
  64. package/dist/apify-client.js.map +0 -1
  65. package/dist/mcp/actors.d.ts +0 -20
  66. package/dist/mcp/actors.d.ts.map +0 -1
  67. package/dist/mcp/actors.js +0 -66
  68. package/dist/mcp/actors.js.map +0 -1
  69. package/dist/mcp/client.d.ts +0 -6
  70. package/dist/mcp/client.d.ts.map +0 -1
  71. package/dist/mcp/client.js +0 -33
  72. package/dist/mcp/client.js.map +0 -1
  73. package/dist/mcp/const.d.ts +0 -3
  74. package/dist/mcp/const.d.ts.map +0 -1
  75. package/dist/mcp/const.js +0 -3
  76. package/dist/mcp/const.js.map +0 -1
  77. package/dist/mcp/proxy.d.ts +0 -4
  78. package/dist/mcp/proxy.d.ts.map +0 -1
  79. package/dist/mcp/proxy.js +0 -29
  80. package/dist/mcp/proxy.js.map +0 -1
  81. package/dist/mcp/server.d.ts +0 -41
  82. package/dist/mcp/server.d.ts.map +0 -1
  83. package/dist/mcp/server.js +0 -177
  84. package/dist/mcp/server.js.map +0 -1
  85. package/dist/mcp/utils.d.ts +0 -26
  86. package/dist/mcp/utils.d.ts.map +0 -1
  87. package/dist/mcp/utils.js +0 -52
  88. package/dist/mcp/utils.js.map +0 -1
  89. package/dist/stdio.d.ts +0 -15
  90. package/dist/stdio.d.ts.map +0 -1
  91. package/dist/stdio.js +0 -46
  92. package/dist/stdio.js.map +0 -1
  93. package/dist/tools/actor.d.ts +0 -40
  94. package/dist/tools/actor.d.ts.map +0 -1
  95. package/dist/tools/actor.js +0 -137
  96. package/dist/tools/actor.js.map +0 -1
  97. package/dist/tools/build.d.ts +0 -12
  98. package/dist/tools/build.d.ts.map +0 -1
  99. package/dist/tools/build.js +0 -120
  100. package/dist/tools/build.js.map +0 -1
  101. package/dist/tools/helpers.d.ts +0 -19
  102. package/dist/tools/helpers.d.ts.map +0 -1
  103. package/dist/tools/helpers.js +0 -62
  104. package/dist/tools/helpers.js.map +0 -1
  105. package/dist/tools/index.d.ts +0 -6
  106. package/dist/tools/index.d.ts.map +0 -1
  107. package/dist/tools/index.js +0 -8
  108. package/dist/tools/index.js.map +0 -1
  109. package/dist/tools/store_collection.d.ts +0 -21
  110. package/dist/tools/store_collection.d.ts.map +0 -1
  111. package/dist/tools/store_collection.js +0 -80
  112. package/dist/tools/store_collection.js.map +0 -1
  113. package/dist/tools/utils.d.ts +0 -77
  114. package/dist/tools/utils.d.ts.map +0 -1
  115. package/dist/tools/utils.js.map +0 -1
package/dist/types.d.ts CHANGED
@@ -1,7 +1,13 @@
1
- import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
1
  import type { ValidateFunction } from 'ajv';
3
2
  import type { ActorDefaultRunOptions, ActorDefinition } from 'apify-client';
4
- import type { ActorsMcpServer } from './mcp/server.js';
3
+ export type Input = {
4
+ actors: string[] | string;
5
+ enableAddingActors?: boolean;
6
+ enableActorAutoLoading?: boolean;
7
+ maxActorMemoryBytes?: number;
8
+ debugActor?: string;
9
+ debugActorInput?: unknown;
10
+ };
5
11
  export interface ISchemaProperties {
6
12
  type: string;
7
13
  title: string;
@@ -32,84 +38,14 @@ export type ActorDefinitionWithDesc = Omit<ActorDefinition, 'input'> & {
32
38
  input?: IActorInputSchema;
33
39
  };
34
40
  export type ActorDefinitionPruned = Pick<ActorDefinitionWithDesc, 'id' | 'actorFullName' | 'buildTag' | 'readme' | 'input' | 'description' | 'defaultRunOptions'>;
35
- /**
36
- * Base interface for all tools in the MCP server.
37
- * Contains common properties shared by all tool types.
38
- */
39
- export interface ToolBase {
40
- /** Unique name/identifier for the tool */
41
+ export interface Tool {
41
42
  name: string;
42
- /** Description of what the tool does */
43
+ actorFullName: string;
43
44
  description: string;
44
- /** JSON schema defining the tool's input parameters */
45
45
  inputSchema: object;
46
- /** AJV validation function for the input schema */
47
46
  ajvValidate: ValidateFunction;
48
- }
49
- /**
50
- * Interface for Actor-based tools - tools that wrap Apify Actors.
51
- * Extends ToolBase with Actor-specific properties.
52
- */
53
- export interface ActorTool extends ToolBase {
54
- /** Full name of the Apify Actor (username/name) */
55
- actorFullName: string;
56
- /** Optional memory limit in MB for the Actor execution */
57
47
  memoryMbytes?: number;
58
48
  }
59
- /**
60
- * Arguments passed to internal tool calls.
61
- * Contains both the tool arguments and server references.
62
- */
63
- export type InternalToolArgs = {
64
- /** Arguments passed to the tool */
65
- args: Record<string, unknown>;
66
- /** Reference to the Apify MCP server instance */
67
- apifyMcpServer: ActorsMcpServer;
68
- /** Reference to the MCP server instance */
69
- mcpServer: Server;
70
- /** Apify API token */
71
- apifyToken: string;
72
- };
73
- /**
74
- * Interface for internal tools - tools implemented directly in the MCP server.
75
- * Extends ToolBase with a call function implementation.
76
- */
77
- export interface HelperTool extends ToolBase {
78
- /**
79
- * Executes the tool with the given arguments
80
- * @param toolArgs - Arguments and server references
81
- * @returns Promise resolving to the tool's output
82
- */
83
- call: (toolArgs: InternalToolArgs) => Promise<object>;
84
- }
85
- /**
86
- * Actorized MCP server tool where this MCP server acts as a proxy.
87
- * Extends ToolBase with tool associated MCP server.
88
- */
89
- export interface ActorMCPTool extends ToolBase {
90
- originToolName: string;
91
- actorID: string;
92
- /**
93
- * ID of the Actorized MCP server the tool is associated with.
94
- * See getMCPServerID()
95
- */
96
- serverId: string;
97
- serverUrl: string;
98
- }
99
- /**
100
- * Type discriminator for tools - indicates whether a tool is internal or Actor-based.
101
- */
102
- export type ToolType = 'internal' | 'actor' | 'actor-mcp';
103
- /**
104
- * Wrapper interface that combines a tool with its type discriminator.
105
- * Used to store and manage tools of different types uniformly.
106
- */
107
- export interface ToolWrap {
108
- /** Type of the tool (internal or actor) */
109
- type: ToolType;
110
- /** The tool instance */
111
- tool: ActorTool | HelperTool | ActorMCPTool;
112
- }
113
49
  export interface ActorStats {
114
50
  totalRuns: number;
115
51
  totalUsers30Days: number;
@@ -132,23 +68,4 @@ export interface ActorStorePruned {
132
68
  url: string;
133
69
  totalStars?: number | null;
134
70
  }
135
- /**
136
- * Interface for internal tools - tools implemented directly in the MCP server.
137
- * Extends ToolBase with a call function implementation.
138
- */
139
- export interface InternalTool extends ToolBase {
140
- /**
141
- * Executes the tool with the given arguments
142
- * @param toolArgs - Arguments and server references
143
- * @returns Promise resolving to the tool's output
144
- */
145
- call: (toolArgs: InternalToolArgs) => Promise<object>;
146
- }
147
- export type Input = {
148
- actors: string[] | string;
149
- enableActorAutoLoading?: boolean;
150
- maxActorMemoryBytes?: number;
151
- debugActor?: string;
152
- debugActorInput?: unknown;
153
- };
154
71
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,EAAE,MAAM,CAAC;IACd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BAAuB,EAC5D,IAAI,GAAG,eAAe,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,aAAa,GAAG,mBAAmB,CAAC,CAAA;AAEnG,MAAM,WAAW,IAAI;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,UAAU;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,yBAAyB,EAAE,OAAO,CAAC;CACtC;AAED,MAAM,WAAW,WAAW;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;IAClB,kBAAkB,EAAE,WAAW,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B"}
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@apify/actors-mcp-server",
3
- "version": "0.1.22-beta.13",
3
+ "version": "0.1.22-beta.15",
4
4
  "type": "module",
5
- "description": "Model Context Protocol Server for Apify",
5
+ "description": "Model Context Protocol Server for Apify Actors",
6
6
  "engines": {
7
7
  "node": ">=18.0.0"
8
8
  },
9
9
  "main": "dist/index.js",
10
10
  "bin": {
11
- "actors-mcp-server": "./dist/stdio.js"
11
+ "actors-mcp-server": "./dist/index.js"
12
12
  },
13
13
  "files": [
14
14
  "dist",
@@ -30,43 +30,41 @@
30
30
  "model context protocol"
31
31
  ],
32
32
  "dependencies": {
33
- "@apify/log": "^2.5.16",
34
- "@modelcontextprotocol/sdk": "^1.9.0",
33
+ "@modelcontextprotocol/sdk": "^1.3.1",
35
34
  "ajv": "^8.17.1",
36
- "apify": "^3.4.0",
37
- "apify-client": "^2.12.1",
35
+ "apify": "^3.2.6",
36
+ "apify-client": "^2.11.2",
38
37
  "express": "^4.21.2",
39
- "minimist": "^1.2.8",
38
+ "yargs-parser": "^21.1.1",
40
39
  "zod": "^3.24.1",
41
40
  "zod-to-json-schema": "^3.24.1"
42
41
  },
43
42
  "devDependencies": {
44
43
  "@anthropic-ai/sdk": "^0.33.1",
45
44
  "@anthropic-ai/tokenizer": "^0.0.4",
46
- "@apify/eslint-config": "^1.0.0",
45
+ "@apify/eslint-config": "^0.5.0-beta.2",
47
46
  "@apify/tsconfig": "^0.1.0",
48
47
  "@types/express": "^4.0.0",
49
48
  "@types/minimist": "^1.2.5",
49
+ "@types/yargs-parser": "^21.0.3",
50
50
  "dotenv": "^16.4.7",
51
- "eslint": "^9.19.0",
51
+ "eslint": "^9.17.0",
52
52
  "eventsource": "^3.0.2",
53
53
  "tsx": "^4.6.2",
54
54
  "typescript": "^5.3.3",
55
- "typescript-eslint": "^8.23.0",
55
+ "typescript-eslint": "^8.18.2",
56
56
  "vitest": "^3.0.8"
57
57
  },
58
58
  "scripts": {
59
59
  "start": "npm run start:dev",
60
60
  "start:prod": "node dist/main.js",
61
61
  "start:dev": "tsx src/main.ts",
62
- "lint": "./node_modules/.bin/eslint .",
63
- "lint:fix": "./node_modules/.bin/eslint . --fix",
62
+ "lint": "eslint .",
63
+ "lint:fix": "eslint . --fix",
64
64
  "build": "tsc",
65
- "build:watch": "tsc -w",
66
- "inspector": "npx @modelcontextprotocol/inspector dist/stdio.js",
67
- "test": "vitest run",
68
- "type-check": "tsc --noEmit",
69
- "clean": "tsc -b src --clean"
65
+ "watch": "tsc --watch",
66
+ "inspector": "npx @modelcontextprotocol/inspector dist/index.js",
67
+ "test": "vitest run"
70
68
  },
71
69
  "author": "Apify",
72
70
  "license": "MIT"
@@ -1,10 +0,0 @@
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
- SSE = "/sse",
8
- MESSAGE = "/message"
9
- }
10
- //# sourceMappingURL=const.d.ts.map
@@ -1 +0,0 @@
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,OAAO,aAAa;CACvB"}
@@ -1,11 +0,0 @@
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["SSE"] = "/sse";
9
- Routes["MESSAGE"] = "/message";
10
- })(Routes || (Routes = {}));
11
- //# sourceMappingURL=const.js.map
@@ -1 +0,0 @@
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,MAIX;AAJD,WAAY,MAAM;IACd,oBAAU,CAAA;IACV,sBAAY,CAAA;IACZ,8BAAoB,CAAA;AACxB,CAAC,EAJW,MAAM,KAAN,MAAM,QAIjB"}
@@ -1,4 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/actor/server.ts"],"names":[],"mappings":"AAMA,OAAO,OAAO,MAAM,SAAS,CAAC;AAK9B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIxD,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,eAAe,GAC3B,OAAO,CAAC,OAAO,CA0EjB"}
@@ -1,82 +0,0 @@
1
- /*
2
- * Express server implementation used for standby Actor mode.
3
- */
4
- import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
5
- import express from 'express';
6
- import log from '@apify/log';
7
- import { HEADER_READINESS_PROBE, Routes } from './const.js';
8
- import { getActorRunData } from './utils.js';
9
- import { processParamsGetTools } from '../mcp/utils.js';
10
- export function createExpressApp(host, mcpServer) {
11
- const HELP_MESSAGE = `Connect to the server with GET request to ${host}/sse?token=YOUR-APIFY-TOKEN`
12
- + ` and then send POST requests to ${host}/message?token=YOUR-APIFY-TOKEN`;
13
- const app = express();
14
- let transport;
15
- app.route(Routes.ROOT)
16
- .get(async (req, res) => {
17
- if (req.headers && req.get(HEADER_READINESS_PROBE) !== undefined) {
18
- log.debug('Received readiness probe');
19
- res.status(200).json({ message: 'Server is ready' }).end();
20
- return;
21
- }
22
- try {
23
- log.info(`Received GET message at: ${Routes.ROOT}`);
24
- const tools = await processParamsGetTools(req.url, process.env.APIFY_TOKEN);
25
- if (tools) {
26
- mcpServer.updateTools(tools);
27
- }
28
- res.setHeader('Content-Type', 'text/event-stream');
29
- res.setHeader('Cache-Control', 'no-cache');
30
- res.setHeader('Connection', 'keep-alive');
31
- res.status(200).json({ message: `Actor is using Model Context Protocol. ${HELP_MESSAGE}`, data: getActorRunData() }).end();
32
- }
33
- catch (error) {
34
- log.error(`Error in GET ${Routes.ROOT} ${error}`);
35
- res.status(500).json({ message: 'Internal Server Error' }).end();
36
- }
37
- })
38
- .head((_req, res) => {
39
- res.status(200).end();
40
- });
41
- app.route(Routes.SSE)
42
- .get(async (req, res) => {
43
- try {
44
- log.info(`Received GET message at: ${Routes.SSE}`);
45
- const tools = await processParamsGetTools(req.url, process.env.APIFY_TOKEN);
46
- if (tools) {
47
- mcpServer.updateTools(tools);
48
- }
49
- transport = new SSEServerTransport(Routes.MESSAGE, res);
50
- await mcpServer.connect(transport);
51
- }
52
- catch (error) {
53
- log.error(`Error in GET ${Routes.SSE}: ${error}`);
54
- res.status(500).json({ message: 'Internal Server Error' }).end();
55
- }
56
- });
57
- app.route(Routes.MESSAGE)
58
- .post(async (req, res) => {
59
- try {
60
- log.info(`Received POST message at: ${Routes.MESSAGE}`);
61
- if (transport) {
62
- await transport.handlePostMessage(req, res);
63
- }
64
- else {
65
- res.status(400).json({
66
- message: 'Server is not connected to the client. '
67
- + 'Connect to the server with GET request to /sse endpoint',
68
- });
69
- }
70
- }
71
- catch (error) {
72
- log.error(`Error in POST ${Routes.MESSAGE}: ${error}`);
73
- res.status(500).json({ message: 'Internal Server Error' }).end();
74
- }
75
- });
76
- // Catch-all for undefined routes
77
- app.use((req, res) => {
78
- res.status(404).json({ message: `There is nothing at route ${req.method} ${req.originalUrl}. ${HELP_MESSAGE}` }).end();
79
- });
80
- return app;
81
- }
82
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/actor/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAE7E,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBA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;
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/actor/types.ts"],"names":[],"mappings":"AACA,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"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/actor/types.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import type { ActorRunData } from './types.js';
2
- export declare function getActorRunData(): ActorRunData | null;
3
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/actor/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAuBrD"}
@@ -1,26 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/actor/utils.ts"],"names":[],"mappings":"AACA,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"}
@@ -1,6 +0,0 @@
1
- import type { ApifyClientOptions } from 'apify';
2
- import { ApifyClient as _ApifyClient } from 'apify-client';
3
- export declare class ApifyClient extends _ApifyClient {
4
- constructor(options: ApifyClientOptions);
5
- }
6
- //# sourceMappingURL=apify-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apify-client.d.ts","sourceRoot":"","sources":["../src/apify-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,cAAc,CAAC;AAiB3D,qBAAa,WAAY,SAAQ,YAAY;gBAC7B,OAAO,EAAE,kBAAkB;CAO1C"}
@@ -1,23 +0,0 @@
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
- const updatedConfig = { ...config };
10
- updatedConfig.headers = updatedConfig.headers ?? {};
11
- updatedConfig.headers['User-Agent'] = `${updatedConfig.headers['User-Agent'] ?? ''}; ${USER_AGENT_ORIGIN}`;
12
- return updatedConfig;
13
- }
14
- export class ApifyClient extends _ApifyClient {
15
- constructor(options) {
16
- super({
17
- ...options,
18
- baseUrl: process.env.APIFY_API_BASE_URL || undefined,
19
- requestInterceptors: [addUserAgent],
20
- });
21
- }
22
- }
23
- //# sourceMappingURL=apify-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apify-client.js","sourceRoot":"","sources":["../src/apify-client.ts"],"names":[],"mappings":"AAEA,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,aAAa,CAAC,OAAO,IAAI,EAAE,CAAC;IACpD,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,iBAAiB,EAAE,CAAC;IAC3G,OAAO,aAAa,CAAC;AACzB,CAAC;AAED,MAAM,OAAO,WAAY,SAAQ,YAAY;IACzC,YAAY,OAA2B;QACnC,KAAK,CAAC;YACF,GAAG,OAAO;YACV,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,SAAS;YACpD,mBAAmB,EAAE,CAAC,YAAY,CAAC;SACtC,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -1,20 +0,0 @@
1
- import { ActorDefinition } from "apify-client";
2
- export declare function isActorMCPServer(actorID: string, apifyToken: string): Promise<boolean>;
3
- export declare function getActorsMCPServerPath(actorID: string, apifyToken: string): Promise<string | undefined>;
4
- export declare function getActorsMCPServerURL(actorID: string, apifyToken: string): Promise<string>;
5
- /**
6
- * Gets Actor ID from the Actor object.
7
- *
8
- * @param actorID
9
- */
10
- export declare function getRealActorID(actorID: string, apifyToken: string): Promise<string>;
11
- /**
12
- * Returns standby URL for given Actor ID.
13
- *
14
- * @param actorID
15
- * @param standbyBaseUrl
16
- * @returns
17
- */
18
- export declare function getActorStandbyURL(actorID: string, apifyToken: string, standbyBaseUrl?: string): Promise<string>;
19
- export declare function getActorDefinition(actorID: string, apifyToken: string): Promise<ActorDefinition>;
20
- //# sourceMappingURL=actors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../src/mcp/actors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG5F;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAG7G;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOhG;AAED;;;;EAIE;AACF,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASzF;AAED;;;;;;EAME;AACF,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,SAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAG7H;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAuBtG"}
@@ -1,66 +0,0 @@
1
- import { ApifyClient } from "../apify-client.js";
2
- export async function isActorMCPServer(actorID, apifyToken) {
3
- const mcpPath = await getActorsMCPServerPath(actorID, apifyToken);
4
- return (mcpPath?.length || 0) > 0;
5
- }
6
- export async function getActorsMCPServerPath(actorID, apifyToken) {
7
- const actorDefinition = await getActorDefinition(actorID, apifyToken);
8
- return actorDefinition.webServerMcpPath;
9
- }
10
- export async function getActorsMCPServerURL(actorID, apifyToken) {
11
- // TODO: get from API instead
12
- const standbyBaseUrl = process.env.HOSTNAME === 'mcp-securitybyobscurity.apify.com' ?
13
- 'securitybyobscurity.apify.actor' : 'apify.actor';
14
- const standbyUrl = await getActorStandbyURL(actorID, apifyToken, standbyBaseUrl);
15
- const mcpPath = await getActorsMCPServerPath(actorID, apifyToken);
16
- return `${standbyUrl}${mcpPath}`;
17
- }
18
- /**
19
- * Gets Actor ID from the Actor object.
20
- *
21
- * @param actorID
22
- */
23
- export async function getRealActorID(actorID, apifyToken) {
24
- const apifyClient = new ApifyClient({ token: apifyToken });
25
- const actor = apifyClient.actor(actorID);
26
- const info = await actor.get();
27
- if (!info) {
28
- throw new Error(`Actor ${actorID} not found`);
29
- }
30
- return info.id;
31
- }
32
- /**
33
- * Returns standby URL for given Actor ID.
34
- *
35
- * @param actorID
36
- * @param standbyBaseUrl
37
- * @returns
38
- */
39
- export async function getActorStandbyURL(actorID, apifyToken, standbyBaseUrl = 'apify.actor') {
40
- const actorRealID = await getRealActorID(actorID, apifyToken);
41
- return `https://${actorRealID}.${standbyBaseUrl}`;
42
- }
43
- export async function getActorDefinition(actorID, apifyToken) {
44
- const apifyClient = new ApifyClient({ token: apifyToken
45
- });
46
- const actor = apifyClient.actor(actorID);
47
- const info = await actor.get();
48
- if (!info) {
49
- throw new Error(`Actor ${actorID} not found`);
50
- }
51
- const latestBuildID = info.taggedBuilds?.['latest']?.buildId;
52
- if (!latestBuildID) {
53
- throw new Error(`Actor ${actorID} does not have a latest build`);
54
- }
55
- const build = apifyClient.build(latestBuildID);
56
- const buildInfo = await build.get();
57
- if (!buildInfo) {
58
- throw new Error(`Build ${latestBuildID} not found`);
59
- }
60
- const actorDefinition = buildInfo.actorDefinition;
61
- if (!actorDefinition) {
62
- throw new Error(`Build ${latestBuildID} does not have an actor definition`);
63
- }
64
- return actorDefinition;
65
- }
66
- //# sourceMappingURL=actors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actors.js","sourceRoot":"","sources":["../../src/mcp/actors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAe,EAAE,UAAkB;IACtE,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAClE,OAAO,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,OAAe,EAAE,UAAkB;IAC5E,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACtE,OAAQ,eAAuB,CAAC,gBAAgB,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAe,EAAE,UAAkB;IAC3E,6BAA6B;IAC7B,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,mCAAmC,CAAC,CAAC;QACjF,iCAAiC,CAAC,CAAC,CAAC,aAAa,CAAC;IACtD,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;IACjF,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC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a,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,+BAA+B,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,SAAS,aAAa,YAAY,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;IAClD,IAAI,CAAC,eAAe,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,SAAS,aAAa,oCAAoC,CAAC,CAAC;IAChF,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC"}
@@ -1,6 +0,0 @@
1
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
- /**
3
- * Creates and connects a ModelContextProtocol client.
4
- */
5
- export declare function createMCPClient(url: string, token: string): Promise<Client>;
6
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAInE;;GAEG;AACH,wBAAsB,eAAe,CACjC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAC3B,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
@@ -1,33 +0,0 @@
1
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
- import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
3
- import { getMCPServerID } from "./utils.js";
4
- /**
5
- * Creates and connects a ModelContextProtocol client.
6
- */
7
- export async function createMCPClient(url, token) {
8
- const transport = new SSEClientTransport(new URL(url), {
9
- requestInit: {
10
- headers: {
11
- authorization: `Bearer ${token}`,
12
- },
13
- },
14
- eventSourceInit: {
15
- // The EventSource package augments EventSourceInit with a "fetch" parameter.
16
- // You can use this to set additional headers on the outgoing request.
17
- // Based on this example: https://github.com/modelcontextprotocol/typescript-sdk/issues/118
18
- async fetch(input, init) {
19
- const headers = new Headers(init?.headers || {});
20
- headers.set('authorization', `Bearer ${token}`);
21
- return fetch(input, { ...init, headers });
22
- },
23
- // We have to cast to "any" to use it, since it's non-standard
24
- }, // eslint-disable-line @typescript-eslint/no-explicit-any
25
- });
26
- const client = new Client({
27
- name: getMCPServerID(url),
28
- version: "1.0.0",
29
- });
30
- await client.connect(transport);
31
- return client;
32
- }
33
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACjC,GAAW,EAAE,KAAa;IAE1B,MAAM,SAAS,GAAG,IAAI,kBAAkB,CACpC,IAAI,GAAG,CAAC,GAAG,CAAC,EACZ;QACI,WAAW,EAAE;YACT,OAAO,EAAE;gBACL,aAAa,EAAE,UAAU,KAAK,EAAE;aACnC;SACJ;QACD,eAAe,EAAE;YACb,6EAA6E;YAC7E,sEAAsE;YACtE,2FAA2F;YAC3F,KAAK,CAAC,KAAK,CAAC,KAA6B,EAAE,IAAkB;gBACzD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;gBACjD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;gBAChD,OAAO,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9C,CAAC;YACL,8DAA8D;SACtD,EAAE,yDAAyD;KACtE,CAAC,CAAC;IAEP,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACtB,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC;QACzB,OAAO,EAAE,OAAO;KACnB,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare const MAX_TOOL_NAME_LENGTH = 64;
2
- export declare const SERVER_ID_LENGTH = 8;
3
- //# sourceMappingURL=const.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../src/mcp/const.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,gBAAgB,IAAI,CAAA"}
package/dist/mcp/const.js DELETED
@@ -1,3 +0,0 @@
1
- export const MAX_TOOL_NAME_LENGTH = 64;
2
- export const SERVER_ID_LENGTH = 8;
3
- //# sourceMappingURL=const.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/mcp/const.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- import { ToolWrap } from "../types.js";
2
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
- export declare function getMCPServerTools(actorID: string, client: Client, serverUrl: string): Promise<ToolWrap[]>;
4
- //# sourceMappingURL=proxy.d.ts.map