@apify/actors-mcp-server 0.2.10-beta.1 → 0.2.10-beta.2
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 +2 -4
- package/dist/const.d.ts +10 -1
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +10 -0
- package/dist/const.js.map +1 -1
- package/dist/state.d.ts +4 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +4 -1
- package/dist/state.js.map +1 -1
- package/dist/tools/fetch-apify-docs.d.ts +3 -0
- package/dist/tools/fetch-apify-docs.d.ts.map +1 -0
- package/dist/tools/fetch-apify-docs.js +74 -0
- package/dist/tools/fetch-apify-docs.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/search-apify-docs.d.ts +3 -0
- package/dist/tools/search-apify-docs.d.ts.map +1 -0
- package/dist/tools/search-apify-docs.js +61 -0
- package/dist/tools/search-apify-docs.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/apify-docs.d.ts +19 -0
- package/dist/utils/apify-docs.d.ts.map +1 -0
- package/dist/utils/apify-docs.js +72 -0
- package/dist/utils/apify-docs.js.map +1 -0
- package/dist/utils/html-to-md.d.ts +5 -0
- package/dist/utils/html-to-md.d.ts.map +1 -0
- package/dist/utils/html-to-md.js +33 -0
- package/dist/utils/html-to-md.js.map +1 -0
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -92,10 +92,8 @@ You can refer to the specific Actor's documentation for a list of available argu
|
|
|
92
92
|
### Helper tools
|
|
93
93
|
One of the powerful features of MCP with Apify is dynamic actor tooling – the ability for an AI agent to find new tools (Actors) as needed and incorporate them. Here are some special MCP operations and how Apify MCP Server supports them:
|
|
94
94
|
|
|
95
|
-
- Actor discovery and management: Search for Actors (`search-actors`), view details (`get-actor-details`), and dynamically add
|
|
96
|
-
-
|
|
97
|
-
- Dataset access: List datasets, retrieve dataset info and items (`get-dataset`, `get-dataset-list`, `get-dataset-items`).
|
|
98
|
-
- Key-value store access: List key-value stores, view keys, and retrieve records (`get-key-value-store-list`, `get-key-value-store`, `get-key-value-store-keys`, `get-key-value-store-record`).
|
|
95
|
+
- Actor discovery and management: Search for Actors (`search-actors`), view details (`get-actor-details`), and dynamically add them (`add-actor`).
|
|
96
|
+
- Apify documentation: Search Apify documentation (`search-apify-docs`) and fetch specific documents (`fetch-apify-docs`).
|
|
99
97
|
- Built-in help tool: A static helper (`apify-actor-help-tool`) that returns usage info for the Apify MCP Server.
|
|
100
98
|
|
|
101
99
|
## Prompt & Resources
|
package/dist/const.d.ts
CHANGED
|
@@ -24,7 +24,9 @@ export declare enum HelperTools {
|
|
|
24
24
|
KEY_VALUE_STORE_KEYS_GET = "get-key-value-store-keys",
|
|
25
25
|
KEY_VALUE_STORE_RECORD_GET = "get-key-value-store-record",
|
|
26
26
|
APIFY_MCP_HELP_TOOL = "apify-actor-help-tool",
|
|
27
|
-
STORE_SEARCH = "search-actors"
|
|
27
|
+
STORE_SEARCH = "search-actors",
|
|
28
|
+
DOCS_SEARCH = "search-apify-docs",
|
|
29
|
+
DOCS_FETCH = "fetch-apify-docs"
|
|
28
30
|
}
|
|
29
31
|
export declare const defaults: {
|
|
30
32
|
actors: string[];
|
|
@@ -34,6 +36,8 @@ export declare const ACTOR_OUTPUT_TRUNCATED_MESSAGE: string;
|
|
|
34
36
|
export declare const ACTOR_ADDITIONAL_INSTRUCTIONS = "Never call/execute tool/Actor unless confirmed by the user.";
|
|
35
37
|
export declare const ACTOR_CACHE_MAX_SIZE = 500;
|
|
36
38
|
export declare const ACTOR_CACHE_TTL_SECS: number;
|
|
39
|
+
export declare const APIFY_DOCS_CACHE_MAX_SIZE = 500;
|
|
40
|
+
export declare const APIFY_DOCS_CACHE_TTL_SECS: number;
|
|
37
41
|
export declare const ACTOR_PRICING_MODEL: {
|
|
38
42
|
/** Rental actors */
|
|
39
43
|
readonly FLAT_PRICE_PER_MONTH: "FLAT_PRICE_PER_MONTH";
|
|
@@ -49,4 +53,9 @@ export declare const ACTOR_PRICING_MODEL: {
|
|
|
49
53
|
*/
|
|
50
54
|
export declare const ACTOR_SEARCH_ABOVE_LIMIT = 50;
|
|
51
55
|
export declare const MCP_STREAMABLE_ENDPOINT = "/mcp";
|
|
56
|
+
export declare const ALGOLIA: {
|
|
57
|
+
appId: string;
|
|
58
|
+
apiKey: string;
|
|
59
|
+
indexName: string;
|
|
60
|
+
};
|
|
52
61
|
//# 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":"AACA,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAEhD,eAAO,MAAM,kCAAkC,IAAI,CAAC;AAGpD,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAG7C,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAC9C,eAAO,MAAM,cAAc,UAAU,CAAC;AAGtC,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,oBAAY,WAAW;IACnB,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;IAC7B,gBAAgB,oBAAoB;IACpC,cAAc,kBAAkB;IAChC,cAAc,kBAAkB;IAChC,kBAAkB,uBAAuB;IACzC,WAAW,gBAAgB;IAC3B,gBAAgB,qBAAqB;IACrC,iBAAiB,sBAAsB;IACvC,wBAAwB,6BAA6B;IACrD,mBAAmB,wBAAwB;IAC3C,wBAAwB,6BAA6B;IACrD,0BAA0B,+BAA+B;IACzD,mBAAmB,0BAA0B;IAC7C,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kCAAkC;;IAElC,iCAAiC;;CAE3B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,eAAO,MAAM,uBAAuB,SAAS,CAAC;AAE9C,eAAO,MAAM,OAAO;;;;CAInB,CAAC"}
|
package/dist/const.js
CHANGED
|
@@ -30,6 +30,8 @@ export var HelperTools;
|
|
|
30
30
|
HelperTools["KEY_VALUE_STORE_RECORD_GET"] = "get-key-value-store-record";
|
|
31
31
|
HelperTools["APIFY_MCP_HELP_TOOL"] = "apify-actor-help-tool";
|
|
32
32
|
HelperTools["STORE_SEARCH"] = "search-actors";
|
|
33
|
+
HelperTools["DOCS_SEARCH"] = "search-apify-docs";
|
|
34
|
+
HelperTools["DOCS_FETCH"] = "fetch-apify-docs";
|
|
33
35
|
})(HelperTools || (HelperTools = {}));
|
|
34
36
|
export const defaults = {
|
|
35
37
|
actors: [
|
|
@@ -41,8 +43,11 @@ export const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 5000;
|
|
|
41
43
|
export const ACTOR_OUTPUT_TRUNCATED_MESSAGE = `Output was truncated because it will not fit into context.`
|
|
42
44
|
+ `There is no reason to call this tool again! You can use ${HelperTools.DATASET_GET_ITEMS} tool to get more items from the dataset.`;
|
|
43
45
|
export const ACTOR_ADDITIONAL_INSTRUCTIONS = 'Never call/execute tool/Actor unless confirmed by the user.';
|
|
46
|
+
// Cache
|
|
44
47
|
export const ACTOR_CACHE_MAX_SIZE = 500;
|
|
45
48
|
export const ACTOR_CACHE_TTL_SECS = 30 * 60; // 30 minutes
|
|
49
|
+
export const APIFY_DOCS_CACHE_MAX_SIZE = 500;
|
|
50
|
+
export const APIFY_DOCS_CACHE_TTL_SECS = 60 * 60; // 1 hour
|
|
46
51
|
export const ACTOR_PRICING_MODEL = {
|
|
47
52
|
/** Rental actors */
|
|
48
53
|
FLAT_PRICE_PER_MONTH: 'FLAT_PRICE_PER_MONTH',
|
|
@@ -58,4 +63,9 @@ export const ACTOR_PRICING_MODEL = {
|
|
|
58
63
|
*/
|
|
59
64
|
export const ACTOR_SEARCH_ABOVE_LIMIT = 50;
|
|
60
65
|
export const MCP_STREAMABLE_ENDPOINT = '/mcp';
|
|
66
|
+
export const ALGOLIA = {
|
|
67
|
+
appId: 'N8EOCSBQGH',
|
|
68
|
+
apiKey: 'e97714a64e2b4b8b8fe0b01cd8592870', // search only (public) API key
|
|
69
|
+
indexName: 'test_test_apify_sdk',
|
|
70
|
+
};
|
|
61
71
|
//# 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,oBAAoB;AACpB,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAK,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEhD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;AAEpD,kBAAkB;AAClB,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAK,CAAC,CAAC,kGAAkG;AAEhJ,aAAa;AACb,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,qBAAqB;AACrB,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAErD,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAK,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEhD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;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MAAM,yBAAyB,GAAG,GAAG,CAAC;AAC7C,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS;AAE3D,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,oBAAoB;IACpB,oBAAoB,EAAE,sBAAsB;IAC5C,IAAI,EAAE,MAAM;IACZ,kCAAkC;IAClC,sBAAsB,EAAE,wBAAwB;IAChD,iCAAiC;IACjC,aAAa,EAAE,eAAe;CACxB,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAE9C,MAAM,CAAC,MAAM,OAAO,GAAG;IACnB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,kCAAkC,EAAE,+BAA+B;IAC3E,SAAS,EAAE,qBAAqB;CACnC,CAAC"}
|
package/dist/state.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type { ActorDefinitionPruned } from './types.js';
|
|
1
|
+
import type { ActorDefinitionPruned, ApifyDocsSearchResult } from './types.js';
|
|
2
2
|
import { TTLLRUCache } from './utils/ttl-lru.js';
|
|
3
3
|
export declare const actorDefinitionPrunedCache: TTLLRUCache<ActorDefinitionPruned>;
|
|
4
|
+
export declare const searchApifyDocsCache: TTLLRUCache<ApifyDocsSearchResult[]>;
|
|
5
|
+
/** Stores processed Markdown content */
|
|
6
|
+
export declare const fetchApifyDocsCache: TTLLRUCache<string>;
|
|
4
7
|
//# sourceMappingURL=state.d.ts.map
|
package/dist/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,eAAO,MAAM,0BAA0B,oCAAqF,CAAC;AAC7H,eAAO,MAAM,oBAAoB,sCAAiG,CAAC;AACnI,wCAAwC;AACxC,eAAO,MAAM,mBAAmB,qBAAgF,CAAC"}
|
package/dist/state.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { ACTOR_CACHE_MAX_SIZE, ACTOR_CACHE_TTL_SECS } from './const.js';
|
|
1
|
+
import { ACTOR_CACHE_MAX_SIZE, ACTOR_CACHE_TTL_SECS, APIFY_DOCS_CACHE_MAX_SIZE, APIFY_DOCS_CACHE_TTL_SECS } from './const.js';
|
|
2
2
|
import { TTLLRUCache } from './utils/ttl-lru.js';
|
|
3
3
|
export const actorDefinitionPrunedCache = new TTLLRUCache(ACTOR_CACHE_MAX_SIZE, ACTOR_CACHE_TTL_SECS);
|
|
4
|
+
export const searchApifyDocsCache = new TTLLRUCache(APIFY_DOCS_CACHE_MAX_SIZE, APIFY_DOCS_CACHE_TTL_SECS);
|
|
5
|
+
/** Stores processed Markdown content */
|
|
6
|
+
export const fetchApifyDocsCache = new TTLLRUCache(APIFY_DOCS_CACHE_MAX_SIZE, APIFY_DOCS_CACHE_TTL_SECS);
|
|
4
7
|
//# sourceMappingURL=state.js.map
|
package/dist/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE9H,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,WAAW,CAAwB,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;AAC7H,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,WAAW,CAA0B,yBAAyB,EAAE,yBAAyB,CAAC,CAAC;AACnI,wCAAwC;AACxC,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,WAAW,CAAS,yBAAyB,EAAE,yBAAyB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-apify-docs.d.ts","sourceRoot":"","sources":["../../src/tools/fetch-apify-docs.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,aAAa,CAAC;AAU3D,eAAO,MAAM,kBAAkB,EAAE,SA+DhC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import zodToJsonSchema from 'zod-to-json-schema';
|
|
3
|
+
import log from '@apify/log';
|
|
4
|
+
import { HelperTools } from '../const.js';
|
|
5
|
+
import { fetchApifyDocsCache } from '../state.js';
|
|
6
|
+
import { ajv } from '../utils/ajv.js';
|
|
7
|
+
import { htmlToMarkdown } from '../utils/html-to-md.js';
|
|
8
|
+
const fetchApifyDocsToolArgsSchema = z.object({
|
|
9
|
+
url: z.string()
|
|
10
|
+
.min(1)
|
|
11
|
+
.describe(`URL of the Apify documentation page to fetch. This should be the full URL, including the protocol (e.g., https://docs.apify.com/).`),
|
|
12
|
+
});
|
|
13
|
+
export const fetchApifyDocsTool = {
|
|
14
|
+
type: 'internal',
|
|
15
|
+
tool: {
|
|
16
|
+
name: HelperTools.DOCS_FETCH,
|
|
17
|
+
description: `Apify documentation fetch tool. This tool allows you to fetch the full content of an Apify documentation page by its URL.`,
|
|
18
|
+
args: fetchApifyDocsToolArgsSchema,
|
|
19
|
+
inputSchema: zodToJsonSchema(fetchApifyDocsToolArgsSchema),
|
|
20
|
+
ajvValidate: ajv.compile(zodToJsonSchema(fetchApifyDocsToolArgsSchema)),
|
|
21
|
+
call: async (toolArgs) => {
|
|
22
|
+
const { args } = toolArgs;
|
|
23
|
+
const parsed = fetchApifyDocsToolArgsSchema.parse(args);
|
|
24
|
+
const url = parsed.url.trim();
|
|
25
|
+
const urlWithoutFragment = url.split('#')[0];
|
|
26
|
+
// Only allow URLs starting with https://docs.apify.com
|
|
27
|
+
if (!url.startsWith('https://docs.apify.com')) {
|
|
28
|
+
return {
|
|
29
|
+
content: [{
|
|
30
|
+
type: 'text',
|
|
31
|
+
text: `Only URLs starting with https://docs.apify.com are allowed.`,
|
|
32
|
+
}],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// Cache URL without fragment to avoid fetching the same page multiple times
|
|
36
|
+
let markdown = fetchApifyDocsCache.get(urlWithoutFragment);
|
|
37
|
+
// If the content is not cached, fetch it from the URL
|
|
38
|
+
if (!markdown) {
|
|
39
|
+
try {
|
|
40
|
+
const response = await fetch(url);
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
return {
|
|
43
|
+
content: [{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: `Failed to fetch the documentation page at ${url}. Status: ${response.status} ${response.statusText}`,
|
|
46
|
+
}],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const html = await response.text();
|
|
50
|
+
markdown = htmlToMarkdown(html);
|
|
51
|
+
// Cache the processed Markdown content
|
|
52
|
+
// Use the URL without fragment as the key to avoid caching same page with different fragments
|
|
53
|
+
fetchApifyDocsCache.set(urlWithoutFragment, markdown);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
log.error(`Failed to fetch the documentation page at ${url}.`, { error });
|
|
57
|
+
return {
|
|
58
|
+
content: [{
|
|
59
|
+
type: 'text',
|
|
60
|
+
text: `Failed to fetch the documentation page at ${url}. Please check the URL and try again.`,
|
|
61
|
+
}],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
content: [{
|
|
67
|
+
type: 'text',
|
|
68
|
+
text: `Fetched content from ${url}:\n\n${markdown}`,
|
|
69
|
+
}],
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=fetch-apify-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-apify-docs.js","sourceRoot":"","sources":["../../src/tools/fetch-apify-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAEjD,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;SACV,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,oIAAoI,CAAC;CACtJ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAc;IACzC,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE;QACF,IAAI,EAAE,WAAW,CAAC,UAAU;QAC5B,WAAW,EAAE,2HAA2H;QACxI,IAAI,EAAE,4BAA4B;QAClC,WAAW,EAAE,eAAe,CAAC,4BAA4B,CAAC;QAC1D,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,4BAA4B,CAAC,CAAC;QACvE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EA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C,6CAA6C,GAAG,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;oBAC1E,OAAO;wBACH,OAAO,EAAE,CAAC;gCACN,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,6CAA6C,GAAG,uCAAuC;6BAChG,CAAC;qBACL,CAAC;gBACN,CAAC;YACL,CAAC;YAED,OAAO;gBACH,OAAO,EAAE,CAAC;wBACN,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,wBAAwB,GAAG,QAAQ,QAAQ,EAAE;qBACtD,CAAC;aACL,CAAC;QACN,CAAC;KACY;CACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9E,OAAO,EAAE,OAAO,EAAY,MAAM,cAAc,CAAC;AAIjD,eAAO,MAAM,YAAY,mCAoBxB,CAAC;AAEF,eAAO,MAAM,cAAc,mCAG1B,CAAC;AAGF,OAAO,EACH,OAAO,EAEP,gBAAgB,EAChB,mBAAmB,GACtB,CAAC"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Import specific tools that are being used
|
|
2
2
|
import { callActor, callActorGetDataset, getActorsAsTools } from './actor.js';
|
|
3
|
+
import { fetchApifyDocsTool } from './fetch-apify-docs.js';
|
|
3
4
|
import { getActorDetailsTool } from './get-actor-details.js';
|
|
4
5
|
import { addTool, helpTool } from './helpers.js';
|
|
6
|
+
import { searchApifyDocsTool } from './search-apify-docs.js';
|
|
5
7
|
import { searchActors } from './store_collection.js';
|
|
6
8
|
export const defaultTools = [
|
|
7
9
|
// abortActorRun,
|
|
@@ -21,6 +23,8 @@ export const defaultTools = [
|
|
|
21
23
|
getActorDetailsTool,
|
|
22
24
|
helpTool,
|
|
23
25
|
searchActors,
|
|
26
|
+
searchApifyDocsTool,
|
|
27
|
+
fetchApifyDocsTool,
|
|
24
28
|
];
|
|
25
29
|
export const addRemoveTools = [
|
|
26
30
|
addTool,
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,iBAAiB;IACjB,oBAAoB;IACpB,YAAY;IACZ,eAAe;IACf,eAAe;IACf,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,wBAAwB;IACxB,0BAA0B;IAC1B,mBAAmB;IACnB,uBAAuB;IACvB,6BAA6B;IAC7B,SAAS;IACT,mBAAmB;IACnB,QAAQ;IACR,YAAY;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,iBAAiB;IACjB,oBAAoB;IACpB,YAAY;IACZ,eAAe;IACf,eAAe;IACf,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,wBAAwB;IACxB,0BAA0B;IAC1B,mBAAmB;IACnB,uBAAuB;IACvB,6BAA6B;IAC7B,SAAS;IACT,mBAAmB;IACnB,QAAQ;IACR,YAAY;IACZ,mBAAmB;IACnB,kBAAkB;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,OAAO;IACP,cAAc;CACjB,CAAC;AAEF,4CAA4C;AAC5C,OAAO,EACH,OAAO;AACP,cAAc;AACd,gBAAgB,EAChB,mBAAmB,GACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-apify-docs.d.ts","sourceRoot":"","sources":["../../src/tools/search-apify-docs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,aAAa,CAAC;AAwB3D,eAAO,MAAM,mBAAmB,EAAE,SAyCjC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import zodToJsonSchema from 'zod-to-json-schema';
|
|
3
|
+
import { HelperTools } from '../const.js';
|
|
4
|
+
import { ajv } from '../utils/ajv.js';
|
|
5
|
+
import { searchApifyDocsCached } from '../utils/apify-docs.js';
|
|
6
|
+
const searchApifyDocsToolArgsSchema = z.object({
|
|
7
|
+
query: z.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.describe(`Algolia full-text search query to find relevant documentation pages.
|
|
10
|
+
Use only keywords, do not use full sentences or questions.
|
|
11
|
+
For example, "standby actor" will return documentation pages that contain the words "standby" and "actor".`),
|
|
12
|
+
limit: z.number()
|
|
13
|
+
.optional()
|
|
14
|
+
.default(5)
|
|
15
|
+
.describe(`Maximum number of search results to return. Defaults to 5.
|
|
16
|
+
You can increase this limit if you need more results, but keep in mind that the search results are limited to the most relevant pages.`),
|
|
17
|
+
offset: z.number()
|
|
18
|
+
.optional()
|
|
19
|
+
.default(0)
|
|
20
|
+
.describe(`Offset for the search results. Defaults to 0.
|
|
21
|
+
Use this to paginate through the search results. For example, if you want to get the next 5 results, set the offset to 5 and limit to 5.`),
|
|
22
|
+
});
|
|
23
|
+
export const searchApifyDocsTool = {
|
|
24
|
+
type: 'internal',
|
|
25
|
+
tool: {
|
|
26
|
+
name: HelperTools.DOCS_SEARCH,
|
|
27
|
+
description: `Apify documentation search tool. This tool allows you to search the Apify documentation using Algolia's full-text search.
|
|
28
|
+
You can use it to find relevant documentation pages based on keywords. The results will include the URL of the documentation page, a fragment identifier (if available), and a limited piece of content that matches the search query. You can then fetch the full content of the document using the ${HelperTools.DOCS_FETCH} tool by providing the URL.
|
|
29
|
+
Use this tool when a user asks for help with Apify documentation or when you need to find relevant documentation pages based on keywords. For example, when a user wants to build an Apify Actor, you can search "How to build Actors" to find relevant guidance.`,
|
|
30
|
+
args: searchApifyDocsToolArgsSchema,
|
|
31
|
+
inputSchema: zodToJsonSchema(searchApifyDocsToolArgsSchema),
|
|
32
|
+
ajvValidate: ajv.compile(zodToJsonSchema(searchApifyDocsToolArgsSchema)),
|
|
33
|
+
call: async (toolArgs) => {
|
|
34
|
+
const { args } = toolArgs;
|
|
35
|
+
const parsed = searchApifyDocsToolArgsSchema.parse(args);
|
|
36
|
+
const query = parsed.query.trim();
|
|
37
|
+
const resultsRaw = await searchApifyDocsCached(query);
|
|
38
|
+
const results = resultsRaw.slice(parsed.offset, parsed.offset + parsed.limit);
|
|
39
|
+
if (results.length === 0) {
|
|
40
|
+
return {
|
|
41
|
+
content: [{
|
|
42
|
+
type: 'text',
|
|
43
|
+
text: `No results found for the query "${query}" with limit ${parsed.limit} and offset ${parsed.offset}. Try a different query or adjust the limit and offset.`,
|
|
44
|
+
}],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const textContent = `You can use the Apify docs fetch tool to retrieve the full content of a document by its URL. The document fragment refers to the section of the content containing the relevant part for the search result item.
|
|
48
|
+
Search results for "${query}":
|
|
49
|
+
|
|
50
|
+
${results.map((result) => `- Document URL: ${result.url}${result.fragment ? `\n Document fragment: ${result.fragment}` : ''}
|
|
51
|
+
Content: ${result.content}`).join('\n\n')}`;
|
|
52
|
+
return {
|
|
53
|
+
content: [{
|
|
54
|
+
type: 'text',
|
|
55
|
+
text: textContent,
|
|
56
|
+
}],
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=search-apify-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-apify-docs.js","sourceRoot":"","sources":["../../src/tools/search-apify-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;SACZ,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACL;;2GAE+F,CAClG;IACL,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;SACZ,QAAQ,EAAE;SACV,OAAO,CAAC,CAAC,CAAC;SACV,QAAQ,CAAC;uIACqH,CAAC;IACpI,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;SACb,QAAQ,EAAE;SACV,OAAO,CAAC,CAAC,CAAC;SACV,QAAQ,CAAC;yIACuH,CAAC;CACzI,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