From d0e032057345d251f45c69925b0a318672c28bee Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Thu, 29 Jan 2026 14:29:35 +0100 Subject: [PATCH] fix: do not post telemetry entry for unsupported tools --- src/main.ts | 16 +++++++++++----- tests/index.test.ts | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 6ba8ddf41..858978d10 100644 --- a/src/main.ts +++ b/src/main.ts @@ -128,6 +128,8 @@ For more details, visit: https://github.com/ChromeDevTools/chrome-devtools-mcp#u const toolMutex = new Mutex(); +const toolNames = new Set(tools.map(t => t.name)); + function registerTool(tool: ToolDefinition): void { if ( tool.annotations.category === ToolCategory.EMULATION && @@ -222,11 +224,15 @@ function registerTool(tool: ToolDefinition): void { isError: true, }; } finally { - void clearcutLogger?.logToolInvocation({ - toolName: tool.name, - success, - latencyMs: bucketizeLatency(Date.now() - startTime), - }); + if (toolNames.has(tool.name)) { + void clearcutLogger?.logToolInvocation({ + toolName: tool.name, + success, + latencyMs: bucketizeLatency(Date.now() - startTime), + }); + } else { + // TODO: unsupported tools? + } guard.dispose(); } }, diff --git a/tests/index.test.ts b/tests/index.test.ts index 5b3f7a54e..7c0278673 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -85,6 +85,24 @@ describe('e2e', () => { }); }); + it('reports errors for unknown tools', async () => { + await withClient(async client => { + const result = await client.callTool({ + name: 'unknown_tool', + arguments: {}, + }); + assert.deepStrictEqual(result, { + content: [ + { + type: 'text', + text: 'MCP error -32602: Tool unknown_tool not found', + }, + ], + isError: true, + }); + }); + }); + it('has all tools', async () => { await withClient(async client => { const {tools} = await client.listTools();