resolve_uid_to_selector
Convert UID identifiers from browser snapshots into CSS selectors for debugging web elements and automating browser interactions.
Instructions
Resolve a UID to a CSS selector (debugging aid). Fails on stale UIDs—take a fresh snapshot first.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | The UID from a snapshot to resolve |
Implementation Reference
- src/tools/snapshot.ts:130-162 (handler)MCP tool handler: validates input, gets Firefox instance, calls firefox.resolveUidToSelector(uid), handles stale UID errors specifically, returns selector or error.export async function handleResolveUidToSelector(args: unknown): Promise<McpToolResponse> { try { const { uid } = args as { uid: string }; if (!uid || typeof uid !== 'string') { throw new Error('uid parameter is required and must be a string'); } const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); try { const selector = firefox.resolveUidToSelector(uid); return successResponse(`${uid} → ${selector}`); } catch (error) { const errorMsg = (error as Error).message; // Concise error for stale UIDs if ( errorMsg.includes('stale') || errorMsg.includes('Snapshot') || errorMsg.includes('UID') || errorMsg.includes('not found') ) { throw new Error(`UID "${uid}" stale/invalid. Call take_snapshot first.`); } throw error; } } catch (error) { return errorResponse(error as Error); } }
- src/tools/snapshot.ts:37-50 (schema)Tool schema defining the 'resolve_uid_to_selector' tool with inputSchema requiring 'uid' string.export const resolveUidToSelectorTool = { name: 'resolve_uid_to_selector', description: 'Resolve UID to CSS selector. Fails if stale.', inputSchema: { type: 'object', properties: { uid: { type: 'string', description: 'UID from snapshot', }, }, required: ['uid'], }, };
- src/index.ts:127-127 (registration)Registration of the resolve_uid_to_selector tool handler in the MCP server's toolHandlers Map.['resolve_uid_to_selector', tools.handleResolveUidToSelector],
- src/index.ts:171-171 (registration)Registration of the resolveUidToSelectorTool definition in the MCP server's allTools list for listTools requests.tools.resolveUidToSelectorTool,
- src/firefox/index.ts:325-330 (helper)FirefoxClient helper method delegated by the MCP handler, forwarding to snapshot manager.resolveUidToSelector(uid: string): string { if (!this.snapshot) { throw new Error('Not connected'); } return this.snapshot.resolveUidToSelector(uid); }