Skip to content

Commit 1170dfc

Browse files
committed
rename to tool categories, include beta tools as separte preview category, remove beta flag param
1 parent c319b96 commit 1170dfc

File tree

10 files changed

+76
-130
lines changed

10 files changed

+76
-130
lines changed

src/actor/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function createExpressApp(
7373
// Load MCP server tools
7474
const apifyToken = process.env.APIFY_TOKEN as string;
7575
const input = parseInputParamsFromUrl(req.url);
76-
if (input.actors || input.enableAddingActors || input.beta || input.tools) {
76+
if (input.actors || input.enableAddingActors || input.tools) {
7777
log.debug('[SSE] Loading tools from URL', { sessionId: transport.sessionId });
7878
await mcpServer.loadToolsFromUrl(req.url, apifyToken);
7979
}
@@ -159,7 +159,7 @@ export function createExpressApp(
159159
// Load MCP server tools
160160
const apifyToken = process.env.APIFY_TOKEN as string;
161161
const input = parseInputParamsFromUrl(req.url);
162-
if (input.actors || input.enableAddingActors || input.beta || input.tools) {
162+
if (input.actors || input.enableAddingActors || input.tools) {
163163
log.debug('[Streamable] Loading tools from URL', { sessionId: transport.sessionId });
164164
await mcpServer.loadToolsFromUrl(req.url, apifyToken);
165165
}

src/input.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import log from '@apify/log';
55

6-
import type { FeatureToolKey, Input } from './types.js';
6+
import type { Input, ToolCategory } from './types.js';
77

88
/**
99
* Process input parameters, split Actors string into an array
@@ -30,11 +30,8 @@ export function processInput(originalInput: Partial<Input>): Input {
3030
input.enableAddingActors = input.enableAddingActors === true || input.enableAddingActors === 'true';
3131
}
3232

33-
// If beta present, set input.beta to true
34-
input.beta = input.beta !== undefined && (input.beta !== false && input.beta !== 'false');
35-
3633
if (input.tools && typeof input.tools === 'string') {
37-
input.tools = input.tools.split(',').map((tool: string) => tool.trim()) as FeatureToolKey[];
34+
input.tools = input.tools.split(',').map((tool: string) => tool.trim()) as ToolCategory[];
3835
}
3936
return input;
4037
}

src/mcp/server.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@ import {
2323
SERVER_NAME,
2424
SERVER_VERSION,
2525
} from '../const.js';
26-
import { addRemoveTools, betaTools, callActorGetDataset, defaultTools, featureTools, getActorsAsTools } from '../tools/index.js';
26+
import { addRemoveTools, callActorGetDataset, defaultTools, getActorsAsTools, toolCategories } from '../tools/index.js';
2727
import { actorNameToToolName, decodeDotPropertyNames } from '../tools/utils.js';
28-
import type { ActorMcpTool, ActorTool, FeatureToolKey, HelperTool, ToolEntry } from '../types.js';
28+
import type { ActorMcpTool, ActorTool, HelperTool, ToolCategory, ToolEntry } from '../types.js';
2929
import { connectMCPClient } from './client.js';
3030
import { EXTERNAL_TOOL_CALL_TIMEOUT_MSEC } from './const.js';
3131
import { processParamsGetTools } from './utils.js';
3232

3333
type ActorsMcpServerOptions = {
3434
enableAddingActors?: boolean;
3535
enableDefaultActors?: boolean;
36-
enableBeta?: boolean; // Enable beta features
3736
};
3837

3938
type ToolsChangedHandler = (toolNames: string[]) => void;
@@ -52,7 +51,6 @@ export class ActorsMcpServer {
5251
this.options = {
5352
enableAddingActors: options.enableAddingActors ?? true,
5453
enableDefaultActors: options.enableDefaultActors ?? true, // Default to true for backward compatibility
55-
enableBeta: options.enableBeta ?? false, // Disabled by default
5654
};
5755
this.server = new Server(
5856
{
@@ -78,10 +76,6 @@ export class ActorsMcpServer {
7876
this.enableDynamicActorTools();
7977
}
8078

81-
if (this.options.enableBeta) {
82-
this.upsertTools(betaTools, false);
83-
}
84-
8579
// Initialize automatically for backward compatibility
8680
this.initialize().catch((error) => {
8781
log.error('Failed to initialize server:', error);
@@ -172,10 +166,10 @@ export class ActorsMcpServer {
172166
const loadedTools = this.listAllToolNames();
173167
const actorsToLoad: string[] = [];
174168
const toolsToLoad: ToolEntry[] = [];
175-
const internalToolMap = new Map([...defaultTools, ...addRemoveTools, ...betaTools].map((tool) => [tool.tool.name, tool]));
176-
// Add all feature tools
177-
for (const key of Object.keys(featureTools)) {
178-
const tools = featureTools[key as FeatureToolKey];
169+
const internalToolMap = new Map([...defaultTools, ...addRemoveTools].map((tool) => [tool.tool.name, tool]));
170+
// Add all category tools
171+
for (const key of Object.keys(toolCategories)) {
172+
const tools = toolCategories[key as ToolCategory];
179173
for (const tool of tools) {
180174
internalToolMap.set(tool.tool.name, tool);
181175
}

src/stdio.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import { hideBin } from 'yargs/helpers';
2323
import log from '@apify/log';
2424

2525
import { ActorsMcpServer } from './mcp/server.js';
26-
import { featureTools } from './tools/index.js';
27-
import type { FeatureToolKey, Input } from './types.js';
26+
import { toolCategories } from './tools/index.js';
27+
import type { Input, ToolCategory } from './types.js';
2828
import { loadToolsFromInput } from './utils/tools-loader.js';
2929

3030
// Keeping this interface here and not types.ts since
@@ -37,7 +37,7 @@ interface CliArgs {
3737
enableAddingActors: boolean;
3838
/** @deprecated */
3939
enableActorAutoLoading: boolean;
40-
beta: boolean;
40+
/** Tool categories to include */
4141
tools?: string;
4242
}
4343

@@ -63,21 +63,17 @@ const argv = yargs(hideBin(process.argv))
6363
hidden: true,
6464
describe: 'Deprecated: use enable-adding-actors instead.',
6565
})
66-
.option('beta', {
67-
type: 'boolean',
68-
default: false,
69-
describe: 'Enable beta features.',
70-
})
7166
.options('tools', {
7267
type: 'string',
73-
describe: `Comma-separated list of specific feature tools to enable.
68+
describe: `Comma-separated list of specific tool categories to enable.
7469
75-
Available choices: ${Object.keys(featureTools).join(', ')}
70+
Available choices: ${Object.keys(toolCategories).join(', ')}
7671
77-
Feature tools are categorized as follows:
72+
Tool categories are as follows:
7873
- docs: Search and fetch Apify documentation tools.
7974
- runs: Get Actor runs list, run details, and logs from a specific Actor run.
8075
- storage: Access datasets, key-value stores, and their records.
76+
- preview: Experimental tools in preview mode.
8177
8278
Note: Tools that enable you to search Actors from the Apify Store and get their details are always enabled by default.
8379
`,
@@ -96,9 +92,8 @@ Note: Tools that enable you to search Actors from the Apify Store and get their
9692
const enableAddingActors = argv.enableAddingActors && argv.enableActorAutoLoading;
9793
const actors = argv.actors as string || '';
9894
const actorList = actors ? actors.split(',').map((a: string) => a.trim()) : [];
99-
const enableBeta = argv.beta;
100-
// Keys of the feature tools to enable
101-
const featureToolKeys = argv.tools ? argv.tools.split(',').map((t: string) => t.trim()) : [];
95+
// Keys of the tool categories to enable
96+
const toolCategoryKeys = argv.tools ? argv.tools.split(',').map((t: string) => t.trim()) : [];
10297

10398
// Validate environment
10499
if (!process.env.APIFY_TOKEN) {
@@ -107,14 +102,13 @@ if (!process.env.APIFY_TOKEN) {
107102
}
108103

109104
async function main() {
110-
const mcpServer = new ActorsMcpServer({ enableAddingActors, enableDefaultActors: false, enableBeta });
105+
const mcpServer = new ActorsMcpServer({ enableAddingActors, enableDefaultActors: false });
111106

112107
// Create an Input object from CLI arguments
113108
const input: Input = {
114109
actors: actorList.length ? actorList : [],
115110
enableAddingActors,
116-
beta: enableBeta,
117-
tools: featureToolKeys as FeatureToolKey[],
111+
tools: toolCategoryKeys as ToolCategory[],
118112
};
119113

120114
// Use the shared tools loading logic

src/tools/index.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Import specific tools that are being used
2+
import type { ToolCategory } from '../types.js';
23
import { callActor, callActorGetDataset, getActorsAsTools } from './actor.js';
34
import { getDataset, getDatasetItems } from './dataset.js';
45
import { getUserDatasetsList } from './dataset_collection.js';
@@ -12,12 +13,7 @@ import { getUserRunsList } from './run_collection.js';
1213
import { searchApifyDocsTool } from './search-apify-docs.js';
1314
import { searchActors } from './store_collection.js';
1415

15-
export const defaultTools = [
16-
getActorDetailsTool,
17-
searchActors,
18-
];
19-
20-
export const featureTools = {
16+
export const toolCategories = {
2117
docs: [
2218
searchApifyDocsTool,
2319
fetchApifyDocsTool,
@@ -36,10 +32,19 @@ export const featureTools = {
3632
getUserDatasetsList,
3733
getUserKeyValueStoresList,
3834
],
35+
preview: [
36+
callActor,
37+
],
3938
};
39+
export const toolCategoriesEnabledByDefault: ToolCategory[] = [
40+
'docs',
41+
];
4042

41-
export const betaTools = [
42-
callActor,
43+
export const defaultTools = [
44+
getActorDetailsTool,
45+
searchActors,
46+
// Add the tools from the enabled categories
47+
...toolCategoriesEnabledByDefault.map((key) => toolCategories[key]).flat(),
4348
];
4449

4550
export const addRemoveTools = [

src/types.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { ActorDefaultRunOptions, ActorDefinition, ActorStoreList, PricingIn
66

77
import type { ACTOR_PRICING_MODEL } from './const.js';
88
import type { ActorsMcpServer } from './mcp/server.js';
9-
import type { featureTools } from './tools/index.js';
9+
import type { toolCategories } from './tools/index.js';
1010

1111
export interface ISchemaProperties {
1212
type: string;
@@ -214,7 +214,7 @@ export interface InternalTool extends ToolBase {
214214
call: (toolArgs: InternalToolArgs) => Promise<object>;
215215
}
216216

217-
export type FeatureToolKey = keyof typeof featureTools;
217+
export type ToolCategory = keyof typeof toolCategories;
218218

219219
export type Input = {
220220
actors: string[] | string;
@@ -226,9 +226,8 @@ export type Input = {
226226
maxActorMemoryBytes?: number;
227227
debugActor?: string;
228228
debugActorInput?: unknown;
229-
/** Enable beta features flag */
230-
beta?: boolean | string;
231-
tools?: FeatureToolKey[] | string;
229+
/** Tool categories to include */
230+
tools?: ToolCategory[] | string;
232231
};
233232

234233
// Utility type to get a union of values from an object type

src/utils/tools-loader.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55

66
import { defaults } from '../const.js';
7-
import { addRemoveTools, betaTools, featureTools, getActorsAsTools } from '../tools/index.js';
8-
import type { FeatureToolKey, Input, ToolEntry } from '../types.js';
7+
import { addRemoveTools, getActorsAsTools, toolCategories } from '../tools/index.js';
8+
import type { Input, ToolCategory, ToolEntry } from '../types.js';
99

1010
/**
1111
* Load tools based on the provided Input object.
@@ -37,16 +37,11 @@ export async function loadToolsFromInput(
3737
tools.push(...addRemoveTools);
3838
}
3939

40-
// Add beta tools if enabled
41-
if (input.beta) {
42-
tools.push(...betaTools);
43-
}
44-
45-
// Add feature tools based on the input
40+
// Add tools from enabled categories
4641
if (input.tools) {
4742
const toolKeys = Array.isArray(input.tools) ? input.tools : [input.tools];
4843
for (const toolKey of toolKeys) {
49-
const keyTools = featureTools[toolKey as FeatureToolKey] || [];
44+
const keyTools = toolCategories[toolKey as ToolCategory] || [];
5045
tools.push(...keyTools);
5146
}
5247
}

tests/helpers.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/
55
import { expect } from 'vitest';
66

77
import { HelperTools } from '../src/const.js';
8-
import type { FeatureToolKey } from '../src/types.js';
8+
import type { ToolCategory } from '../src/types.js';
99

1010
export interface McpClientOptions {
1111
actors?: string[];
1212
enableAddingActors?: boolean;
13-
enableBeta?: boolean; // Optional, used for beta features
14-
tools?: FeatureToolKey[]; // Optional, used for feature tools
13+
tools?: ToolCategory[]; // Tool categories to include
1514
}
1615

1716
export async function createMcpSseClient(
@@ -22,16 +21,13 @@ export async function createMcpSseClient(
2221
throw new Error('APIFY_TOKEN environment variable is not set.');
2322
}
2423
const url = new URL(serverUrl);
25-
const { actors, enableAddingActors, enableBeta, tools } = options || {};
24+
const { actors, enableAddingActors, tools } = options || {};
2625
if (actors) {
2726
url.searchParams.append('actors', actors.join(','));
2827
}
2928
if (enableAddingActors !== undefined) {
3029
url.searchParams.append('enableAddingActors', enableAddingActors.toString());
3130
}
32-
if (enableBeta !== undefined) {
33-
url.searchParams.append('beta', enableBeta.toString());
34-
}
3531
if (tools && tools.length > 0) {
3632
url.searchParams.append('tools', tools.join(','));
3733
}
@@ -64,16 +60,13 @@ export async function createMcpStreamableClient(
6460
throw new Error('APIFY_TOKEN environment variable is not set.');
6561
}
6662
const url = new URL(serverUrl);
67-
const { actors, enableAddingActors, enableBeta, tools } = options || {};
63+
const { actors, enableAddingActors, tools } = options || {};
6864
if (actors) {
6965
url.searchParams.append('actors', actors.join(','));
7066
}
7167
if (enableAddingActors !== undefined) {
7268
url.searchParams.append('enableAddingActors', enableAddingActors.toString());
7369
}
74-
if (enableBeta !== undefined) {
75-
url.searchParams.append('beta', enableBeta.toString());
76-
}
7770
if (tools && tools.length > 0) {
7871
url.searchParams.append('tools', tools.join(','));
7972
}
@@ -104,17 +97,14 @@ export async function createMcpStdioClient(
10497
if (!process.env.APIFY_TOKEN) {
10598
throw new Error('APIFY_TOKEN environment variable is not set.');
10699
}
107-
const { actors, enableAddingActors, enableBeta, tools } = options || {};
100+
const { actors, enableAddingActors, tools } = options || {};
108101
const args = ['dist/stdio.js'];
109102
if (actors) {
110103
args.push('--actors', actors.join(','));
111104
}
112105
if (enableAddingActors !== undefined) {
113106
args.push('--enable-adding-actors', enableAddingActors.toString());
114107
}
115-
if (enableBeta !== undefined) {
116-
args.push('--beta', enableBeta.toString());
117-
}
118108
if (tools && tools.length > 0) {
119109
args.push('--tools', tools.join(','));
120110
}

0 commit comments

Comments
 (0)