Skip to content

feat(handlers): return structured CONNECTION_FAILED error from bootstrap catch instead of "Bad Request: Server not initialized" #375

@coderabbitai

Description

@coderabbitai

Summary

In src/handlers.ts (around line 413–421), when the connection bootstrap fails (initialize, getClient, or ensureIntrospected throw), the error is currently wrapped and thrown as "Bad Request: Server not initialized". This means toStructuredError() cannot extract the underlying cause and return a structured CONNECTION_FAILED payload to MCP clients.

Desired behaviour

The bootstrap catch (initError) block should call createConnectionFailedError(...) and return its result directly (as a structured tool error response), instead of re-throwing wrapped in a "Bad Request" error. This allows clients to receive the full ConnectionFailedError payload — including instance_url, reconnecting, and suggested_fix — without needing to parse a generic error string.

Why it was deferred

The change alters the public error contract for the bootstrap failure path and was therefore considered out of scope for PR #369 (connection resilience).

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions