Skip to main content
Glama
devskido

Playwright MCP Server

by devskido

playwright_upload_file

Upload files to web page file input elements using CSS selectors and local file paths for browser automation tasks.

Instructions

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

Input Schema

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

Implementation Reference

  • Defines the tool name, description, and input schema for 'playwright_upload_file'.
    {
      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"],
      },
    },
  • The UploadFileTool class implements the core logic for uploading a file using Playwright's setInputFiles method on the specified selector.
    export class UploadFileTool extends BrowserToolBase {
      /**
       * Execute the upload file tool
       */
      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}'`);
        });
      }
    }
  • Dispatches the tool call to the UploadFileTool's execute method in the main tool handler switch statement.
    case "playwright_upload_file":
      return await uploadFileTool.execute(args, context);
  • Instantiates the UploadFileTool instance during tool initialization.
    if (!uploadFileTool) uploadFileTool = new UploadFileTool(server);
  • src/tools.ts:459-459 (registration)
    Lists 'playwright_upload_file' in the BROWSER_TOOLS array for conditional browser launching.
    "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 full burden but only states the basic action without disclosing behavioral traits. It doesn't mention whether this requires the page to be in a specific state, if it waits for upload completion, error handling for invalid selectors or file paths, or any side effects like page navigation. For a mutation tool with zero annotation coverage, this is insufficient.

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, efficient sentence with zero wasted words. It is front-loaded with the core action and target, making it immediately understandable without unnecessary elaboration.

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?

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after upload (e.g., success/failure indicators, return values, or page changes). Given the complexity of file upload interactions and lack of structured data, more context is needed for effective agent use.

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 description coverage is 100%, so the schema already documents both parameters (selector and filePath) adequately. The description adds no additional meaning beyond what the schema provides, such as examples of valid selectors or file path formats. Baseline 3 is appropriate when the schema does the heavy lifting.

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?

The description clearly states the specific action ('upload a file') and target resource ('to an input[type='file'] element on the page'), distinguishing it from sibling tools like playwright_fill or playwright_post which handle different interactions. The verb+resource combination is precise and unambiguous.

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 (for text inputs) or playwright_post (for HTTP file uploads). It lacks context about prerequisites (e.g., needing a file input element visible on the page) or exclusions (e.g., not working 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

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/devskido/customed-playwright'

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