@apify/actors-mcp-server 0.1.22-beta.14 → 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 (104) 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/actors.js +327 -0
  5. package/dist/actors.js.map +1 -0
  6. package/dist/const.d.ts +19 -14
  7. package/dist/const.d.ts.map +1 -1
  8. package/dist/const.js +23 -22
  9. package/dist/const.js.map +1 -1
  10. package/dist/examples/clientSse.d.ts +1 -11
  11. package/dist/examples/clientSse.d.ts.map +1 -1
  12. package/dist/examples/clientSse.js +10 -13
  13. package/dist/examples/clientSse.js.map +1 -1
  14. package/dist/examples/clientStdio.js +6 -6
  15. package/dist/examples/clientStdio.js.map +1 -1
  16. package/dist/examples/clientStdioChat.js +16 -31
  17. package/dist/examples/clientStdioChat.js.map +1 -1
  18. package/dist/index.d.ts +14 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +51 -6
  21. package/dist/index.js.map +1 -1
  22. package/dist/{actor/input.d.ts → input.d.ts} +1 -1
  23. package/dist/input.d.ts.map +1 -0
  24. package/dist/input.js +23 -0
  25. package/dist/input.js.map +1 -0
  26. package/dist/logger.d.ts +3 -0
  27. package/dist/logger.d.ts.map +1 -0
  28. package/dist/logger.js +4 -0
  29. package/dist/logger.js.map +1 -0
  30. package/dist/main.d.ts +0 -4
  31. package/dist/main.d.ts.map +1 -1
  32. package/dist/main.js +122 -23
  33. package/dist/main.js.map +1 -1
  34. package/dist/server.d.ts +43 -0
  35. package/dist/server.d.ts.map +1 -0
  36. package/dist/server.js +178 -0
  37. package/dist/server.js.map +1 -0
  38. package/dist/tools.d.ts +46 -0
  39. package/dist/tools.d.ts.map +1 -0
  40. package/dist/tools.js +128 -0
  41. package/dist/tools.js.map +1 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/dist/types.d.ts +10 -70
  44. package/dist/types.d.ts.map +1 -1
  45. package/package.json +15 -17
  46. package/dist/actor/const.d.ts +0 -12
  47. package/dist/actor/const.d.ts.map +0 -1
  48. package/dist/actor/const.js +0 -18
  49. package/dist/actor/const.js.map +0 -1
  50. package/dist/actor/input.d.ts.map +0 -1
  51. package/dist/actor/input.js +0 -21
  52. package/dist/actor/input.js.map +0 -1
  53. package/dist/actor/server.d.ts +0 -4
  54. package/dist/actor/server.d.ts.map +0 -1
  55. package/dist/actor/server.js +0 -154
  56. package/dist/actor/server.js.map +0 -1
  57. package/dist/actor/types.d.ts +0 -30
  58. package/dist/actor/types.d.ts.map +0 -1
  59. package/dist/actor/types.js +0 -2
  60. package/dist/actor/types.js.map +0 -1
  61. package/dist/actor/utils.d.ts +0 -11
  62. package/dist/actor/utils.d.ts.map +0 -1
  63. package/dist/actor/utils.js +0 -50
  64. package/dist/actor/utils.js.map +0 -1
  65. package/dist/examples/clientStreamableHttp.d.ts +0 -2
  66. package/dist/examples/clientStreamableHttp.d.ts.map +0 -1
  67. package/dist/examples/clientStreamableHttp.js +0 -93
  68. package/dist/examples/clientStreamableHttp.js.map +0 -1
  69. package/dist/mcp-server.d.ts +0 -39
  70. package/dist/mcp-server.d.ts.map +0 -1
  71. package/dist/mcp-server.js +0 -165
  72. package/dist/mcp-server.js.map +0 -1
  73. package/dist/stdio.d.ts +0 -15
  74. package/dist/stdio.d.ts.map +0 -1
  75. package/dist/stdio.js +0 -46
  76. package/dist/stdio.js.map +0 -1
  77. package/dist/tools/actor.d.ts +0 -37
  78. package/dist/tools/actor.d.ts.map +0 -1
  79. package/dist/tools/actor.js +0 -90
  80. package/dist/tools/actor.js.map +0 -1
  81. package/dist/tools/build.d.ts +0 -12
  82. package/dist/tools/build.d.ts.map +0 -1
  83. package/dist/tools/build.js +0 -121
  84. package/dist/tools/build.js.map +0 -1
  85. package/dist/tools/helpers.d.ts +0 -19
  86. package/dist/tools/helpers.d.ts.map +0 -1
  87. package/dist/tools/helpers.js +0 -62
  88. package/dist/tools/helpers.js.map +0 -1
  89. package/dist/tools/index.d.ts +0 -6
  90. package/dist/tools/index.d.ts.map +0 -1
  91. package/dist/tools/index.js +0 -8
  92. package/dist/tools/index.js.map +0 -1
  93. package/dist/tools/mcp-apify-client.d.ts +0 -6
  94. package/dist/tools/mcp-apify-client.d.ts.map +0 -1
  95. package/dist/tools/mcp-apify-client.js +0 -24
  96. package/dist/tools/mcp-apify-client.js.map +0 -1
  97. package/dist/tools/store_collection.d.ts +0 -21
  98. package/dist/tools/store_collection.d.ts.map +0 -1
  99. package/dist/tools/store_collection.js +0 -81
  100. package/dist/tools/store_collection.js.map +0 -1
  101. package/dist/tools/utils.d.ts +0 -77
  102. package/dist/tools/utils.d.ts.map +0 -1
  103. package/dist/tools/utils.js +0 -202
  104. 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,68 +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
