Skip to main content
Glama

set_viewport

Adjust browser viewport dimensions to simulate different screen sizes for responsive design testing and mobile device simulation.

Instructions

Set the browser viewport size (e.g., for mobile simulation)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
widthYesViewport width in pixels
heightYesViewport height in pixels
mobileNoWhether to simulate a mobile device

Implementation Reference

  • The core handler function in BrowserManager class that initializes the page if needed and sets the viewport size using Puppeteer, returning a confirmation message.
    async setViewport(width: number, height: number, isMobile: boolean = false) {
        const page = await this.init();
        await page.setViewport({ width, height, isMobile });
        return `Viewport set to ${width}x${height} (Mobile: ${isMobile})`;
    }
  • The tool schema definition including name, description, and input schema for validation in the TOOLS array.
    {
        name: "set_viewport",
        description: "Set the browser viewport size (e.g., for mobile simulation)",
        inputSchema: {
            type: "object",
            properties: {
                width: { type: "number", description: "Viewport width in pixels" },
                height: { type: "number", description: "Viewport height in pixels" },
                mobile: { type: "boolean", description: "Whether to simulate a mobile device" },
            },
            required: ["width", "height"],
        },
    },
  • src/index.ts:135-141 (registration)
    The switch case registration in the CallToolRequestHandler that dispatches the set_viewport tool call to browserManager.setViewport with parsed arguments.
    case "set_viewport":
        result = await browserManager.setViewport(
            Number(args?.width),
            Number(args?.height),
            Boolean(args?.mobile)
        );
        break;
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool sets the viewport size and hints at mobile simulation, but lacks critical behavioral details: it doesn't specify if this affects current page rendering, requires an active browser context, has side effects (e.g., page reload), or error conditions (e.g., invalid dimensions). For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 a single, efficient sentence that front-loads the core purpose ('Set the browser viewport size') and includes a concise, relevant example. Every word earns its place, with no redundancy or unnecessary elaboration, making it highly scannable and clear.

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 tool's complexity (a mutation operation with 3 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like how the viewport change is applied, what happens to the current page, error handling, or return values. For a tool that modifies browser state, more context is needed to ensure safe and correct usage by an AI agent.

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?

Schema description coverage is 100%, with clear descriptions for 'width', 'height', and 'mobile' parameters. The description adds marginal value by linking 'mobile simulation' to the 'mobile' parameter, but doesn't provide additional semantics beyond what the schema already documents (e.g., no guidance on typical width/height values, interaction between 'mobile' and dimensions, or default behaviors). Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('Set') and resource ('browser viewport size'), with the parenthetical example providing additional context about mobile simulation. It distinguishes from siblings like 'navigate' or 'screenshot' by focusing on viewport configuration rather than navigation or capture. However, it doesn't explicitly differentiate from all siblings (e.g., it could mention this is for visual/rendering adjustments vs. interaction tools like 'click' or 'type').

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 the example 'e.g., for mobile simulation', which implies a use case but doesn't specify when to use this tool versus alternatives or prerequisites. There's no explicit when/when-not guidance, no mention of dependencies (e.g., requires a browser session), and no comparison to sibling tools like 'navigate' for page loading or 'screenshot' for capturing the viewport after setting it.

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/samusilv/qa-agent-mcp'

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