Skip to main content
Glama

browser_run_python

Destructive

Run Python scripts to automate the current browser session: read pages, click, fill forms, scroll, hover, drag, type, wait, and return results.

Instructions

Browse with Python: read, click, scroll, hover, drag, type, fill and wait in one call. Trusted local Python with host file/network access, NOT a sandbox. The supplied browser uses this client's session and permissions. No imports or kitsune.connect() are needed. Variables reset each call; tabs persist. tab is the MCP-selected Tab, else the tab the user views (None with several windows). Scripts need no browser_tabs list/select first: browser.tabs() lists tabs and browser.tab(id) reads or acts on any of them. browser.tabs() returns list[dict] (id, url, title, owned); browser.tab(id) wraps a tab ID, NOT a list index. browser.new_tab(url) returns a Tab; scripts do not change MCP selection. Return JSON via result or print selected output. Group actions whose targets are already known, then read the needed result once. Do not guess refs or replay a failed script. Print/result share 16,000 UTF-8 bytes: scope reads, filter locally, return evidence with coverage.

Action/scoped-snapshot targets: refs like e12 or supported selectors, not DOM ref attributes. tab.snapshot(target=None, max_depth=None, text=True) includes visible text; no depth/boxes args. tab.find(query) searches descriptions, not text/regex; filter scoped reads in Python for those. tab.query(selector, fields=['text', 'href'], limit=20) is CSS-only, current document; no refs. tab.text(); tab.forms(); tab.info(). tab.click(target); tab.double_click(target); tab.hover(target); tab.drag(source, destination). tab.scroll('down', 700, target=None) scrolls window or element; also up/left/right/top/bottom. tab.fill(target, value) replaces; tab.type(target, text): fields append, editors insert at caret. tab.fill_form({'#name': 'Ada'}); tab.check(target, True); tab.select_option(target, value). tab.press('Enter', target=None, modifiers={'ctrl': True}); omitted target uses focus, not the last target. tab.navigate(url); tab.back(). tab.wait_for(text='Done', timeout=10000) or target/url/text_gone (one condition, timeout in ms). wait_for(target=...) accepts CSS/refs, not :has-text or text=/role=; actions may use those. Example: tab.fill('e12', 'Ada'); tab.click('e15'); result = tab.snapshot(text=True). help(tab.scroll) prints a specific method's signature. Prefer this API over page evaluate.

Limits: 16 KB output/result, 100 API calls, fresh variables, no top-level await. A failed API call stops even if caught; earlier writes remain. For needs_user use the failed operation's direct tool via browser_tools_call, then run ONLY remaining work. Never put confirm/resume tokens in scripts. Use browser_tabs for handoff (request), browser_ask_user for human help, and browser_take_screenshot for images. For a page dict t from browser.tabs(), use browser.tab(t["id"]).snapshot(text=True).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "browser_run_python"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesPython code. Use the supplied browser; assign a JSON result or print selected output.
timeoutNoExecution deadline in seconds, including browser calls.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.8.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations say destructive/open-world/non-idempotent, and the description goes well beyond them: 'Trusted local Python with host file/network access, NOT a sandbox', 'uses this client's session and permissions', 'Variables reset each call; tabs persist', and critically 'A failed API call stops even if caught; earlier writes remain.' It also states hard limits (16 KB output, 100 API calls, no top-level await) and the token-handling prohibition.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The purpose and trust/sandbox warning are front-loaded, then API surface, then limits and escalation paths — a sensible order. It is dense and long, but nearly every clause carries callable detail (method signatures, ref semantics, wait_for restrictions) rather than filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a highly complex, no-output-schema tool this covers the essentials: what the runtime is, how tabs/refs work, key methods and their constraints, failure semantics, output budget, and where to escalate when user interaction is required. Nothing an agent needs to invoke it safely is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and both params are documented there, so baseline is 3; the description adds real meaning by specifying what code should produce ('Return JSON via result or print selected output') and how the combined 16,000-byte result/print budget constrains writing, which the schema does not convey.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb set and resource: 'Browse with Python: read, click, scroll, hover, drag, type, fill and wait in one call.' It immediately distinguishes itself from siblings by naming browser_tabs, browser_ask_user, browser_take_screenshot, browser_tools_call and browser_resume with their roles.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit routing: 'Scripts need no browser_tabs list/select first', 'Use browser_tabs for handoff (request), browser_ask_user for human help, and browser_take_screenshot for images', and for needs_user 'use the failed operation's direct tool via browser_tools_call, then run ONLY remaining work.' It also excludes page evaluate and gives a group-actions-then-read pattern, which is genuine when-to-use guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.