Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getImages

Extract all images from web pages for web scraping, testing, or content analysis using browser automation.

Instructions

Get all images from the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that executes the getImages tool logic by evaluating JavaScript in the browser context to extract image elements' 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'); } }
  • Defines the tool schema including name, description, and empty input schema (no parameters required).
    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)
    Registers the getImages tool in the tools dictionary used for MCP capabilities.
    getImages: GET_IMAGES_TOOL,
  • src/server.ts:733-738 (registration)
    Dispatches the tool call to the playwrightController.getImages() handler in the MCP request handler.
    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