From 0d2c927ce1d578289b58ea397223a08b63276e7a Mon Sep 17 00:00:00 2001 From: Raiko Funakami Date: Tue, 16 Sep 2025 16:50:03 +0900 Subject: [PATCH] fix(mobile_take_screenshot): fix MCP client compatibility and response format - Change from server.tool() to tool() helper function for better MCP client compatibility - Simplify return format from complex object to Data URL string format - Improve error handling with ActionableError for consistency Fixes mobile_take_screenshot function returning empty responses to MCP clients. --- src/server.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/server.ts b/src/server.ts index c134b20..239b108 100644 --- a/src/server.ts +++ b/src/server.ts @@ -394,7 +394,7 @@ export const createMcpServer = (): McpServer => { } ); - server.tool( + tool( "mobile_take_screenshot", "Take a screenshot of the mobile device. Use this to understand what's on screen, if you need to press an element that is available through view hierarchy then you must list elements on screen instead. Do not cache this result.", { @@ -432,15 +432,10 @@ export const createMcpServer = (): McpServer => { const screenshot64 = screenshot.toString("base64"); trace(`Screenshot taken: ${screenshot.length} bytes`); - return { - content: [{ type: "image", data: screenshot64, mimeType }] - }; + return `data:${mimeType};base64,${screenshot64}`; } catch (err: any) { error(`Error taking screenshot: ${err.message} ${err.stack}`); - return { - content: [{ type: "text", text: `Error: ${err.message}` }], - isError: true, - }; + throw new ActionableError(`Error taking screenshot: ${err.message}`); } } );