type_text
Enter text into specified input fields using CSS selectors with customizable keystroke delays. Enables precise automation in browser interactions via MCP Browser Server.
Instructions
Type text into an input field
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| delay | No | Delay between keystrokes in milliseconds | |
| selector | Yes | CSS selector for the input element | |
| text | Yes | Text to type |
Implementation Reference
- src/index.ts:501-517 (handler)Handler for the 'type_text' tool. Validates arguments with TypeTextSchema, uses Playwright's page.fill() to input text into the specified selector, ignores delay parameter, and returns a confirmation message.case 'type_text': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = TypeTextSchema.parse(args); await currentPage.fill(params.selector, params.text); return { content: [ { type: 'text', text: `Typed "${params.text}" into element: ${params.selector}` } ] }; }
- src/index.ts:33-37 (schema)Zod schema defining the input parameters for the type_text tool: selector (CSS selector), text (string to type), delay (optional ms between keystrokes, default 100).const TypeTextSchema = z.object({ selector: z.string(), text: z.string(), delay: z.number().default(100) });
- src/index.ts:196-218 (registration)Registration of the 'type_text' tool in the ListToolsRequestSchema handler response, providing name, description, and JSON schema matching the Zod schema.{ name: 'type_text', description: 'Type text into an input field', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the input element' }, text: { type: 'string', description: 'Text to type' }, delay: { type: 'number', default: 100, description: 'Delay between keystrokes in milliseconds' } }, required: ['selector', 'text'] } },