Skip to main content
Glama
Playwright Report MCP

Playwright Report MCP

by nora-weisser

Playwright Report MCP

一个 MCP 服务器,将 Playwright JSON 测试报告以工具的形式提供给 LLM 智能体。

环境要求

  • Python >= 3.10

  • uv(brew install uv 或 curl -LsSf https://astral.sh/uv/install.sh | sh)

  • Node.js + npx — 仅用于 mcp dev,它会启动 MCP Inspector

Related MCP server: QA Copilot MCP Server

1. 安装依赖

从仓库根目录:

uv sync

这会创建 .venv/,并以可编辑模式安装项目。下面的所有命令都通过 uv run 运行,因此你无需手动激活 venv。

2. 生成 Playwright JSON 报告

服务器读取由 json 报告器生成的 Playwright 报告。在你的 Playwright 项目中:

npx playwright test --reporter=json > results.json

或者将其永久配置在 playwright.config.ts 中:

export default defineConfig({
  reporter: [['json', { outputFile: 'results.json' }]],
});

该文件必须包含标准顶层键 config、suites、errors、stats。

如果你只是想试用服务器,仓库中附带了一份示例报告 results.json。

3. 配置报告路径

在仓库根目录创建一个指向该报告的 .env 文件(建议使用绝对路径):

REPORT_PATH=/absolute/path/to/results.json

如果要改用附带的示例报告:

REPORT_PATH=/absolute/path/to/playwright-test-analysis-mcp/src/playwright_report_mcp/results.json

REPORT_PATH 在每次工具调用时都会被读取,因此你无需重启服务器即可重新生成报告。如果未设置,工具调用将失败并提示 REPORT_PATH environment variable is not set.

4. 运行服务器

交互式开发(MCP Inspector)

uv run mcp dev src/playwright_report_mcp/server.py

会在你的浏览器中打开 MCP Inspector,让你可以手动列出并调用工具。需要 npx。

纯 stdio 服务器

uv run playwright-report-mcp

或者,等价地:

uv run mcp run src/playwright_report_mcp/server.py

通过 stdin/stdout 以 MCP 协议进行通信。适合接入 MCP 客户端,或用于快速冒烟测试:

printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"t","version":"1"}}}\n' \
  | uv run playwright-report-mcp

你应该会收到一个 JSON-RPC 结果,其中包含 "serverInfo":{"name":"Playwright Report",...}。

将其连接到客户端

将服务器注册到 Claude Desktop:

uv run mcp install src/playwright_report_mcp/server.py

或者手动将其添加到 MCP 客户端配置中(例如 claude_desktop_config.json):

{
  "mcpServers": {
    "playwright-report": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/playwright-test-analysis-mcp",
        "run",
        "playwright-report-mcp"
      ]
    }
  }
}

--directory 很重要:它使 uv 能够解析此项目的 venv,并让 load_dotenv() 找到 .env 文件。

工具

工具

描述

get_test_summary

最近一次运行的摘要:start_time、duration_ms、passed、failed、skipped、flaky。

get_failures

失败测试的列表,每项包含 title、file、status 和第一条 error 消息。

运行测试

pytest 和 pytest-asyncio 已安装,但仓库中还没有测试文件,因此目前会收集到 0 个测试:

uv run pytest

故障排除

症状

解决方法

REPORT_PATH environment variable is not set.

在仓库根目录创建 .env,或在启动服务器的 shell 中导出 REPORT_PATH。

工具调用时出现 FileNotFoundError

REPORT_PATH 指向的文件不存在——请使用绝对路径。

KeyError: 'stats'

该 JSON 不是 Playwright json 报告器生成的报告(例如它是 HTML 报告或原始数据块)。

mcp dev 启动失败

安装 Node.js 以确保 npx 可用,或改用 mcp run。

Available Tools

2 tools
get_failuresA

Return failed tests of the latest Playwright test run.

NameRequiredDescriptionDefault

No parameters

Output Schema

NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It conveys read-only behavior via 'Return' and adds the useful 'latest run' scope, but it does not disclose behavior such as how empty results are handled or whether failures are ordered or grouped. These gaps are minor for a simple parameterless read and are partly covered by the output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence that front-loads the action and object and contains no filler. Every word contributes to selection and invocation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the zero-parameter complexity and the presence of an output schema, the description is nearly complete for correct tool selection and invocation. The only material gap is the lack of any interaction with the sibling get_test_summary, but that is a usage-guidance concern rather than a completeness failure for this simple read.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so there is no parameter semantics burden for the description to carry. The baseline of 4 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a clear action ('Return'), a precise resource ('failed tests'), and a scoping qualifier ('latest Playwright test run'). It effectively distinguishes itself from get_test_summary by focusing on failures rather than a summary.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives no explicit guidance about when to use this tool versus get_test_summary. It implies only that results are scoped to the latest run, but does not state when to prefer failures over a summary or whether get_test_summary is the alternative for successful tests.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_test_summaryA

Return summary of the latest Playwright test run.

NameRequiredDescriptionDefault

No parameters

Output Schema

NameRequiredDescription
flakyYes
failedYes
passedYes
skippedYes
start_timeYes
duration_msYes

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the behavioral disclosure burden. The word 'Return' suggests a read-only operation, but the description does not mention what happens when no test run exists, whether the summary is limited by filters, or any side effects. This is minimally adequate but lacks richer behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, compact sentence that front-loads the action ('Return') and the object ('summary') with no filler or unnecessary detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter retrieval tool, the description is sufficiently complete: the resource is identified, the action is clear, and the presence of an output schema covers return-value details. The main gap is lack of usage guidance relative to the sibling, but that is a separate dimension.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the input schema is trivially complete. The description does not need to explain parameter semantics, and the baseline of 4 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Return') and the resource ('summary of the latest Playwright test run'). It distinguishes from the sibling 'get_failures' by focusing on the overall summary rather than failures, but it does not explicitly name or contrast the sibling.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this tool versus 'get_failures' or any other alternative. The description implies it is for retrieving a summary, but it does not state exclusion criteria, prerequisites, or when another tool would be preferable.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv0.1.0
    • First observedget_failures
    • First observedget_test_summary

TDQS

A3.8/5.0

Scored across 2 tools

Disambiguation5/5

get_failures and get_test_summary have clearly distinct purposes: one retrieves only failed tests, the other an aggregate summary. There is no overlap or ambiguity between them.

Naming Consistency5/5

Both tools follow a consistent get_[noun] pattern, making the naming predictable and easy to infer. The convention is uniform across the entire set.

Tool Count3/5

With only two tools, the set is on the thin side and falls into the borderline range. The tools are focused and justified, but the count is minimal for a server that could reasonably include more report-oriented operations.

Completeness4/5

For a server scoped to the latest Playwright test run, get_failures and get_test_summary cover the primary reporting needs. Minor gaps exist—such as retrieving test details or run history—but they do not create dead ends for the core use case.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers