browser_press_key
Simulate pressing a key in the browser to automate keyboard input for web interactions.
Instructions
browser press key
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "browser_press_key"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/browser_tools.js:402-428 (handler)The main handler function for 'browser_press_key'. It validates the 'key' argument, gets the current page via getPage(), calls page.keyboard.press(key) to simulate a keyboard press, and returns a success/error response.
async function browserPressKey(key) { try { if (!key) { return { success: false, message: 'Key is required' }; } const page = await getPage(); await page.keyboard.press(key); return { success: true, message: `Pressed key: ${key}`, key }; } catch (error) { logger.error(`Error pressing key: ${error.message}`); return { success: false, message: error.message }; } } - src/mcp/server.js:127-135 (registration)Registration: 'browser_press_key' is added to the list of browser extra tools in the MCP server tool registry (line 129). A tool entry with name 'browser_press_key' and a basic description is pushed into the tools array.
const browserExtras = [ { n:'browser_navigate_back' }, { n:'browser_navigate_forward' }, { n:'browser_hover' }, { n:'browser_drag' }, { n:'browser_select_option' }, { n:'browser_press_key' }, { n:'browser_snapshot' }, { n:'browser_console_messages' }, { n:'browser_network_requests' }, { n:'browser_tab_list' }, { n:'browser_tab_new' }, { n:'browser_tab_select' }, { n:'browser_tab_close' }, { n:'browser_file_upload' }, { n:'browser_wait' }, { n:'browser_wait_for' }, { n:'browser_resize' }, { n:'browser_handle_dialog' } ]; for (const b of browserExtras) { tools.push({ name: b.n, description: b.n.replace(/_/g,' '), inputSchema: { type:'object', properties:{} } }); - src/mcp/server.js:282-282 (registration)Dispatch/case handler: In the MCP server's tool call dispatch, the case 'browser_press_key' delegates to browserTools.browserPressKey(args.key).
case 'browser_press_key': data = await browserTools.browserPressKey(args.key); break; - src/tools/browser_tools.js:1139-1145 (helper)Export: browserPressKey is exported from the browser_tools module (line 1139) so it can be imported by the MCP server.
browserPressKey, // Capture browserTakeScreenshot, browserSnapshot, browserPdfSave,