Skip to content

Conversation

@Suhaib3100
Copy link

Description

Adds a new browser_set_checked MCP tool that allows setting the checked state of checkboxes and radio buttons.

What does this PR do?

  • Adds browser_set_checked tool in packages/playwright/src/mcp/browser/tools/snapshot.ts
  • The tool accepts:
    • element: Human-readable element description
    • ref: Exact target element reference from the page snapshot
    • checked: Boolean to set the checked state (true/false)
  • Generates Playwright code like await page.getByRole('checkbox', { name: 'Accept' }).setChecked(true);
  • Includes snapshot in response for verification

Why is this needed?

The existing browser_check and browser_uncheck tools are marked as skillOnly: true (not exposed to MCP). This new tool provides a single interface to both check and uncheck elements, which is the expected API for LLM agents interacting with forms.

Tests

Added tests/mcp/set-checked.spec.ts with 3 tests:

  • browser_set_checked (checkbox) - Tests checking and unchecking a checkbox
  • browser_set_checked (radio button) - Tests selecting a radio button
  • browser_set_checked (already checked) - Tests unchecking a pre-checked element

All tests pass locally with npm run ctest-mcp.

Fixes microsoft/playwright-mcp#1342

Adds a new browser_set_checked MCP tool that allows setting the checked
state of checkboxes and radio buttons. This tool provides a single
interface to both check and uncheck elements, complementing the existing
browser_check and browser_uncheck tools.

Fixes microsoft/playwright-mcp#1342
@Suhaib3100
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: browser_set_checked mcp tool is missing

1 participant