- };
71
- /**
72
- * Interface for internal tools - tools implemented directly in the MCP server.
73
- * Extends ToolBase with a call function implementation.
74
- */
75
- export interface HelperTool extends ToolBase {
76
- /**
77
- * Executes the tool with the given arguments
78
- * @param toolArgs - Arguments and server references
79
- * @returns Promise resolving to the tool's output
80
- */
81
- call: (toolArgs: InternalToolArgs) => Promise<object>;
82
- }
83
- /**
84
- * Type discriminator for tools - indicates whether a tool is internal or Actor-based.
85
- */
86
- export type ToolType = 'internal' | 'actor' | 'actor-mcp';
87
- /**
88
- * Wrapper interface that combines a tool with its type discriminator.
89
- * Used to store and manage tools of different types uniformly.
90
- */
91
- export interface ToolWrap {
92
- /** Type of the tool (internal or actor) */
93
- type: ToolType;
94
- /** The tool instance */
95
- tool: ActorTool | HelperTool;
96
- }
97
49
  export interface ActorStats {
98
50
  totalRuns: number;
99
51
  totalUsers30Days: number;
@@ -116,16 +68,4 @@ export interface ActorStorePruned {
116
68
  url: string;
117
69
  totalStars?: number | null;
118
70
  }
119
- /**
120
- * Interface for internal tools - tools implemented directly in the MCP server.
121
- * Extends ToolBase with a call function implementation.
122
- */
123
- export interface InternalTool extends ToolBase {
124
- /**
125
- * Executes the tool with the given arguments
126
- * @param toolArgs - Arguments and server references
127
- * @returns Promise resolving to the tool's output
128
- */
129
- call: (toolArgs: InternalToolArgs) => Promise<object>;
130
- }
131
71
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,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,WAAW,EAAE,MAAM,CAAC;IAEpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IAErB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,IAAI,EAAE,MAAM,CAAC;IAEb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAE9C,QAAQ,CAAC,EAAE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AC;IAC1C,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC7B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,uBAAuB,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.14",
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,29 +30,29 @@
30
30
  "model context protocol"
31
31
  ],
