get_search_html
Extract HTML content from web pages by searching with regex patterns to locate specific elements and retrieve surrounding context for browser automation testing.
Instructions
Search page HTML by regex pattern and return surrounding HTML context for matches.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| regex | Yes | Regular expression pattern to search for | |
| index | No | Optional 0-based index of which match to return | |
| tab_id | No | Optional tab/window ID |
Implementation Reference
- src/tools.ts:30-48 (registration)Tool registration for get_search_html in tools.ts.
name: 'get_search_html', description: 'Search page HTML by regex pattern and return surrounding HTML context for matches.', inputSchema: { type: 'object' as const, properties: { regex: { type: 'string', description: 'Regular expression pattern to search for', }, index: { type: 'number', description: 'Optional 0-based index of which match to return', }, tab_id: { type: 'string', description: 'Optional tab/window ID' }, }, required: ['regex'], }, }, - src/index.ts:21-25 (handler)The tool handler in index.ts dynamically calls the bridge client using the tool name.
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params try { const result = (await bridge.call(name, (args as Record<string, unknown>) || {})) as Record<string, unknown> - src/bridge-client.ts:24-72 (helper)The BridgeClient performs the actual HTTP request to the backend service. When get_search_html is called, this client maps it to /api/get_search_html.
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() }) } }