server.getContext() anywhere in the call tree during a live request:
This page is under construction. The outline below sketches what it will cover.
- How context works — ambient via
AsyncLocalStorage;getContext()throws outside a live request handler; available in tool, resource, and prompt handlers. - Logging and progress —
log(level, message)plus RFC 5424 shorthands (debug/info/warning/error/…);reportProgress(progress, total?, message?)(a no-op when the request carries no progress token). - Client round-trips —
sample(params)for LLM inference,elicit(message, schema)for user input forms,listRoots()— each throws if the client lacks the corresponding capability. - Per-session state —
getState/setState/deleteState, scoped per HTTP session (one shared map for stdio); plusauthandrequestIdfields.