A black-and-white photograph of a boy shouting into a studio microphone behind a pop filter.
Kampung in Practice · Part 3 of 3 All parts ↓

When I started this project, the Claude app on my phone could search the web in voice mode, but it could not open the pages I wanted it to read. It answered from search snippets, and even when I knew exactly which page held the answer (a Polymarket market, a stock chart, CNN’s Fear & Greed index), it could not go there and read it. Some conversations ended with me looking the number up and reading it back to my own assistant.

So I built it a browser. The first real page it opened was a CNBC live-updates page. The text came back right. The element list did not: 80 lines of navigation, “Add To Watchlist” and share buttons, then “236 more”. The page had 344 clickable elements, and the link the agent actually wanted (“17% jump in its Nasdaq debut”) was about the 12th link in the story.

Compact formatting solves only part of that. A tidy list of 344 elements is still 344 elements, and for an agent that speaks its answers, every unnecessary token adds to the wait. The harder question is which parts of a page are worth returning at all.

The tool is browser-mcp, a private MCP server I run for one user: one headless Chromium on a 2 GB Amazon Lightsail instance, added to the Claude app as a custom connector, so the voice mode on my phone can open, read and click real pages. We shipped six releases in two days, and almost every one changed what a result leaves out.

TL;DR: A browser MCP server has to decide what an agent should see, what it may act on, and what it should trust. Put story links ahead of repeated controls, return what is new after a same-page action, never offer hidden spam-trap fields, report blocked pages, and mark page text as untrusted. Then measure what you removed: a smaller response is not always a more useful one, and a faster browser can return less of the page.

Every element you return costs context, whether the agent needs it or not.


The voice agent owned the tool

The browser is not for me. I never read its output; the voice agent does. So I made the voice agent the tool’s owner, and a Claude Code session in the browser-mcp repo on my Mac its builder.

The two worked against a shared contract. The voice agent raised its needs and complaints. The coding session built a fix and shipped a release. The voice agent tested it on real sites and came back with what still broke:

The voice agent on the phone and Claude Code on the Mac exchange messages only through Kampung. Claude Code ships releases of browser-mcp, and the voice agent tests each one on real sites, so the owner's feedback reaches the builder without a person relaying it.

It started with a feature request the voice agent wrote itself: open a page, read the whole article, click and type, screenshot a chart, answer in about 5 seconds, stay read-only, and treat page text as data. Then the rounds:

  • v0.1.0 met CNBC. The text was right and the element list was noise. The agent decided what it wanted instead, which became v0.1.1.
  • Its function tests on CNBC found the search result arriving too early and every click re-sending the whole article. Those became v0.1.3.
  • Reddit blocked the server with “You’ve been blocked by network security”, and the agent asked to be told plainly when that happens. That became v0.1.5.

None of those messages went through me. They went through Kampung, the small message service I run so that agents on different machines can leave each other notes, which the Claude app on my phone can use too. Without it, I would have been the courier for all six releases: copying the agent’s complaints into the coding session, and reading release notes back to the phone.

The five rules below came out of those rounds. They cover what the agent should see (Rules 1 and 2), what it may act on (Rule 3), and what it should trust (Rules 4 and 5).


The common failure pattern

My first version worked like this:

A four-step flow: the agent calls open with a URL, the tool returns all 80 elements it lists for a page, the agent reads every one, and it needs one link from the story.

That is fine on example.com and on small forms. On a news page, a quote page, or a GitHub issue list, most of the clickable elements are furniture: menus, tabs, “Like” and “Share” on every row. All of it enters the agent’s context before it picks a link.

Other browser servers meet the same cost. In its August 2026 benchmark, the Charlotte README reports a 1,137,928-character snapshot of Wikipedia’s AI article from Playwright MCP v0.0.79. A find tool helps once the agent knows what it is looking for. Mine had just opened a page from a web search and did not know yet. It wanted the story’s links.

Why build one instead of using Playwright MCP or something like it? I needed a browser that the Claude app could reach from my phone in the middle of a voice call. Hosted options exist, such as Browserbase’s MCP server, and Playwright MCP does far more than mine. But I wanted control over what each tool call returned, how long it waited, and what the agent was allowed to do. The safety rules live inside the server: it never types a password or payment details. I built it for one specific need, not because the others are bad.


Rule 1: List the story, not the page

I call this story-first output: the default result describes the content the agent came for, and everything else is one parameter away.

Keeping only the main content region was not enough: on the CNBC live page, 280 of the 344 elements sat inside it, 115 of them buttons, mostly watchlist and share. So since v0.1.1, open, click, type, back and scroll list at most 25 elements by default, in page order:

  • text fields anywhere on the page;
  • named elements inside a dialog (a cookie wall) or a form with a text field;
  • links in the story, each name once;
  • story buttons whose name is unique there, and that do not start with “Share”.

