From 81c3a5331ec508b87f5a183e863d7d6096ca31a7 Mon Sep 17 00:00:00 2001 From: Jorge Cabiedes <57368278+jorge-cab@users.noreply.github.com> Date: Tue, 27 May 2025 08:59:35 -0700 Subject: [PATCH] Error handling --- .../packages/react-mcp-server/src/index.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/compiler/packages/react-mcp-server/src/index.ts b/compiler/packages/react-mcp-server/src/index.ts index f50ff32ada..2871027d64 100644 --- a/compiler/packages/react-mcp-server/src/index.ts +++ b/compiler/packages/react-mcp-server/src/index.ts @@ -386,18 +386,22 @@ server.tool( url: z.string().optional().default('http://localhost:3000'), }, async ({url}) => { - try { - const componentTree = await parseReactComponentTree(url); + const componentTree = await parseReactComponentTree(url); - return { - content: [ - { - type: 'text' as const, - text: componentTree, - }, - ], - }; + return { + content: [ + { + type: 'text' as const, + text: componentTree, + }, + ], + }; + } catch (err) { + return { + isError: true, + content: [{type: 'text' as const, text: `Error: ${err.stack}`}], + }; } }, );