Repository navigation
Conversation
## Motivation and Context
`create_form_elicitation` sends to any client that declares `elicitation`, including one that declares only
`elicitation.url`, which the specification forbids. The `input_required` check and `require_client_capability!` take
`false` as declared, and `create_url_elicitation` raises `TypeError` on a declaration that is not an object.
The lookup (symbol or string keys) and the mode rule move to a private `ClientCapabilities` module used by all of
them. The rule is the one the `input_required` check already had: form mode is declared by `elicitation.form`, or
implied when neither `form` nor `url` is declared. That keeps `elicitation: {}` working, as well as declarations with
other members, such as the top-level `applyDefaults` of TypeScript SDK 1.22.0.
## How Has This Been Tested?
- `test/mcp/server_elicitation_test.rb`: form mode is refused for a URL-only, `false` or non-object declaration, and
accepted when neither mode or both are declared. URL mode is refused for a non-object declaration.
- `test/mcp/server/input_required_result_test.rb` and `test/mcp/server_context_test.rb`: `false` counts as not
declared, and form mode is implied when neither mode is declared.
Five of the seven tests fail on `main`; the two for accepted declarations guard existing behavior. Reverting any one
part of the change fails one of them. The fixture of `test/mcp/server_session_request_timeout_test.rb` declared only
URL mode while sending a form request, so it now declares both.
## Breaking Changes
None for clients that declare the modes they support. A server that sends form requests to a URL-only client, or to
one declaring `elicitation` as something other than an object, now gets the `RuntimeError` documented for an
unsupported client.
Fixes modelcontextprotocol#728.
8 of 13 tasks
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.
Form elicitation is no longer sent to clients that declare only URL mode, and a capability declared as
falsecounts as not declared.Fixes #728
Motivation and Context
create_form_elicitationsends to any client that declareselicitation, including one that declares onlyelicitation.url, which the specification forbids. Theinput_requiredcheck andrequire_client_capability!takefalseas declared, andcreate_url_elicitationraisesTypeErroron a declaration that is not an object.The lookup (symbol or string keys) and the mode rule move to a private
ClientCapabilitiesmodule used by all of them. The rule is the one theinput_requiredcheck already had: form mode is declared byelicitation.form, or implied when neitherformnorurlis declared. That keepselicitation: {}working, as well as declarations with other members, such as the top-levelapplyDefaultsof TypeScript SDK 1.22.0.How Has This Been Tested?
Automated unit / integration tests
Tested manually
Tested in a real application
test/mcp/server_elicitation_test.rb: form mode is refused for a URL-only,falseor non-object declaration, and accepted when neither mode or both are declared. URL mode is refused for a non-object declaration.test/mcp/server/input_required_result_test.rbandtest/mcp/server_context_test.rb:falsecounts as not declared, and form mode is implied when neither mode is declared.Five of the seven tests fail on
main; the two for accepted declarations guard existing behavior. Reverting any one part of the change fails one of them. The fixture oftest/mcp/server_session_request_timeout_test.rbdeclared only URL mode while sending a form request, so it now declares both.bundle exec rake test(2,815 tests, 10,202 assertions on Ruby 4.0.9; also run on 2.7),bundle exec rake rubocop,bundle exec yard --no-outputandbundle exec rake conformance:test(baseline) pass locally.Breaking Changes
None for clients that declare the modes they support. A server that sends form requests to a URL-only client, or to one declaring
elicitationas something other than an object, now gets theRuntimeErrordocumented for an unsupported client.Types of changes
Checklist
docs/_server/elicitation.md)Additional context
The TypeScript server's session check refuses form mode unless
formis declared orelicitationis empty; its multi round-trip check and the Python SDK's also accept other members. This PR uses one rule for both, so no declaration theinput_requiredcheck accepts today is refused, apart from capabilities set tofalse. Using the stricter rule for sessions is easy if you prefer it.