Repository navigation
Description
Summary
mcpcompat's server session exposes the client capabilities the session declared at initialize, and says whether they are actually known. An embedding server can then tell whether a client supports URL-mode elicitation before sending one. Today ClientSession carries only the session ID and notification plumbing. The go-sdk ServerSession that holds InitializeParams is unexported behind it.
Consumed by stacklok/toolhive#6970.
Use case
A ToolHive vMCP tool handler answers a 2025-11-25 tools/call with -32042 only when the client declared elicitation.url. The MCP spec forbids sending an elicitation mode the client did not declare.
A rehydrated session is seeded with elicitation: {} (mcpcompat/server/transports.go) so that go-sdk's gate admits form elicitation. The client never declared that value, so the accessor must not present it as declared. Otherwise a later change to the seed would silently make consumers send modes no client declared.
Scenario 1. A handler reads the declared capabilities
Work:
mcpcompat/server: a read-only accessor, reachable from the sessionClientSessionFromContextreturns, that returns(capabilities, known bool). On a session that sawinitializeit returns the declared capabilities from the bound go-sdk session'sInitializeParams, translated to mcpcompat types, including theelicitation.formandelicitation.urlsub-objects.
Acceptance:
- AC1.1: Inside a tool handler on a session that saw
initialize, the accessor reportsknowntrue, withelicitation.urlpresent for a client that declared{url: {}}and absent for{}and for no elicitation.- verify:
Unit: TestClientSession_DeclaredCapabilities
- verify:
- AC1.2: On a rehydrated session and on a stateless request, the accessor reports
knownfalse.- verify:
Unit: TestClientSession_DeclaredCapabilities_UnknownWhenNotObserved
- verify:
Out of scope
| Item | Defer to | Why |
|---|---|---|
| Persisting capabilities through rehydration | Unscheduled | Consumers fall back when capabilities are unknown |
Delivery shape
One PR, released as a tagged toolhive-core version.
Activity
mcpcompat/server: expose a session's declared client capabilities (#448)