Skip to main content
Glama

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
NameRequiredDescriptionDefault
uidYesThe UID from a snapshot to resolve

Implementation Reference

  • 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); } }
  • 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,
  • 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); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/freema/firefox-devtools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server