start_recording_macro
Record user clicks, typing, and navigation in a browser tab to create a macro for automation.
Instructions
Start recording user actions (clicks, typing, navigation) in a tab. Inject the macro recorder content script.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tabId | No | Target tab ID (defaults to currently active tab) | |
| apiKey | No | API key for authentication if enabled |
Implementation Reference
- src/tools/macros.ts:7-27 (registration)The `start_recording_macro` tool is registered on the MCP server via `server.tool()`. It accepts optional `tabId` and `apiKey` parameters, sends a 'start_recording_macro' command over the WebSocket bridge, and returns the result as JSON text.
server.tool( 'start_recording_macro', 'Start recording user actions (clicks, typing, navigation) in a tab. Inject the macro recorder content script.', { tabId: z.number().optional().describe('Target tab ID (defaults to currently active tab)'), apiKey: z.string().optional().describe('API key for authentication if enabled'), }, async ({ tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'start_recording_macro', params: {}, tabId, apiKey, timeout: LONG_TIMEOUT, }); if (!result.success) { return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } ); - src/tools/macros.ts:10-13 (schema)Input schema for start_recording_macro: tabId (optional number) and apiKey (optional string).
{ tabId: z.number().optional().describe('Target tab ID (defaults to currently active tab)'), apiKey: z.string().optional().describe('API key for authentication if enabled'), }, - src/websocket-bridge.ts:63-103 (helper)WebSocketBridge.sendCommand() is the helper method that serializes the 'start_recording_macro' command and sends it over WebSocket to the Chrome extension side, awaiting a response.
async sendCommand(cmd: BridgeCommand): Promise<BridgeResponse> { if (!this.isConnected()) { return { success: false, error: { code: 'NOT_CONNECTED', message: 'Chrome extension is not connected. Ensure the extension is installed, enabled, and the browser is running.', }, }; } const id = crypto.randomUUID(); const timeout = cmd.timeout ?? DEFAULT_TIMEOUT; return new Promise<BridgeResponse>((resolve, reject) => { const timer = setTimeout(() => { this.pending.delete(id); resolve({ success: false, error: { code: 'TIMEOUT', message: `Command '${cmd.command}' timed out after ${timeout}ms`, }, }); }, timeout); this.pending.set(id, { resolve, reject, timer }); const message = { id, type: 'request', command: cmd.command, params: cmd.params, tabId: cmd.tabId, apiKey: cmd.apiKey, timestamp: Date.now(), }; this.client!.send(JSON.stringify(message)); }); } - src/tools/index.ts:53-55 (registration)The registerMacroTools function is called in registerAllTools to register all macro tools (including start_recording_macro) on the MCP server.
registerMacroTools(server, bridge); registerVisualRegressionTools(server, bridge); }