Skip to main content
Glama

playwright-pom-mcp

An MCP server that generates functional Page Object Models from live Playwright accessibility snapshots. Navigate your browser to any page state — including behind a login — and get a ready-to-use .page.ts file back.

Installation

npm install -g @blastoiseomg/playwright-pom-mcp
npx playwright install chromium

Chromium is required for browser capture. Run it once after installing.

Related MCP server: Fast Playwright MCP

MCP server

Claude Code

claude mcp add -e ANTHROPIC_API_KEY=sk-ant-... playwright-pom-mcp -- playwright-pom-mcp

Or add manually to ~/.claude/settings.json:

{
  "mcpServers": {
    "playwright-pom-mcp": {
      "command": "playwright-pom-mcp",
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-..."
      }
    }
  }
}

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "playwright-pom-mcp": {
      "command": "playwright-pom-mcp",
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-..."
      }
    }
  }
}

Without global install (npx)

{
  "mcpServers": {
    "playwright-pom-mcp": {
      "command": "npx",
      "args": ["-y", "@blastoiseomg/playwright-pom-mcp"],
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-..."
      }
    }
  }
}

Tools

Tool

Description

generate_pom

Snapshot a page and generate a new POM TypeScript file

CLI

An interactive CLI is included alongside the MCP server. It opens a real (headed) browser, lets you navigate to any page state, and drives POM generation from your terminal.

pom-gen                                      # fully interactive
pom-gen https://example.com -n home -o poms  # with arguments

Options

Flag

Description

Default

[url]

URL to open (paste in browser if omitted)

about:blank

-n, --name <name>

Page name

prompted

-o, --output <dir>

Output directory

prompted (default poms)

--class

Generate a class-based POM instead of factory function style

—

Interactive menu actions

Action

Description

Capture ARIA snapshot & generate POM

Snapshots the current page and generates (or overwrites) the .page.ts file

Navigate to a different URL

Navigates the browser to a new URL and updates the page name

Exit

Closes the browser and exits

Environment variables

Variable

Required

Default

Description

ANTHROPIC_API_KEY

Yes

—

Anthropic API key

ANTHROPIC_MODEL

No

claude-sonnet-4-6

Model to use for POM generation

How it works

MCP tools:

  1. generate_pom — launches Chromium (headless by default, headed when waitForUrl is set), navigates to the URL, captures page.locator('body').ariaSnapshot(), sends the YAML to Claude with a system prompt enforcing functional POM conventions, and writes the result to disk.

CLI (pom-gen):

Runs a headed browser session you control. On startup, prompts for page name and output directory if not supplied as flags. The interactive menu lets you:

  • Capture — take an ARIA snapshot of the current browser state and generate a new POM

  • Navigate — send the browser to a new URL and optionally rename the current page

Generated POMs follow these conventions:

  • Factory function pattern: createCheckoutPage(page: Page) (default)

  • Class pattern: CheckoutPage with readonly locator properties (with --class)

  • locators object with semantic locators (getByRole, getByLabel, etc.)

  • All action methods are async and return Promise<void>

Development

git clone https://github.com/vincenzo-gasparo/playwright-pom-mcp.git
cd playwright-pom-mcp
pnpm install
npx playwright install chromium
export ANTHROPIC_API_KEY="sk-ant-..."
pnpm build

Command

Description

pnpm build

Compile TypeScript to dist/

pnpm dev

Run MCP server with tsx (no build needed)

pnpm dev:cli

Run interactive CLI with tsx (no build needed)

pnpm test

Run unit tests

Testing with MCP Inspector

npx @modelcontextprotocol/inspector node dist/index.js

Open http://localhost:5173, select generate_pom, and try:

{
  "url": "https://playwright.dev",
  "name": "home",
  "outputDir": "./out"
}

Available Tools

1 tool
generate_pomGenerate POMA

Generate a functional Page Object Model TypeScript file from a live Playwright accessibility snapshot. Optionally launches a headed browser so you can log in or navigate to the desired state first.

Inputs: url (required), name (required), outputDir (required), style, +2 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 1 tool

    Disambiguation5/5

    There is only one tool, so there is no possibility of confusion or misselection. Its purpose (generate a POM TypeScript file from a live accessibility snapshot) is stated explicitly and unambiguously.

    Naming Consistency5/5

    The single tool follows a clear verb_noun snake_case convention (generate_pom). With only one name there are no deviations or mixed conventions to worry about.

    Tool Count3/5

    A one-tool server is thin even for a narrow purpose; generation is the core operation but the surface offers no supporting operations. The count is defensible for a focused generator, but it sits at the borderline of 'too few.'

    Completeness3/5

    The generate step is covered, but there is no way to list existing POMs, update/append methods to an existing page object, or validate regenerated files against a live snapshot. Agents can work around this by regenerating, but lifecycle coverage is partial.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables browser automation and web interaction through structured accessibility snapshots using Playwright. Provides fast, deterministic web page interaction without requiring screenshots or vision models.
      10,706,557 npm
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables token-optimized browser automation with Playwright, featuring batch execution, diff detection, and advanced filtering to reduce token usage by 70-95% while providing LLM-friendly structured accessibility snapshots instead of screenshots.
      3,821 npm
      40
      Apache 2.0
    • A
      license
      A
      quality
      Not graded
      maintenance
      Enables browser automation through Playwright using accessibility tree snapshots instead of screenshots. Supports web scraping, form interactions, testing, and connecting to existing browser sessions with logged-in accounts.
      23
      8,303 npm
      5
      -
    • A
      license
      A
      quality
      B
      maintenance
      Drives a real Chromium browser to extract a page's DOM into compact Semantic JSON with Playwright-native locators, enabling AI agents to generate consistent, accurate Playwright tests.
      13
      25 npm
      3
      MIT