Skip to content

feat(mcp): add browser_emulate_media tool and --color-scheme option - #42244

Closed
Lars Kiesow (lkiesow) wants to merge 1 commit into
microsoft:mainfrom
lkiesow:feat-mcp-emulate-media
Closed

Lars Kiesow (lkiesow) wants to merge 1 commit into
microsoft:mainfrom
lkiesow:feat-mcp-emulate-media

Conversation

@lkiesow

Copy link
Copy Markdown

Lets agents check a UI in both light and dark mode. The tool wraps page.emulateMedia, so reduced motion, forced colors, contrast and the print media type are covered as well. Omitted parameters keep their current emulation state.

--color-scheme (and PLAYWRIGHT_MCP_COLOR_SCHEME) maps to contextOptions.colorScheme so a whole session can start in dark mode.

Fixes #42243

Lets agents check a UI in both light and dark mode. The tool wraps
page.emulateMedia, so reduced motion, forced colors, contrast and the
print media type are covered as well. Omitted parameters keep their
current emulation state.

--color-scheme (and PLAYWRIGHT_MCP_COLOR_SCHEME) maps to
contextOptions.colorScheme so a whole session can start in dark mode.

Fixes microsoft#42243
@lkiesow

Copy link
Copy Markdown
Author

Sorry, in the contributor.md, I missed the

Approval Required: Only proceed with a PR once the issue has been officially assigned to you or approved for community contribution.

Closing this for now, but happy to provide the patch again

@pavelfeldman

Copy link
Copy Markdown
Member

Your patch looks good, please feel free to reopen it as is. I'd probably have playwright-cli set- in the CLI instead of passing camelCase options though.

description: 'Emulate CSS media features for the page, for example switch between the light and dark color scheme. Omitted parameters are left unchanged.',
inputSchema: z.object({
colorScheme: z.enum(['light', 'dark']).optional().describe('Emulates the prefers-color-scheme media feature'),
reducedMotion: z.enum(['reduce', 'no-preference']).optional().describe('Emulates the prefers-reduced-motion media feature'),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use kebob case to be consistent with other options

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

6 failed
❌ [chrome] › mcp/config.spec.ts:203 › chromiumSandbox › --sandbox enables the sandbox @mcp-ubuntu-latest-chrome
❌ [firefox] › mcp/annotate.spec.ts:349 › should annotate when context has no fixed viewport @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-devtools.spec.ts:115 › per-part commands extract individual parts @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-save-as.spec.ts:26 › screenshot @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-save-as.spec.ts:56 › screenshot --filename infers webp from extension @mcp-windows-latest-firefox
❌ [webkit] › mcp/annotate.spec.ts:269 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest-webkit

8171 passed, 1391 skipped


Merge workflow run.

@dgozman

Copy link
Copy Markdown
Collaborator

Closing as stale.

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.

[MCP]: switch between light and dark color scheme

4 participants