Skip to main content
Glama

browser_type

Enter text into web page input fields using CSS selectors for automated form filling and data entry in browser automation.

Instructions

Type text into an input field specified by selector

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYes
textYes

Implementation Reference

  • Executes the browser_type tool by validating input, connecting to Playwright if needed, and using page.fill() to type text into the specified selector.
    async (params: any) => { try { const input = z.object({ selector: z.string(), text: z.string() }).parse(params); await this.playwright.ensureConnected(); const page = this.playwright.getPage(); await page.fill(input.selector, input.text); return { content: [{ type: 'text', text: `Successfully typed text into element: ${input.selector}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Type text failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
  • src/server.ts:194-230 (registration)
    Registers the 'browser_type' tool with the MCP server, including title, description, input schema, and handler reference.
    'browser_type', { title: 'Type Text', description: 'Type text into an input field specified by selector', inputSchema: { selector: z.string(), text: z.string() } }, async (params: any) => { try { const input = z.object({ selector: z.string(), text: z.string() }).parse(params); await this.playwright.ensureConnected(); const page = this.playwright.getPage(); await page.fill(input.selector, input.text); return { content: [{ type: 'text', text: `Successfully typed text into element: ${input.selector}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Type text failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
  • Zod schema defining the input structure for the browser_type tool: selector (string) and text (string). Also has corresponding TypeScript type at line 63.
    export const BrowserTypeInputSchema = z.object({ selector: z.string(), text: z.string() });

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/b3nw/playwright-mcp-server'

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