Skip to content

Commit d0e0320

Browse files
committed
fix: do not post telemetry entry for unsupported tools
1 parent d491d87 commit d0e0320

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

src/main.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ For more details, visit: https://github.com/ChromeDevTools/chrome-devtools-mcp#u
128128

129129
const toolMutex = new Mutex();
130130

131+
const toolNames = new Set<string>(tools.map(t => t.name));
132+
131133
function registerTool(tool: ToolDefinition): void {
132134
if (
133135
tool.annotations.category === ToolCategory.EMULATION &&
@@ -222,11 +224,15 @@ function registerTool(tool: ToolDefinition): void {
222224
isError: true,
223225
};
224226
} finally {
225-
void clearcutLogger?.logToolInvocation({
226-
toolName: tool.name,
227-
success,
228-
latencyMs: bucketizeLatency(Date.now() - startTime),
229-
});
227+
if (toolNames.has(tool.name)) {
228+
void clearcutLogger?.logToolInvocation({
229+
toolName: tool.name,
230+
success,
231+
latencyMs: bucketizeLatency(Date.now() - startTime),
232+
});
233+
} else {
234+
// TODO: unsupported tools?
235+
}
230236
guard.dispose();
231237
}
232238
},

tests/index.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ describe('e2e', () => {
8585
});
8686
});
8787

88+
it('reports errors for unknown tools', async () => {
89+
await withClient(async client => {
90+
const result = await client.callTool({
91+
name: 'unknown_tool',
92+
arguments: {},
93+
});
94+
assert.deepStrictEqual(result, {
95+
content: [
96+
{
97+
type: 'text',
98+
text: 'MCP error -32602: Tool unknown_tool not found',
99+
},
100+
],
101+
isError: true,
102+
});
103+
});
104+
});
105+
88106
it('has all tools', async () => {
89107
await withClient(async client => {
90108
const {tools} = await client.listTools();

0 commit comments

Comments
 (0)