Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ For more details, visit: https://github.com/ChromeDevTools/chrome-devtools-mcp#u

const toolMutex = new Mutex();

const toolNames = new Set<string>(tools.map(t => t.name));

function registerTool(tool: ToolDefinition): void {
if (
tool.annotations.category === ToolCategory.EMULATION &&
Expand Down Expand Up @@ -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();
}
},
Expand Down
18 changes: 18 additions & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down