Skip to main content
Glama

browser_file_upload

Upload single or multiple files via browser automation using Playwright MCP. Specify absolute file paths to integrate file uploads into web interactions without manual intervention.

Instructions

Upload one or multiple files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsYesThe absolute paths to the files to upload. Can be a single file or multiple files.

Implementation Reference

  • The execute handler for the browser_file_upload tool. It finds the fileChooser modal state, prepares code comment, defines action to set files and clear modal, and returns execution plan.
    handle: async (context, params) => { const modalState = context.modalStates().find(state => state.type === 'fileChooser'); if (!modalState) throw new Error('No file chooser visible'); const code = [ `// <internal code to chose files ${params.paths.join(', ')}`, ]; const action = async () => { await modalState.fileChooser.setFiles(params.paths); context.clearModalState(modalState); }; return { code, action, captureSnapshot, waitForNetwork: true, }; },
  • Schema definition for browser_file_upload tool, specifying name, title, description, input schema (array of file paths), and destructive type.
    schema: { name: 'browser_file_upload', title: 'Upload files', description: 'Upload one or multiple files', inputSchema: z.object({ paths: z.array(z.string()).describe('The absolute paths to the files to upload. Can be a single file or multiple files.'), }), type: 'destructive', },
  • src/tools.ts:40-40 (registration)
    Registration of browser_file_upload tool via spreading files(true) into snapshotTools array.
    ...files(true),
  • Top-level registration where snapshotTools (including browser_file_upload) are selected based on config.vision, filtered, and passed to Context for MCP server initialization.
    import { snapshotTools, visionTools } from './tools.js'; import { packageJSON } from './package.js'; import { FullConfig, validateConfig } from './config.js'; import type { BrowserContextFactory } from './browserContextFactory.js'; export function createConnection(config: FullConfig, browserContextFactory: BrowserContextFactory): Connection { const allTools = config.vision ? visionTools : snapshotTools; const tools = allTools.filter(tool => !config.capabilities || tool.capability === 'core' || config.capabilities.includes(tool.capability)); validateConfig(config); const context = new Context(tools, config, browserContextFactory);

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/lewisvoncken/playwright-mcp'

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