Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(mcp): add experimental MCP interface to test server #35312

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Mar 21, 2025

No description provided.

@Skn0tt Skn0tt requested review from pavelfeldman and Copilot March 21, 2025 09:35
@Skn0tt Skn0tt self-assigned this Mar 21, 2025
@@ -36,3 +36,12 @@ export const chokidar = chokidarLibrary;

import * as getEastAsianWidthLibrary from 'get-east-asian-width';
export const getEastAsianWidth = getEastAsianWidthLibrary;

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
Copy link
Member Author

@Skn0tt Skn0tt Mar 21, 2025

Choose a reason for hiding this comment

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

This grows the utils bundle from 200kb to 300kb. If that's too much, I guess we could write our own implementation. Not sure if that's worth it though.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an experimental MCP interface for the test server, adding support for MCP-based tools in both the test harness and the server.

  • Adds integration tests for MCP functionality in Playwright tests.
  • Implements MCP server functionality with tool registration for listing and running tests.
  • Updates common fixtures and utility bundles to support MCP client and server components.

Reviewed Changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/playwright-test/ui-mode-mcp.spec.ts Adds integration tests that leverage the experimental MCP interface.
packages/playwright/src/runner/mcp.ts Introduces MCP server functionality with tool registration (“listTests” and “runTests”).
tests/config/commonFixtures.ts Implements an attachMCP function to support MCP in test processes.
packages/playwright/src/utilsBundle.ts Exports MCP-related utilities and types.
packages/playwright/bundles/utils/src/utilsBundleImpl.ts Re-exports MCP server components and zod schema validation.
packages/playwright/src/runner/testServer.ts Starts the MCP server when the PW_MCP flag is set.
Files not reviewed (2)
  • package.json: Language not supported
  • packages/playwright/bundles/utils/package.json: Language not supported

try {
const parsed = JSON.parse(message);
transport.onmessage?.(parsed);
} catch {}
Copy link
Preview

Copilot AI Mar 21, 2025

Choose a reason for hiding this comment

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

Swallowing errors in the JSON.parse block may hinder debugging issues with incoming messages. Consider logging the error or providing a minimal handling mechanism to help diagnose malformed input.

Suggested change
} catch {}
} catch (error) {
console.error('Failed to parse message:', message, error);
}

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

Test results for "tests 1"

5 flaky ⚠️ [chromium-page] › tests/page/page-request-continue.spec.ts:72:3 › should delete header with undefined value @chromium-ubuntu-22.04-node18
⚠️ [chromium-page] › tests/page/page-request-continue.spec.ts:72:3 › should delete header with undefined value @chromium-ubuntu-22.04-node22
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:403:3 › should throw for too deep reference chain @firefox-ubuntu-22.04-node18
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-test.spec.ts:99:5 › should generate routeFromHAR with --save-har @ubuntu-22.04-chromium-tip-of-tree
⚠️ [webkit-page] › tests/page/page-screenshot.spec.ts:345:5 › page screenshot › should work while navigating @webkit-ubuntu-22.04-node18

38822 passed, 809 skipped
✔️✔️✔️

Merge workflow run.

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.

1 participant