Skip to content

Commit b17d15e

Browse files
committed
test: update test to include off by defaults tools
1 parent d04611a commit b17d15e

3 files changed

Lines changed: 70 additions & 3 deletions

File tree

skills/troubleshooting/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ All tools in `chrome-devtools-mcp` are annotated with `readOnlyHint: true` (for
5252
If the tools related to extensions (like `install_extension`) are not available, or if the extensions you load are not functioning:
5353

5454
1. **Check for the `--categoryExtensions` flag**: Ensure this flag is passed in the MCP server configuration to enable the extension category tools.
55-
2. **Make sure the MCP server in configured to launch Chrome instead of connecting to an instance. Chrome before 149 is not able to load extensions when connecting to existing instance (`--auto-connect`, `--browserUrl`).
55+
2. \*\*Make sure the MCP server in configured to launch Chrome instead of connecting to an instance. Chrome before 149 is not able to load extensions when connecting to existing instance (`--auto-connect`, `--browserUrl`).
5656

5757
#### Other Common Errors
5858

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export async function createMcpServer(
136136
}
137137
if (
138138
tool.annotations.category === ToolCategory.EXTENSIONS &&
139-
!serverArgs.categoryExtensions
139+
serverArgs.categoryExtensions === false
140140
) {
141141
return;
142142
}

tests/index.test.ts

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import {Client} from '@modelcontextprotocol/sdk/client/index.js';
1212
import {StdioClientTransport} from '@modelcontextprotocol/sdk/client/stdio.js';
1313
import {executablePath} from 'puppeteer';
1414

15-
import type {ToolDefinition} from '../src/tools/ToolDefinition';
15+
import {
16+
OFF_BY_DEFAULT_CATEGORIES,
17+
ToolCategory,
18+
} from '../src/tools/categories.js';
19+
import type {ToolDefinition} from '../src/tools/ToolDefinition.js';
1620

1721
describe('e2e', () => {
1822
async function withClient(
@@ -71,6 +75,56 @@ describe('e2e', () => {
7175
});
7276
});
7377

78+
it('has all tools with off by default categories', async () => {
79+
await withClient(
80+
async client => {
81+
const {tools} = await client.listTools();
82+
const exposedNames = tools.map(t => t.name).sort();
83+
const files = fs.readdirSync('build/src/tools');
84+
const definedNames = [];
85+
for (const file of files) {
86+
if (
87+
file === 'ToolDefinition.js' ||
88+
file === 'tools.js' ||
89+
file === 'slim'
90+
) {
91+
continue;
92+
}
93+
const fileTools = await import(`../src/tools/${file}`);
94+
for (const maybeTool of Object.values<unknown>(fileTools)) {
95+
if (typeof maybeTool === 'function') {
96+
const tool = (maybeTool as (val: boolean) => ToolDefinition)(
97+
false,
98+
);
99+
if (tool && typeof tool === 'object' && 'name' in tool) {
100+
if (tool.annotations?.conditions) {
101+
continue;
102+
}
103+
definedNames.push(tool.name);
104+
}
105+
continue;
106+
}
107+
if (
108+
typeof maybeTool === 'object' &&
109+
maybeTool !== null &&
110+
'name' in maybeTool
111+
) {
112+
const tool = maybeTool as ToolDefinition;
113+
if (tool.annotations?.conditions) {
114+
continue;
115+
}
116+
definedNames.push(tool.name);
117+
}
118+
}
119+
}
120+
121+
definedNames.sort();
122+
assert.deepStrictEqual(exposedNames, definedNames);
123+
},
124+
OFF_BY_DEFAULT_CATEGORIES.map(category => `--category-${category}`),
125+
);
126+
});
127+
74128
it('has all tools', async () => {
75129
await withClient(async client => {
76130
const {tools} = await client.listTools();
@@ -93,6 +147,12 @@ describe('e2e', () => {
93147
if (tool.annotations?.conditions) {
94148
continue;
95149
}
150+
if (
151+
tool.annotations?.category &&
152+
tool.annotations?.category === ToolCategory.EXTENSIONS
153+
) {
154+
continue;
155+
}
96156
definedNames.push(tool.name);
97157
}
98158
continue;
@@ -106,10 +166,17 @@ describe('e2e', () => {
106166
if (tool.annotations?.conditions) {
107167
continue;
108168
}
169+
if (
170+
tool.annotations?.category &&
171+
tool.annotations?.category === ToolCategory.EXTENSIONS
172+
) {
173+
continue;
174+
}
109175
definedNames.push(tool.name);
110176
}
111177
}
112178
}
179+
113180
definedNames.sort();
114181
assert.deepStrictEqual(exposedNames, definedNames);
115182
});

0 commit comments

Comments
 (0)