stop_recording_macro
Halts the current macro recording and outputs the captured events in JSON format for automation tasks.
Instructions
Stop recording and return the macro JSON with recorded events.
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/index.ts:26-26 (registration)Import of registerMacroTools which registers the stop_recording_macro tool
import { registerMacroTools } from './macros.js'; - src/tools/index.ts:53-53 (registration)Registration call to registerMacroTools which registers stop_recording_macro
registerMacroTools(server, bridge); - src/tools/macros.ts:29-49 (handler)Handler for stop_recording_macro tool - sends command via WebSocket bridge to stop macro recording and returns recorded events
server.tool( 'stop_recording_macro', 'Stop recording and return the macro JSON with recorded events.', { 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: 'stop_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:32-35 (schema)Input schema for stop_recording_macro: optional tabId and apiKey parameters
{ 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 helper that relays the command to the Chrome extension and returns the 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)); }); }