Skip to content

Commit dec9c29

Browse files
committed
fix: disable cleint capabilities tools swapping
1 parent 69b16af commit dec9c29

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

src/utils/tools-loader.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { getActorOutput } from '../tools/get-actor-output.js';
1515
import { addTool } from '../tools/helpers.js';
1616
import { getActorsAsTools, toolCategories, toolCategoriesEnabledByDefault } from '../tools/index.js';
1717
import type { Input, InternalTool, InternalToolArgs, ToolCategory, ToolEntry } from '../types.js';
18-
import { doesMcpClientSupportDynamicTools } from './mcp-clients.js';
1918
import { getExpectedToolsByCategories } from './tools.js';
2019

2120
// Lazily-computed cache of internal tools by name to avoid circular init issues.
@@ -41,7 +40,7 @@ function getInternalToolByNameMap(): Map<string, ToolEntry> {
4140
export async function loadToolsFromInput(
4241
input: Input,
4342
apifyClient: ApifyClient,
44-
initializeRequestData?: InitializeRequest,
43+
_initializeRequestData?: InitializeRequest,
4544
): Promise<ToolEntry[]> {
4645
// Helpers for readability
4746
const normalizeSelectors = (value: Input['tools']): (string | ToolCategory)[] | undefined => {
@@ -142,15 +141,16 @@ export async function loadToolsFromInput(
142141
result.push(getActorOutput);
143142
}
144143

144+
// TEMP: for now we disable this swapping logic as the add-actor tool was misbehaving in some clients
145145
// Handle client capabilities logic for 'actors' category to swap call-actor for add-actor
146146
// if client supports dynamic tools.
147-
const selectorContainsCallActor = selectors?.some((s) => s === HelperTools.ACTOR_CALL);
148-
if (doesMcpClientSupportDynamicTools(initializeRequestData) && hasCallActor && !selectorContainsCallActor) {
149-
// Remove call-actor
150-
result = result.filter((entry) => entry.tool.name !== HelperTools.ACTOR_CALL);
151-
// Replace with add-actor if not already present
152-
if (!hasAddActorTool) result.push(addTool);
153-
}
147+
//const selectorContainsCallActor = selectors?.some((s) => s === HelperTools.ACTOR_CALL);
148+
//if (doesMcpClientSupportDynamicTools(initializeRequestData) && hasCallActor && !selectorContainsCallActor) {
149+
// // Remove call-actor
150+
// result = result.filter((entry) => entry.tool.name !== HelperTools.ACTOR_CALL);
151+
// // Replace with add-actor if not already present
152+
// if (!hasAddActorTool) result.push(addTool);
153+
//}
154154

155155
// De-duplicate by tool name for safety
156156
const seen = new Set<string>();

tests/integration/suite.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -979,23 +979,44 @@ export function createIntegrationTestsSuite(
979979
expect(tools.tools.length).toBeGreaterThan(0);
980980
});
981981

982-
it.runIf(options.transport === 'streamable-http')('should swap call-actor for add-actor when client supports dynamic tools', async () => {
982+
// TEMP: this logic is currently disabled, see src/utils/tools-loader.ts
983+
//it.runIf(options.transport === 'streamable-http')('should swap call-actor for add-actor when client supports dynamic tools', async () => {
984+
// client = await createClientFn({ clientName: 'Visual Studio Code', tools: ['actors'] });
985+
// const names = getToolNames(await client.listTools());
986+
987+
// // should not contain call-actor but should contain add-actor
988+
// expect(names).not.toContain('call-actor');
989+
// expect(names).toContain('add-actor');
990+
991+
// await client.close();
992+
//});
993+
//it.runIf(options.transport === 'streamable-http')(`should swap call-actor for add-actor when client supports dynamic tools for default tools`, async () => {
994+
// client = await createClientFn({ clientName: 'Visual Studio Code' });
995+
// const names = getToolNames(await client.listTools());
996+
997+
// // should not contain call-actor but should contain add-actor
998+
// expect(names).not.toContain('call-actor');
999+
// expect(names).toContain('add-actor');
1000+
1001+
// await client.close();
1002+
//});
1003+
it.runIf(options.transport === 'streamable-http')('should NOT swap call-actor for add-actor even when client supports dynamic tools', async () => {
9831004
client = await createClientFn({ clientName: 'Visual Studio Code', tools: ['actors'] });
9841005
const names = getToolNames(await client.listTools());
9851006

9861007
// should not contain call-actor but should contain add-actor
987-
expect(names).not.toContain('call-actor');
988-
expect(names).toContain('add-actor');
1008+
expect(names).toContain('call-actor');
1009+
expect(names).not.toContain('add-actor');
9891010

9901011
await client.close();
9911012
});
992-
it.runIf(options.transport === 'streamable-http')(`should swap call-actor for add-actor when client supports dynamic tools for default tools`, async () => {
1013+
it.runIf(options.transport === 'streamable-http')(`should NOT swap call-actor for add-actor even when client supports dynamic tools for default tools`, async () => {
9931014
client = await createClientFn({ clientName: 'Visual Studio Code' });
9941015
const names = getToolNames(await client.listTools());
9951016

9961017
// should not contain call-actor but should contain add-actor
997-
expect(names).not.toContain('call-actor');
998-
expect(names).toContain('add-actor');
1018+
expect(names).toContain('call-actor');
1019+
expect(names).not.toContain('add-actor');
9991020

10001021
await client.close();
10011022
});

0 commit comments

Comments
 (0)