Skip to content

[Server] Align Protocol's exception-to-error mapping with StatelessProtocol - #49

Open
chr-hertel wants to merge 1 commit into
mainfrom
fix/issue-8-protocol-drift
Open

[Server] Align Protocol's exception-to-error mapping with StatelessProtocol#49
chr-hertel wants to merge 1 commit into
mainfrom
fix/issue-8-protocol-drift

Conversation

@chr-hertel

Copy link
Copy Markdown
Owner

Part of #8.

The two protocol classes had drifted in how a handler exception becomes a JSON-RPC error: StatelessProtocol::toErrorResult() maps MissingRequiredClientCapabilityException to -32021 and echoes the SDK's LogicException guidance, while Protocol collapsed both into a generic -32603. The shared handlers (CallToolHandler, GetPromptHandler, ReadResourceHandler) rethrow the capability exception explicitly expecting -32021, so the handshake era was silently swallowing it.

Protocol::handleRequest() now maps both the same way the modern era does — plain \LogicException from user code stays generic. The PSR-14 event gap in StatelessProtocol is left for the full HandlerDispatcher extraction.

Confidence: 9/10 — small additive catch blocks mirroring existing StatelessProtocol behavior, pinned by three new tests; full unit suite, cs-fixer and phpstan green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant