@apify/actors-mcp-server 0.17.5-beta.0 → 0.17.5-beta.10

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 (137) hide show
  1. package/README.md +7 -2
  2. package/dist/apify_client.d.ts +10 -0
  3. package/dist/apify_client.d.ts.map +1 -1
  4. package/dist/apify_client.js +12 -0
  5. package/dist/apify_client.js.map +1 -1
  6. package/dist/const.d.ts +18 -8
  7. package/dist/const.d.ts.map +1 -1
  8. package/dist/const.js +23 -9
  9. package/dist/const.js.map +1 -1
  10. package/dist/index_internals.d.ts +4 -0
  11. package/dist/index_internals.d.ts.map +1 -1
  12. package/dist/mcp/legacy_server.d.ts.map +1 -1
  13. package/dist/mcp/legacy_server.js +1 -5
  14. package/dist/mcp/legacy_server.js.map +1 -1
  15. package/dist/mcp/stateless_server.js +1 -1
  16. package/dist/mcp/stateless_server.js.map +1 -1
  17. package/dist/mcp/tool_dispatch.d.ts.map +1 -1
  18. package/dist/mcp/tool_dispatch.js +2 -1
  19. package/dist/mcp/tool_dispatch.js.map +1 -1
  20. package/dist/payments/helpers.d.ts +1 -1
  21. package/dist/payments/helpers.d.ts.map +1 -1
  22. package/dist/payments/helpers.js +5 -3
  23. package/dist/payments/helpers.js.map +1 -1
  24. package/dist/resources/api_resources.d.ts +16 -11
  25. package/dist/resources/api_resources.d.ts.map +1 -1
  26. package/dist/resources/api_resources.js +35 -25
  27. package/dist/resources/api_resources.js.map +1 -1
  28. package/dist/state.d.ts +3 -0
  29. package/dist/state.d.ts.map +1 -1
  30. package/dist/state.js +3 -0
  31. package/dist/state.js.map +1 -1
  32. package/dist/test_kit/cases/schedules.cases.d.ts +3 -0
  33. package/dist/test_kit/cases/schedules.cases.d.ts.map +1 -0
  34. package/dist/test_kit/cases/schedules.cases.js +156 -0
  35. package/dist/test_kit/cases/schedules.cases.js.map +1 -0
  36. package/dist/test_kit/cases/storage.cases.d.ts.map +1 -1
  37. package/dist/test_kit/cases/storage.cases.js +39 -0
  38. package/dist/test_kit/cases/storage.cases.js.map +1 -1
  39. package/dist/test_kit/index.d.ts +1 -0
  40. package/dist/test_kit/index.d.ts.map +1 -1
  41. package/dist/test_kit/index.js +3 -0
  42. package/dist/test_kit/index.js.map +1 -1
  43. package/dist/test_kit/tsconfig.tsbuildinfo +1 -1
  44. package/dist/tools/actor_tool_naming.d.ts +4 -0
  45. package/dist/tools/actor_tool_naming.d.ts.map +1 -1
  46. package/dist/tools/actor_tool_naming.js +6 -0
  47. package/dist/tools/actor_tool_naming.js.map +1 -1
  48. package/dist/tools/actors/actor_definition.d.ts.map +1 -1
  49. package/dist/tools/actors/actor_definition.js +3 -5
  50. package/dist/tools/actors/actor_definition.js.map +1 -1
  51. package/dist/tools/actors/actor_executor.d.ts.map +1 -1
  52. package/dist/tools/actors/actor_executor.js +2 -1
  53. package/dist/tools/actors/actor_executor.js.map +1 -1
  54. package/dist/tools/actors/actor_run_response.d.ts +1 -0
  55. package/dist/tools/actors/actor_run_response.d.ts.map +1 -1
  56. package/dist/tools/actors/actor_tools_factory.d.ts.map +1 -1
  57. package/dist/tools/actors/actor_tools_factory.js +30 -3
  58. package/dist/tools/actors/actor_tools_factory.js.map +1 -1
  59. package/dist/tools/actors/search_actors.d.ts +4 -1
  60. package/dist/tools/actors/search_actors.d.ts.map +1 -1
  61. package/dist/tools/actors/search_actors.js +20 -34
  62. package/dist/tools/actors/search_actors.js.map +1 -1
  63. package/dist/tools/api/apify_api_blocklist.d.ts +35 -0
  64. package/dist/tools/api/apify_api_blocklist.d.ts.map +1 -0
  65. package/dist/tools/api/apify_api_blocklist.js +91 -0
  66. package/dist/tools/api/apify_api_blocklist.js.map +1 -0
  67. package/dist/tools/api/apify_api_details.d.ts +6 -0
  68. package/dist/tools/api/apify_api_details.d.ts.map +1 -0
  69. package/dist/tools/api/apify_api_details.js +91 -0
  70. package/dist/tools/api/apify_api_details.js.map +1 -0
  71. package/dist/tools/api/apify_api_path.d.ts +9 -0
  72. package/dist/tools/api/apify_api_path.d.ts.map +1 -0
  73. package/dist/tools/api/apify_api_path.js +11 -0
  74. package/dist/tools/api/apify_api_path.js.map +1 -0
  75. package/dist/tools/api/apify_api_read.d.ts +6 -0
  76. package/dist/tools/api/apify_api_read.d.ts.map +1 -0
  77. package/dist/tools/api/apify_api_read.js +67 -0
  78. package/dist/tools/api/apify_api_read.js.map +1 -0
  79. package/dist/tools/api/apify_api_request.d.ts +59 -0
  80. package/dist/tools/api/apify_api_request.d.ts.map +1 -0
  81. package/dist/tools/api/apify_api_request.js +316 -0
  82. package/dist/tools/api/apify_api_request.js.map +1 -0
  83. package/dist/tools/api/apify_api_search.d.ts +6 -0
  84. package/dist/tools/api/apify_api_search.d.ts.map +1 -0
  85. package/dist/tools/api/apify_api_search.js +84 -0
  86. package/dist/tools/api/apify_api_search.js.map +1 -0
  87. package/dist/tools/api/apify_api_spec.d.ts +51 -0
  88. package/dist/tools/api/apify_api_spec.d.ts.map +1 -0
  89. package/dist/tools/api/apify_api_spec.js +298 -0
  90. package/dist/tools/api/apify_api_spec.js.map +1 -0
  91. package/dist/tools/api/apify_api_write.d.ts +6 -0
  92. package/dist/tools/api/apify_api_write.d.ts.map +1 -0
  93. package/dist/tools/api/apify_api_write.js +129 -0
  94. package/dist/tools/api/apify_api_write.js.map +1 -0
  95. package/dist/tools/index.d.ts.map +1 -1
  96. package/dist/tools/index.js +3 -0
  97. package/dist/tools/index.js.map +1 -1
  98. package/dist/tools/registry.d.ts +3 -0
  99. package/dist/tools/registry.d.ts.map +1 -1
  100. package/dist/tools/registry.js +8 -1
  101. package/dist/tools/registry.js.map +1 -1
  102. package/dist/tools/runs/get_actor_run.d.ts +2 -0
  103. package/dist/tools/runs/get_actor_run.d.ts.map +1 -1
  104. package/dist/tools/runs/get_actor_run.js +11 -3
  105. package/dist/tools/runs/get_actor_run.js.map +1 -1
  106. package/dist/tools/storage/get_dataset.d.ts.map +1 -1
  107. package/dist/tools/storage/get_dataset.js +2 -1
  108. package/dist/tools/storage/get_dataset.js.map +1 -1
  109. package/dist/tools/storage/get_key_value_store.d.ts.map +1 -1
  110. package/dist/tools/storage/get_key_value_store.js +3 -1
  111. package/dist/tools/storage/get_key_value_store.js.map +1 -1
  112. package/dist/tools/structured_output_schemas.d.ts +149 -0
  113. package/dist/tools/structured_output_schemas.d.ts.map +1 -1
  114. package/dist/tools/structured_output_schemas.js +93 -1
  115. package/dist/tools/structured_output_schemas.js.map +1 -1
  116. package/dist/tools/widgets/fetch_actor_details_widget.d.ts.map +1 -1
  117. package/dist/tools/widgets/fetch_actor_details_widget.js +0 -1
  118. package/dist/tools/widgets/fetch_actor_details_widget.js.map +1 -1
  119. package/dist/tools/widgets/search_actors_widget.d.ts.map +1 -1
  120. package/dist/tools/widgets/search_actors_widget.js +0 -1
  121. package/dist/tools/widgets/search_actors_widget.js.map +1 -1
  122. package/dist/tsconfig.tsbuildinfo +1 -1
  123. package/dist/types.d.ts +11 -0
  124. package/dist/types.d.ts.map +1 -1
  125. package/dist/types.js.map +1 -1
  126. package/dist/utils/logging.d.ts +6 -0
  127. package/dist/utils/logging.d.ts.map +1 -1
  128. package/dist/utils/logging.js +22 -6
  129. package/dist/utils/logging.js.map +1 -1
  130. package/dist/utils/server-instructions/index.d.ts.map +1 -1
  131. package/dist/utils/server-instructions/index.js +4 -1
  132. package/dist/utils/server-instructions/index.js.map +1 -1
  133. package/dist/utils/tools.d.ts +0 -3
  134. package/dist/utils/tools.d.ts.map +1 -1
  135. package/dist/utils/tools.js +7 -16
  136. package/dist/utils/tools.js.map +1 -1
  137. package/package.json +2 -6
@@ -0,0 +1,84 @@
1
+ import dedent from 'dedent';
2
+ import { z } from 'zod';
3
+ import { HELPER_TOOLS } from '../../const.js';
4
+ import { ALL_TOOLS_PRESENT, TOOL_TYPE } from '../../types.js';
5
+ import { compileSchema, fixZodSchemaRequired } from '../../utils/ajv.js';
6
+ import { respondOk } from '../../utils/mcp.js';
7
+ import { apifyApiSearchOutputSchema } from '../structured_output_schemas.js';
8
+ import { fetchApiOperationIndex, searchApiOperations } from './apify_api_spec.js';
9
+ const apifyApiSearchArgs = z.object({
10
+ query: z
11
+ .string()
12
+ .min(1)
13
+ .describe('Keywords for what the operation does, for example "list webhooks" or "update dataset".'),
14
+ limit: z
15
+ .number()
16
+ .int()
17
+ .min(1)
18
+ .max(20)
19
+ .describe('Maximum number of operations to return. Default is 10. Maximum is 20.')
20
+ .default(10),
21
+ });
22
+ function buildDescription({ hasTool }) {
23
+ const callTools = [
24
+ hasTool(HELPER_TOOLS.API_READ) && `${HELPER_TOOLS.API_READ} for a GET`,
25
+ hasTool(HELPER_TOOLS.API_WRITE) && `${HELPER_TOOLS.API_WRITE} for a POST, PUT, PATCH, or DELETE`,
26
+ ].filter(Boolean);
27
+ const nextSteps = [
28
+ hasTool(HELPER_TOOLS.API_DETAILS) &&
29
+ `get its parameters with ${HELPER_TOOLS.API_DETAILS} by its method and path`,
30
+ callTools.length > 0 && `call it with ${callTools.join(' or ')}`,
31
+ ].filter(Boolean);
32
+ const nextStepsSentence = nextSteps.length > 0 ? `\nAfter finding an operation, ${nextSteps.join(', then ')}.` : '';
33
+ return dedent `
34
+ Search the Apify API reference for operations by keywords. Returns each operation's method, path
35
+ template, summary, and link to the API reference.${nextStepsSentence}
36
+ To call an operation, fill its path template with real values: /v2/datasets/{datasetId}/items
37
+ becomes /v2/datasets/abc/items. A name is written username~name, or ~name for one you own, as in
38
+ /v2/actors/~my-actor.
39
+ Prefer a dedicated Apify tool when one does what the user asks.
40
+
41
+ USAGE:
42
+ - Use when no dedicated tool does what the user asks and the Apify API might.
43
+
44
+ USAGE EXAMPLES:
45
+ - user_input: Did my webhooks deliver their last calls?
46
+ - user_input: What is my monthly spending limit?
47
+ `;
48
+ }
49
+ /**
50
+ * Searches the operations of the published Apify API spec, https://docs.apify.com/api/v2.
51
+ */
52
+ export const apifyApiSearch = Object.freeze({
53
+ type: TOOL_TYPE.INTERNAL,
54
+ name: HELPER_TOOLS.API_SEARCH,
55
+ title: 'Search Apify API',
56
+ description: buildDescription(ALL_TOOLS_PRESENT),
57
+ buildDescription,
58
+ inputSchema: fixZodSchemaRequired(z.toJSONSchema(apifyApiSearchArgs)),
59
+ outputSchema: apifyApiSearchOutputSchema,
60
+ ajvValidate: compileSchema(fixZodSchemaRequired(z.toJSONSchema(apifyApiSearchArgs))),
61
+ annotations: {
62
+ title: 'Search Apify API',
63
+ readOnlyHint: true,
64
+ destructiveHint: false,
65
+ idempotentHint: true,
66
+ openWorldHint: false,
67
+ },
68
+ call: async (toolArgs) => {
69
+ const parsed = apifyApiSearchArgs.parse(toolArgs.args);
70
+ const index = await fetchApiOperationIndex();
71
+ const operations = searchApiOperations(index, parsed.query, parsed.limit).map((operation) => ({
72
+ method: operation.method,
73
+ path: operation.path,
74
+ summary: operation.summary,
75
+ docsUrl: operation.docsUrl,
76
+ }));
77
+ const result = { operations };
78
+ const summary = operations.length > 0
79
+ ? `Found ${operations.length} API operations for "${parsed.query}".`
80
+ : `No API operation matches "${parsed.query}". Try other keywords.`;
81
+ return respondOk([JSON.stringify(result), summary], { structuredContent: result });
82
+ },
83
+ });
84
+ //# sourceMappingURL=apify_api_search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_search.js","sourceRoot":"","sources":["../../../src/tools/api/apify_api_search.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE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AAC;QAC5E,OAAO,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC,CAAC;IACvF,CAAC;CACK,CAAC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { ApiBlockRule } from './apify_api_blocklist.js';
2
+ export declare const APIFY_API_OPENAPI_URL = "https://docs.apify.com/api/openapi.json";
3
+ /** HEAD is left out: it returns no body, and each HEAD operation has a GET twin. */
4
+ export declare const API_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE"];
5
+ export type ApiMethod = (typeof API_METHODS)[number];
6
+ export type ApiParameter = {
7
+ name: string;
8
+ in: 'path' | 'query';
9
+ isRequired: boolean;
10
+ description?: string;
11
+ schema?: unknown;
12
+ };
13
+ export type ApiOperation = {
14
+ /** The spec's key for the operation. Internal: the tools find operations by method and path. */
15
+ operationId: string;
16
+ method: ApiMethod;
17
+ /** Path template, for example `/v2/actors/{actorId}`. */
18
+ path: string;
19
+ summary: string;
20
+ description: string;
21
+ /** The operation's page in the API reference. */
22
+ docsUrl: string;
23
+ tags: string[];
24
+ /** Path and query parameters; header parameters are left out, the tools never send them. */
25
+ parameters: ApiParameter[];
26
+ /** Dereferenced JSON schema of the request body; absent when the operation takes none. */
27
+ requestBody?: {
28
+ isRequired: boolean;
29
+ schema: unknown;
30
+ };
31
+ };
32
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
33
+ /**
34
+ * Builds the operation index from an OpenAPI document. Deprecated operations, HEAD operations, operations a
35
+ * blocklist rule matches (`API_BLOCK_RULES`), and anything outside `/v2/` are left out, so no tool that reads
36
+ * the index offers them; malformed entries are skipped rather than failing the whole spec.
37
+ * It throws when the spec lists no operation.
38
+ */
39
+ export declare function buildApiOperationIndex(spec: unknown, rules?: readonly ApiBlockRule[]): Map<string, ApiOperation>;
40
+ /**
41
+ * The operation index, from the published spec, cached for a day. Concurrent calls share one
42
+ * download. A failed download throws and is not cached, and the next call tries again.
43
+ */
44
+ export declare function fetchApiOperationIndex(): Promise<Map<string, ApiOperation>>;
45
+ /**
46
+ * Operations matching the query's keywords, best first, scored by where each keyword is found. A verb for
47
+ * the method alone does not match. The description counts only for keywords no operation's name has, and
48
+ * only with two or more of them, since one word alone is in too many descriptions. Ties go to the shorter path.
49
+ */
50
+ export declare function searchApiOperations(index: Map<string, ApiOperation>, query: string, limit: number): ApiOperation[];
51
+ //# sourceMappingURL=apify_api_spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_spec.d.ts","sourceRoot":"","sources":["../../../src/tools/api/apify_api_spec.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG7D,eAAO,MAAM,qBAAqB,4CAA4C,CAAC;AAE/E,oFAAoF;AACpF,eAAO,MAAM,WAAW,oDAAqD,CAAC;AAC9E,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAKrD,MAAM,MAAM,YAAY,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACvB,gGAAgG;IAChG,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,CAAC;IAClB,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,4FAA4F;IAC5F,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,0FAA0F;IAC1F,WAAW,CAAC,EAAE;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1D,CAAC;AA4BF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AA6ED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAyBhH;AA0BD;;;GAGG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAYjF;AAmED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CAoClH"}
@@ -0,0 +1,298 @@
1
+ import { z } from 'zod';
2
+ import { apifyApiOperationsCache } from '../../state.js';
3
+ import { isEndpointBlocked } from './apify_api_blocklist.js';
4
+ export const APIFY_API_OPENAPI_URL = 'https://docs.apify.com/api/openapi.json';
5
+ /** HEAD is left out: it returns no body, and each HEAD operation has a GET twin. */
6
+ export const API_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];
7
+ /** The API reference has one page per operation, at the operation ID in kebab case. */
8
+ const API_DOCS_BASE_URL = 'https://docs.apify.com/api/v2';
9
+ /** Schema keywords that only cost context. `x-*` vendor extensions are dropped by prefix in `dereference()`. */
10
+ const DROPPED_SCHEMA_KEYS = new Set(['example', 'examples']);
11
+ const openApiOperationValidator = z.object({
12
+ operationId: z.string().min(1),
13
+ summary: z.string().optional(),
14
+ description: z.string().optional(),
15
+ tags: z.array(z.string()).optional(),
16
+ deprecated: z.boolean().optional(),
17
+ parameters: z.array(z.unknown()).optional(),
18
+ requestBody: z.unknown().optional(),
19
+ });
20
+ const openApiParameterValidator = z.object({
21
+ name: z.string().min(1),
22
+ in: z.string(),
23
+ required: z.boolean().optional(),
24
+ description: z.string().optional(),
25
+ schema: z.unknown().optional(),
26
+ });
27
+ const openApiRequestBodyValidator = z.object({
28
+ required: z.boolean().optional(),
29
+ content: z.record(z.string(), z.object({ schema: z.unknown().optional() })),
30
+ });
31
+ export function isRecord(value) {
32
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
33
+ }
34
+ /** Walks a local `#/...` reference; `undefined` when it does not resolve. */
35
+ function resolveLocalRef(spec, ref) {
36
+ if (!ref.startsWith('#/'))
37
+ return undefined;
38
+ let node = spec;
39
+ for (const segment of ref.slice(2).split('/')) {
40
+ if (!isRecord(node))
41
+ return undefined;
42
+ node = node[segment];
43
+ }
44
+ return node;
45
+ }
46
+ /**
47
+ * Resolves local `$ref`s and drops examples and vendor extensions. Property names under `properties`
48
+ * are kept as they are, since a property can be named `example`.
49
+ */
50
+ function dereference(node, spec, seenRefs = new Set()) {
51
+ if (Array.isArray(node))
52
+ return node.map((item) => dereference(item, spec, seenRefs));
53
+ if (!isRecord(node))
54
+ return node;
55
+ if (typeof node.$ref === 'string') {
56
+ // A reference cycle would recurse forever; the published spec has none.
57
+ if (seenRefs.has(node.$ref))
58
+ return {};
59
+ return dereference(resolveLocalRef(spec, node.$ref), spec, new Set([...seenRefs, node.$ref]));
60
+ }
61
+ const result = {};
62
+ for (const [key, value] of Object.entries(node)) {
63
+ if (DROPPED_SCHEMA_KEYS.has(key) || key.startsWith('x-'))
64
+ continue;
65
+ result[key] =
66
+ key === 'properties' && isRecord(value)
67
+ ? Object.fromEntries(Object.entries(value).map(([name, schema]) => [name, dereference(schema, spec, seenRefs)]))
68
+ : dereference(value, spec, seenRefs);
69
+ }
70
+ return result;
71
+ }
72
+ /** Lowercase words of a text, splitting camelCase, snake_case, kebab-case, and paths. */
73
+ function splitWords(text) {
74
+ return text
75
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
76
+ .toLowerCase()
77
+ .split(/[^a-z0-9]+/)
78
+ .filter(Boolean);
79
+ }
80
+ function parseParameters(rawParameters, spec) {
81
+ const parameters = [];
82
+ for (const rawParameter of rawParameters !== null && rawParameters !== void 0 ? rawParameters : []) {
83
+ const parsed = openApiParameterValidator.safeParse(dereference(rawParameter, spec));
84
+ if (!parsed.success)
85
+ continue;
86
+ const { name, in: location, required, description, schema } = parsed.data;
87
+ if (location !== 'path' && location !== 'query')
88
+ continue;
89
+ parameters.push({
90
+ name,
91
+ in: location,
92
+ // OpenAPI makes every path parameter required.
93
+ isRequired: location === 'path' || required === true,
94
+ ...(description && { description }),
95
+ ...(schema !== undefined && { schema }),
96
+ });
97
+ }
98
+ return parameters;
99
+ }
100
+ function parseRequestBody(rawRequestBody, spec) {
101
+ var _a, _b;
102
+ if (rawRequestBody === undefined)
103
+ return undefined;
104
+ const parsed = openApiRequestBodyValidator.safeParse(dereference(rawRequestBody, spec));
105
+ if (!parsed.success)
106
+ return undefined;
107
+ const { content, required } = parsed.data;
108
+ // Every body is sent as JSON; the key-value store record operations declare `*/*`.
109
+ const media = (_a = content['application/json']) !== null && _a !== void 0 ? _a : content['*/*'];
110
+ if (!media)
111
+ return undefined;
112
+ return { isRequired: required === true, schema: (_b = media.schema) !== null && _b !== void 0 ? _b : {} };
113
+ }
114
+ /**
115
+ * Builds the operation index from an OpenAPI document. Deprecated operations, HEAD operations, operations a
116
+ * blocklist rule matches (`API_BLOCK_RULES`), and anything outside `/v2/` are left out, so no tool that reads
117
+ * the index offers them; malformed entries are skipped rather than failing the whole spec.
118
+ * It throws when the spec lists no operation.
119
+ */
120
+ export function buildApiOperationIndex(spec, rules) {
121
+ const index = new Map();
122
+ const paths = isRecord(spec) && isRecord(spec.paths) ? spec.paths : {};
123
+ for (const [path, pathItem] of Object.entries(paths)) {
124
+ if (!path.startsWith('/v2/') || !isRecord(pathItem))
125
+ continue;
126
+ for (const method of API_METHODS) {
127
+ const parsed = openApiOperationValidator.safeParse(pathItem[method.toLowerCase()]);
128
+ if (!parsed.success || parsed.data.deprecated || isEndpointBlocked(method, path, rules))
129
+ continue;
130
+ const { operationId, summary, description, tags, parameters, requestBody } = parsed.data;
131
+ const body = parseRequestBody(requestBody, spec);
132
+ index.set(operationId, {
133
+ operationId,
134
+ method,
135
+ path,
136
+ summary: summary !== null && summary !== void 0 ? summary : '',
137
+ description: description !== null && description !== void 0 ? description : '',
138
+ docsUrl: `${API_DOCS_BASE_URL}/${splitWords(operationId).join('-')}`,
139
+ tags: tags !== null && tags !== void 0 ? tags : [],
140
+ parameters: parseParameters(parameters, spec),
141
+ ...(body && { requestBody: body }),
142
+ });
143
+ }
144
+ }
145
+ if (index.size === 0)
146
+ throw new Error('the spec lists no /v2/ operations.');
147
+ return index;
148
+ }
149
+ /** How long the spec download may take; MCP clients stop waiting for a tool call after 60 seconds. */
150
+ const SPEC_DOWNLOAD_TIMEOUT_MS = 30000;
151
+ let pendingIndex;
152
+ async function downloadApiOperationIndex() {
153
+ const failure = `Failed to load the Apify API operations from ${APIFY_API_OPENAPI_URL}`;
154
+ // Every session waits on this one download, so a stalled one must not hold them all.
155
+ const response = await fetch(APIFY_API_OPENAPI_URL, { signal: AbortSignal.timeout(SPEC_DOWNLOAD_TIMEOUT_MS) });
156
+ if (!response.ok)
157
+ throw new Error(`${failure}: HTTP ${response.status}.`);
158
+ let spec;
159
+ try {
160
+ spec = await response.json();
161
+ }
162
+ catch {
163
+ throw new Error(`${failure}: the response is not JSON.`);
164
+ }
165
+ // An index without operations is not cached.
166
+ try {
167
+ return buildApiOperationIndex(spec);
168
+ }
169
+ catch (error) {
170
+ throw new Error(`${failure}: ${error instanceof Error ? error.message : String(error)}`);
171
+ }
172
+ }
173
+ /**
174
+ * The operation index, from the published spec, cached for a day. Concurrent calls share one
175
+ * download. A failed download throws and is not cached, and the next call tries again.
176
+ */
177
+ export async function fetchApiOperationIndex() {
178
+ const cached = apifyApiOperationsCache.get(APIFY_API_OPENAPI_URL);
179
+ if (cached)
180
+ return cached;
181
+ pendingIndex !== null && pendingIndex !== void 0 ? pendingIndex : (pendingIndex = downloadApiOperationIndex()
182
+ .then((index) => {
183
+ apifyApiOperationsCache.set(APIFY_API_OPENAPI_URL, index);
184
+ return index;
185
+ })
186
+ .finally(() => {
187
+ pendingIndex = undefined;
188
+ }));
189
+ return pendingIndex;
190
+ }
191
+ /** Words that tell no operation apart, such as the question words and pronouns that fill the descriptions. */
192
+ const SEARCH_STOP_WORDS = new Set([
193
+ 'a',
194
+ 'all',
195
+ 'an',
196
+ 'and',
197
+ 'apify',
198
+ 'are',
199
+ 'be',
200
+ 'can',
201
+ 'did',
202
+ 'does',
203
+ 'for',
204
+ 'has',
205
+ 'have',
206
+ 'how',
207
+ 'in',
208
+ 'is',
209
+ 'its',
210
+ 'my',
211
+ 'of',
212
+ 'on',
213
+ 'or',
214
+ 'that',
215
+ 'the',
216
+ 'this',
217
+ 'to',
218
+ 'what',
219
+ 'where',
220
+ 'which',
221
+ 'who',
222
+ 'why',
223
+ 'with',
224
+ 'you',
225
+ 'your',
226
+ ]);
227
+ /** Verbs for what each method does, so a verb the summary does not use, such as rename, still counts. */
228
+ const METHOD_VERBS = {
229
+ GET: ['get', 'list', 'read'],
230
+ POST: ['add', 'create', 'push', 'start'],
231
+ PUT: ['update', 'set', 'rename', 'change'],
232
+ PATCH: ['update', 'patch', 'change'],
233
+ DELETE: ['delete', 'remove'],
234
+ };
235
+ /** A prefix match, or the plural of a word, so `env` finds `environment` and `runs` finds `run`. */
236
+ function hasMatchingWord(term, words) {
237
+ return words.some((word) => word.startsWith(term) || term === `${word}s`);
238
+ }
239
+ /** The same word, or its plural or singular: a prefix match finds too many words in prose, such as endpoint for end. */
240
+ function hasWholeWord(term, words) {
241
+ return words.some((word) => word === term || word === `${term}s` || term === `${word}s`);
242
+ }
243
+ /**
244
+ * Paths that reach a run's own copy of a resource: the default storages and actions of a run or of the
245
+ * last run, and the synchronous runs. A plain ask such as "add items to a dataset" means the storage
246
+ * itself, so these rank lower unless the query is about runs or tasks.
247
+ */
248
+ const RUN_SCOPED_PATH_REGEX = /^\/v2\/actor-runs\/\{runId\}\/|\/runs\/last\/|\/run-sync/;
249
+ const RUN_SCOPE_TERMS = new Set(['run', 'runs', 'last', 'task', 'tasks', 'sync']);
250
+ const RUN_SCOPED_PENALTY = 2;
251
+ /**
252
+ * Operations matching the query's keywords, best first, scored by where each keyword is found. A verb for
253
+ * the method alone does not match. The description counts only for keywords no operation's name has, and
254
+ * only with two or more of them, since one word alone is in too many descriptions. Ties go to the shorter path.
255
+ */
256
+ export function searchApiOperations(index, query, limit) {
257
+ // One-letter terms, such as the s of "run's", match too many words.
258
+ const terms = [...new Set(splitWords(query))].filter((term) => term.length > 1 && !SEARCH_STOP_WORDS.has(term));
259
+ const isAboutRuns = terms.some((term) => RUN_SCOPE_TERMS.has(term));
260
+ const nameWords = [...index.values()].flatMap((operation) => splitWords(`${operation.summary} ${operation.operationId} ${operation.path} ${operation.tags.join(' ')}`));
261
+ // A keyword a name has is left to the names: a description also lists fields, such as the
262
+ // maxMonthlyUsageUsd of Update limits, which would rank that operation above Get limits.
263
+ const descriptionTerms = terms.filter((term) => !hasMatchingWord(term, nameWords));
264
+ const scored = [];
265
+ for (const operation of index.values()) {
266
+ const summaryWords = splitWords(operation.summary);
267
+ const idWords = splitWords(`${operation.operationId} ${operation.path}`);
268
+ const tagWords = splitWords(operation.tags.join(' '));
269
+ const descriptionWords = splitWords(operation.description);
270
+ const verbs = METHOD_VERBS[operation.method];
271
+ let score = 0;
272
+ let verbScore = 0;
273
+ let descriptionHits = 0;
274
+ for (const term of terms) {
275
+ if (hasMatchingWord(term, summaryWords))
276
+ score += 3;
277
+ else if (hasMatchingWord(term, idWords))
278
+ score += 2;
279
+ else if (hasMatchingWord(term, tagWords))
280
+ score += 1;
281
+ else if (verbs.includes(term))
282
+ verbScore += 2;
283
+ else if (descriptionTerms.includes(term) && hasWholeWord(term, descriptionWords))
284
+ descriptionHits += 1;
285
+ }
286
+ if (descriptionHits >= 2)
287
+ score += 2 * descriptionHits;
288
+ if (score === 0)
289
+ continue;
290
+ const penalty = !isAboutRuns && RUN_SCOPED_PATH_REGEX.test(operation.path) ? RUN_SCOPED_PENALTY : 0;
291
+ scored.push({ operation, score: score + verbScore - penalty });
292
+ }
293
+ return scored
294
+ .sort((a, b) => b.score - a.score || a.operation.path.length - b.operation.path.length)
295
+ .slice(0, limit)
296
+ .map(({ operation }) => operation);
297
+ }
298
+ //# sourceMappingURL=apify_api_spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_spec.js","sourceRoot":"","sources":["../../../src/tools/api/apify_api_spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,yCAAyC,CAAC;AAE/E,oFAAoF;AACpF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAG9E,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,+BAA+B,CAAC;AA2B1D,gHAAgH;AAChH,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;AAElF,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,IAAI,EAAE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I,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,gBAAgB,CAAC;gBAAE,eAAe,IAAI,CAAC,CAAC;QAC3G,CAAC;QACD,IAAI,eAAe,IAAI,CAAC;YAAE,KAAK,IAAI,CAAC,GAAG,eAAe,CAAC;QACvD,IAAI,KAAK,KAAK,CAAC;YAAE,SAAS;QAC1B,MAAM,OAAO,GAAG,CAAC,WAAW,IAAI,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;QACpG,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,MAAM;SACR,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;SACtF,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;SACf,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ToolEntry } from '../../types.js';
2
+ /**
3
+ * Sends a POST, PUT, PATCH, or DELETE to a path of the Apify API, https://docs.apify.com/api/v2, as a proxy.
4
+ */
5
+ export declare const apifyApiWrite: ToolEntry;
6
+ //# sourceMappingURL=apify_api_write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_write.d.ts","sourceRoot":"","sources":["../../../src/tools/api/apify_api_write.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA4C,SAAS,EAAmB,MAAM,gBAAgB,CAAC;AAgG3G;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,SAuCjB,CAAC"}
@@ -0,0 +1,129 @@
1
+ import dedent from 'dedent';
2
+ import { z } from 'zod';
3
+ import { HELPER_TOOLS, MAX_INLINE_BYTES } from '../../const.js';
4
+ import { ALL_TOOLS_PRESENT, TOOL_TYPE } from '../../types.js';
5
+ import { compileSchema } from '../../utils/ajv.js';
6
+ import { respondUserError } from '../../utils/mcp.js';
7
+ import { apifyApiCallOutputSchema } from '../structured_output_schemas.js';
8
+ import { isEndpointBlocked } from './apify_api_blocklist.js';
9
+ import { normalizeApiPath } from './apify_api_path.js';
10
+ import { API_CALL_DESCRIPTION, apiCallArgsShape, callApi, findPathOperations, formatList, redactApiCallArgs, } from './apify_api_request.js';
11
+ import { API_METHODS, fetchApiOperationIndex } from './apify_api_spec.js';
12
+ const apifyApiWriteArgs = z.object({
13
+ path: apiCallArgsShape.path,
14
+ method: z
15
+ .enum(['POST', 'PUT', 'PATCH', 'DELETE'])
16
+ .optional()
17
+ .describe('HTTP method: POST, PUT, PATCH, or DELETE. Omit it only when the path has one method in the API spec.'),
18
+ query: apiCallArgsShape.query,
19
+ body: z.unknown().optional().describe('The request body: a JSON object or array, sent as JSON.'),
20
+ });
21
+ function buildDescription({ hasTool }) {
22
+ const findPath = hasTool(HELPER_TOOLS.API_SEARCH) ? `\nFind the path with ${HELPER_TOOLS.API_SEARCH}.` : '';
23
+ const getParameters = hasTool(HELPER_TOOLS.API_DETAILS)
24
+ ? `\nGet the operation's parameters and body schema first with ${HELPER_TOOLS.API_DETAILS} and the method.`
25
+ : '';
26
+ return dedent `
27
+ Send a POST, PUT, PATCH, or DELETE request to the Apify API at a path, such as /v2/datasets/abc.
28
+ ${API_CALL_DESCRIPTION}${findPath}${getParameters}
29
+ The request is sent once and applies at once.
30
+ Returns the parsed response body, JSON with its data wrapper included: integers above 2^53 can
31
+ lose precision. A body over ${MAX_INLINE_BYTES} bytes is not returned.
32
+
33
+ Example call: {"path": "/v2/datasets/abc", "method": "PUT", "body": {"name": "leads-2026"}}
34
+
35
+ USAGE:
36
+ - Use to change something no dedicated tool changes, such as a dataset's name or a webhook.
37
+ - Change only what the user asked for.
38
+
39
+ USAGE EXAMPLES:
40
+ - user_input: Rename my dataset to leads-2026
41
+ - user_input: Add a webhook that calls https://example.com/hook when a run of my-actor fails
42
+ `;
43
+ }
44
+ /**
45
+ * The method of a call that omits it: the path's only operation in the spec, when that is a write and
46
+ * the path has no blocked write method; otherwise why the caller must give one. The caller is asked
47
+ * only for the write methods; a GET goes to the read tool.
48
+ */
49
+ async function inferWriteMethod(path, loadedToolNames) {
50
+ const index = await fetchApiOperationIndex().catch(() => undefined);
51
+ if (!index)
52
+ return { error: 'The API spec could not be loaded to choose the method; specify the method.' };
53
+ const operations = findPathOperations(index, normalizeApiPath(path));
54
+ if (operations.length === 0)
55
+ return { error: 'The path is not in the API spec; specify the method.' };
56
+ const writeMethods = operations
57
+ .map((operation) => operation.method)
58
+ .filter((method) => method !== 'GET');
59
+ const readTool = loadedToolNames.includes(HELPER_TOOLS.API_READ) ? `; call it with ${HELPER_TOOLS.API_READ}` : '';
60
+ if (writeMethods.length === 0) {
61
+ return { error: `The path has only the GET method, which this tool does not send${readTool}.` };
62
+ }
63
+ // The index leaves out a blocked operation, so the one operation left may not be the path's only write method.
64
+ const hasBlockedWriteMethod = API_METHODS.some((method) => method !== 'GET' && isEndpointBlocked(method, operations[0].path));
65
+ if (operations.length === 1 && !hasBlockedWriteMethod)
66
+ return { method: writeMethods[0] };
67
+ const getNote = writeMethods.length < operations.length ? ` This tool does not send its GET${readTool}.` : '';
68
+ return { error: `Specify a method for this path: ${formatList(writeMethods, 'or')}.${getNote}` };
69
+ }
70
+ /**
71
+ * The body to send. A client may send the untyped body as a string of JSON, so a string is parsed to
72
+ * the value it holds; sent as is, it would reach the API as a JSON string.
73
+ */
74
+ function parseBody(body) {
75
+ if (typeof body !== 'string')
76
+ return { value: body };
77
+ try {
78
+ return { value: JSON.parse(body) };
79
+ }
80
+ catch {
81
+ return { error: 'The body is a string that is not valid JSON; give it as a JSON object or array.' };
82
+ }
83
+ }
84
+ /**
85
+ * Sends a POST, PUT, PATCH, or DELETE to a path of the Apify API, https://docs.apify.com/api/v2, as a proxy.
86
+ */
87
+ export const apifyApiWrite = Object.freeze({
88
+ type: TOOL_TYPE.INTERNAL,
89
+ name: HELPER_TOOLS.API_WRITE,
90
+ title: 'Write Apify API',
91
+ description: buildDescription(ALL_TOOLS_PRESENT),
92
+ buildDescription,
93
+ inputSchema: z.toJSONSchema(apifyApiWriteArgs),
94
+ outputSchema: apifyApiCallOutputSchema,
95
+ ajvValidate: compileSchema(z.toJSONSchema(apifyApiWriteArgs)),
96
+ annotations: {
97
+ title: 'Write Apify API',
98
+ readOnlyHint: false,
99
+ destructiveHint: true,
100
+ idempotentHint: false,
101
+ // It starts runs and builds, and creates webhooks that call any URL, like the tools that start runs.
102
+ openWorldHint: true,
103
+ },
104
+ // A body can carry secrets: environment variable values, webhook headers, stored records. So can the
105
+ // webhooks query parameter of a run, whose webhooks carry headers.
106
+ redactArgs: redactApiCallArgs,
107
+ call: async (toolArgs) => {
108
+ const parsed = apifyApiWriteArgs.parse(toolArgs.args);
109
+ const body = parseBody(parsed.body);
110
+ if ('error' in body)
111
+ return respondUserError(body.error);
112
+ const resolved = parsed.method
113
+ ? { method: parsed.method }
114
+ : await inferWriteMethod(parsed.path, toolArgs.loadedToolNames);
115
+ if ('error' in resolved)
116
+ return respondUserError(resolved.error);
117
+ return callApi({
118
+ client: toolArgs.apifyClient,
119
+ token: toolArgs.apifyToken,
120
+ method: resolved.method,
121
+ path: parsed.path,
122
+ query: parsed.query,
123
+ body: body.value,
124
+ signal: toolArgs.signal,
125
+ loadedToolNames: toolArgs.loadedToolNames,
126
+ });
127
+ },
128
+ });
129
+ //# sourceMappingURL=apify_api_write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_write.js","sourceRoot":"","sources":["../../../src/tools/api/apify_api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.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EACH,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,8BAA8B,EACjC,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,kBAAkB,EAAE,MAAM,EAKtC,CAAC;AAIF,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,8BAA8B,EAAE,CAAC;AAE/G;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,GAAE,WAAiC,GAAG,SAAS,EAAE,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,YAAY,EAAE,CAM/D;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EACH,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,8BAA8B,EACjC,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,kBAAkB,EAAE,MAAM,EAQtC,CAAC;AAIF,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,8BAA8B,EAAE,CAAC;AAE/G;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,GAAE,WAAiC,GAAG,SAAS,EAAE,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,YAAY,EAAE,CAM/D;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
@@ -9,6 +9,9 @@ export const unauthEnabledTools = [
9
9
  HELPER_TOOLS.DOCS_FETCH,
10
10
  HELPER_TOOLS.STORE_SEARCH,
11
11
  HELPER_TOOLS.ACTOR_GET_DETAILS,
12
+ // They read only the public API spec from docs.apify.com, never the API itself.
13
+ HELPER_TOOLS.API_SEARCH,
14
+ HELPER_TOOLS.API_DETAILS,
12
15
  ];
13
16
  // Re-export from registry.ts
14
17
  // This is actually needed to avoid circular dependency issues
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EACH,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,8BAA8B,GACjC,MAAM,eAAe,CAAC;AAEvB,qFAAqF;AACrF,MAAM,CAAC,MAAM,kBAAkB,GAAa;IACxC,YAAY,CAAC,WAAW;IACxB,YAAY,CAAC,UAAU;IACvB,YAAY,CAAC,YAAY;IACzB,YAAY,CAAC,iBAAiB;CACjC,CAAC;AAEF,6BAA6B;AAC7B,8DAA8D;AAC9D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,8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