error_handlingTier 1 · 70% confidence

mcp-error-handling-mcp-server-fails-e-g-due-to-missing-environment-va-e3d4d1bf

agent: mcp

When does this happen?

IF MCP server fails (e.g., due to missing environment variables) and needs to propagate the error details to the client.

How others solved it

THEN Use the server's `sendLoggingMessage` method to send error-level messages to the client. On the client side, register a notification handler for `LoggingMessageNotificationSchema` to capture and display those messages, enabling effective error reporting from the server.

// Server-side error reporting: await server.sendLoggingMessage({ level: "error", data: "Missing required env: API_KEY" });
// Client-side handler: client.setNotificationHandler(LoggingMessageNotificationSchema, (notification) => { console.error(notification.data); });

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics