browser_type
Input text into web page elements using element selectors, supporting multiple parallel browser instances with configurable delays and timeouts.
Instructions
Type text into an element
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"instanceId": "<instanceId>",
"selector": "<selector>",
"text": "<text>"
},
"name": "browser_type"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instanceId | Yes | Instance ID | |
| selector | Yes | Element selector | |
| text | Yes | Text to input | |
| delay | No | Input delay in milliseconds | |
| timeout | No | Timeout in milliseconds |
Implementation Reference
- src/tools.ts:722-745 (handler)The handler function that implements the core logic of the 'browser_type' tool. It retrieves the browser instance, locates the target element by selector, and types the provided text using Playwright's page.type() method with optional delay and timeout.
private async type(instanceId: string, selector: string, text: string, options: TypeOptions): Promise<ToolResult> { const instance = this.browserManager.getInstance(instanceId); if (!instance) { return { success: false, error: `Instance ${instanceId} not found` }; } try { const typeOptions: any = {}; if (options.delay) typeOptions.delay = options.delay; if (options.timeout) typeOptions.timeout = options.timeout; await instance.page.type(selector, text, typeOptions); return { success: true, data: { selector, text, typed: true }, instanceId }; } catch (error) { return { success: false, error: `Type failed: ${error instanceof Error ? error.message : error}`, instanceId }; } } - src/tools.ts:205-236 (registration)The tool registration object defining the 'browser_type' tool's name, description, and input schema. This is returned as part of the getTools() array for MCP tool discovery.
{ name: 'browser_type', description: 'Type text into an element', inputSchema: { type: 'object', properties: { instanceId: { type: 'string', description: 'Instance ID' }, selector: { type: 'string', description: 'Element selector', }, text: { type: 'string', description: 'Text to input', }, delay: { type: 'number', description: 'Input delay in milliseconds', default: 0 }, timeout: { type: 'number', description: 'Timeout in milliseconds', default: 30000 } }, required: ['instanceId', 'selector', 'text'] } }, - src/types.ts:66-69 (schema)TypeScript interface defining the options structure (delay and timeout) used in the browser_type tool handler, matching the inputSchema properties.
export interface TypeOptions { delay?: number; timeout?: number; } - src/tools.ts:541-545 (handler)The switch case dispatcher in executeTools() method that routes calls to the browser_type tool to the specific type() handler.
case 'browser_type': return await this.type(args.instanceId, args.selector, args.text, { delay: args.delay || 0, timeout: args.timeout || 30000 });