Skip to main content
Glama
devskido

Playwright MCP Server

by devskido

playwright_upload_file

Use this tool to upload a file to a web page's file input element by providing the CSS selector and the file's absolute path. Simplifies browser automation tasks in Playwright MCP Server.

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 UploadFileTool.execute method implements the core logic for uploading a file using Playwright's page.setInputFiles after waiting for the 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}'`); }); } }
  • Tool definition including name, description, and input schema for validation.
    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"], }, },
  • Dispatch in handleToolCall switch statement routes the tool call to the UploadFileTool instance.
    case "playwright_upload_file": return await uploadFileTool.execute(args, context);
  • Instantiation of the UploadFileTool class in initializeTools function.
    if (!uploadFileTool) uploadFileTool = new UploadFileTool(server);
  • Listed in BROWSER_TOOLS array for conditional browser launch checks.
    "playwright_upload_file",

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