32
32
  "dependencies": {
33
- "@apify/log": "^2.5.16",
34
- "@modelcontextprotocol/sdk": "github:jirispilka/mcp-typescript-sdk#fix/add-src-dir",
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": {
@@ -61,12 +61,10 @@
61
61
  "start:dev": "tsx src/main.ts",
62
62
  "lint": "eslint .",
63
63
  "lint:fix": "eslint . --fix",
64
- "build": "tsc -b src",
65
- "build:watch": "tsc -b src -w",
66
- "type-check": "tsc --noEmit",
67
- "inspector": "npx @modelcontextprotocol/inspector dist/stdio.js",
68
- "test": "vitest run",
69
- "clean": "tsc -b src --clean"
64
+ "build": "tsc",
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,12 +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
- MCP = "/mcp",
8
- SSE = "/sse",
9
- MESSAGE = "/message"
10
- }
11
- export declare const getHelpMessage: (host: string) => string;
12
- //# 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,GAAG,SAAS;IACZ,OAAO,aAAa;CACvB;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,WAKW,CAAC"}
@@ -1,18 +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["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
@@ -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,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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/actor/input.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAejE"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Process input parameters, split actors string into an array
3
- * @param originalInput
4
- * @returns input
5
- */
6
- export function processInput(originalInput) {
7
- const input = originalInput;
8
- // actors can be a string or an array of strings
9
- if (input.actors && typeof input.actors === 'string') {
10
- input.actors = input.actors.split(',').map((format) => format.trim());
11
- }
12
- // Convert string boolean to actual boolean
13
- if (input.enableActorAutoLoading && typeof input.enableActorAutoLoading === 'string') {
14
- input.enableActorAutoLoading = input.enableActorAutoLoading === 'true';
15
- }
16
- if (!input.enableActorAutoLoading) {
17
- input.enableActorAutoLoading = false;
18
- }
19
- return input;
20
- }
21
- //# sourceMappingURL=input.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/actor/input.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,aAA6B;IACtD,MAAM,KAAK,GAAG,aAAsB,CAAC;IAErC,gDAAgD;IAChD,IAAI,KAAK,CAAC,MAAM,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QACnD,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAa,CAAC;IAC9F,CAAC;IACD,2CAA2C;IAC3C,IAAI,KAAK,CAAC,sBAAsB,IAAI,OAAO,KAAK,CAAC,sBAAsB,KAAK,QAAQ,EAAE,CAAC;QACnF,KAAK,CAAC,sBAAsB,GAAG,KAAK,CAAC,sBAAsB,KAAK,MAAM,CAAC;IAC3E,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,sBAAsB,EAAE,CAAC;QAChC,KAAK,CAAC,sBAAsB,GAAG,KAAK,CAAC;IACzC,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -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":"AASA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIxD,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,eAAe,GAC3B,OAAO,CAAC,OAAO,CA8IjB"}
@@ -1,154 +0,0 @@
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 { getHelpMessage, HEADER_READINESS_PROBE, Routes } from './const.js';
10
- import { getActorRunData, processParamsGetTools } from './utils.js';
11
- export function createExpressApp(host, mcpServer) {
12
- const app = express();
13
- app.use(express.json());
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);
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);
57
- if (tools) {
58
- mcpServer.updateTools(tools);
59
- }
60
- transportSSE = new SSEServerTransport(Routes.MESSAGE, res);
61
- await mcpServer.connect(transportSSE);
62
- }
63
- catch (error) {
64
- respondWithError(res, error, `Error in GET ${Routes.SSE}`);
65
- }
66
- });
67
- app.post(Routes.MESSAGE, async (req, res) => {
68
- try {
69
- log.info(`Received POST message at: ${Routes.MESSAGE}`);
70
- if (transportSSE) {
71
- await transportSSE.handlePostMessage(req, res);
72
- }
73
- else {
74
- log.error('Server is not connected to the client.');
75
- res.status(400).json({
76
- jsonrpc: '2.0',
77
- error: {
78
- code: -32000,
79
- message: 'Bad Request: Server is not connected to the client. '
80
- + 'Connect to the server with GET request to /sse endpoint',
81
- },
82
- id: null,
83
- });
84
- }
85
- }
86
- catch (error) {
87
- respondWithError(res, error, `Error in POST ${Routes.MESSAGE}`);
88
- }
89
- });
90
- app.post(Routes.MCP, async (req, res) => {
91
- log.info('Received MCP request:', req.body);
92
- try {
93
- // Check for existing session ID
94
- const sessionId = req.headers['mcp-session-id'];
95
- let transport;
96
- if (sessionId && transports[sessionId]) {
97
- // Reuse existing transport
98
- transport = transports[sessionId];
99
- }
100
- else if (!sessionId && isInitializeRequest(req.body)) {
101
- // New initialization request - use JSON response mode
102
- transport = new StreamableHTTPServerTransport({
103
- sessionIdGenerator: () => randomUUID(),
104
- enableJsonResponse: true, // Enable JSON response mode
105
- });
106
- // Connect the transport to the MCP server BEFORE handling the request
107
- await mcpServer.connect(transport);
108
- // After handling the request, if we get a session ID back, store the transport
109
- await transport.handleRequest(req, res, req.body);
110
- // Store the transport by session ID for future requests
111
- if (transport.sessionId) {
112
- transports[transport.sessionId] = transport;
113
- }
114
- return; // Already handled
115
- }
116
- else {
117
- // Invalid request - no session ID or not initialization request
118
- res.status(400).json({
119
- jsonrpc: '2.0',
120
- error: {
121
- code: -32000,
122
- message: 'Bad Request: No valid session ID provided or not initialization request',
123
- },
124
- id: null,
125
- });
126
- return;
127
- }
128
- // Handle the request with existing transport - no need to reconnect
129
- await transport.handleRequest(req, res, req.body);
130
- }
131
- catch (error) {
132
- respondWithError(res, error, 'Error handling MCP request');
133
- }
134
- });
135
- // Handle GET requests for SSE streams according to spec
136
- app.get(Routes.MCP, async (_req, res) => {
137
- // We don't support GET requests for this server
138
- // The spec requires returning 405 Method Not Allowed in this case
139
- res.status(405).set('Allow', 'POST').send('Method Not Allowed');
140
- });
141
- // Catch-all for undefined routes
142
- app.use((req, res) => {
143
- res.status(404).json({ message: `There is nothing at route ${req.method} ${req.originalUrl}. ${getHelpMessage(host)}` }).end();
144
- });
145
- return app;
146
- }
147
- // Helper function to detect initialize requests
148
- function isInitializeRequest(body) {
149
- if (Array.isArray(body)) {
150
- return body.some((msg) => typeof msg === 'object' && msg !== null && 'method' in msg && msg.method === 'initialize');
151
- }
152
- return typeof body === 'object' && body !== null && 'method' in body && body.method === 'initialize';
153
- }
154
- //# 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,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,cAAc,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEpE,MAAM,UAAU,gBAAgB,CAC5B,IAAY,EACZ,SAA0B;IAE1B,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACxB,IAAI,YAAgC,CAAC;IACrC,MAAM,UAAU,GAA2D,EAAE,CAAC;IAE9E,SAAS,gBAAg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CAAC,GAAG,EAAE,KAAK,EAAE,IAAa,EAAE,GAAa,EAAE,EAAE;QACvD,gDAAgD;QAChD,kEAAkE;QAClE,GAAG,CAAC,MAAM,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"}
@@ -1,30 +0,0 @@
1
- export type Input = {
2
- actors: string[] | string;
3
- enableActorAutoLoading?: boolean;
4
- maxActorMemoryBytes?: number;
5
- debugActor?: string;
6
- debugActorInput?: unknown;
7
- };
8
- export interface ActorRunData {
9
- id?: string;
10
- actId?: string;
11
- userId?: string;
12
- startedAt?: string;
13
- finishedAt: null;
14
- status: 'RUNNING';
15
- meta: {
16
- origin?: string;
17
- };
18
- options: {
19
- build?: string;
20
- memoryMbytes?: string;
21
- };
22
- buildId?: string;
23
- defaultKeyValueStoreId?: string;
24
- defaultDatasetId?: string;
25
- defaultRequestQueueId?: string;
26
- buildNumber?: string;
27
- containerUrl?: string;
28
- standbyUrl?: string;
29
- }
30
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/actor/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IAChB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,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,11 +0,0 @@
1
- import type { ToolWrap } from '../types.js';
2
- import type { ActorRunData, Input } from './types.js';
3
- export declare function parseInputParamsFromUrl(url: string): Input;
4
- /**
5
- * Process input parameters and get tools
6
- * If URL contains query parameter `actors`, return tools from Actors otherwise return null.
7
- * @param url
8
- */
9
- export declare function processParamsGetTools(url: string): Promise<ToolWrap[]>;
10
- export declare function getActorRunData(): ActorRunData | null;
11
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/actor/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAI1D;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,uBAUtD;AAED,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAuBrD"}
@@ -1,50 +0,0 @@
1
- import { parse } from 'node:querystring';
2
- import { Actor } from 'apify';
3
- import { addTool, getActorsAsTools, removeTool } from '../tools/index.js';
4
- import { processInput } from './input.js';
5
- export function parseInputParamsFromUrl(url) {
6
- const query = url.split('?')[1] || '';
7
- const params = parse(query);
8
- return processInput(params);
9
- }
10
- /**
11
- * Process input parameters and get tools
12
- * If URL contains query parameter `actors`, return tools from Actors otherwise return null.
13
- * @param url
14
- */
15
- export async function processParamsGetTools(url) {
16
- const input = parseInputParamsFromUrl(url);
17
- let tools = [];
18
- if (input.actors) {
19
- tools = await getActorsAsTools(input.actors);
20
- }
21
- if (input.enableActorAutoLoading) {
22
- tools.push(addTool, removeTool);
23
- }
24
- return tools;
25
- }
26
- export function getActorRunData() {
27
- return Actor.isAtHome() ? {
28
- id: process.env.ACTOR_RUN_ID,
29
- actId: process.env.ACTOR_ID,
30
- userId: process.env.APIFY_USER_ID,
31
- startedAt: process.env.ACTOR_STARTED_AT,
32
- finishedAt: null,
33
- status: 'RUNNING',
34
- meta: {
35
- origin: process.env.APIFY_META_ORIGIN,
36
- },
37
- options: {
38
- build: process.env.ACTOR_BUILD_NUMBER,
39
- memoryMbytes: process.env.ACTOR_MEMORY_MBYTES,
40
- },
41
- buildId: process.env.ACTOR_BUILD_ID,
42
- defaultKeyValueStoreId: process.env.ACTOR_DEFAULT_KEY_VALUE_STORE_ID,
43
- defaultDatasetId: process.env.ACTOR_DEFAULT_DATASET_ID,
44
- defaultRequestQueueId: process.env.ACTOR_DEFAULT_REQUEST_QUEUE_ID,
45
- buildNumber: process.env.ACTOR_BUILD_NUMBER,
46
- containerUrl: process.env.ACTOR_WEB_SERVER_URL,
47
- standbyUrl: process.env.ACTOR_STANDBY_URL,
48
- } : null;
49
- }
50
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/actor/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,MAAM,UAAU,uBAAuB,CAAC,GAAW;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAqB,CAAC;IACh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AAO,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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=clientStreamableHttp.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientStreamableHttp.d.ts","sourceRoot":"","sources":["../../src/examples/clientStreamableHttp.ts"],"names":[],"mappings":""}