ctx: ToolContext. Use it for cancellation and request information without making the tool definition specific to a server or auth provider.
Fields
request, its metadata, and any client details are frozen per-request copies. Changing data in one request cannot mutate another request’s snapshot. Client details are unverified and are absent where the transport and era provide none, such as legacy HTTP. Never use a client name or capability declaration as an authenticated identity.
Client info/capabilities use a readonly union of modern and legacy wire types. ToolRequest is not a discriminated union: checking protocolVersion does not narrow the client type. Guard fields that differ between eras.
Application data
Use context providers for services such as database access, and integration-specific auth accessors for verified identity.ToolContext itself remains non-generic. Provider accessors return promises; JWT and Clerk useAuth(ctx) accessors remain synchronous.
Constructing a context for tests
0, the modern revision, no client, empty metadata, a fresh signal, and no registered providers. Reusing one context reuses its provider cache. Use the helper rather than hand-building context objects; future fields may be supplied by the helper. Direct calls bypass server validation and authorization.