Skip to main content
Glama

Attach files in browser

browser_upload_file
DestructiveIdempotent

Attach local files to a file input in an agent's browser tab by snapshot index, as if the user selected them, without opening a picker or using keyboard and mouse.

Instructions

Attach local files to a file input in one of the agent's tabs, by its browser_snapshot index, as if the user had picked them: Chrome sets the input's files and the page gets its usual input and change events. No file picker opens, the tab is not selected or raised, and no keyboard or mouse input is used. Snapshots list file inputs as input[file], including ones a page hides behind a styled upload button; the index of a label for one works too, and any other element is refused. Paths are absolute paths of regular files on the computer running Chrome and this server, which may not be the machine you run on; each is checked before anything is sent. Several paths need an input that takes several files (multiple). It never submits a form, but the page gets its change event, and many sites start uploading on it at once and then empty or replace the input; the reply names the files the page got and says when it took them that way. Check the page's own upload state before submitting or attaching again, so nothing is uploaded twice. Where the page waits for it, submit or press its upload button yourself when the user wants that, then check the page. Never click a file input or its upload button to open the picker: the native dialog cannot be driven from here.

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": {
      "tab_id": "<tab_id>",
      "index": "<index>",
      "paths": "<paths>"
    },
    "name": "browser_upload_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
indexYesElement index of the file input (input[file]), or of a label for one, from the latest browser_snapshot of this tab.
pathsYesAbsolute paths of the files to attach, on the computer running Chrome and this server. Each must exist and be a regular file, not a folder. More than one needs an input with the multiple attribute. Replaces whatever files the input held.
tab_idYestab_id of one of the agent's tabs, from browser_open_tab or browser_list_tabs
session_idNoStable task or thread ID. Pass the same value on every browser call for this task. Different IDs isolate tabs and cleanup within one MCP process. Omit for the default process session.
return_stateNoAppend a current snapshot and readiness status after acting. Without wait_for_selector, only a short pause and bounded navigation wait are used; SPA readiness is not guaranteed. Snapshot indices replace earlier ones. A timeout does not mean the action failed: re-observe with browser_snapshot before repeating it.
wait_timeout_msNoBound for wait_for_selector in milliseconds (default 8000, maximum 10000; 0 checks once). Requires wait_for_selector. Timeout preserves action success and returns current state. Use browser_snapshot with the same wait to re-observe without repeating an action.
wait_for_selectorNoWait for any visible element matching this CSS selector in the page or any of its frames (iframes), including open shadow roots (web components); a timeout says how many frames could not be searched. On actions requires return_state=true. Returns readiness met, timeout or error; only this condition is checked, not general app readiness. Prefer a selector specific to the expected new UI.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.14.0
    • changedInput schema / properties / wait_for_selector / description
      Previous value: -"Wait for any visible element matching this CSS selector in the page, including open shadow roots (web components); child frames are not searched, and a timeout says how many were visible. On actions requires return_state=true. Returns readiness met, timeout or error; only this condition is checked, not general app readiness. Prefer a selector specific to the expected new UI."New value: +"Wait for any visible element matching this CSS selector in the page or any of its frames (iframes), including open shadow roots (web components); a timeout says how many frames could not be searched. On actions requires return_state=true. Returns readiness met, timeout or error; only this condition is checked, not general app readiness. Prefer a selector specific to the expected new UI."
  2. Addedv0.13.0

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond annotations: states no picker opens, tab not raised, no keyboard/mouse input, paths checked before sending, never submits a form but fires change so sites may upload at once and empty/replace the input, reply names the files and warns to avoid double uploads. The note about repeated attaches causing site-side uploads mildly nuances idempotentHint=true but does not flatly contradict it.

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?

Purpose is front-loaded and every sentence carries real guidance, but it is a dense single paragraph with mild redundancy (the picker/click warning appears twice). Acceptable density for a complex tool.

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?

No output schema, but the description fully covers return behavior ('reply names the files the page got'), edge cases (label index, hidden inputs, multi-file, cross-machine paths), and safety (no double uploads). Nothing an agent needs to invoke it correctly is missing.

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

Parameters3/5

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

Schema coverage is 100% and already documents index, paths, tab_id, and the wait/return_state params. The description mainly reinforces the same facts (label indices, absolute paths on the Chrome machine, multiple-file inputs) rather than adding new per-parameter meaning, so baseline 3 fits.

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?

Specific verb+resource: 'Attach local files to a file input... by its browser_snapshot index.' It also explicitly distinguishes itself from the click tools by stating the picker 'cannot be driven from here' and never to click a file input.

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 when-to-use (attach by snapshot index as if user picked files), when-not (never click a file input or its upload button to open the picker), and what to do after (check page upload state, submit or press upload button yourself, then re-check). Close to exhaustive.

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