Menus, tabs, unnamed elements and loose checkboxes are left out. When elements are omitted, elements_dropped says how many, and elements="all" brings back the full list, paged by 80. The filter changes only the returned list, so it does not invalidate IDs on the current page.

The numbers were the agent’s call: about 20 to 30 elements and a count of what was dropped. It finds pages with web search and, after an open, follows a link in the story.

Per-row controls fill the list

On a GitHub issue list, “Filter by author alice”, “Filter by author bob” and so on each have a unique name, so the uniqueness rule kept every one, and they filled the 25 slots before any issue title appeared.

The fix in v0.1.4 and v0.1.5 treats a name as per-row furniture when it repeats three times or more, or when enough distinct names share a pattern:

Pattern Example names Keyed on
leading count “968 Reactions” first three words, numbers blanked
varying last word “Filter by author alice” all but the last word
colon prefix “Copy link to the section: Pricing” the part before the colon
long shared lead “Like this comment along with 12 other people” the first four words (five names must share it)

A leading year is not a count (“2024 Annual report” stays), and a name ending in a number (“Story link 12”) is treated as a numbered list, not a control.

What the agent gets now

The original CNBC live page is gone, so I opened CNBC’s world front page with v0.1.5 instead (from my Mac, not the server). The default result listed 25 elements and reported elements_dropped: 376, so 94% of the page’s 401 elements were left out. After a markets banner and five index tickers came 14 headlines and five topic links. No watchlist or share button made the list.

Bar chart of the CNBC world front page on browser-mcp v0.1.5. The page has 401 clickable elements; the default result returns 25, including 14 headlines. 376, or 94%, are left out.

The rules are not finished. The Nvidia article on Wikipedia returned 25 of 3,375 elements, and they were the search box, the Search button, a protection notice and 22 infobox links (“Nasdaq”, “NVDA”, “Sunnyvale, California”). Not one link from the article’s body text made the cut. Finding the main content is not the same as finding the useful links inside it.

What the cut saves, and what it does not

To check the context claim, I took one fresh snapshot of each page and serialized the same open response three ways: the default, an 80-element view matching the first version’s element limit, and every element at once. The counts are characters of the whole response, page text included:

Page Default (25) First page (80) Every element
CNBC world 9,347 11,522 24,632 (401)
BBC front page 10,604 13,204 21,042 (219)
Wikipedia, Nvidia 8,858 10,535 121,769 (3,375)

Against the 80-element view, the default response is only 16 to 20% smaller, because the page text (capped at about 2,000 tokens) accounts for much of both responses. The bigger gain is in what the agent gets to read: 14 headlines on CNBC, and no watchlist or share buttons. Against a tool that sends every element, the saving is large, and on Wikipedia it is the difference between about 9,000 characters and over 120,000.


Rule 2: After a same-page action, return what is new

The voice agent’s function tests found this one. On CNBC, clicking the search button and typing “TSM” each sent the whole article back, about 8,000 characters, to report a few new lines.

Since v0.1.3, when click or type leaves the page at the same URL (a dropdown, “show more”, a dialog), the result has changed_text with only the new text blocks and the new elements, plus more_from: 0, meaning read gives the full page. If the block list is also unchanged, the result says “no visible change”. full=true returns the whole page when the agent wants it.

It reports what was added, not every change. When text disappears or reorders (a sort) without new text blocks or element IDs, the result falls back to the full page. Two cases can still mislead: text removed alongside new text shows only the new text, and an attribute-only change, such as a ticked checkbox, reports “no visible change”.

The agent chose this simple diff, comparing text blocks before and after the action rather than tracking every DOM mutation, because, for voice, robustness matters more than precision. Saving tokens must not cost it the answer, so if the before-snapshot fails, the server returns the full page.

What counts as noise also depends on the action. A menu is furniture when the agent opens an article, but when a click opens that menu, its options are the answer, so they come back with IDs even though the story filter normally drops menu items.

Wait for the answer, not for quiet

A submit taught me that “what changed” depends on when you look. The agent typed “TSM” into CNBC’s search and pressed Enter, and got “5 Quote Results” and “No results found” in the same result.

I only realized this after timing that search on the server: the article stays up for about 2.7 seconds with CNBC’s search dropdown open, then the browser navigates to the quote page, which finishes drawing at about 7.5 seconds. The settle step stopped at 1.5 seconds, before the navigation had even started. Simply raising the settle cap would not have fixed it, because the network goes quiet before the navigation begins.

So after a submit, the server now waits up to 4 seconds for a navigation to start, then settles on the new page. If nothing loads and the page is still busy, the result says “results may still be loading”.


Rule 3: Never give a spam-trap field an ID

Many forms carry a honeypot: a text field hidden from people that only bots fill in. An agent that is offered every field may fill it, and then the site can drop the submission.

Since v0.1.4, a text field that is off the page, transparent, too small or marked aria-hidden gets no ID. If the agent names it anyway, type refuses with “it looks like a spam trap (honeypot); leave it empty”.

