Skip to content

fix(server): validate elicitation form/url sub-capabilities in check_capability#2979

Open
syf2211 wants to merge 1 commit into
modelcontextprotocol:mainfrom
syf2211:fix/2965-elicitation-sub-capability-check
Open

fix(server): validate elicitation form/url sub-capabilities in check_capability#2979
syf2211 wants to merge 1 commit into
modelcontextprotocol:mainfrom
syf2211:fix/2965-elicitation-sub-capability-check

Conversation

@syf2211

@syf2211 syf2211 commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Connection.check_capability() now validates elicitation sub-capabilities (form / url) when the caller specifies them, instead of only checking whether the client declared elicitation at all.

Motivation

Fixes #2965.

When a client supports URL-mode elicitation only, check_capability(ClientCapabilities(elicitation=ElicitationCapability(form=FormElicitationCapability()))) incorrectly returned True. The function only compared top-level have.elicitation is None, never inspecting individual sub-capabilities.

This mirrors the existing sampling.context / sampling.tools sub-capability checks in the same function.

Changes

  • src/mcp/server/connection.py: Add nested form / url presence checks under the elicitation branch.
  • tests/server/test_connection.py: Add 6 parametrized regression cases covering form/url mismatch, match, and generic elicitation checks.

Tests

  • uv run pytest tests/server/test_connection.py — 44 passed
  • uv run ruff check src/mcp/server/connection.py tests/server/test_connection.py — clean
  • uv run ruff format --check src/mcp/server/connection.py tests/server/test_connection.py — clean

Notes

  • ServerSession.check_client_capability() delegates to Connection.check_capability(), so this fix applies to both APIs.
  • AI assistance disclosure: fix and tests prepared with AI assistance; locally verified and reviewed before submission.

…capability

Connection.check_capability() only verified that the client declared
elicitation at all, not whether specific sub-capabilities (form vs url)
matched. Mirror the existing sampling sub-capability checks.

Fixes modelcontextprotocol#2965

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@itxaiohanglover

Copy link
Copy Markdown

Good fix! Validating each elicitation sub-capability (form/url) separately is more precise than the previous all-or-nothing check. The parametrized test matrix covering form-only, url-only, both, and mismatched cases is thorough.

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.

[Bug] check_capability does not validate elicitation sub-capabilities (form/url)

3 participants