Skip to main content
Glama

viewpo_compare_viewports

Compare webpage layouts across different screen sizes to identify responsive design issues by detecting elements with differing CSS styles or dimensions between specified viewport widths.

Instructions

Compare the layout of a URL at two different viewport widths. Returns a list of elements whose size or CSS styles differ between the two viewports. Use this to find responsive design issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL to compare
viewport_aYesFirst viewport width in CSS pixels (e.g. 375 for phone)
viewport_bYesSecond viewport width in CSS pixels (e.g. 1920 for desktop)
selectorNoCSS selector to scope comparison to a subtree

Implementation Reference

  • Main handler function for viewpo_compare_viewports tool. Registers the tool with MCP server using server.tool(), defines the schema (url, viewport_a, viewport_b, selector parameters), and implements the async handler that calls client.compare() and formats the response.
    // --- Tool: viewpo_compare_viewports ---
    
    server.tool(
      "viewpo_compare_viewports",
      "Compare the layout of a URL at two different viewport widths. Returns a list of elements whose size or CSS styles differ between the two viewports. Use this to find responsive design issues.",
      {
        url: z.string().url().describe("The URL to compare"),
        viewport_a: z
          .number()
          .int()
          .min(100)
          .max(3840)
          .describe("First viewport width in CSS pixels (e.g. 375 for phone)"),
        viewport_b: z
          .number()
          .int()
          .min(100)
          .max(3840)
          .describe("Second viewport width in CSS pixels (e.g. 1920 for desktop)"),
        selector: z
          .string()
          .optional()
          .describe("CSS selector to scope comparison to a subtree"),
      },
      async ({ url, viewport_a, viewport_b, selector }) => {
        try {
          const result = await client.compare({
            url,
            viewport_a,
            viewport_b,
            selector,
          });
    
          const summary =
            result.differences.length === 0
              ? "No layout differences found between the two viewports."
              : `Found ${result.differences.length} difference(s) between ${result.viewport_a}px and ${result.viewport_b}px:`;
    
          return {
            content: [
              {
                type: "text" as const,
                text: `${summary}\n\n${JSON.stringify(result, null, 2)}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Compare failed: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Client method that performs the actual comparison by sending a POST request to the Viewpo macOS app's /compare endpoint.
    async compare(request: CompareRequest): Promise<CompareResponse> {
      return this.post<CompareResponse>("/compare", request);
    }
  • TypeScript interfaces defining the request and response schemas for the compare operation, including CompareRequest, CompareResponse, and LayoutDifference.
    export interface CompareRequest {
      url: string;
      viewport_a: number;
      viewport_b: number;
      selector?: string;
    }
    
    export interface LayoutDifference {
      selector: string;
      tag: string;
      property: string;
      value_a: string;
      value_b: string;
    }
    
    export interface CompareResponse {
      url: string;
      viewport_a: number;
      viewport_b: number;
      differences: LayoutDifference[];
    }
Behavior3/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 effectively describes the core behavior (comparing layouts and returning differences) and the purpose (finding responsive design issues), but lacks details on potential side effects, performance characteristics, error handling, or authentication needs. For a tool with no annotations, this is adequate but leaves gaps in behavioral understanding.

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 perfectly concise and front-loaded, consisting of two sentences that efficiently convey the tool's purpose, output, and usage. Every sentence earns its place: the first explains what the tool does and returns, while the second provides the usage context. There is zero waste or redundancy.

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

Completeness3/5

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

Given the tool's moderate complexity (comparing layouts across viewports) and the absence of both annotations and an output schema, the description is minimally complete. It covers the core functionality and use case but lacks details on output format, error conditions, or limitations. Without structured fields to rely on, the description should ideally provide more context, but it meets basic adequacy.

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, providing clear documentation for all parameters (url, viewport_a, viewport_b, selector). The description adds minimal value beyond the schema, only implicitly reinforcing the purpose of viewport comparison. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't significantly enhance parameter understanding.

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

Purpose5/5

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

The description clearly states the specific action ('Compare the layout of a URL at two different viewport widths'), identifies the resource (URL layout), and distinguishes from siblings by focusing on responsive design comparison rather than layout mapping or screenshot capture. It explicitly mentions the outcome ('Returns a list of elements whose size or CSS styles differ') and use case ('find responsive design issues').

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('Use this to find responsive design issues'), which implicitly differentiates it from siblings like viewpo_get_layout_map (likely for mapping layouts) and viewpo_screenshot (for capturing visuals). However, it does not explicitly state when NOT to use it or name specific alternatives, keeping it at a 4 rather than a 5.

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/littlebearapps/viewpo-mcp'

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