Skip to main content
Glama

resolve_uid_to_selector

Convert UIDs from browser snapshots into CSS selectors for automated testing and web scraping with Firefox DevTools.

Instructions

Resolve UID to CSS selector. Fails if stale.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesUID from snapshot

Implementation Reference

  • MCP tool handler: validates uid input, retrieves Firefox instance, calls resolveUidToSelector on it, returns selector or handles stale UID errors with user-friendly message.
    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); } }
  • MCP tool schema definition including name, description, and 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:126-128 (registration)
    Registration of the tool handler in the central toolHandlers Map used by the MCP server.
    ['take_snapshot', tools.handleTakeSnapshot], ['resolve_uid_to_selector', tools.handleResolveUidToSelector], ['clear_snapshot', tools.handleClearSnapshot],
  • src/index.ts:170-172 (registration)
    Inclusion of the tool definition in the allTools array returned by listTools.
    tools.takeSnapshotTool, tools.resolveUidToSelectorTool, tools.clearSnapshotTool,
  • FirefoxClient helper method delegated to by the tool handler, which forwards to SnapshotManager.
    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