[Client] Add client-side elicitation support#371
Open
wachterjohannes wants to merge 1 commit into
Open
Conversation
2315af2 to
5d1f416
Compare
The SDK could send elicitation/create requests from a server tool via ClientGateway::elicit(), but the client could not receive them: there was no request handler, and ElicitRequest was not registered in MessageFactory, so incoming elicitation/create messages failed to parse. This adds the client half, mirroring the existing Sampling pattern: - Register ElicitRequest in MessageFactory so elicitation/create parses. - ElicitationRequestHandler wraps a user callback and returns an ElicitResult (accept/decline/cancel) or an Error. - ElicitationCallbackInterface defines the callback contract. - ElicitationException forwards a specific message to the server; any other throwable returns a generic error. Includes unit tests, a runnable client example against the elicitation demo server, and client docs/README updates.
5d1f416 to
6f04701
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The SDK already supports server-initiated elicitation (
ClientGateway::elicit()), but the client could not receiveelicitation/createrequests:ElicitRequestwas not registered inMessageFactory, so incomingelicitation/createmessages failed to parse (InvalidInputMessageException).This PR closes that gap, mirroring the existing Sampling pattern one-to-one.
Changes
MessageFactory— registerElicitRequest::classsoelicitation/createparses (the critical fix).ElicitationRequestHandler— handles incomingelicitation/create, wraps a user callback, returnsResponse<ElicitResult>or anError.ElicitationCallbackInterface— the__invoke(ElicitRequest): ElicitResultcontract users implement.ElicitationException— throw from a callback to forward a specific message to the server; any other throwable returns a generic error (same semantics asSamplingException).MessageFactoryparse test.examples/client/stdio_elicitation.phpagainst the existing elicitation demo server.docs/client.mdElicitation section +README.mdcapability entries.ROADMAP.md: tick "Implement full support for elicitations" (now complete end-to-end).Usage
Verification
elicitation/createparsing).examples/client/stdio_elicitation.phpagainstexamples/server/elicitation/server.php—book_restaurantround-trips elicited content into a confirmed booking;confirm_actionreturns the boolean.php-cs-fixerclean; no new PHPStan errors introduced.