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
| Name | Required | Description | Default |
|---|---|---|---|
| paths | Yes | The absolute paths to the files to upload. Can be a single file or multiple files. |
Implementation Reference
- src/tools/files.ts:33-53 (handler)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, }; },
- src/tools/files.ts:23-31 (schema)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),
- src/connection.ts:22-33 (registration)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);