Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getImages

Extract all images from a webpage using PlayMCP's automation capabilities. Ideal for web scraping, testing, or saving visual content efficiently.

Instructions

Get all images from the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function in PlaywrightController class that evaluates all img elements on the current page and extracts their src, alt, title, width, and height attributes.
    async getImages(): Promise<Array<{src: string, alt?: string, title?: string, width?: number, height?: number}>> { try { if (!this.isInitialized()) { throw new Error('Browser not initialized'); } this.log('Getting page images'); const images = await this.state.page?.evaluate(() => { const imgElements = Array.from(document.querySelectorAll('img')); return imgElements.map(img => ({ src: (img as HTMLImageElement).src, alt: img.getAttribute('alt') || undefined, title: img.getAttribute('title') || undefined, width: (img as HTMLImageElement).naturalWidth || undefined, height: (img as HTMLImageElement).naturalHeight || undefined })); }); this.log('Images retrieved:', images?.length); return images || []; } catch (error: any) { console.error('Get images error:', error); throw new BrowserError('Failed to get images', 'Check if the page is loaded'); } }
  • The Tool schema definition for 'getImages', including name, description, and inputSchema (no required parameters).
    const GET_IMAGES_TOOL: Tool = { name: "getImages", description: "Get all images from the current page", inputSchema: { type: "object", properties: {}, required: [] } };
  • src/server.ts:530-530 (registration)
    Registration of the getImages tool in the tools object used for MCP capabilities.
    getImages: GET_IMAGES_TOOL,
  • src/server.ts:733-738 (registration)
    The dispatch handler in callTool request that invokes the playwrightController.getImages() and returns the result in MCP format.
    case 'getImages': { const images = await playwrightController.getImages(); return { content: [{ type: "text", text: JSON.stringify(images, null, 2) }] }; }

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/jomon003/PlayMCP'

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