From e6fca5874026f7b84c562987d55c74a6873ff806 Mon Sep 17 00:00:00 2001 From: masnwilliams <43387599+masnwilliams@users.noreply.github.com> Date: Fri, 31 Jul 2026 15:35:29 +0000 Subject: [PATCH 1/3] Flag failed playwright executions as tool errors --- src/lib/mcp/tools/playwright.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/mcp/tools/playwright.ts b/src/lib/mcp/tools/playwright.ts index 9e8f3cc..6de7801 100644 --- a/src/lib/mcp/tools/playwright.ts +++ b/src/lib/mcp/tools/playwright.ts @@ -56,6 +56,9 @@ export function registerPlaywrightTool(server: McpServer) { ], }; } catch (error) { + // The code never ran -- the session was gone, unleased, or the request failed. + // Distinct from code that ran and threw, which comes back as a 200 with + // success: false so the agent can read the failure and adjust. return { content: [ { @@ -70,6 +73,7 @@ export function registerPlaywrightTool(server: McpServer) { ), }, ], + isError: true, }; } }, From 512194f521e04913648519ceb080d16d9ee0eb1d Mon Sep 17 00:00:00 2001 From: masnwilliams <43387599+masnwilliams@users.noreply.github.com> Date: Fri, 31 Jul 2026 21:42:18 +0000 Subject: [PATCH 2/3] Describe the caught failure more precisely --- src/lib/mcp/tools/playwright.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/mcp/tools/playwright.ts b/src/lib/mcp/tools/playwright.ts index 6de7801..0375cfb 100644 --- a/src/lib/mcp/tools/playwright.ts +++ b/src/lib/mcp/tools/playwright.ts @@ -11,7 +11,7 @@ export function registerPlaywrightTool(server: McpServer) { code: z .string() .describe( - 'Playwright/TypeScript code with `page`, `context`, and `browser` objects in scope; the value you `return` is sent back. Example: `await page.goto(\'https://example.com\'); return await page.title();` Return only what you need — prefer a targeted selector (e.g. `await page.locator(\'h1\').innerText()`) or a region-scoped snapshot (e.g. `await page.locator(\'main\').ariaSnapshot()`) rather than dumping the whole page.', + "Playwright/TypeScript code with `page`, `context`, and `browser` objects in scope; the value you `return` is sent back. Example: `await page.goto('https://example.com'); return await page.title();` Return only what you need — prefer a targeted selector (e.g. `await page.locator('h1').innerText()`) or a region-scoped snapshot (e.g. `await page.locator('main').ariaSnapshot()`) rather than dumping the whole page.", ), session_id: z .string() @@ -56,9 +56,9 @@ export function registerPlaywrightTool(server: McpServer) { ], }; } catch (error) { - // The code never ran -- the session was gone, unleased, or the request failed. - // Distinct from code that ran and threw, which comes back as a 200 with - // success: false so the agent can read the failure and adjust. + // No normal API response came back -- the session was gone, unleased, the request + // was rejected, or it timed out. Distinct from code that ran and threw, which comes + // back as a 200 with success: false so the agent can read the failure and adjust. return { content: [ { From 7764544dd61ee31c52e0aa552a59ba9a47e9803a Mon Sep 17 00:00:00 2001 From: masnwilliams <43387599+masnwilliams@users.noreply.github.com> Date: Fri, 31 Jul 2026 21:42:38 +0000 Subject: [PATCH 3/3] Restore quote style on an untouched line --- src/lib/mcp/tools/playwright.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/mcp/tools/playwright.ts b/src/lib/mcp/tools/playwright.ts index 0375cfb..3e1a266 100644 --- a/src/lib/mcp/tools/playwright.ts +++ b/src/lib/mcp/tools/playwright.ts @@ -11,7 +11,7 @@ export function registerPlaywrightTool(server: McpServer) { code: z .string() .describe( - "Playwright/TypeScript code with `page`, `context`, and `browser` objects in scope; the value you `return` is sent back. Example: `await page.goto('https://example.com'); return await page.title();` Return only what you need — prefer a targeted selector (e.g. `await page.locator('h1').innerText()`) or a region-scoped snapshot (e.g. `await page.locator('main').ariaSnapshot()`) rather than dumping the whole page.", + 'Playwright/TypeScript code with `page`, `context`, and `browser` objects in scope; the value you `return` is sent back. Example: `await page.goto(\'https://example.com\'); return await page.title();` Return only what you need — prefer a targeted selector (e.g. `await page.locator(\'h1\').innerText()`) or a region-scoped snapshot (e.g. `await page.locator(\'main\').ariaSnapshot()`) rather than dumping the whole page.', ), session_id: z .string()