@apify/actors-mcp-server 0.1.22-beta.8 → 0.1.22
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.
- package/README.md +62 -64
- package/dist/actors.d.ts +74 -0
- package/dist/actors.d.ts.map +1 -0
- package/dist/{tools/utils.js → actors.js} +241 -112
- package/dist/actors.js.map +1 -0
- package/dist/const.d.ts +18 -14
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +22 -22
- package/dist/const.js.map +1 -1
- package/dist/examples/clientSse.d.ts +1 -10
- package/dist/examples/clientSse.d.ts.map +1 -1
- package/dist/examples/clientSse.js +4 -7
- package/dist/examples/clientSse.js.map +1 -1
- package/dist/examples/clientStdio.js +2 -2
- package/dist/examples/clientStdio.js.map +1 -1
- package/dist/examples/clientStdioChat.js +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -6
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +1 -1
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +8 -6
- package/dist/input.js.map +1 -1
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +4 -0
- package/dist/logger.js.map +1 -0
- package/dist/main.d.ts +0 -4
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +121 -31
- package/dist/main.js.map +1 -1
- package/dist/server.d.ts +43 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +178 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +46 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +128 -0
- package/dist/tools.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +10 -93
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -18
- package/dist/actor/const.d.ts +0 -10
- package/dist/actor/const.d.ts.map +0 -1
- package/dist/actor/const.js +0 -11
- package/dist/actor/const.js.map +0 -1
- package/dist/actor/server.d.ts +0 -4
- package/dist/actor/server.d.ts.map +0 -1
- package/dist/actor/server.js +0 -82
- package/dist/actor/server.js.map +0 -1
- package/dist/actor/types.d.ts +0 -23
- package/dist/actor/types.d.ts.map +0 -1
- package/dist/actor/types.js +0 -2
- package/dist/actor/types.js.map +0 -1
- package/dist/actor/utils.d.ts +0 -3
- package/dist/actor/utils.d.ts.map +0 -1
- package/dist/actor/utils.js +0 -26
- package/dist/actor/utils.js.map +0 -1
- package/dist/apify-client.d.ts +0 -6
- package/dist/apify-client.d.ts.map +0 -1
- package/dist/apify-client.js +0 -23
- package/dist/apify-client.js.map +0 -1
- package/dist/mcp/actors.d.ts +0 -3
- package/dist/mcp/actors.d.ts.map +0 -1
- package/dist/mcp/actors.js +0 -13
- package/dist/mcp/actors.js.map +0 -1
- package/dist/mcp/client.d.ts +0 -6
- package/dist/mcp/client.d.ts.map +0 -1
- package/dist/mcp/client.js +0 -33
- package/dist/mcp/client.js.map +0 -1
- package/dist/mcp/const.d.ts +0 -3
- package/dist/mcp/const.d.ts.map +0 -1
- package/dist/mcp/const.js +0 -3
- package/dist/mcp/const.js.map +0 -1
- package/dist/mcp/proxy.d.ts +0 -4
- package/dist/mcp/proxy.d.ts.map +0 -1
- package/dist/mcp/proxy.js +0 -29
- package/dist/mcp/proxy.js.map +0 -1
- package/dist/mcp/server.d.ts +0 -41
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/server.js +0 -177
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/utils.d.ts +0 -34
- package/dist/mcp/utils.d.ts.map +0 -1
- package/dist/mcp/utils.js +0 -69
- package/dist/mcp/utils.js.map +0 -1
- package/dist/stdio.d.ts +0 -15
- package/dist/stdio.d.ts.map +0 -1
- package/dist/stdio.js +0 -46
- package/dist/stdio.js.map +0 -1
- package/dist/tools/actor.d.ts +0 -40
- package/dist/tools/actor.d.ts.map +0 -1
- package/dist/tools/actor.js +0 -136
- package/dist/tools/actor.js.map +0 -1
- package/dist/tools/build.d.ts +0 -12
- package/dist/tools/build.d.ts.map +0 -1
- package/dist/tools/build.js +0 -120
- package/dist/tools/build.js.map +0 -1
- package/dist/tools/helpers.d.ts +0 -19
- package/dist/tools/helpers.d.ts.map +0 -1
- package/dist/tools/helpers.js +0 -62
- package/dist/tools/helpers.js.map +0 -1
- package/dist/tools/index.d.ts +0 -6
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -8
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/store_collection.d.ts +0 -21
- package/dist/tools/store_collection.d.ts.map +0 -1
- package/dist/tools/store_collection.js +0 -80
- package/dist/tools/store_collection.js.map +0 -1
- package/dist/tools/utils.d.ts +0 -77
- package/dist/tools/utils.d.ts.map +0 -1
- package/dist/tools/utils.js.map +0 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ajv } from 'ajv';
|
|
2
|
+
import { ApifyClient } from 'apify-client';
|
|
3
|
+
import { ACTOR_ADDITIONAL_INSTRUCTIONS, defaults, MAX_DESCRIPTION_LENGTH, ACTOR_README_MAX_LENGTH, ACTOR_ENUM_MAX_LENGTH } from './const.js';
|
|
4
|
+
import { log } from './logger.js';
|
|
2
5
|
export function actorNameToToolName(actorName) {
|
|
3
6
|
return actorName
|
|
4
7
|
.replace(/\//g, '-slash-')
|
|
@@ -6,58 +9,160 @@ export function actorNameToToolName(actorName) {
|
|
|
6
9
|
.slice(0, 64);
|
|
7
10
|
}
|
|
8
11
|
/**
|
|
9
|
-
*
|
|
12
|
+
* Get actor input schema by actor name.
|
|
13
|
+
* First, fetch the actor details to get the default build tag and buildId.
|
|
14
|
+
* Then, fetch the build details and return actorName, description, and input schema.
|
|
15
|
+
* @param {string} actorIdOrName - Actor ID or Actor full name.
|
|
16
|
+
* @param {number} limit - Truncate the README to this limit.
|
|
17
|
+
* @returns {Promise<ActorDefinitionWithDesc | null>} - The actor definition with description or null if not found.
|
|
18
|
+
*/
|
|
19
|
+
export async function getActorDefinition(actorIdOrName, limit = ACTOR_README_MAX_LENGTH) {
|
|
20
|
+
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
|
|
21
|
+
const actorClient = client.actor(actorIdOrName);
|
|
22
|
+
try {
|
|
23
|
+
// Fetch actor details
|
|
24
|
+
const actor = await actorClient.get();
|
|
25
|
+
if (!actor) {
|
|
26
|
+
log.error(`Failed to fetch input schema for Actor: ${actorIdOrName}. Actor not found.`);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
// fnesveda: The default build is not necessarily tagged, you can specify any build number as default build.
|
|
30
|
+
// There will be a new API endpoint to fetch a default build.
|
|
31
|
+
// For now, we'll use the tagged build, it will work for 90% of Actors. Later, we can update this.
|
|
32
|
+
const tag = actor.defaultRunOptions?.build || '';
|
|
33
|
+
const buildId = actor.taggedBuilds?.[tag]?.buildId || '';
|
|
34
|
+
if (!buildId) {
|
|
35
|
+
log.error(`Failed to fetch input schema for Actor: ${actorIdOrName}. Build ID not found.`);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
// Fetch build details and return the input schema
|
|
39
|
+
const buildDetails = await client.build(buildId).get();
|
|
40
|
+
if (buildDetails?.actorDefinition) {
|
|
41
|
+
const actorDefinitions = buildDetails?.actorDefinition;
|
|
42
|
+
actorDefinitions.id = actor.id;
|
|
43
|
+
actorDefinitions.readme = truncateActorReadme(actorDefinitions.readme || '', limit);
|
|
44
|
+
actorDefinitions.description = actor.description || '';
|
|
45
|
+
actorDefinitions.actorFullName = `${actor.username}/${actor.name}`;
|
|
46
|
+
actorDefinitions.defaultRunOptions = actor.defaultRunOptions;
|
|
47
|
+
return pruneActorDefinition(actorDefinitions);
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const errorMessage = `Failed to fetch input schema for Actor: ${actorIdOrName} with error ${error}.`;
|
|
53
|
+
log.error(errorMessage);
|
|
54
|
+
throw new Error(errorMessage);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function pruneActorDefinition(response) {
|
|
58
|
+
return {
|
|
59
|
+
id: response.id,
|
|
60
|
+
actorFullName: response.actorFullName || '',
|
|
61
|
+
buildTag: response?.buildTag || '',
|
|
62
|
+
readme: response?.readme || '',
|
|
63
|
+
input: response?.input && 'type' in response.input && 'properties' in response.input
|
|
64
|
+
? { ...response.input,
|
|
65
|
+
type: response.input.type,
|
|
66
|
+
properties: response.input.properties }
|
|
67
|
+
: undefined,
|
|
68
|
+
description: response.description,
|
|
69
|
+
defaultRunOptions: response.defaultRunOptions,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Helper function to shorten the enum list if it is too long.
|
|
10
74
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
75
|
+
* @param {string[]} enumList - The list of enum values to be shortened.
|
|
76
|
+
* @returns {string[] | undefined} - The shortened enum list or undefined if the list is too long.
|
|
77
|
+
*/
|
|
78
|
+
export function shortenEnum(enumList) {
|
|
79
|
+
let charCount = 0;
|
|
80
|
+
const resultEnumList = enumList.filter((enumValue) => {
|
|
81
|
+
charCount += enumValue.length;
|
|
82
|
+
return charCount <= ACTOR_ENUM_MAX_LENGTH;
|
|
83
|
+
});
|
|
84
|
+
return resultEnumList.length > 0 ? resultEnumList : undefined;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Shortens the description, enum, and items.enum properties of the schema properties.
|
|
88
|
+
* @param properties
|
|
89
|
+
*/
|
|
90
|
+
export function shortenProperties(properties) {
|
|
91
|
+
for (const property of Object.values(properties)) {
|
|
92
|
+
if (property.description.length > MAX_DESCRIPTION_LENGTH) {
|
|
93
|
+
property.description = `${property.description.slice(0, MAX_DESCRIPTION_LENGTH)}...`;
|
|
94
|
+
}
|
|
95
|
+
if (property.enum && property.enum?.length > 0) {
|
|
96
|
+
property.enum = shortenEnum(property.enum);
|
|
97
|
+
}
|
|
98
|
+
if (property.items?.enum && property.items.enum.length > 0) {
|
|
99
|
+
property.items.enum = shortenEnum(property.items.enum);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return properties;
|
|
103
|
+
}
|
|
104
|
+
/** Prune Actor README if it is too long
|
|
105
|
+
* If the README is too long
|
|
106
|
+
* - We keep the README as it is up to the limit.
|
|
107
|
+
* - After the limit, we keep heading only
|
|
108
|
+
* - We add a note that the README was truncated because it was too long.
|
|
109
|
+
*/
|
|
110
|
+
export function truncateActorReadme(readme, limit = ACTOR_README_MAX_LENGTH) {
|
|
111
|
+
if (readme.length <= limit) {
|
|
112
|
+
return readme;
|
|
113
|
+
}
|
|
114
|
+
const readmeFirst = readme.slice(0, limit);
|
|
115
|
+
const readmeRest = readme.slice(limit);
|
|
116
|
+
const lines = readmeRest.split('\n');
|
|
117
|
+
const prunedReadme = lines.filter((line) => line.startsWith('#'));
|
|
118
|
+
return `${readmeFirst}\n\nREADME was truncated because it was too long. Remaining headers:\n${prunedReadme.join(', ')}`;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Helps determine the type of items in an array schema property.
|
|
122
|
+
* Priority order: explicit type in items > prefill type > default value type > editor type.
|
|
15
123
|
*
|
|
16
|
-
*
|
|
17
|
-
* For request list sources (type='array', editor='requestListSources'), adds URL structure to items.
|
|
124
|
+
* Based on JSON schema, the array needs a type, and most of the time Actor input schema does not have this, so we need to infer that.
|
|
18
125
|
*
|
|
19
|
-
* @param {Record<string, ISchemaProperties>} properties - The input schema properties
|
|
20
|
-
* @returns {Record<string, ISchemaProperties>} Modified properties with nested properties
|
|
21
126
|
*/
|
|
22
|
-
export function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
127
|
+
export function inferArrayItemType(property) {
|
|
128
|
+
return property.items?.type
|
|
129
|
+
|| (Array.isArray(property.prefill) && property.prefill.length > 0 && typeof property.prefill[0])
|
|
130
|
+
|| (Array.isArray(property.default) && property.default.length > 0 && typeof property.default[0])
|
|
131
|
+
|| (property.editor && getEditorItemType(property.editor))
|
|
132
|
+
|| null;
|
|
133
|
+
function getEditorItemType(editor) {
|
|
134
|
+
const editorTypeMap = {
|
|
135
|
+
requestListSources: 'object',
|
|
136
|
+
stringList: 'string',
|
|
137
|
+
json: 'object',
|
|
138
|
+
globs: 'object',
|
|
139
|
+
};
|
|
140
|
+
return editorTypeMap[editor] || null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Add enum values as string to property descriptions.
|
|
145
|
+
*
|
|
146
|
+
* This is done as a preventive measure to prevent cases where library or agent framework
|
|
147
|
+
* does not handle enums or examples based on JSON schema definition.
|
|
148
|
+
*
|
|
149
|
+
* https://json-schema.org/understanding-json-schema/reference/enum
|
|
150
|
+
* https://json-schema.org/understanding-json-schema/reference/annotations
|
|
151
|
+
*
|
|
152
|
+
* @param properties
|
|
153
|
+
*/
|
|
154
|
+
function addEnumsToDescriptionsWithExamples(properties) {
|
|
155
|
+
for (const property of Object.values(properties)) {
|
|
156
|
+
if (property.enum && property.enum.length > 0) {
|
|
157
|
+
property.description = `${property.description}\nPossible values: ${property.enum.slice(0, 20).join(',')}`;
|
|
40
158
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...property.items,
|
|
46
|
-
type: 'object',
|
|
47
|
-
title: 'Request list source',
|
|
48
|
-
description: 'Request list source',
|
|
49
|
-
properties: {
|
|
50
|
-
url: {
|
|
51
|
-
title: 'URL',
|
|
52
|
-
type: 'string',
|
|
53
|
-
description: 'URL of the request list source',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
159
|
+
const value = property.prefill ?? property.default;
|
|
160
|
+
if (value && !(Array.isArray(value) && value.length === 0)) {
|
|
161
|
+
property.examples = Array.isArray(value) ? value : [value];
|
|
162
|
+
property.description = `${property.description}\nExample values: ${JSON.stringify(value)}`;
|
|
58
163
|
}
|
|
59
164
|
}
|
|
60
|
-
return
|
|
165
|
+
return properties;
|
|
61
166
|
}
|
|
62
167
|
/**
|
|
63
168
|
* Filters schema properties to include only the necessary fields.
|
|
@@ -104,7 +209,7 @@ export function filterSchemaProperties(properties) {
|
|
|
104
209
|
* @param {IActorInputSchema} input - Actor input object containing properties and required fields
|
|
105
210
|
* @returns {Record<string, ISchemaProperties>} - Modified properties with required fields marked
|
|
106
211
|
*/
|
|
107
|
-
|
|
212
|
+
function markInputPropertiesAsRequired(input) {
|
|
108
213
|
const { required = [], properties } = input;
|
|
109
214
|
for (const property of Object.keys(properties)) {
|
|
110
215
|
if (required.includes(property)) {
|
|
@@ -117,82 +222,106 @@ export function markInputPropertiesAsRequired(input) {
|
|
|
117
222
|
return properties;
|
|
118
223
|
}
|
|
119
224
|
/**
|
|
120
|
-
*
|
|
121
|
-
* Priority order: explicit type in items > prefill type > default value type > editor type.
|
|
122
|
-
*
|
|
123
|
-
* Based on JSON schema, the array needs a type, and most of the time Actor input schema does not have this, so we need to infer that.
|
|
124
|
-
*
|
|
125
|
-
*/
|
|
126
|
-
export function inferArrayItemType(property) {
|
|
127
|
-
return property.items?.type
|
|
128
|
-
|| (Array.isArray(property.prefill) && property.prefill.length > 0 && typeof property.prefill[0])
|
|
129
|
-
|| (Array.isArray(property.default) && property.default.length > 0 && typeof property.default[0])
|
|
130
|
-
|| (property.editor && getEditorItemType(property.editor))
|
|
131
|
-
|| null;
|
|
132
|
-
function getEditorItemType(editor) {
|
|
133
|
-
const editorTypeMap = {
|
|
134
|
-
requestListSources: 'object',
|
|
135
|
-
stringList: 'string',
|
|
136
|
-
json: 'object',
|
|
137
|
-
globs: 'object',
|
|
138
|
-
};
|
|
139
|
-
return editorTypeMap[editor] || null;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Add enum values as string to property descriptions.
|
|
225
|
+
* Builds nested properties for object types in the schema.
|
|
144
226
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
227
|
+
* Specifically handles special cases like proxy configuration and request list sources
|
|
228
|
+
* by adding predefined nested properties to these object types.
|
|
229
|
+
* This is necessary for the agent to correctly infer how to structure object inputs
|
|
230
|
+
* when passing arguments to the Actor.
|
|
147
231
|
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
232
|
+
* For proxy objects (type='object', editor='proxy'), adds 'useApifyProxy' property.
|
|
233
|
+
* For request list sources (type='array', editor='requestListSources'), adds URL structure to items.
|
|
150
234
|
*
|
|
151
|
-
* @param properties
|
|
235
|
+
* @param {Record<string, ISchemaProperties>} properties - The input schema properties
|
|
236
|
+
* @returns {Record<string, ISchemaProperties>} Modified properties with nested properties
|
|
152
237
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
238
|
+
function buildNestedProperties(properties) {
|
|
239
|
+
const clonedProperties = { ...properties };
|
|
240
|
+
for (const [propertyName, property] of Object.entries(clonedProperties)) {
|
|
241
|
+
if (property.type === 'object' && property.editor === 'proxy') {
|
|
242
|
+
clonedProperties[propertyName] = {
|
|
243
|
+
...property,
|
|
244
|
+
properties: {
|
|
245
|
+
...property.properties,
|
|
246
|
+
useApifyProxy: {
|
|
247
|
+
title: 'Use Apify Proxy',
|
|
248
|
+
type: 'boolean',
|
|
249
|
+
description: 'Whether to use Apify Proxy - ALWAYS SET TO TRUE.',
|
|
250
|
+
default: true,
|
|
251
|
+
examples: [true],
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
required: ['useApifyProxy'],
|
|
255
|
+
};
|
|
157
256
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
257
|
+
else if (property.type === 'array' && property.editor === 'requestListSources') {
|
|
258
|
+
clonedProperties[propertyName] = {
|
|
259
|
+
...property,
|
|
260
|
+
items: {
|
|
261
|
+
...property.items,
|
|
262
|
+
type: 'object',
|
|
263
|
+
title: 'Request list source',
|
|
264
|
+
description: 'Request list source',
|
|
265
|
+
properties: {
|
|
266
|
+
url: {
|
|
267
|
+
title: 'URL',
|
|
268
|
+
type: 'string',
|
|
269
|
+
description: 'URL of the request list source',
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
};
|
|
162
274
|
}
|
|
163
275
|
}
|
|
164
|
-
return
|
|
276
|
+
return clonedProperties;
|
|
165
277
|
}
|
|
166
278
|
/**
|
|
167
|
-
*
|
|
279
|
+
* Fetches actor input schemas by Actor IDs or Actor full names and creates MCP tools.
|
|
168
280
|
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
*
|
|
182
|
-
* @
|
|
281
|
+
* This function retrieves the input schemas for the specified actors and compiles them into MCP tools.
|
|
282
|
+
* It uses the AJV library to validate the input schemas.
|
|
283
|
+
*
|
|
284
|
+
* Tool name can't contain /, so it is replaced with _
|
|
285
|
+
*
|
|
286
|
+
* The input schema processing workflow:
|
|
287
|
+
* 1. Properties are marked as required using markInputPropertiesAsRequired() to add "REQUIRED" prefix to descriptions
|
|
288
|
+
* 2. Nested properties are built by analyzing editor type (proxy, requestListSources) using buildNestedProperties()
|
|
289
|
+
* 3. Properties are filtered using filterSchemaProperties()
|
|
290
|
+
* 4. Properties are shortened using shortenProperties()
|
|
291
|
+
* 5. Enums are added to descriptions with examples using addEnumsToDescriptionsWithExamples()
|
|
292
|
+
*
|
|
293
|
+
* @param {string[]} actors - An array of actor IDs or Actor full names.
|
|
294
|
+
* @returns {Promise<Tool[]>} - A promise that resolves to an array of MCP tools.
|
|
183
295
|
*/
|
|
184
|
-
export function
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
296
|
+
export async function getActorsAsTools(actors) {
|
|
297
|
+
const ajv = new Ajv({ coerceTypes: 'array', strict: false });
|
|
298
|
+
const results = await Promise.all(actors.map(getActorDefinition));
|
|
299
|
+
const tools = [];
|
|
300
|
+
for (const result of results) {
|
|
301
|
+
if (result) {
|
|
302
|
+
if (result.input && 'properties' in result.input && result.input) {
|
|
303
|
+
result.input.properties = markInputPropertiesAsRequired(result.input);
|
|
304
|
+
result.input.properties = buildNestedProperties(result.input.properties);
|
|
305
|
+
result.input.properties = filterSchemaProperties(result.input.properties);
|
|
306
|
+
result.input.properties = shortenProperties(result.input.properties);
|
|
307
|
+
result.input.properties = addEnumsToDescriptionsWithExamples(result.input.properties);
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
const memoryMbytes = result.defaultRunOptions?.memoryMbytes || defaults.maxMemoryMbytes;
|
|
311
|
+
tools.push({
|
|
312
|
+
name: actorNameToToolName(result.actorFullName),
|
|
313
|
+
actorFullName: result.actorFullName,
|
|
314
|
+
description: `${result.description} Instructions: ${ACTOR_ADDITIONAL_INSTRUCTIONS}`,
|
|
315
|
+
inputSchema: result.input || {},
|
|
316
|
+
ajvValidate: ajv.compile(result.input || {}),
|
|
317
|
+
memoryMbytes: memoryMbytes > defaults.maxMemoryMbytes ? defaults.maxMemoryMbytes : memoryMbytes,
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
catch (validationError) {
|
|
321
|
+
log.error(`Failed to compile AJV schema for Actor: ${result.actorFullName}. Error: ${validationError}`);
|
|
322
|
+
}
|
|
194
323
|
}
|
|
195
324
|
}
|
|
196
|
-
return
|
|
325
|
+
return tools;
|
|
197
326
|
}
|
|
198
|
-
//# sourceMappingURL=
|
|
327
|
+
//# sourceMappingURL=actors.js.map
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export declare const ACTOR_MAX_DESCRIPTION_LENGTH = 500;
|
|
4
|
-
export declare const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 5000;
|
|
5
|
-
export declare const ACTOR_OUTPUT_TRUNCATED_MESSAGE: string;
|
|
6
|
-
export declare const ACTOR_ADDITIONAL_INSTRUCTIONS: string;
|
|
7
|
-
export declare const ACTOR_MAX_MEMORY_MBYTES = 4096;
|
|
8
1
|
export declare const SERVER_NAME = "apify-mcp-server";
|
|
9
2
|
export declare const SERVER_VERSION = "0.1.0";
|
|
3
|
+
export declare const HEADER_READINESS_PROBE = "x-apify-container-server-readiness-probe";
|
|
4
|
+
export declare const MAX_DESCRIPTION_LENGTH = 500;
|
|
10
5
|
export declare const USER_AGENT_ORIGIN = "Origin/mcp-server";
|
|
11
|
-
export declare enum HelperTools {
|
|
12
|
-
SEARCH = "search",
|
|
13
|
-
ADD_TOOL = "add-tool",
|
|
14
|
-
REMOVE_TOOL = "remove-tool",
|
|
15
|
-
GET_TOOL_DETAILS = "get-tool-details"
|
|
16
|
-
}
|
|
17
6
|
export declare const defaults: {
|
|
18
7
|
actors: string[];
|
|
19
8
|
enableActorAutoLoading: boolean;
|
|
20
9
|
maxMemoryMbytes: number;
|
|
21
10
|
};
|
|
22
|
-
export declare const
|
|
11
|
+
export declare const ACTOR_README_MAX_LENGTH = 5000;
|
|
12
|
+
export declare const ACTOR_ENUM_MAX_LENGTH = 200;
|
|
13
|
+
export declare const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 5000;
|
|
14
|
+
export declare const ACTOR_OUTPUT_TRUNCATED_MESSAGE: string;
|
|
15
|
+
export declare const ACTOR_ADDITIONAL_INSTRUCTIONS: string;
|
|
16
|
+
export declare enum InternalTools {
|
|
17
|
+
DISCOVER_ACTORS = "discover-actors",
|
|
18
|
+
ADD_ACTOR_TO_TOOLS = "add-actor-to-tools",
|
|
19
|
+
REMOVE_ACTOR_FROM_TOOLS = "remove-actor-from-tools",
|
|
20
|
+
GET_ACTOR_DETAILS = "get-actor-details"
|
|
21
|
+
}
|
|
22
|
+
export declare enum Routes {
|
|
23
|
+
ROOT = "/",
|
|
24
|
+
SSE = "/sse",
|
|
25
|
+
MESSAGE = "/message"
|
|
26
|
+
}
|
|
23
27
|
//# sourceMappingURL=const.d.ts.map
|
package/dist/const.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAC9C,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,eAAO,MAAM,sBAAsB,6CAA6C,CAAC;AACjF,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,eAAO,MAAM,QAAQ;;;;CAQpB,CAAC;AAEF,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,+BAA+B,OAAQ,CAAC;AACrD,eAAO,MAAM,8BAA8B,QACQ,CAAC;AACpD,eAAO,MAAM,6BAA6B,QACuB,CAAC;AAElE,oBAAY,aAAa;IACrB,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;IACzC,uBAAuB,4BAA4B;IACnD,iBAAiB,sBAAsB;CAC1C;AAED,oBAAY,MAAM;IACd,IAAI,MAAM;IACV,GAAG,SAAS;IACZ,OAAO,aAAa;CACvB"}
|
package/dist/const.js
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
// Actor input const
|
|
2
|
-
export const ACTOR_README_MAX_LENGTH = 5_000;
|
|
3
|
-
export const ACTOR_ENUM_MAX_LENGTH = 200;
|
|
4
|
-
export const ACTOR_MAX_DESCRIPTION_LENGTH = 500;
|
|
5
|
-
// Actor output const
|
|
6
|
-
export const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 5_000;
|
|
7
|
-
export const ACTOR_OUTPUT_TRUNCATED_MESSAGE = `Output was truncated because it will not fit into context.`
|
|
8
|
-
+ `There is no reason to call this tool again!`;
|
|
9
|
-
export const ACTOR_ADDITIONAL_INSTRUCTIONS = 'Never call/execute tool/Actor unless confirmed by the user. '
|
|
10
|
-
+ 'Always limit the number of results in the call arguments.';
|
|
11
|
-
// Actor run const
|
|
12
|
-
export const ACTOR_MAX_MEMORY_MBYTES = 4_096; // If the Actor requires 8GB of memory, free users can't run actors-mcp-server and requested Actor
|
|
13
|
-
// MCP Server
|
|
14
1
|
export const SERVER_NAME = 'apify-mcp-server';
|
|
15
2
|
export const SERVER_VERSION = '0.1.0';
|
|
16
|
-
|
|
3
|
+
export const HEADER_READINESS_PROBE = 'x-apify-container-server-readiness-probe';
|
|
4
|
+
export const MAX_DESCRIPTION_LENGTH = 500;
|
|
17
5
|
export const USER_AGENT_ORIGIN = 'Origin/mcp-server';
|
|
18
|
-
export var HelperTools;
|
|
19
|
-
(function (HelperTools) {
|
|
20
|
-
HelperTools["SEARCH"] = "search";
|
|
21
|
-
HelperTools["ADD_TOOL"] = "add-tool";
|
|
22
|
-
HelperTools["REMOVE_TOOL"] = "remove-tool";
|
|
23
|
-
HelperTools["GET_TOOL_DETAILS"] = "get-tool-details";
|
|
24
|
-
})(HelperTools || (HelperTools = {}));
|
|
25
6
|
export const defaults = {
|
|
26
7
|
actors: [
|
|
27
8
|
'apify/instagram-scraper',
|
|
@@ -31,5 +12,24 @@ export const defaults = {
|
|
|
31
12
|
enableActorAutoLoading: false,
|
|
32
13
|
maxMemoryMbytes: 4096,
|
|
33
14
|
};
|
|
34
|
-
export const
|
|
15
|
+
export const ACTOR_README_MAX_LENGTH = 5_000;
|
|
16
|
+
export const ACTOR_ENUM_MAX_LENGTH = 200;
|
|
17
|
+
export const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 5_000;
|
|
18
|
+
export const ACTOR_OUTPUT_TRUNCATED_MESSAGE = `Output was truncated because it will not fit into context.`
|
|
19
|
+
+ `There is no reason to call this tool again!`;
|
|
20
|
+
export const ACTOR_ADDITIONAL_INSTRUCTIONS = 'Never call/execute tool/Actor unless confirmed by the user. '
|
|
21
|
+
+ 'Always limit the number of results in the call arguments.';
|
|
22
|
+
export var InternalTools;
|
|
23
|
+
(function (InternalTools) {
|
|
24
|
+
InternalTools["DISCOVER_ACTORS"] = "discover-actors";
|
|
25
|
+
InternalTools["ADD_ACTOR_TO_TOOLS"] = "add-actor-to-tools";
|
|
26
|
+
InternalTools["REMOVE_ACTOR_FROM_TOOLS"] = "remove-actor-from-tools";
|
|
27
|
+
InternalTools["GET_ACTOR_DETAILS"] = "get-actor-details";
|
|
28
|
+
})(InternalTools || (InternalTools = {}));
|
|
29
|
+
export var Routes;
|
|
30
|
+
(function (Routes) {
|
|
31
|
+
Routes["ROOT"] = "/";
|
|
32
|
+
Routes["SSE"] = "/sse";
|
|
33
|
+
Routes["MESSAGE"] = "/message";
|
|
34
|
+
})(Routes || (Routes = {}));
|
|
35
35
|
//# sourceMappingURL=const.js.map
|
package/dist/const.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,sBAAsB,GAAG,0CAA0C,CAAC;AACjF,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAErD,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,MAAM,EAAE;QACJ,yBAAyB;QACzB,uBAAuB;QACvB,8CAA8C;KACjD;IACD,sBAAsB,EAAE,KAAK;IAC7B,eAAe,EAAE,IAAI;CACxB,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;AACrD,MAAM,CAAC,MAAM,8BAA8B,GAAG,4DAA4D;MACpG,6CAA6C,CAAC;AACpD,MAAM,CAAC,MAAM,6BAA6B,GAAG,8DAA8D;MACrG,2DAA2D,CAAC;AAElE,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACrB,oDAAmC,CAAA;IACnC,0DAAyC,CAAA;IACzC,oEAAmD,CAAA;IACnD,wDAAuC,CAAA;AAC3C,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAED,MAAM,CAAN,IAAY,MAIX;AAJD,WAAY,MAAM;IACd,oBAAU,CAAA;IACV,sBAAY,CAAA;IACZ,8BAAoB,CAAA;AACxB,CAAC,EAJW,MAAM,KAAN,MAAM,QAIjB"}
|
|
@@ -4,14 +4,5 @@
|
|
|
4
4
|
*
|
|
5
5
|
* It requires the `APIFY_TOKEN` in the `.env` file.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
declare global {
|
|
9
|
-
var EventSource: {
|
|
10
|
-
new (url: string, eventSourceInitDict?: EventSourceInit): EventSource;
|
|
11
|
-
prototype: EventSource;
|
|
12
|
-
CONNECTING: 0;
|
|
13
|
-
OPEN: 1;
|
|
14
|
-
CLOSED: 2;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
7
|
+
export {};
|
|
17
8
|
//# sourceMappingURL=clientSse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientSse.d.ts","sourceRoot":"","sources":["../../src/examples/clientSse.ts"],"names":[],"mappings":"AACA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"clientSse.d.ts","sourceRoot":"","sources":["../../src/examples/clientSse.ts"],"names":[],"mappings":"AACA;;;;;GAKG"}
|
|
@@ -12,16 +12,15 @@ import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
|
12
12
|
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
13
13
|
import dotenv from 'dotenv';
|
|
14
14
|
import { EventSource } from 'eventsource';
|
|
15
|
-
import { actorNameToToolName } from '../
|
|
15
|
+
import { actorNameToToolName } from '../actors.js';
|
|
16
16
|
const REQUEST_TIMEOUT = 120_000; // 2 minutes
|
|
17
17
|
const filename = fileURLToPath(import.meta.url);
|
|
18
18
|
const dirname = path.dirname(filename);
|
|
19
19
|
dotenv.config({ path: path.resolve(dirname, '../../.env') });
|
|
20
|
-
const SERVER_URL =
|
|
20
|
+
const SERVER_URL = 'https://actors-mcp-server.apify.actor/sse';
|
|
21
21
|
// We need to change forward slash / to underscore -- in the tool name as Anthropic does not allow forward slashes in the tool name
|
|
22
22
|
const SELECTED_TOOL = actorNameToToolName('apify/rag-web-browser');
|
|
23
|
-
|
|
24
|
-
const QUERY = 'apify';
|
|
23
|
+
const QUERY = 'web browser for Anthropic';
|
|
25
24
|
if (!process.env.APIFY_TOKEN) {
|
|
26
25
|
console.error('APIFY_TOKEN is required but not set in the environment variables.');
|
|
27
26
|
process.exit(1);
|
|
@@ -72,14 +71,12 @@ async function main() {
|
|
|
72
71
|
catch (error) {
|
|
73
72
|
if (error instanceof Error) {
|
|
74
73
|
console.error('Error:', error.message);
|
|
74
|
+
console.error(error.stack);
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
77
|
console.error('An unknown error occurred:', error);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
finally {
|
|
81
|
-
await client.close();
|
|
82
|
-
}
|
|
83
80
|
}
|
|
84
81
|
await main();
|
|
85
82
|
//# sourceMappingURL=clientSse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientSse.js","sourceRoot":"","sources":["../../src/examples/clientSse.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"clientSse.js","sourceRoot":"","sources":["../../src/examples/clientSse.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,eAAe,GAAG,OAAO,CAAC,CAAC,YAAY;AAC7C,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;AAE7D,MAAM,UA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AM,CAAC;YACJ,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACvD,CAAC;IACL,CAAC;AACL,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
|
|
@@ -12,12 +12,12 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
|
12
12
|
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
13
13
|
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
14
14
|
import dotenv from 'dotenv';
|
|
15
|
-
import { actorNameToToolName } from '../
|
|
15
|
+
import { actorNameToToolName } from '../actors.js';
|
|
16
16
|
// Resolve dirname equivalent in ES module
|
|
17
17
|
const filename = fileURLToPath(import.meta.url);
|
|
18
18
|
const dirname = path.dirname(filename);
|
|
19
19
|
dotenv.config({ path: path.resolve(dirname, '../../.env') });
|
|
20
|
-
const SERVER_PATH = path.resolve(dirname, '../../dist/
|
|
20
|
+
const SERVER_PATH = path.resolve(dirname, '../../dist/index.js');
|
|
21
21
|
const NODE_PATH = execSync(process.platform === 'win32' ? 'where node' : 'which node').toString().trim();
|
|
22
22
|
const TOOLS = 'apify/rag-web-browser,lukaskrivka/google-maps-with-contact-details';
|
|
23
23
|
const SELECTED_TOOL = actorNameToToolName('apify/rag-web-browser');
|