FDE Times dataFDE jobs open 932▼14 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 62Companies hiring 202Remote-friendly 24%Median US pay $201kTop hirer Databricks 92
中文VI

The newspaper of the Forward Deployed Engineer

Guides

Let agents work legacy web apps, but keep the Save button human

Playwright MCP lets an agent read internal pages that have no API, while people keep control of the login session and every write.

ShareLinkedInFacebookX

In brief

  • Playwright MCP reads an accessibility snapshot, so the agent clicks by ref, such as e5, and does not guess coordinates on a screenshot.
  • --allowed-origins is not a security boundary; the real protection is a human approving tool calls and a log for audit.
  • Use MCP to explore; once the workflow is stable, record it as a script with codegen, because MCP uses far more tokens.
In a third-party benchmark, the same task cost about 114,000 tokens via Playwright MCP and about 27,000 tokens via Playwright CLI. Two horizontal bars are drawn to scale. In the article's hypothetical calculation, at 50 orders a day consumption is 5,700,000 tokens versus 1,350,000 tokens.
Once a workflow is stable, move from MCP to a script or CLI. The figures depend on configuration, so treat them as indicative only. The 50-orders-a-day figure is a hypothetical calculation in the article. Source: a third-party benchmark, not part of the official Playwright documentation.

Microsoft’s Playwright MCP gives an LLM control of a browser without a screenshot or a vision model. It is an MCP server built on Playwright, and it works from a structured accessibility snapshot of the page.

That makes it a practical answer to a situation FDEs should be ready for before they sit down with a client: the operations team wants an agent to update order statuses, but the internal system was written years ago, has only a web interface and offers no API.

This guide covers five steps, applied to a hypothetical case: an agent logs in to an internal order management site, fills in a status update form and clicks “Save” only when a person approves. You need Node.js, Playwright installed, a client that supports MCP and a web app to try it on. If you have no real internal app, a demo running locally will do.

Step 1: The login session is your most sensitive asset

The agent should not type a password on every run. Playwright recommends saving the login state to a file for reuse, placing that file in the playwright/.auth directory and adding the directory to .gitignore.

mkdir -p playwright/.auth
echo "playwright/.auth" >> .gitignore
git status   # the .auth directory must not appear here

The reason is in Playwright’s own documentation: the authentication state file contains sensitive information, and the docs strongly discourage committing it to a repo, even a private one. At a client, this file usually holds the session cookie of a real employee. If the file leaks, so does that person’s access.

Check after this step: run git status and make sure no file in .auth shows up. To create the state file, follow the Authentication page in the Playwright documentation.

Step 2: Launch the server with the session preloaded

Playwright MCP has a --storage-state option that loads a login session into an isolated session, so the agent is already signed in when it opens the browser. The snippet below illustrates only the flags; take the exact launch command and client configuration syntax from the README of the microsoft/playwright-mcp repo.

# Illustrative and simplified: replace <launch command> per the README
<Playwright MCP launch command> \
  --storage-state playwright/.auth/user.json \
  --allowed-origins https://orders.internal.example

The --allowed-origins flag limits the origins the browser may request, which makes it harder for the agent to wander off to other sites. But the README says plainly that the flag is not a security boundary. Treating it as your only safeguard is a design error.

Step 3: The agent reads a snapshot instead of guessing coordinates

When the agent opens a page, it receives a snapshot describing the element tree. Each element has a ref, such as e5, which the agent uses in subsequent tool calls. The Playwright documentation sums it up: no screenshots, no guessing at coordinates.

# Illustrative snapshot, abridged
- textbox "Order ID" [ref=e5]
- combobox "Status" [ref=e7]
- button "Save" [ref=e9]

For an old internal app, the difference is large. A vision model has to guess which pixel the “Save” button sits on; with a snapshot, the agent only has to say “fill e5, select e7, click e9”. When the interface shifts by a few pixels, working by ref still holds.

Check after this step: have the agent list the form’s refs before it does anything. If the snapshot is missing names, for example an input with no label, you have found the reason the agent will pick the wrong element. Note it down to report to the client’s team.

Step 4: The real safeguard is a person

As step 2 showed, --allowed-origins is not enough of a barrier. The MCP specification says where the barrier should be: there should always be a human in the loop, with the ability to deny tool calls. It also recommends that clients ask for confirmation before sensitive operations and keep logs for audit.

In the order example, reading the snapshot and filling in fields can be left to the agent. Clicking e9 (“Save”) changes real data, so the agent must stop and wait for approval. One rule is easy to apply: any action that cannot be undone requires confirmation, and every tool call is logged with its ref and the value entered.

Step 5: Explore with MCP, run daily with a script

The official documentation places MCP with specialized agentic loops and exploratory automation. The price is tokens: tool schemas and snapshots both sit in the context. For coding agents such as Claude Code or Copilot working in large codebases, Playwright recommends the CLI.

A third-party benchmark, which is not part of the official documentation, found that the same task used about 114,000 tokens through MCP and about 27,000 through the Playwright CLI.

The figures depend on configuration and should be treated only as a reference. Still, assume that each order update costs the same as the benchmark task: an agent updating 50 orders a day would use 5,700,000 tokens instead of 1,350,000.

So once the workflow is clear, settle it as a script. Playwright codegen records your actions and favors locators by role, text and test id.

To do this, start codegen and repeat by hand the same steps the agent went through. Codegen records them and returns a script that is easy to review. It does not convert refs such as e5; the locators it generates by role, text and test id take their place in the script.

Stage Sensible tool Why
Workflow not yet understood, unfamiliar interface Playwright MCP The agent reads snapshots and experiments on its own
Workflow clear, run repeatedly Codegen script or CLI Fewer tokens, stable, easy to review

The most common mistakes

The first mistake is committing the login state file, usually because nobody updated .gitignore before creating it. The second is trusting --allowed-origins to be safe enough and skipping confirmation. The third is leaving MCP running indefinitely on a workflow that has already stabilized, then being surprised by the token bill.

A less visible problem lies in the interface itself. A snapshot is only good when the page has clear accessibility labels. Faced with a form full of unnamed fields, resist writing a longer prompt. Suggest that the client add labels or test ids, a small change that helps both the agent and the codegen script.

How this skill shows up on a CV

When an FDE job description mentions phrases such as “legacy systems”, “internal tools”, “browser automation” or “human-in-the-loop”, that is the place to bring up this skill. On your CV, go further than “used Playwright MCP”.

Tell the whole sequence: you automated a system with no API, kept the login session out of the repo, put an approval step on data writes, then moved to a script to cut costs.

On your first day with a client, start by sitting next to the operator and noting which actions they can undo and which they cannot. That list will decide where you put the confirmation steps, and it often matters more than any prompt you write for the agent.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
6 sources
Read next on the roadmap · Stage 2: Broad engineeringWhy “Nguyễn Thị Huệ” doesn’t equal “Nguyễn Thị Huệ” in your joinUnicode lets one Vietnamese letter be stored two ways, and without normalising first, the join drops customers without raising an error.