xjE& dZddlmZddlmZmZmZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZddlmZddlmZddlmZmZddlmZd d gZ e!e"efZ# dd ed zd e#d zde!e"efd zfdZ$Gdd Z%y )aTyped MCP request sugar over an `Outbound`. `ClientPeer` wraps any `Outbound` (anything with `send_raw_request` and `notify`) and exposes the server-to-client request methods (sampling, elicitation, roots, ping) as typed methods. `ClientPeer` does no capability gating: it builds the params, calls `send_raw_request(method, params)`, and parses the result into the typed model. Gating (and `NoBackChannelError`) is the wrapped `Outbound`'s job. )Mapping)Anycastoverload)CreateMessageRequestParamsCreateMessageResultCreateMessageResultWithToolsElicitRequestedSchemaElicitRequestFormParamsElicitRequestURLParams ElicitResultIncludeContextListRootsResultModelPreferences RequestParamsRequestParamsMetaSamplingMessageTool ToolChoice) BaseModel) deprecated) CallOptionsOutbound)MCPDeprecationWarning ClientPeerMetaNmodelmetareturnc||jdddnd}|rVttt|jddd}t |xsi}i|j di||d<|S)avSerialize a params model to a wire dict, merging `meta` into `_meta`. Shared by `ClientPeer` and `Connection` so every typed convenience method gets the same `_meta` handling. `meta` keys take precedence over any `_meta` already present on the model. `meta` is serialized through `RequestParams` so Python field names emit their wire aliases: an inbound `ctx.meta` carries `progress_token` (the key `_extract_meta` validation produces), and forwarding it outbound via `meta=ctx.meta` must put `progressToken` back on the wire. Keys not declared on `RequestParamsMeta` pass through unchanged. NTjson)by_aliasmode exclude_none)_meta)r"r#r%) model_dumprrrdictget)rrout wire_metas c/mnt/ssd/data/Dropbox/adrian/sandbox/mcp-query/venv/lib/python3.12/site-packages/mcp/shared/peer.py dump_paramsr,,sNSM^%  DvD  IdhC !->(EFQQ[_flQmnuv 39"o<#'''2.<)<G JcteZdZdZdeddfdZ d)dedeeefdzde dzde eeffd Z d)dedeeefdzde dzddfd Z e ed e ddddddddddd deedededzdedzdedzdeedzde eefdzdedzdddddedzde dzdefdZe ed e dddddddddd deedededzdedzdedzdeedzde eefdzdedzdeededzdedzde dzdefdZe ed e dddddddddd deedededzdedzdedzdeedzde eefdzdedzdeedzdededzde dzdefdZed e ddddddddddd deedededzdedzdedzdeedzde eefdzdedzdeedzdedzdedzde dzdeezfdZdddd ed!ededzde dzdef d"Zdddd ed#ed$ededzde dzdef d%Zed&e ddddedzde dzde fd'Z!ddddedzde dzddfd(Z"y)*raTyped server-to-client request methods over a wrapped `Outbound`. Use this when you have a bare dispatcher (or any `Outbound`) and want the typed methods (`sample`, `elicit_form`, `elicit_url`, `list_roots`, `ping`) without writing your own host class. outboundrNc||_yN) _outbound)selfr/s r+__init__zClientPeer.__init__Is !r-methodparamsoptscXK|jj|||d{S7wr1)r2send_raw_requestr3r5r6r7s r+r9zClientPeer.send_raw_requestLs' ^^44VVTJJJJs !*(*cZK|jj|||d{y7wr1)r2notifyr:s r+r<zClientPeer.notifyTs"nn##FFD999 !+)+zBThe sampling capability is deprecated as of 2026-07-28 (SEP-2577).)category) system_promptinclude_context temperaturestop_sequencesmetadatamodel_preferencestools tool_choicerr7messages max_tokensr?r@rArBrCrDrErFrc  Kywr1 r3rGrHr?r@rArBrCrDrErFrr7s r+samplezClientPeer.sampleWs "") r?r@rArBrCrDrFrr7c  Kywr1rJrKs r+rLzClientPeer.samplei "(+rM) r?r@rArBrCrDrErr7c  Kywr1rJrKs r+rLzClientPeer.sample{rOrMc Kt||||||||| |  } |jdt| | | d{}| | tj|dSt j|dS76w)a6Send a `sampling/createMessage` request to the peer. Raises: MCPError: The peer responded with an error. NoBackChannelError: No back-channel for server-initiated requests. pydantic.ValidationError: The peer's result does not match the expected result type. ) rGr?r@rArHrBrCrDrErFzsampling/createMessageNFby_name)rr9r,r model_validater)r3rGrHr?r@rArBrCrDrErFrr7r6results r+rLzClientPeer.samples0,'+#!)/#  ,,-E{SY[_G`bfgg   7/>>vuU U"11&%HHhs6A1A/7A1)rr7messagerequested_schemacKt||}|jdt|||d{}tj|dS7w)a0Send a form-mode `elicitation/create` request. Raises: MCPError: The peer responded with an error. NoBackChannelError: No back-channel for server-initiated requests. pydantic.ValidationError: The peer's result does not match the expected result type. )rVrWelicitation/createNFrR)r r9r,r rT)r3rVrWrr7r6rUs r+ elicit_formzClientPeer.elicit_formsO)K[\,,-A;vW[C\^bcc**65AAds.AA Aurlelicitation_idcKt|||}|jdt|||d{}tj|dS7w)a/Send a URL-mode `elicitation/create` request. Raises: MCPError: The peer responded with an error. NoBackChannelError: No back-channel for server-initiated requests. pydantic.ValidationError: The peer's result does not match the expected result type. )rVr[r\rYNFrR)r r9r,r rT)r3rVr[r\rr7r6rUs r+ elicit_urlzClientPeer.elicit_urlsQ (SQ_`,,-A;vW[C\^bcc**65AAds/AA Az?The roots capability is deprecated as of 2026-07-28 (SEP-2577).cK|jdtd||d{}tj|dS7w)aSend a `roots/list` request. Raises: MCPError: The peer responded with an error. NoBackChannelError: No back-channel for server-initiated requests. pydantic.ValidationError: The peer's result does not match the expected result type. z roots/listNFrR)r9r,rrT)r3rr7rUs r+ list_rootszClientPeer.list_rootss@,,\;tT;RTXYY--feDDZs!A?AcZK|jdtd||d{y7w)zSend a `ping` request and ignore the result. Raises: MCPError: The peer responded with an error. NoBackChannelError: No back-channel for server-initiated requests. pingN)r9r,)r3rr7s r+rbzClientPeer.pings'##FKd,CTJJJr=r1)#__name__ __module__ __qualname____doc__rr4strrrrr'r9r<rrrlistrintrfloatrrrrLrrr r r rZr^rr`rbrJr-r+rrAs""d"$( KKS!D(KD K c3h K:3:S0AD0H:P[^bPb:nr:T_tu %)15$(+/*.59  #'"'" " Tz " ($. "T\"S D("sCx.4'",d2"""Tk"D " "v" T_tu %)15$(+/*.59)- #'+'+ + Tz + ($. +T\+S D(+sCx.4'+,d2+Dz+ $&+Tk+D + &+v+ T_tu %)15$(+/*.59#' #'+'+ + Tz + ($. +T\+S D(+sCx.4'+,d2+DzD + +Tk+D + &+v+ T_tu %)15$(+/*.59#')- #'&I'&I &I Tz &I ($. &IT\&IS D(&IsCx.4'&I,d2&IDzD &I $&&ITk&ID &I ; ;&Iv&IZ!#' BB0B Tk B D B B2!#'BBB B Tk BD B B(Q\qr6:W[ Et E+PTBT E`o Es E15QUK$+KK$rss $&&"(77   CH~Ny4'td{d3PS8nW[F[*oKoKr-