Skip to main content
Glama

browser_file_upload

Upload files to web forms by specifying file paths and element locators for automated browser testing and interaction.

Instructions

Uploads a file using a file input element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
byYesLocator strategy to find element
valueYesValue for the locator strategy
timeoutNoMaximum time to wait for element in milliseconds
filePathYesAbsolute path to the file to upload

Implementation Reference

  • Registers the browser_file_upload MCP tool, defining its input schema (locator strategy, value, timeout, filePath) and handler function that uses ElementService to perform the upload.
    server.tool(
      'browser_file_upload',
      'Uploads a file using a file input element',
      {
        ...locatorSchema,
        filePath: z.string().describe('Absolute path to the file to upload'),
      },
      async ({ by, value, filePath, timeout = 15000 }) => {
        try {
          const driver = stateManager.getDriver();
          const elementService = new ElementService(driver);
          await elementService.uploadFile({ by, value, filePath, timeout });
          return {
            content: [{ type: 'text', text: 'File upload initiated' }],
          };
        } catch (e) {
          return {
            content: [
              {
                type: 'text',
                text: `Error uploading file: ${(e as Error).message}`,
              },
            ],
          };
        }
      }
    );
  • Core implementation of file upload in ElementService: locates the file input element and sends the absolute file path using Selenium's sendKeys method.
    async uploadFile(params: LocatorParams & { filePath: string }): Promise<void> {
      const element = await this.findElement(params);
      await element.sendKeys(params.filePath);
    }
  • locatorSchema defining the input parameters for element location (by, value, timeout), spread into the tool's schema.
    export const locatorSchema = {
      by: z
        .enum(['id', 'css', 'xpath', 'name', 'tag', 'class', 'link', 'partialLink'])
        .describe('Locator strategy to find element'),
      value: z.string().describe('Value for the locator strategy'),
      timeout: z.number().optional().describe('Maximum time to wait for element in milliseconds'),
    };
Behavior2/5

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

With no annotations, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits like error handling (e.g., what happens if the file doesn't exist or element isn't found), side effects, or performance implications (e.g., timeouts). This is inadequate for a mutation tool with potential failures.

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

Conciseness5/5

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

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core action, making it easy to parse quickly.

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?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks information on success/failure behavior, return values, or error conditions, which are critical for an agent to use this tool effectively in a browser automation context.

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 parameters are well-documented in the schema. The description adds no additional meaning beyond implying 'filePath' is used for uploads, which is already clear from the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Uploads') and target ('a file using a file input element'), which distinguishes it from sibling tools like browser_navigate or browser_type. However, it doesn't explicitly differentiate from other file-related operations (none exist in siblings), so it's not a perfect 5.

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?

No guidance is provided on when to use this tool versus alternatives or in what context. The description only states what it does, not when it's appropriate, leaving the agent to infer usage from the tool name alone.

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

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/pshivapr/selenium-mcp'

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