clear_and_replace_commands
Replace all commands in a Selenix browser automation test with a new set, removing existing commands first to update test workflows.
Instructions
Replace ALL commands in a test with a new set. This removes all existing commands first.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| test_id | Yes | The test ID | |
| commands | Yes | The new set of commands for the test |
Implementation Reference
- src/bridge-client.ts:24-71 (handler)The handler logic uses a BridgeClient that dynamically forwards the tool call (endpoint) to the Selenix backend via HTTP. The tool name 'clear_and_replace_commands' corresponds to the endpoint '/api/clear_and_replace_commands'.
export class BridgeClient { async call(endpoint: string, body: Record<string, unknown> = {}): Promise<unknown> { // Re-read config on every call so we pick up new tokens after Selenix restarts const config = readConfig() return new Promise((resolve, reject) => { const data = JSON.stringify(body) const req = http.request( { hostname: '127.0.0.1', port: config.port, path: `/api/${endpoint}`, method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${config.token}`, 'Content-Length': Buffer.byteLength(data), }, timeout: 180000, // 3 minutes for long-running operations like run_test }, (res) => { let responseData = '' res.on('data', (chunk: string) => (responseData += chunk)) res.on('end', () => { try { resolve(JSON.parse(responseData)) } catch { resolve({ raw: responseData }) } }) } ) req.on('error', (err) => reject( new Error( `Cannot connect to Selenix bridge at 127.0.0.1:${config.port}. ` + `Is Selenix running with MCP Server enabled? (${err.message})` ) ) ) req.on('timeout', () => { req.destroy() reject(new Error('Request timed out after 180 seconds')) }) req.write(data) req.end() }) } - src/tools.ts:216-242 (schema)Tool definition and input schema for clear_and_replace_commands.
name: 'clear_and_replace_commands', description: 'Replace ALL commands in a test with a new set. This removes all existing commands first.', inputSchema: { type: 'object' as const, properties: { test_id: { type: 'string', description: 'The test ID', }, commands: { type: 'array', items: { type: 'object', properties: { command: { type: 'string' }, target: { type: 'string' }, value: { type: 'string' }, }, required: ['command'], }, description: 'The new set of commands for the test', }, }, required: ['test_id', 'commands'], }, },