Skip to main content
Glama

pilot_file_upload

Upload files to a file input element on a page by providing the element reference and absolute file paths. Use for attaching documents, images, or other files.

Instructions

Upload one or more files to a file input element on the page. Use when the user wants to attach files, upload images, or submit documents through a file input field.

Parameters:

  • ref: The file input element reference from snapshot (e.g., "@e8") or a CSS selector pointing to an

  • paths: Array of absolute file paths to upload (e.g., ["/home/user/photo.png", "/home/user/doc.pdf"])

Returns: Confirmation with file names and sizes uploaded.

Errors:

  • "File not found": One or more paths do not exist on the filesystem. Verify the file paths.

  • "Element not found": The ref is stale or does not point to a file input. Run pilot_snapshot.

  • "Not a file input": The element is not an .

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refYesFile input element ref or CSS selector
pathsYesFile paths to upload

Implementation Reference

  • The full implementation of the 'pilot_file_upload' tool. Defined via server.tool(), it accepts a ref (element reference or CSS selector) and an array of file paths. It validates that files exist on disk, resolves the element via BrowserManager, uses Playwright's setInputFiles to upload, and returns a confirmation with file names and sizes. On error, it returns an isError response.
      server.tool(
        'pilot_file_upload',
        `Upload one or more files to a file input element on the page.
    Use when the user wants to attach files, upload images, or submit documents through a file input field.
    
    Parameters:
    - ref: The file input element reference from snapshot (e.g., "@e8") or a CSS selector pointing to an <input type="file">
    - paths: Array of absolute file paths to upload (e.g., ["/home/user/photo.png", "/home/user/doc.pdf"])
    
    Returns: Confirmation with file names and sizes uploaded.
    
    Errors:
    - "File not found": One or more paths do not exist on the filesystem. Verify the file paths.
    - "Element not found": The ref is stale or does not point to a file input. Run pilot_snapshot.
    - "Not a file input": The element is not an <input type="file">.`,
          {
          ref: z.string().describe('File input element ref or CSS selector'),
          paths: z.array(z.string()).describe('File paths to upload'),
        },
        async ({ ref, paths }) => {
          await bm.ensureBrowser();
          try {
            const resolvedPaths = paths.map(fp => {
              if (!fs.existsSync(fp)) throw new Error(`File not found: ${fp}`);
              return fs.realpathSync(fp);
            });
            const page = bm.getPage();
            const resolved = await bm.resolveRef(ref);
            if ('locator' in resolved) {
              await resolved.locator.setInputFiles(resolvedPaths);
            } else {
              await page.locator(resolved.selector).setInputFiles(resolvedPaths);
            }
            const fileInfo = resolvedPaths.map(fp => {
              const stat = fs.statSync(fp);
              return `${path.basename(fp)} (${stat.size}B)`;
            }).join(', ');
            bm.resetFailures();
            return { content: [{ type: 'text' as const, text: `Uploaded: ${fileInfo}` }] };
          } catch (err) {
            bm.incrementFailures();
            return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
          }
        }
      );
  • Zod schema for pilot_file_upload inputs: 'ref' (string) and 'paths' (array of strings).
      {
      ref: z.string().describe('File input element ref or CSS selector'),
      paths: z.array(z.string()).describe('File paths to upload'),
    },
  • registerAllTools in register.ts calls registerInteractionTools (which registers pilot_file_upload). Note that 'pilot_file_upload' is NOT in the core or standard tool sets, so it is only available in the 'full' profile.
    export function registerAllTools(server: McpServer, bm: BrowserManager, profile: ToolProfile = 'full'): void {
      const allowed = PROFILE_TOOLS[profile];
      const effectiveServer = allowed ? createFilteredServer(server, allowed) : server;
    
      registerNavigationTools(effectiveServer, bm);
      registerSnapshotTools(effectiveServer, bm);
      registerInteractionTools(effectiveServer, bm);
      registerPageTools(effectiveServer, bm);
      registerInspectionTools(effectiveServer, bm);
      registerVisualTools(effectiveServer, bm);
      registerTabTools(effectiveServer, bm);
      registerSettingsTools(effectiveServer, bm);
      registerIframeTools(effectiveServer, bm);
      registerAutomationTools(effectiveServer, bm);
    }
Behavior3/5

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

No annotations are provided, so the description must cover behavioral traits. It includes error cases and return values but does not disclose details like whether it overwrites existing files, handles multiple files simultaneously, or any permission/auth requirements. The description is adequate but not comprehensive.

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 concise, well-structured with clear sections (Usage, Parameters, Returns, Errors), and every sentence is informative without redundancy.

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

Completeness5/5

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

Despite no output schema, the description explains the return value (confirmation with file names and sizes) and lists all possible errors. For a two-parameter tool with straightforward behavior, this is complete and actionable.

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

Parameters4/5

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

Schema coverage is 100%, but the description adds value by clarifying that 'ref' can be an element ref or CSS selector and that 'paths' are absolute file paths, with examples. This goes beyond the schema's basic description.

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

Purpose5/5

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

The description explicitly states 'Upload one or more files to a file input element on the page.' It uses a specific verb and resource, and the tool's purpose is clearly distinct from siblings (e.g., no other upload tool).

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

Usage Guidelines4/5

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

The description says 'Use when the user wants to attach files, upload images, or submit documents through a file input field.' This provides clear context for when to use it, though it does not explicitly mention when not to use or name alternatives (but no direct alternatives exist among siblings).

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/TacosyHorchata/Pilot'

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