Skip to main content
Glama

test-data-mcp

CI MCP Playwright

Fresh, isolated test data on request, for Playwright tests and AI agents.

Ask for "a user with 2 items in the cart and an expired card" and get one in milliseconds, built through an API instead of clicking through the UI, with its own unique login and automatic cleanup.

A learning project: how an MCP server works inside, and why test data is the quiet cause of slow and flaky UI tests. It includes its own small demo shop to test against, so everything runs locally.

How it fits together

flowchart LR
    T["Playwright test<br/>makeUser({ cart, card })"] --> C
    A["AI agent<br/>(Claude Code)"] -- "MCP over stdio" --> M["MCP server<br/>tools · resources · prompt"]
    M --> C["TestDataClient<br/>unique · tagged · safe host"]
    C -- "HTTP + admin key" --> S["Practice Shop<br/>test data API"]
    T -- "browser" --> S

One library builds the data. Tests call it directly through fixtures; agents call it through the MCP server. Either way the data is built the same way.

Related MCP server: tuxedo-qa

What it proves

All measured in this repo (e2e/why-test-data.spec.ts):

Experiment

Result

Build a 3-item cart through the API vs the UI

3 ms vs 447 ms

14 UI tests × 3 repeats on 4 parallel workers, one fresh user each

42 / 42 passed, 0 users left behind

The same cart tests sharing one login

4 / 4 failed: they saw each other's items

Quick start

npm install
npx playwright install chromium   # once
npm test                          # library + MCP server tests, then the UI tests

Playwright starts the shop for the UI tests itself. To explore by hand: npm run app, then open http://127.0.0.1:3100 and log in as demo / demo123.

Use it from Claude Code

The repo's .mcp.json registers the server. Start the shop (npm run app), open Claude Code in the repo, approve the test-data server, then try:

Create a test user with a backpack and two coffee mugs in the cart and an expired card, then tell me what happens at checkout.

The agent calls create_test_user, logs in with the credentials it got back, and can clean up with cleanup_test_data. To poke at the server without an agent, run npm run inspect (the official MCP Inspector).

In a test

import { test, expect } from './fixtures.ts';

test('an expired card is declined and the cart is kept', async ({ page, makeUser, loginAs }) => {
  const shopper = await makeUser({ card: 'expired', cart: ['t-shirt'] }); // ~3 ms, through the API
  await loginAs(shopper);
  await page.getByTestId('nav-cart').click();
  await page.getByTestId('checkout').click();
  await expect(page.getByTestId('error')).toHaveText('Payment declined: card ending 4242 has expired.');
}); // shopper is deleted automatically, pass or fail

What the MCP server offers

Kind

Name

What it does

Tool

create_test_user

A unique user, optionally locked, with an expired card, a cart and past orders. Returns the login

Tool

add_to_cart, create_order

Add to an existing test user

Tool

get_test_user, list_test_data

Read-only lookups

Tool

cleanup_test_data

Delete this session's test data (or every run's). Marked destructive

Resource

test-data://products, test-data://guide

The product catalogue, and the rules for using test data

Prompt

test_with_fresh_data

"Write a Playwright test for scenario", with the right setup steps

Safety rules built in

  • Unique: every username is label_run_counter, so parallel tests never share data.

  • Tagged: everything created carries test-data, run:<id> and owner:<who>. Cleanup deletes only those, never real or seed users. A global teardown catches anything a crashed test left.

  • Safe host: it refuses any host except localhost unless you add it to TEST_DATA_ALLOWED_HOSTS. Test data tools must never point at production.

  • Admin key: the shop's test data API needs the x-admin-key header (ADMIN_KEY).

Project layout

Path

What

demo-app/

Practice Shop: UI, customer API and test data API (Node's http, no framework)

src/core/test-data.ts

The test data library: recipes, unique names, tags, cleanup, host check

src/mcp/server.ts

The MCP server: tools, resources and a prompt over stdio

e2e/

Playwright fixtures (user, makeUser, loginAs) and UI tests

test/

Library tests, and MCP tests that drive the server with the official MCP client

Learn more: docs/HOW-IT-WORKS.md walks through a real MCP exchange, the design choices, and exercises to try.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to create, run, autocorrect, and monitor Playwright tests for your app with a local dashboard, credential vault, and public status page.
      16
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables AI assistants to create, sanitize, and manage disposable Hypernode Brancher preview environments cloned from production, with automatic PII anonymization, credential reset, and sandbox-forcing before any access URL is revealed.
      7
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to use isolated, persistent Chromium profiles with real WebAuthn passkeys, and provides Playwright MCP tools for browser automation with exclusive per-agent access.
      1
      MIT