diff --git a/docs/cli.md b/docs/cli.md index 46b2239d0..b2140e8dc 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -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. diff --git a/scripts/generate-cli.ts b/scripts/generate-cli.ts index c8c0dc520..c5db4974d 100644 --- a/scripts/generate-cli.ts +++ b/scripts/generate-cli.ts @@ -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(); diff --git a/src/bin/cliDefinitions.ts b/src/bin/cliDefinitions.ts index 6e317a333..d32705617 100644 --- a/src/bin/cliDefinitions.ts +++ b/src/bin/cliDefinitions.ts @@ -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.', @@ -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;