browser_file_upload
Enable file uploads to web pages by specifying absolute paths for one or multiple files, facilitating structured interactions with web interfaces.
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-46 (handler)Handler function for the 'browser_file_upload' tool. It locates the file chooser modal, adds code to set files, clears the modal state, and waits for completion.handle: async (tab, params, response) => { response.setIncludeSnapshot(); const modalState = tab.modalStates().find(state => state.type === 'fileChooser'); if (!modalState) throw new Error('No file chooser visible'); response.addCode(`await fileChooser.setFiles(${JSON.stringify(params.paths)})`); tab.clearModalState(modalState); await tab.waitForCompletion(async () => { await modalState.fileChooser.setFiles(params.paths); }); },
- src/tools/files.ts:23-31 (schema)Schema definition for the 'browser_file_upload' tool, including name, title, description, Zod input schema for file paths, and 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/files.ts:50-52 (registration)Export of the defined tool for registration in the tool collection.export default [ uploadFile, ];