Skip to content

mcpcompat/server: document and test declared client capabilities edge cases - #450

Merged
tgrunnagle merged 1 commit into
mainfrom
mcpcompat-declared-caps-doc-followups
Nov 2, 2026
Merged

tgrunnagle merged 1 commit into
mainfrom
mcpcompat-declared-caps-doc-followups

Conversation

@tgrunnagle

@tgrunnagle tgrunnagle commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #448, addressing the non-blocking notes from its approving review.

Summary

Documents three things a consumer of DeclaredClientCapabilities needs to know, and adds tests that pin the behavior the accessor depends on. There is no change to production behavior.

Changes

mcpcompat/server

  • Docs on SessionWithClientCapabilities.DeclaredClientCapabilities:
    • {"elicitation":{}} means form-only support, so form support is Elicitation != nil && (Elicitation.Form != nil || Elicitation.URL == nil), not Elicitation.Form != nil alone. URL-mode support is Elicitation != nil && Elicitation.URL != nil.
    • Only the initialize-handshake capabilities are read. Under protocol version 2026-07-28 a client sends its capabilities per request in _meta, and those are not reflected, so known=false there does not mean the client lacks a capability.
    • Tasks is always nil because go-sdk does not carry it, so nil means "not reported" rather than "not declared".
  • Form-rule test: TestClientSession_DeclaredCapabilities gains a wantFormSupported column that applies the documented rule, plus a form-only row.
  • End-to-end reap and rehydrate: TestDeclaredClientCapabilities_UnknownAfterReapAndRehydrate initializes with elicitation.url and checks known=true. It then closes the bound go-sdk session, which is the event the idle reaper produces, so there is no timer to make it flaky. It requests the same session ID again, which a rehydrated session serves, and checks known=false with zero capabilities.
  • Pointer comparison: TestDeclaredClientCapabilities_UnknownWhenReboundToSeededSession binds one session ID to two real go-sdk sessions that both carry InitializeParams.

Implementation Notes

  • Why the second new test exists. After a reap the shim drops the entry, so a rehydrated session starts with a nil initializedOn and the end-to-end test alone cannot tell a pointer comparison from a nil check. The older unit case "initialize observed on a different session" does not pin it either: it uses zero-value ServerSessions, whose InitializeParams() is nil, so it reports known=false regardless. The new test is the only one that fails if c.initializedOn.Load() != ss is replaced with c.initializedOn.Load() == nil.
  • Spec version claim. The _meta note is backed by go-sdk v1.8.0's MetaKeyClientCapabilities (io.modelcontextprotocol/clientCapabilities) in mcp/protocol.go.

Verification

  • task: lint reports 0 issues. and all packages pass, including mcpcompat/server.
  • task license-check: exit 0.
  • go test -race -count=20 -run 'DeclaredCapabilities|DeclaredClientCapabilities|FromGoSDKClientCapabilities' ./server from mcpcompat/: passes.
  • Mutation checks: dropping the initializedOn comparison fails the end-to-end test and the two existing rehydrate cases. Replacing it with a nil check fails only TestDeclaredClientCapabilities_UnknownWhenReboundToSeededSession.

🤖 Generated with Claude Code

… cases

Follow-ups from the review of #448:
- Document that {"elicitation":{}} means form-only support and how to
  check for form support, that only initialize-handshake capabilities are
  read (2026-07-28 carries them per request in _meta), and that Tasks is
  always nil because go-sdk does not carry it.
- Cover the form-support rule with an integration test row, including a
  form-only case.
- Add an end-to-end test that a session reaped and rehydrated under the
  same ID on one instance reports known=false.
- Add a test that binds one session ID to two go-sdk sessions that both
  carry InitializeParams, so the initializedOn comparison is what reports
  the newer session's seeded capabilities as unknown.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@tgrunnagle
tgrunnagle merged commit 9876910 into main Nov 2, 2026
6 checks passed
@tgrunnagle
tgrunnagle deleted the mcpcompat-declared-caps-doc-followups branch November 2, 2026 22:15
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.

2 participants