Skip to content

Commit a41f751

Browse files
authored
fix: disable client capabilities tools swapping (#312)
* fix: disable cleint capabilities tools swapping * lint
1 parent 69b16af commit a41f751

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

src/utils/tools-loader.ts

Lines changed: 10 additions & 10 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 => {
@@ -108,7 +107,7 @@ export async function loadToolsFromInput(
108107
} // else: selectors provided but none are actors => do not load defaults
109108

110109
// Compose final tool list
111-
let result: ToolEntry[] = [];
110+
const result: ToolEntry[] = [];
112111

113112
// Internal tools
114113
if (selectorsProvided) {
@@ -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: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -979,23 +979,45 @@ 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')(
994+
// `should swap call-actor for add-actor when client supports dynamic tools for default tools`, async () => {
995+
// client = await createClientFn({ clientName: 'Visual Studio Code' });
996+
// const names = getToolNames(await client.listTools());
997+
998+
// // should not contain call-actor but should contain add-actor
999+
// expect(names).not.toContain('call-actor');
1000+
// expect(names).toContain('add-actor');
1001+
1002+
// await client.close();
1003+
// });
1004+
it.runIf(options.transport === 'streamable-http')('should NOT swap call-actor for add-actor even when client supports dynamic tools', async () => {
9831005
client = await createClientFn({ clientName: 'Visual Studio Code', tools: ['actors'] });
9841006
const names = getToolNames(await client.listTools());
9851007

9861008
// should not contain call-actor but should contain add-actor
987-
expect(names).not.toContain('call-actor');
988-
expect(names).toContain('add-actor');
1009+
expect(names).toContain('call-actor');
1010+
expect(names).not.toContain('add-actor');
9891011

9901012
await client.close();
9911013
});
992-
it.runIf(options.transport === 'streamable-http')(`should swap call-actor for add-actor when client supports dynamic tools for default tools`, async () => {
1014+
it.runIf(options.transport === 'streamable-http')(`should NOT swap call-actor for add-actor even when client supports dynamic tools for default tools`, async () => {
9931015
client = await createClientFn({ clientName: 'Visual Studio Code' });
9941016
const names = getToolNames(await client.listTools());
9951017

9961018
// should not contain call-actor but should contain add-actor
997-
expect(names).not.toContain('call-actor');
998-
expect(names).toContain('add-actor');
1019+
expect(names).toContain('call-actor');
1020+
expect(names).not.toContain('add-actor');
9991021

10001022
await client.close();
10011023
});

0 commit comments

Comments
 (0)