xj dZddlmZddlmZmZddlZddlmZddl m Z ddl m Z m Z ddlmZd gZe d eed ZGd d eeZy)a`BaseContext` - the user-facing per-request context. Composition over a `DispatchContext`: forwards the transport metadata, the back-channel (`send_raw_request`/`notify`), progress reporting, and the cancel event. Adds `meta` (the inbound request's `_meta` field). Satisfies `Outbound`, so `ClientPeer` can wrap it. Shared between client and server: the server's `Context` extends this with `lifespan`/`connection`; `ClientContext` is just an alias. )Mapping)AnyGenericN)RequestParamsMeta)TypeVar) CallOptionsDispatchContext)TransportContext BaseContext TransportTT)bounddefault covariantc 6eZdZdZddeededzddfdZedefdZ ede jfdZ ede fd Zededzfd Z dd ed eeefdzd edzdeeeffdZdd ed eeefdzd edzddfdZddededzdedzddfdZy)r zPer-request context wrapping a `DispatchContext`. `ServerRunner` constructs one per inbound request and passes it to the user's handler. Ndctxmetareturnc ||_||_yN)_dctx_meta)selfrrs f/mnt/ssd/data/Dropbox/adrian/sandbox/mcp-query/venv/lib/python3.12/site-packages/mcp/shared/context.py__init__zBaseContext.__init__"s  c.|jjS)z5Transport-specific metadata for this inbound request.)r transportrs rrzBaseContext.transport&szz###rc.|jjS)zCSet when the peer sends `notifications/cancelled` for this request.)rcancel_requestedrs rr zBaseContext.cancel_requested+szz***rc.|jjS)zWhether the back-channel can currently deliver server-initiated requests. `False` when the transport has no back-channel, or when the underlying dispatch context has been closed because the inbound request finished. )rcan_send_requestrs rr"zBaseContext.can_send_request0szz***rc|jS)z0The inbound request's `_meta` field, if present.)rrs rrzBaseContext.meta9szzrmethodparamsoptscXK|jj|||d{S7w)zSend a request to the peer on the back-channel. Raises: MCPError: The peer responded with an error. NoBackChannelError: `can_send_request` is `False`. N)rsend_raw_requestrr$r%r&s rr(zBaseContext.send_raw_request>s'ZZ00FFFFs !*(*cZK|jj|||d{y7w)z4Send a notification to the peer on the back-channel.N)rnotifyr)s rr+zBaseContext.notifyLs"jj555 !+)+progresstotalmessagecZK|jj|||d{y7w)z~Report progress for this request, if the peer supplied a progress token. A no-op when no token was supplied. N)rr-)rr-r.r/s rreport_progresszBaseContext.report_progressPs$ jj!!(E7;;;r,r)NN)__name__ __module__ __qualname____doc__r r rrpropertyranyioEventr boolr"rstrrrrdictr(r+floatr1rrr r sX _Z8@QTX@Xdh$:$$+%+++++$++'$.$( G GS!D( GD G c3h G636S0AD0H6P[^bPb6nr6rEsL $ '%>9 / \)9CS_c d :<'*%: