Skip to main content
Glama

pilot_file_upload

Upload files to web forms by specifying file paths and targeting file input elements using references or CSS selectors.

Instructions

Upload file(s) to a file input element.

Input Schema

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

Implementation Reference

  • Implementation of the pilot_file_upload tool, including schema definition and execution logic.
    server.tool(
      'pilot_file_upload',
      'Upload file(s) to a file input element.',
      {
        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 {
          for (const fp of paths) {
            if (!fs.existsSync(fp)) throw new Error(`File not found: ${fp}`);
          }
          const page = bm.getPage();
          const resolved = await bm.resolveRef(ref);
          if ('locator' in resolved) {
            await resolved.locator.setInputFiles(paths);
          } else {
            await page.locator(resolved.selector).setInputFiles(paths);
          }
          const fileInfo = paths.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 };
        }
      }
    );

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