Skip to content

mcpcompat: expose a session's declared client capabilities #447

Closed

Description

@tgrunnagle

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 session ClientSessionFromContext returns, that returns (capabilities, known bool). On a session that saw initialize it returns the declared capabilities from the bound go-sdk session's InitializeParams, translated to mcpcompat types, including the elicitation.form and elicitation.url sub-objects.

Acceptance:

  • AC1.1: Inside a tool handler on a session that saw initialize, the accessor reports known true, with elicitation.url present for a client that declared {url: {}} and absent for {} and for no elicitation.
    • verify: Unit: TestClientSession_DeclaredCapabilities
  • AC1.2: On a rehydrated session and on a stateless request, the accessor reports known false.
    • verify: Unit: TestClientSession_DeclaredCapabilities_UnknownWhenNotObserved

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

  1. added
    enhancement
    on Nov 2, 2026
  2. added
    needs-triage
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions