Skip to main content
Glama

fill_form

Automate form completion for login, registration, or search by filling multiple fields sequentially with optional Enter key presses and submit button clicks.

Instructions

Fill out one or multiple form fields in sequence, perfect for login forms, registration, search inputs, or any text entry. Supports pressing Enter after each field and clicking a submit button. Commonly used for authentication flows before accessing chat interfaces. Each field can be filled independently with optional Enter key press.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID obtained from initialize_session
fieldsYesArray of form field objects to fill in sequence. Each field requires a CSS selector and value. Example: [{selector: 'input[name="email"]', value: 'user@example.com'}, {selector: 'input[type="password"]', value: 'mypassword'}]
submitButtonNoOptional CSS selector for submit button to click after all fields are filled (e.g., 'button[type="submit"]', '#login-button')

Implementation Reference

  • Core implementation of the fill_form tool handler. Fills specified form fields using Playwright's page.fill and page.click methods, handles optional Enter presses and submit button, returns success status with page info.
    export async function fillForm(sessionId, fields, submitButton = null) { const session = getSession(sessionId); const { page } = session; try { for (const field of fields) { const { selector, value, pressEnter = false } = field; await page.waitForSelector(selector, { timeout: 5000 }); await page.fill(selector, value); if (pressEnter) { await page.press(selector, "Enter"); await page.waitForTimeout(1000); } } if (submitButton) { await page.click(submitButton); await page.waitForTimeout(2000); } return { success: true, sessionId, currentUrl: page.url(), title: await page.title(), message: `Filled ${fields.length} field(s) successfully`, }; } catch (error) { throw new Error(`Failed to fill form: ${error.message}`); } }
  • MCP tool schema definition for 'fill_form' including name, description, and detailed inputSchema with properties for sessionId, fields array (with selector/value/pressEnter), and optional submitButton.
    { name: "fill_form", description: "Fill out one or multiple form fields in sequence, perfect for login forms, registration, search inputs, or any text entry. Supports pressing Enter after each field and clicking a submit button. Commonly used for authentication flows before accessing chat interfaces. Each field can be filled independently with optional Enter key press.", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "Session ID obtained from initialize_session", }, fields: { type: "array", description: "Array of form field objects to fill in sequence. Each field requires a CSS selector and value. Example: [{selector: 'input[name=\"email\"]', value: 'user@example.com'}, {selector: 'input[type=\"password\"]', value: 'mypassword'}]", items: { type: "object", properties: { selector: { type: "string", description: "CSS selector for the input field (e.g., 'input[name=\"username\"]', '#email', '.search-box')", }, value: { type: "string", description: "Text value to enter into the field", }, pressEnter: { type: "boolean", description: "Press Enter key after filling this field to submit or trigger search (default: false)", }, }, required: ["selector", "value"], }, }, submitButton: { type: "string", description: "Optional CSS selector for submit button to click after all fields are filled (e.g., 'button[type=\"submit\"]', '#login-button')", }, }, required: ["sessionId", "fields"], }, },
  • src/index.js:459-474 (registration)
    Registration and dispatch logic in the CallToolRequestSchema handler: validates parameters and calls the fillForm handler function for the 'fill_form' tool.
    case "fill_form": { const { sessionId, fields, submitButton } = args; if (!sessionId) { throw new McpError( ErrorCode.InvalidParams, "sessionId parameter is required" ); } if (!fields || !Array.isArray(fields)) { throw new McpError( ErrorCode.InvalidParams, "fields parameter must be an array" ); } result = await fillForm(sessionId, fields, submitButton); break;
  • src/index.js:13-26 (registration)
    Import statement registering the fillForm function by importing it into the main MCP server index.js for use in tool handlers.
    takeScreenshot, clickElement, fillForm, switchTab, waitForElement, navigateToUrl, getCurrentPageInfo, initializeSession, closeSession, startNetworkCapture, stopNetworkCapture, getNetworkCaptureStatus, clearNetworkCapture, } from "./tools/reverseEngineer.js";
  • Re-export of fillForm from interaction.js, enabling centralized import in src/index.js.
    export { clickElement, fillForm, waitForElement } from "./interaction.js";

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/pyscout/webscout-mcp'

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