Skip to main content
Glama
livoras

Better Playwright MCP

by livoras

browserFileUpload

Upload files to a specified input element using page ID and XPath reference, with configurable wait time for snapshots in browser automation.

Instructions

上传文件到指定元素

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageIdYes页面ID
pathsYes要上传的文件路径数组
refYes文件输入元素的xp引用值
waitForTimeoutNo操作后等待获取快照的延迟时间(毫秒,默认2000)

Implementation Reference

  • Defines and exports the browser_file_upload tool using defineTabTool, which likely registers it as a tab tool.
    const uploadFile = defineTabTool({
        capability: 'core',
        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',
        },
        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);
            });
        },
        clearsModalState: 'fileChooser',
    });
    export default [
        uploadFile,
    ];
  • The handler function that finds the file chooser modal and sets the files from params.paths, 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);
        });
    },
  • Tool schema defining name 'browser_file_upload', input schema expecting array of file paths, marked as destructive.
    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',
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action (upload files) but lacks details on permissions needed, whether it's destructive (e.g., overwrites existing files), rate limits, error handling, or what happens after upload (e.g., page changes). For a mutation tool with zero annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence ('上传文件到指定元素') that directly states the tool's function without unnecessary words. It's front-loaded and appropriately sized for its purpose, though it could benefit from more context to improve completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no annotations, no output schema, and involves mutation (uploading files), the description is incomplete. It doesn't cover behavioral aspects like side effects, return values, or error conditions. For a 4-parameter tool in a browser automation context, more detail is needed to ensure safe and correct usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters (pageId, paths, ref, waitForTimeout) with descriptions. The tool description adds no additional meaning beyond what's in the schema, such as explaining how 'ref' identifies the element or format of 'paths'. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '上传文件到指定元素' (Upload files to specified element) states a clear verb+resource combination, indicating it uploads files to an element. However, it doesn't distinguish this tool from other browser interaction tools like 'browserClick' or 'browserType', which also target elements. The purpose is understandable but lacks sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There are no explicit instructions on prerequisites (e.g., needing an open page or specific element type), exclusions, or comparisons to other tools like 'downloadImage' or general file handling. Usage is implied by the action but not contextualized.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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

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