Skip to main content
Glama

browser_type

Automate text input into specified web elements using Playwright MCP Server. Define a selector and text to interact with input fields for web automation tasks.

Instructions

Type text into an input field specified by selector

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYes
textYes

Implementation Reference

  • The handler function for the 'browser_type' tool that types text into a page element using Playwright's page.fill method.
    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:193-230 (registration)
    Registration of the 'browser_type' tool with the MCP server, including metadata, input schema, and inline handler function.
    this.server.registerTool( '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 input schema definition for the browser_type tool inputs for TypeScript type inference.
    export const BrowserTypeInputSchema = z.object({ selector: z.string(), text: z.string() });

Other Tools

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

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