Skip to main content
Glama

playwright_upload_file

Upload files to web pages by specifying the CSS selector of the input element and the file’s absolute path using browser automation with Playwright.

Instructions

Upload a file to an input[type='file'] element on the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the file to upload
selectorYesCSS selector for the file input element

Implementation Reference

  • The execute method of UploadFileTool class implements the tool logic: waits for the file input selector and uses Playwright's page.setInputFiles to upload the specified file.
    async execute(args: any, context: ToolContext): Promise<ToolResponse> {
      return this.safeExecute(context, async (page) => {
          await page.waitForSelector(args.selector);
          await page.setInputFiles(args.selector, args.filePath);
          return createSuccessResponse(`Uploaded file '${args.filePath}' to '${args.selector}'`);
      });
    }
  • Defines the input schema, name, and description for the playwright_upload_file tool.
    {
      name: "playwright_upload_file",
      description: "Upload a file to an input[type='file'] element on the page",
      inputSchema: {
        type: "object",
        properties: {
          selector: { type: "string", description: "CSS selector for the file input element" },
          filePath: { type: "string", description: "Absolute path to the file to upload" }
        },
        required: ["selector", "filePath"],
      },
    },
  • In handleToolCall function, the switch case registers and dispatches calls to the UploadFileTool instance.
    case "playwright_upload_file":
      return await uploadFileTool.execute(args, context);
  • Instantiates the UploadFileTool class instance used for handling the tool calls.
    if (!uploadFileTool) uploadFileTool = new UploadFileTool(server);
  • src/tools.ts:459-459 (registration)
    Includes the tool name in the BROWSER_TOOLS array for conditional browser launch checks.
    "playwright_upload_file",
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions uploading a file but fails to describe key behaviors: whether it waits for the upload to complete, handles errors (e.g., invalid file paths or selectors), or affects page state. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness5/5

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

The description is a single, direct sentence that efficiently conveys the core purpose without unnecessary words. It is front-loaded with the main action and target, making it easy to parse quickly. Every part of the sentence serves a clear functional role.

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

Completeness2/5

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

Given the tool's complexity (a mutation operation with no annotations and no output schema), the description is incomplete. It doesn't address behavioral aspects like error handling, success criteria, or return values, leaving gaps that could hinder an agent's ability to use it effectively. The high schema coverage helps but doesn't compensate for the lack of operational context.

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?

The input schema has 100% description coverage, with clear documentation for both parameters (filePath and selector). The description adds no additional semantic context beyond what the schema provides, such as examples or constraints (e.g., file size limits or selector specificity). This meets the baseline for high schema coverage but doesn't enhance understanding.

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

Purpose4/5

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

The description clearly states the action ('upload a file') and target ('to an input[type='file'] element on the page'), which is specific and unambiguous. It doesn't explicitly differentiate from sibling tools like playwright_fill or playwright_select, but the focus on file uploads makes it reasonably distinct within the Playwright toolset.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like playwright_fill (which might handle text inputs) or other file-handling methods. It lacks context about prerequisites, such as needing the element to be visible or interactable, or when not to use it (e.g., for non-file inputs).

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

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/executeautomation/mcp-playwright'

If you have feedback or need assistance with the MCP directory API, please join our Discord server