The other guards cover what the agent may send: no password, one-time-code or payment fields, and no write-method form submits unless a site is marked write = true in policy.toml. Allowing GET searches is a conservative default, not a guarantee that every GET request is read-only.


Rule 4: Say plainly when the site blocks you

An agent that cannot tell a block page from content may summarize the block, the failure behind the Cloudflare 403 problem in AI agent web tools.

Reddit started this one: from the server, it answered with “You’ve been blocked by network security”. From the same Singapore Lightsail address, Reuters and WSJ returned 401, AP served a Cloudflare challenge, and Kalshi returned a 429 from a Vercel checkpoint. The New York Times was worse: it served the article once, then a 49-character bot page on every visit after.

Since v0.1.5, open reports this as blocked: {kind, hint}, with kind set to bot_check, network_block or login_wall. Each hint is a sentence the agent can say aloud (“the site wants a sign-in, and I never type credentials”). When some real content rendered under the block, the report becomes blocked: {kind, hint, partial: true}. The tool never tries to get past a block. For a voice agent, “that site blocks me” is a correct answer.


Rule 5: Mark page text as untrusted

Page text, titles and element labels arrive inside <untrusted-page-content> tags, and the server instructions say that content is data, never instructions. The wrapper strips any copy of the tag from the text first, repeatedly, so a page cannot close the boundary early by printing a closing tag of its own.

The element list is inside the boundary too, because a link’s name is page text. The boundary is a signal to the model, not a guarantee that it will ignore an instruction inside a page. It is the same trust problem as hidden-text prompt injection in PDFs, met at a different layer.


A faster browser can return a worse answer

Speed is the other half of a voice reply, and two of my speed optimizations also removed content I needed.

These are tuning experiments from before v0.1.0: 10 mixed sites (Wikipedia, Hacker News, BBC, the Guardian, CNBC, a Yahoo quote, a Google Finance quote, Polymarket, TradingView and NVIDIA investor relations), opened on the 2 GB instance in 3 alternating rounds, comparing open time and the length of the text returned.

Ad and tracker blocking refuses requests to about 76,000 known ad and tracker hosts:

Bar chart of open time over 30 opens per setting. With ad blocking, the median falls from 5.29 to 4.30 seconds and the 90th percentile from 22.4 to 10.5 seconds, 53% lower.

The median fell 19%, but the p90 matters more for voice, where a long silence is what the user notices: the 90th-percentile open time fell from 22.4 s to 10.5 s, less than half. The cost: NVIDIA’s investor relations page lost about 560 of its 4,300 characters (13%) on every blocked run, because one of the blocked hosts serves real content. That is why policy.toml takes adblock = false per site.

The settle cap is how long the server waits for the page to go quiet. Ad blocking was enabled in all three configurations, and the 3.0 s cap is the reference:

Bar chart of the settle cap trade-off. Median and 90th-percentile open time: 4.10 and 10.95 seconds at a 3.0 s cap, 3.29 and 7.85 at 1.5 s (the chosen cap), 2.67 and 6.91 at 1.0 s. Compared with the 3.0 s cap, TradingView keeps 57% of its text at 1.5 s and Google Finance keeps 49% at 1.0 s.

I picked 1.5 seconds because it was the fastest tested cap that preserved the quote-page text. The 3.0 second cap added 0.8 seconds at the median and 3.1 seconds at the 90th percentile. At 1.0 seconds the loss reaches Google Finance, a quote page the agent reads as text, and half of it is gone; NVIDIA’s investor relations page is trimmed too. TradingView does lose text at 1.5 seconds, but it is a chart page, and charts are read through screenshot, which waits up to 3 seconds. A faster median that hands the agent half a quote page is a wrong answer delivered sooner.

One caveat that cuts against me: these are 3 rounds on one box, run by me, against live sites. Hacker News returned 128 characters in 2 of the 3 blocked runs, probably rate limiting since the blocked run always went second, but I cannot rule out the ad blocker. The Rule 1 checks are single runs from a Mac, counted in characters, not tokens. I have not run Playwright MCP on the same sites, so this post makes no claim about which tool is faster or smaller.


Return the story, then measure what you cut

Most browser tools are built to expose what is on a page. A browser for an AI agent also has to decide what is worth exposing.

The opening problem is gone, at least on pages that let the server in. In a voice call, the agent now opens CNN’s Fear & Greed index and reads me the number, its history and all seven indicators from one page, instead of me looking it up and reading it back.

Story-first output makes the default far more useful on CNBC, and Wikipedia shows how much the filter can still miss. Neither removes the need to check it: these defaults grew out of the voice agent’s own failures on real pages, and two of the speed wins quietly removed the text they were supposed to deliver faster.

Decide what the agent should see, then measure what that decision throws away.

mcp ai-agents llm
Kevin Tan

Kevin Tan

Cloud Solutions Architect and Engineering Leader based in Singapore. I write about AWS, distributed systems, and building reliable software at scale.