Skip to main content
Glama

safari_take_screenshot

Capture a screenshot of the current webpage in Safari by providing the session ID, enabling browser automation and monitoring tasks.

Instructions

Take a screenshot of the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession identifier

Implementation Reference

  • MCP tool handler for 'safari_take_screenshot': extracts sessionId, calls driverManager.takeScreenshot(), returns text confirmation and base64 PNG image data.
    private async takeScreenshot(args: Record<string, any>): Promise<Array<{ type: string; text?: string; data?: string; mimeType?: string }>> { const { sessionId } = args; const screenshot = await this.driverManager.takeScreenshot(sessionId); return [ { type: 'text', text: `Screenshot captured successfully (${screenshot.length} bytes base64 data)` }, { type: 'image', data: screenshot, mimeType: 'image/png' } ];
  • Supporting method in SafariDriverManager that retrieves the session and calls Selenium WebDriver's takeScreenshot() to capture base64 screenshot.
    async takeScreenshot(sessionId: string): Promise<string> { const session = this.getSession(sessionId); if (!session) { throw new Error(`Session ${sessionId} not found`); } try { return await session.driver.takeScreenshot(); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); throw new Error(`Screenshot failed: ${errorMessage}`); } }
  • Tool registration in listTools handler: defines name, description, and input schema requiring sessionId.
    { name: 'safari_take_screenshot', description: 'Take a screenshot of the current page', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Session identifier' } }, required: ['sessionId'] } },
  • Dispatcher case in handleToolCall switch that routes to the takeScreenshot handler.
    case 'safari_take_screenshot': return await this.takeScreenshot(args);

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/lxman/safari-mcp-server'

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