Skip to content
Merged
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
8 changes: 8 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,11 @@ For more verbose logs, set the `DEBUG` environment variable:
```sh
DEBUG=* chrome-devtools list_pages
```

## CLI generation

Implemented in `scripts/generate-cli.ts`. Some commands are excluded from CLI
generation such as `wait_for` and `fill_form`.

`chrome-devtools-mcp` args are also filtered in `src/bin/chrome-devtools.ts`
because not all args make sense in a CLI interface.
17 changes: 16 additions & 1 deletion scripts/generate-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,23 @@ function schemaToCLIOptions(schema: JsonSchema): CliOption[] {

async function generateCli() {
const tools = await fetchTools();

// Sort tools by name
const sortedTools = tools.sort((a, b) => a.name.localeCompare(b.name));
const sortedTools = tools
.sort((a, b) => a.name.localeCompare(b.name))
.filter(tool => {
// Skipping fill_form because it is not relevant in shell scripts
// and CLI does not handle array/JSON args well.
if (tool.name === 'fill_form') {
return false;
}
// Skipping wait_for because CLI does not handle array/JSON args well
// and shell scripts have many mechanisms for waiting.
if (tool.name === 'wait_for') {
return false;
}
return true;
});

const staticTools = createTools(parseArguments());
const toolNameToCategory = new Map<string, string>();
Expand Down
39 changes: 0 additions & 39 deletions src/bin/cliDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,25 +184,6 @@ export const commands: Commands = {
},
},
},
fill_form: {
description: 'Fill out multiple form elements at once',
category: 'Input automation',
args: {
elements: {
name: 'elements',
type: 'array',
description: 'Elements from snapshot to fill out.',
required: true,
},
includeSnapshot: {
name: 'includeSnapshot',
type: 'boolean',
description:
'Whether to include a snapshot in the response. Default is false.',
required: false,
},
},
},
get_console_message: {
description:
'Gets a console message by its ID. You can get all messages by calling list_console_messages.',
Expand Down Expand Up @@ -722,24 +703,4 @@ export const commands: Commands = {
},
},
},
wait_for: {
description: 'Wait for the specified text to appear on the selected page.',
category: 'Navigation automation',
args: {
text: {
name: 'text',
type: 'array',
description:
'Non-empty list of texts. Resolves when any value appears on the page.',
required: true,
},
timeout: {
name: 'timeout',
type: 'integer',
description:
'Maximum wait time in milliseconds. If set to 0, the default timeout will be used.',
required: false,
},
},
},
} as const;
Loading