Skip to content

Commit 2b04713

Browse files
authored
Merge branch 'main' into orkon/release-cli
2 parents 753b64b + 0c0a538 commit 2b04713

8 files changed

Lines changed: 38 additions & 45 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ To use the Chrome DevTools MCP server follow the instructions from <a href="http
122122

123123
This will make the Chrome DevTools MCP server automatically connect to the browser that Antigravity is using. If you are not using port 9222, make sure to adjust accordingly.
124124

125-
Chrome DevTools MCP will not start the browser instance automatically using this approach as as the Chrome DevTools MCP server runs in Antigravity's built-in browser. If the browser is not already running, you have to start it first by clicking the Chrome icon at the top right corner.
125+
Chrome DevTools MCP will not start the browser instance automatically using this approach because the Chrome DevTools MCP server connects to Antigravity's built-in browser. If the browser is not already running, you have to start it first by clicking the Chrome icon at the top right corner.
126126

127127
</details>
128128

docs/cli.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,11 @@ For more verbose logs, set the `DEBUG` environment variable:
9191
```sh
9292
DEBUG=* chrome-devtools list_pages
9393
```
94+
95+
## CLI generation
96+
97+
Implemented in `scripts/generate-cli.ts`. Some commands are excluded from CLI
98+
generation such as `wait_for` and `fill_form`.
99+
100+
`chrome-devtools-mcp` args are also filtered in `src/bin/chrome-devtools.ts`
101+
because not all args make sense in a CLI interface.

scripts/generate-cli.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,23 @@ function schemaToCLIOptions(schema: JsonSchema): CliOption[] {
102102

103103
async function generateCli() {
104104
const tools = await fetchTools();
105+
105106
// Sort tools by name
106-
const sortedTools = tools.sort((a, b) => a.name.localeCompare(b.name));
107+
const sortedTools = tools
108+
.sort((a, b) => a.name.localeCompare(b.name))
109+
.filter(tool => {
110+
// Skipping fill_form because it is not relevant in shell scripts
111+
// and CLI does not handle array/JSON args well.
112+
if (tool.name === 'fill_form') {
113+
return false;
114+
}
115+
// Skipping wait_for because CLI does not handle array/JSON args well
116+
// and shell scripts have many mechanisms for waiting.
117+
if (tool.name === 'wait_for') {
118+
return false;
119+
}
120+
return true;
121+
});
107122

108123
const staticTools = createTools(parseArguments());
109124
const toolNameToCategory = new Map<string, string>();

src/bin/chrome-devtools.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,12 @@ y.command('status', 'Checks if chrome-devtools-mcp is running', async () => {
114114
socketPath: string;
115115
startDate: string;
116116
version: string;
117+
args: string[];
117118
};
118119
console.log(
119120
`pid=${data.pid} socket=${data.socketPath} start-date=${data.startDate} version=${data.version}`,
120121
);
122+
console.log(`args=${JSON.stringify(data.args)}`);
121123
} else {
122124
console.error('Error:', response.error);
123125
process.exit(1);

src/bin/cliDefinitions.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,6 @@ export const commands: Commands = {
184184
},
185185
},
186186
},
187-
fill_form: {
188-
description: 'Fill out multiple form elements at once',
189-
category: 'Input automation',
190-
args: {
191-
elements: {
192-
name: 'elements',
193-
type: 'array',
194-
description: 'Elements from snapshot to fill out.',
195-
required: true,
196-
},
197-
includeSnapshot: {
198-
name: 'includeSnapshot',
199-
type: 'boolean',
200-
description:
201-
'Whether to include a snapshot in the response. Default is false.',
202-
required: false,
203-
},
204-
},
205-
},
206187
get_console_message: {
207188
description:
208189
'Gets a console message by its ID. You can get all messages by calling list_console_messages.',
@@ -722,24 +703,4 @@ export const commands: Commands = {
722703
},
723704
},
724705
},
725-
wait_for: {
726-
description: 'Wait for the specified text to appear on the selected page.',
727-
category: 'Navigation automation',
728-
args: {
729-
text: {
730-
name: 'text',
731-
type: 'array',
732-
description:
733-
'Non-empty list of texts. Resolves when any value appears on the page.',
734-
required: true,
735-
},
736-
timeout: {
737-
name: 'timeout',
738-
type: 'integer',
739-
description:
740-
'Maximum wait time in milliseconds. If set to 0, the default timeout will be used.',
741-
required: false,
742-
},
743-
},
744-
},
745706
} as const;

src/daemon/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export async function startDaemon(mcpArgs: string[] = []) {
8585
stdio: 'ignore',
8686
env: process.env,
8787
cwd: process.cwd(),
88+
windowsHide: true,
8889
});
8990
child.unref();
9091

src/daemon/daemon.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ logger(`Writing ${process.pid.toString()} to ${pidFilePath}`);
4444
const socketPath = getSocketPath();
4545

4646
const startDate = new Date();
47+
const mcpServerArgs = process.argv.slice(2);
4748

4849
let mcpClient: Client | null = null;
4950
let mcpTransport: StdioClientTransport | null = null;
@@ -52,11 +53,10 @@ let server: Server | null = null;
5253
async function setupMCPClient() {
5354
console.log('Setting up MCP client connection...');
5455

55-
const args = process.argv.slice(2);
5656
// Create stdio transport for chrome-devtools-mcp
5757
mcpTransport = new StdioClientTransport({
5858
command: process.execPath,
59-
args: [INDEX_SCRIPT_PATH, ...args],
59+
args: [INDEX_SCRIPT_PATH, ...mcpServerArgs],
6060
env: process.env as Record<string, string>,
6161
});
6262
mcpClient = new Client(
@@ -118,6 +118,7 @@ async function handleRequest(msg: DaemonMessage) {
118118
socketPath,
119119
startDate: startDate.toISOString(),
120120
version: VERSION,
121+
args: mcpServerArgs,
121122
}),
122123
};
123124
}

tests/tools/pages.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,18 @@ describe('pages', () => {
162162

163163
assert.ok(extensionId);
164164

165-
const _sidePanelPage = await context.newPage();
166-
await _sidePanelPage.pptrPage.goto(
165+
const sidePanelPage = await context.newPage();
166+
await sidePanelPage.pptrPage.goto(
167167
`chrome-extension://${extensionId}/sidepanel.html`,
168168
);
169169

170170
await context.waitForTextOnPage(['Side Panel']);
171171

172+
// Wait for service worker used in the snapshot.
173+
await context.browser.waitForTarget(
174+
target => target.type() === 'service_worker',
175+
);
176+
172177
const listPageDef = listPages({
173178
categoryExtensions: true,
174179
} as ParsedArguments);

0 commit comments

Comments
 (0)