Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

uploadFiles

Upload files to web forms using file input elements. Specify a CSS selector and file paths to automate file uploads in browser automation workflows.

Instructions

Upload files through a file input element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYes
filePathsYesArray of absolute file paths to upload

Implementation Reference

  • The core handler function that executes the file upload logic using Playwright's locator.setInputFiles method.
    async uploadFiles(selector: string, filePaths: string[]): Promise<void> {
      try {
        if (!this.isInitialized() || !this.state.page) {
          throw new Error('Browser not initialized');
        }
        this.log('Uploading files', { selector, filePaths });
        const locator = this.state.page.locator(selector);
        await locator.setInputFiles(filePaths);
        this.log('File upload complete');
      } catch (error: any) {
        console.error('File upload error:', error);
        throw new BrowserError('Failed to upload files', 'Check if selector is a file input and files exist');
      }
    }
  • Defines the Tool object including name, description, and input schema for validation.
    const UPLOAD_FILES_TOOL: Tool = {
      name: "uploadFiles",
      description: "Upload files through a file input element",
      inputSchema: {
        type: "object",
        properties: {
          selector: { type: "string" },
          filePaths: {
            type: "array",
            items: { type: "string" },
            description: "Array of absolute file paths to upload"
          }
        },
        required: ["selector", "filePaths"]
      }
    };
  • src/server.ts:546-546 (registration)
    Registers the uploadFiles tool in the MCP server's tools capabilities map.
    uploadFiles: UPLOAD_FILES_TOOL,
  • MCP server request handler case that validates inputs and delegates to the Playwright controller for execution.
    case 'uploadFiles': {
      if (!args.selector || !args.filePaths) {
        return {
          content: [{ type: "text", text: "Selector and file paths are required" }],
          isError: true
        };
      }
      await playwrightController.uploadFiles(args.selector as string, args.filePaths as string[]);
      return {
        content: [{ type: "text", text: "Files uploaded successfully" }]
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the action but fails to describe key traits: whether it requires specific permissions, how it handles errors (e.g., invalid file paths), if it's synchronous/asynchronous, or what the expected outcome is (e.g., success confirmation). This leaves significant gaps for a mutation tool.

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 zero waste—it directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, 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?

Given the tool's complexity (a mutation operation with 2 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects, parameter meanings, or expected results, making it inadequate for safe and effective use by an AI agent.

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 50% (only 'filePaths' has a description), so the description must compensate but adds no parameter details. It doesn't explain what 'selector' means (e.g., CSS selector for the file input) or provide context beyond the schema. Baseline 3 is appropriate as the schema covers half the parameters, but the description adds no value.

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 ('upload files') and the mechanism ('through a file input element'), which distinguishes it from general file operations. However, it doesn't explicitly differentiate from sibling tools like 'dragAndDrop' or 'type' that might also handle files, keeping it from a perfect score.

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 like 'dragAndDrop' for file uploads or other browser interaction tools. It lacks context about prerequisites (e.g., needing an open browser or specific page state) or exclusions, leaving usage unclear.

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/jomon003/PlayMCP'

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