Skip to content

Commit 4dd3a6d

Browse files
authored
fix: hack tool call from claude-desktop. Claude is using prefix local (#133)
fix: hack tool call from claude-desktop. Claude is using prefix local__name__actor-name
1 parent 68563f2 commit 4dd3a6d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/mcp/server.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ export class ActorsMcpServer {
345345
* @throws {McpError} - based on the McpServer class code from the typescript MCP SDK
346346
*/
347347
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
348-
const { name, arguments: args } = request.params;
348+
// eslint-disable-next-line prefer-const
349+
let { name, arguments: args } = request.params;
349350
const apifyToken = (request.params.apifyToken || process.env.APIFY_TOKEN) as string;
350351

351352
// Remove apifyToken from request.params just in case
@@ -362,6 +363,16 @@ export class ActorsMcpServer {
362363
);
363364
}
364365

366+
// Claude is saving tool names with 'local__' prefix, name is local__apify-actors__compass-slash-crawler-google-places
367+
// We are interested in the Actor name only, so we remove the 'local__apify-actors__' prefix
368+
if (name.startsWith('local__')) {
369+
// we split the name by '__' and take the last part, which is the actual Actor name
370+
const parts = name.split('__');
371+
log.info(`Tool name with prefix detected: ${name}, using last part: ${parts[parts.length - 1]}`);
372+
if (parts.length > 1) {
373+
name = parts[parts.length - 1];
374+
}
375+
}
365376
// TODO - if connection is /mcp client will not receive notification on tool change
366377
// Find tool by name or actor full name
367378
const tool = Array.from(this.tools.values())

0 commit comments

Comments
 (0)