Skip to main content
Glama
sethbang

MCP Screenshot Server

by sethbang

take_screenshot

Capture screenshots of web pages or local HTML files by specifying URL, viewport dimensions, and output options for documentation or testing purposes.

Instructions

Capture a screenshot of any web page or local GUI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to capture (can be http://, https://, or file:///)
widthNoViewport width in pixels
heightNoViewport height in pixels
fullPageNoCapture full scrollable page
outputPathNoCustom output path (optional)

Implementation Reference

  • The main handler for the 'take_screenshot' tool. Validates input, launches Puppeteer in headless mode, sets viewport if specified, navigates to the URL, generates a timestamped filename, saves the screenshot (full page optional), and returns the relative path or error message.
      this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
        if (request.params.name !== 'take_screenshot') {
          throw new McpError(
            ErrorCode.MethodNotFound,
            `Unknown tool: ${request.params.name}`
          );
        }
    
        const options = request.params.arguments as unknown as ScreenshotOptions;
        if (!options?.url) {
          throw new McpError(
            ErrorCode.InvalidParams,
            'URL is required'
          );
        }
        
        try {
          const browser = await puppeteer.launch({
            headless: true,
            args: ['--no-sandbox', '--disable-setuid-sandbox'],
          });
    
          const page = await browser.newPage();
          
          // Set viewport if dimensions provided
          if (options.width && options.height) {
            await page.setViewport({
              width: options.width,
              height: options.height,
            });
          }
    
          // Navigate to URL
          await page.goto(options.url, {
            waitUntil: 'networkidle0',
            timeout: 30000,
          });
    
          // Generate filename with timestamp
          const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
          const filename = `screenshot-${timestamp}.png`;
          
          // If outputPath is provided, ensure it's relative to current working directory
          const outputPath = options.outputPath 
            ? path.join(process.cwd(), options.outputPath)
            : path.join(this.outputDir, filename);
    
          // Ensure output directory exists
          const outputDir = path.dirname(outputPath);
          if (!fs.existsSync(outputDir)) {
            fs.mkdirSync(outputDir, { recursive: true });
          }
    
          // Take screenshot
          await page.screenshot({
            path: outputPath,
            fullPage: options.fullPage || false,
          });
    
          await browser.close();
    
          // Return path relative to current working directory
          const relativePath = path.relative(process.cwd(), outputPath);
          return {
            content: [
              {
                type: 'text',
                text: `Screenshot saved to: ${relativePath}`,
              },
            ],
          };
        } catch (error: any) {
          return {
            content: [
              {
                type: 'text',
                text: `Screenshot error: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
      });
    }
  • src/index.ts:35-69 (registration)
    Registration of the 'take_screenshot' tool in the MCP server capabilities, defining name, description, and input schema.
      take_screenshot: {
        name: 'take_screenshot',
        description: 'Capture a screenshot of any web page or local GUI',
        inputSchema: {
          type: 'object',
          properties: {
            url: {
              type: 'string',
              description: 'URL to capture (can be http://, https://, or file:///)',
            },
            width: {
              type: 'number',
              description: 'Viewport width in pixels',
              minimum: 1,
              maximum: 3840,
            },
            height: {
              type: 'number',
              description: 'Viewport height in pixels',
              minimum: 1,
              maximum: 2160,
            },
            fullPage: {
              type: 'boolean',
              description: 'Capture full scrollable page',
            },
            outputPath: {
              type: 'string',
              description: 'Custom output path (optional)',
            },
          },
          required: ['url'],
        },
      },
    },
  • TypeScript interface defining the ScreenshotOptions used in the tool handler for input validation.
    interface ScreenshotOptions {
      url: string;
      width?: number;
      height?: number;
      fullPage?: boolean;
      outputPath?: string;
    }
  • src/index.ts:97-131 (registration)
    Tool schema returned by the ListTools handler.
      {
        name: 'take_screenshot',
        description: 'Capture a screenshot of any web page or local GUI',
        inputSchema: {
          type: 'object',
          properties: {
            url: {
              type: 'string',
              description: 'URL to capture (can be http://, https://, or file:///)',
            },
            width: {
              type: 'number',
              description: 'Viewport width in pixels',
              minimum: 1,
              maximum: 3840,
            },
            height: {
              type: 'number',
              description: 'Viewport height in pixels',
              minimum: 1,
              maximum: 2160,
            },
            fullPage: {
              type: 'boolean',
              description: 'Capture full scrollable page',
            },
            outputPath: {
              type: 'string',
              description: 'Custom output path (optional)',
            },
          },
          required: ['url'],
        },
      },
    ],
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions capturing web pages or local GUI but doesn't address critical aspects like authentication needs, rate limits, file format output, error conditions, or whether the operation is read-only or has side effects.

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 communicates the core functionality without any wasted words. It's appropriately sized and front-loaded with the essential information.

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?

For a tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns (image format, file location, error responses), behavioral constraints, or usage context, leaving significant gaps for agent 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?

Schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description doesn't add any meaningful parameter semantics beyond what's in the schema, maintaining the baseline score for high schema coverage.

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 ('capture') and target ('screenshot of any web page or local GUI'), providing a specific verb+resource combination. However, with no sibling tools mentioned, there's no opportunity to differentiate from alternatives, preventing a perfect score.

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 offers no guidance on when to use this tool versus alternatives, prerequisites, or limitations. It simply states what the tool does without context about appropriate use cases or constraints.

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/sethbang/mcp-screenshot-server'

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