Agent tools
Read a page with Browser MCP
An agent can read a page by calling browser tools over the Model Context Protocol. This lab plays a recorded trace of those calls. The question stays on the page.
Understanding the labHow to use it and why you'd want to
Why you'd want to
You want an agent that can read a page and show the tool it called. The question should stay here, and the browser should stay on this site.
How to use it
- Accept, then press Next through the example.
- Watch the example tool calls, the snapshot, and the answer.
- Open a source link. It is a page on this site.
- Open How we built it for the code and the event map.
WalkthroughHow we built itShowHide
Example vendor setup is marked below. eVar and event numbers are examples. This lab does not call Adobe.
The Browser MCP lab plays a recorded tool trace for a question about this site. Navigation stays on this origin, the tools are read-only, and the question is not logged. After Accept it queues mcp_question_asked, mcp_tool_called, and mcp_answer_shown. The lab does not call Adobe.
Choose a recorded trace
pickTrace matches dataLayer or measurement words and returns a fixed trace. The question is not copied into the trace and it is not written to a log.
Stay on this origin
isAllowedNavigation accepts only this site’s origin, and only a lab path or the home page. A username, a password, or another host returns false. traceIsReadOnly also rejects a submit.
Cap the route
allowMcp stops the ninth request from one IP inside ten minutes on that instance. The response is rate_limited and does not include the question. A firewall rule in front is the durable cap.
Play the calls, then the answer
The panel reveals each tool call, then the trimmed accessibility snapshot, then the answer and its source links. Reduced motion shows the steps without the wait. The page does not launch a browser.
Queue the tool name only
After Accept, demonstrateEvent sends mcp_question_asked with no parameters, mcp_tool_called with the tool name, and mcp_answer_shown with no answer text. Consent off skips the route and the events.
From the code
Only this origin, and only a lab path or the home page.
export function isAllowedNavigation(value: string) {
try {
const url = new URL(value)
if (url.origin !== SITE_ORIGIN) return false
if (url.username || url.password) return false
if (!url.pathname.startsWith("/")) return false
return url.pathname === "/" || url.pathname.startsWith("/lab") || url.pathname.startsWith("/es")
} catch {
return false
}
}The cap runs first. The question selects a trace and is not returned.
export async function POST(request: NextRequest) {
if (!allowMcp(mcpClientIp(request.headers))) {
return json({ error: "rate_limited" }, 429)
}
let body: unknown
try {
body = await request.json()
} catch {
return json({ error: "invalid_json" }, 400)
}
const record = body && typeof body === "object" ? (body as Record<string, unknown>) : {}
const question = typeof record.question === "string" ? record.question.replace(/\s+/g, " ").trim().slice(0, 240) : ""
if (!question) return json({ error: "empty" }, 400)
const trace = pickTrace(question)
if (!traceIsReadOnly(trace)) return json({ error: "trace_rejected" }, 500)
return json(publicTrace(trace))Each revealed tool queues its name. The answer event carries no text.
for (let index = 0; index < payload.tools.length; index += 1) {
await wait(700)
setShown(index + 1)
demonstrateEvent("mcp_tool_called", { tool: payload.tools[index]?.tool ?? "" })
}
await wait(400)
setAnswerOn(true)
demonstrateEvent("mcp_answer_shown", {})Google and Adobe
Google queues mcp_tool_called after Accept. Adobe is an example of the same fields.
After Accept, this lab queues mcp_question_asked with no parameters, then mcp_tool_called with the tool name only, then mcp_answer_shown with no answer text. Arguments, the snapshot, and the question stay on the page. Register tool as an event-scoped custom dimension. This site does not call gtag('set') or Adobe.
Simplified shape of the object queued after Accept. Register any new parameter as an event-scoped custom dimension. This site does not call gtag('set').
dataLayer.push({
event: "mcp_tool_called",
tool: "browser_snapshot",
})Example implementation. This site does not call Adobe. eVar118, prop118, and event118 are example variable numbers. In Launch, a data element reads the value and a rule sends it when the value changes. In the report suite, enable eVar118 with Most Recent allocation and expire it on the hit. A processing rule is unnecessary if the data element maps straight to that eVar.
Example alloy payload. _example is a placeholder schema, not a real tenant.
alloy("sendEvent", {
xdm: {
eventType: "web.webinteraction.linkClicks",
_example: {
mcpTool: "browser_snapshot",
},
},
})Example hit. eVar118 is hit-scoped in this example. prop118 dies at the same hit.
s.eVar118 = "browser_snapshot"
s.prop118 = "browser_snapshot"
s.events = "event118"
s.linkTrackVars = "eVar118,prop118,events"
s.linkTrackEvents = "event118"
s.tl(true, "o", "mcp_tool_called")Translation
Each lab field, the GA4 name, and the example Adobe variable. Scope is the part that usually gets lost in the translation.
Question asked
GA4. Event mcp_question_asked after Accept. No parameters. The question text is not sent.
Adobe. Example event118. This site does not call Adobe. Do not put the question in an eVar.
Scope. Event. A user property would remember that a question was asked.
Tool called
GA4. Event mcp_tool_called. Parameter tool is browser_navigate, browser_snapshot, browser_click, or browser_evaluate. Arguments are not sent.
Adobe. Example eVar118 for the tool name, Most Recent, expire on the hit. This site does not call Adobe.
Scope. Event. A user property would keep the last tool after the next call.
Answer shown
GA4. Event mcp_answer_shown after the example answer is on the page. No answer text.
Adobe. Example event118. This site does not call Adobe. Do not put the answer in a prop.
Scope. Event. It records that an answer was shown, not what it said.
Navigation URL
GA4. Not a parameter. The example URL is checked against this origin and then shown on the page.
Adobe. Example prop118. Not sent. This site does not call Adobe.
Scope. Page copy. It is not an event parameter and not a user property.
Example trace
Accept measurement to record the step. The example still moves. Nothing is pushed before Accept.
Ask
Example trace. The question stays on this page. The recorded call is browser_navigate to /lab.
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": { "name": "browser_navigate", "arguments": { "url": "https://www.blackboxpersonalization.com/lab" } }
}Response
Move forward to see this result.
Client, server, tools
- The client is the agent. It asks the server which tools exist, then calls one tool at a time.
- The server is the browser adapter. It exposes a tools list and runs a tool call.
- A tool call is a JSON-RPC request with a name and arguments. The tool result is the next message.
Safety
- Navigation stays on this site’s origin. Any other host is rejected.
- The tool list is read-only: navigate, snapshot, click a link, and evaluate a read. There is no form submit.
- The route allows eight requests from one IP in ten minutes on that instance. A firewall rule is the durable cap.
- Accept comes first. The question is not logged and is not a parameter of the events.
Two ways to run it
This page uses recorded traces. A live browser is a later choice, not what visitors run here. The figures below are a planning estimate, not an invoice.
Recorded trace
A short function returns JSON. No Chromium, no model call, and the tool list cannot leave this origin. Cost stays at a fraction of a cent per question, mostly the function invocation.
Live Playwright MCP
A Vercel Sandbox or a large function would start Chromium for about 15 to 30 seconds, often near 1 GB. Plan on several cents to a few tens of cents per question before any model tokens, plus a queue so a burst does not start a browser for every click.
Keep the public lab on recorded traces. A live browser, if added later, belongs behind the same origin allowlist, the same read-only tools, and a hard cap.
Recommended next
Why these picksReading path transitions…