OpenFilePicker is an action, not a component. It opens the browser’s native file picker when triggered — attach it to any clickable element and it handles the rest: reading selected files to base64 and passing them to onSuccess as $event.
This is the counterpart to DropZone. Where DropZone gives you a dedicated upload area, OpenFilePicker turns any existing element into a file input. A button, a badge, an icon — anything with an on_click.
All file reading happens in the browser. Files are never sent to a server unless you explicitly wire up an
on_success action (like CallTool) to do so.Processing Files with a Tool
Files are read client-side, but they don’t go anywhere until you tell them to. The typical pattern is to nest aCallTool inside on_success — pick the file, then send its base64 data to your MCP server for processing.
Multiple Files
Setmultiple=True to let users select several files at once. $event is always list[FileUpload] regardless of multiple, but the OS file picker restricts multi-select to when multiple=True.
Multiple file upload
File Size Limits
Themax_size parameter rejects files that exceed a byte limit before they ever reach onSuccess. Oversized files are silently dropped with a toast notification — the user sees the error, your tool never has to deal with it.
With size limit
Error Handling
Theon_error callback on the nested CallTool fires if the server-side processing fails. The error message is available as $error.
With error handling
The FileUpload Type
Both OpenFilePicker and DropZone produce the same $event shape. Prefab ships a FileUpload type you can use to annotate your tool parameters — see The FileUpload Type for details and usage.
User Activation
One constraint worth knowing:OpenFilePicker must execute before any async server actions in the same chain. Browsers require a recent user gesture to open the file picker — if a CallTool or SendMessage fires first, the activation window expires and the picker silently won’t open. This is the natural ordering anyway (pick the file, then send it), but it’s worth understanding why.
API Reference
OpenFilePicker Parameters
File type filter. Accepts MIME types (
"image/*"), extensions (".csv"), or a comma-separated mix.Allow selecting multiple files.
$event is always list[FileUpload]; this controls whether the OS file picker allows multi-select.Maximum file size in bytes. Oversized files are rejected with a toast notification.
Action(s) to run after files are selected.
$event is always list[FileUpload].Action(s) to run if file reading fails.
Protocol Reference
OpenFilePicker