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);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'Fails if stale', which hints at potential failure modes, but doesn't cover other critical aspects like error handling, performance, side effects, or return format. This leaves significant gaps for a tool that resolves identifiers.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with two short sentences that are front-loaded and waste no words. Every part ('Resolve UID to CSS selector' and 'Fails if stale') earns its place by stating purpose and a key behavioral note.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of resolving UIDs to CSS selectors, no annotations, and no output schema, the description is incomplete. It lacks details on what the tool returns, how failures are handled, or the context of UIDs from snapshots, making it inadequate for full understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'uid' parameter documented as 'UID from snapshot'. The description adds no additional parameter semantics beyond this, so it meets the baseline of 3 where the schema does the heavy lifting without compensating for any gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Resolve UID to CSS selector', specifying the verb (resolve) and resource (UID to CSS selector). It distinguishes from siblings like click_by_uid or fill_by_uid by focusing on resolution rather than interaction. However, it doesn't explicitly differentiate from tools like take_snapshot that might also involve UIDs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance with 'Fails if stale', implying usage when the UID is fresh, but offers no explicit when-to-use advice, alternatives, or context compared to siblings. It lacks clear prerequisites or scenarios for choosing this tool over others.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/mozilla/firefox-devtools-mcp'

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