+
    ÆÚjqe  ã                   ó”  a € R= tD0 t R t^ RIt^ RIt^ RIt^ RIHtHtHtH	t	 ^ RI
Ht ^ RIHt ^ RIHtHtHt ^ RIHtHtHtHt ^ RIHtHtHtHtHtHtHt ^ RIH t  . R>Ot!Rt"] ^ k  Rt#] ^k  Rt$] ^k  Rt%] ^k  ]! RRRRRR/4      t&] ^k  ]PN                  ! R4      t(]PN                  ! R4      t)]PN                  ! R4      t*]+! 0 R?m4      t,] ^k ]+! 0 R@m4      t-] ^k ]+! 0 RAm4      t.] ^k ]+! 0 RBm4      t/] ^k R R lt0R R lt1R R lt2R R lt3Rt4] ^	k  R  R! lt5R" R# lt6R$ R% lt7R& R' lt8R( R) lt9]! ]R*]R*]R*]R*]R*]R*]R+/4      t:] ^
k  ]! R,R-7       ! R. R
4      4       t;]! R,R-7       ! R/ R	4      4       t<]+! ]"]#]$04      t=] ^k R0 R1 lt>] 3R2 R3 llt?R4RR5] /R6 R7 llt@]PN                  ! R84      tAR9 R: ltBR; R< ltCR# )Ca@  Inbound request classification for the modern per-request-envelope path.

Pure module: no I/O, no transport, no `mcp.server` imports. Runs the
validation ladder against a decoded JSON-RPC body and returns either an
:class:`InboundModernRoute` (every rung passed) or an
:class:`InboundLadderRejection` (the first rung that failed). Callers map a
rejection's `code` through :data:`ERROR_CODE_HTTP_STATUS` to pick the HTTP
status.

Also hosts the shared header-value codec and the `x-mcp-header` schema
validator so client emit and server validate read the same source of truth.
N)ÚIterableÚIteratorÚMappingÚSequence)Ú	dataclass)ÚMappingProxyType)ÚAnyÚFinalÚcast)ÚCLIENT_CAPABILITIES_META_KEYÚCLIENT_INFO_META_KEYÚPROTOCOL_VERSION_META_KEYÚ#UnsupportedProtocolVersionErrorData)ÚHEADER_MISMATCHÚINVALID_PARAMSÚINVALID_REQUESTÚMETHOD_NOT_FOUNDÚ"MISSING_REQUIRED_CLIENT_CAPABILITYÚPARSE_ERRORÚUNSUPPORTED_PROTOCOL_VERSION)ÚMODERN_PROTOCOL_VERSIONSÚInboundLadderRejectionÚInboundModernRoutezmcp-protocol-versionz
mcp-methodzmcp-namezx-mcp-headerz
tools/callÚnamezprompts/getzresources/readÚuriz^=\?base64\?(?P<payload>.*)\?=$z^[\x20-\x7E]*$z^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$c          	      ó²   € V ^8„  d   QhR\         R\        \        \        \        R3,          R,          \        \        \         3,          3,          ,          /# )é   ÚrootÚreturn.N©r   r   ÚtupleÚstrÚdict)Úformats   "Ú‰/opt/data/installs/351f81cc06284494/environments/aa258815729c481f8402f54f4c368f83/venv/lib/python3.14/site-packages/mcp/shared/inbound.pyÚ__annotate__r%   x   sG   € ÷ Xñ X¤ð X¬´%¼¼cÀ3¸h½È$Õ8NÔPTÔUXÔZ]ÐU]ÕP^Ð8^Õ2_Õ)`ñ Xó    c           	   #  ó®  "  € RV 3.pV'       EdÃ   VP                  4       w  r#\        V\        4      '       g   K3  \        \        \        \
        3,          V4      pW$3x € VP                  4        EFZ  w  rVVR8X  do   \        V\        4      '       dY   \        \        \        \
        3,          V4      P                  4        F#  w  rxTP                  Ve   . VOVN5MRV34       K%  	  K{  V\        9   d   VP                  RV34       K›  V\        9   dJ   \        V\        4      '       d4   VP                  R \        \        \
        ,          V4       4       4       Kï  V\        9   g   Kü  \        V\        4      '       g   EK  VP                  R \        \        \        \
        3,          V4      P                  4        4       4       EK]  	  EKË  R# 5i)aø  Yield `(properties_path, schema)` for every schema position in `root`.

`properties_path` is the chain of `properties` keys from the root to the
position, or `None` once any other applicator keyword has been crossed.
The root itself yields `()`. Only the JSON Schema 2020-12 applicators
listed above are entered; instance-data keywords are not, and `$ref` is
not dereferenced, so the walk terminates on any finite JSON value. An
explicit stack keeps the function total even on pathologically deep input.
Ú
propertiesNc              3   ó*   "  € T F	  pR V3x € K  	  R # 5i©N© ©Ú.0Úsubs   & r$   Ú	<genexpr>Ú)_walk_schema_positions.<locals>.<genexpr>�   s   é € ÐIÑ4H¨S˜d C�[Ó4Hùó   ‚c              3   ó*   "  € T F	  pR V3x € K  	  R # 5ir*   r+   r,   s   & r$   r/   r0   ’   s   é € ÐWÑ4V¨S˜d C�[Ó4Vùr1   r+   )ÚpopÚ
isinstancer"   r
   r!   r   ÚitemsÚappendÚ_SUBSCHEMA_SINGLEÚ_SUBSCHEMA_LISTÚlistÚextendÚ_SUBSCHEMA_MAPÚvalues)	r   ÚstackÚpathÚnodeÚschemaÚkwÚvalr   r.   s	   &        r$   Ú_walk_schema_positionsrC   x   sH  é € ð 9;¸D°z°l€Eß
ˆ%Ø—Y‘Y“[‰
ˆÜ˜$¤×%Ò%ÙÜ”dœ3¤˜8•n dÓ+ˆØˆlÒØ—|‘|—~‰GˆBØ�\Ô!¤j°´d×&;Ò&;Ü!%¤d¬3´¨8¥n°cÓ!:×!@Ñ!@Ö!B‘I�DØ—L‘L°4Ò3C - D -¨$¢-ÈÈsÐ!SÖTó "CàÔ(Ô(Ø—‘˜d C˜[Ö)Ø”Ô&¬:°c¼4×+@Ò+@Ø—‘ÑI´D¼¼c½ÀCÔ4HÓIÖIØ”~Ö%¬*°S¼$×*?Õ*?Ø—‘ÑW´D¼¼cÄ3¸h½ÈÓ4M×4TÑ4TÔ4VÓW×Wô &ñ ùs   ‚G‘EGÅ-GÆAGc                ó0   € V ^8„  d   QhR\         R\         /# )r   Úvaluer   ©r!   )r#   s   "r$   r%   r%   •   s   € ÷ 
Sñ 
Sœsð 
S¤sñ 
Sr&   c                ó
  € \         P                  V 4      '       d2   W P                  4       8X  d   \        P                  V 4      '       g   V # R\        P
                  ! V P                  R4      4      P                  R4       R2# )aX  Wrap `value` in the `=?base64?...?=` sentinel when it would not survive an HTTP field round-trip.

Plain printable ASCII without leading/trailing whitespace passes verbatim;
anything else (control chars, non-ASCII, edge whitespace, or a value that
already looks like the sentinel) is base64-wrapped so the receiver can
recover the exact bytes.
z	=?base64?úutf-8Úasciiz?=)Ú_HEADER_SAFEÚ	fullmatchÚstripÚ_B64_SENTINELÚbase64Ú	b64encodeÚencodeÚdecode©rE   s   &r$   Úencode_header_valuerS   •   se   € ô ×Ñ˜e×$Ò$¨·+±+³-Ô)?Ì×H_ÑH_Ð`e×HfÒHfØˆØ”v×'Ò'¨¯©°WÓ(=Ó>×EÑEÀgÓNÐOÈrÐRÐRr&   c                óL   € V ^8„  d   QhR\         R,          R\         R,          /# )r   rE   Nr   rF   )r#   s   "r$   r%   r%   ¢   s"   € ÷ ñ œs T�zð ¬c°D­jñ r&   c                óp  € V f   R# \         P                  V 4      pVf   V # VP                  R4      p \        P                  ! VRR7      p\        P                  ! T4      P                  R4      T8w  d   R#  TP                  R4      #   \
        P                   d     R# i ; i  \         d     R# i ; i)u~  Inverse of :func:`encode_header_value`.

Returns the value verbatim unless it carries the `=?base64?...?=` sentinel,
in which case the payload is decoded as UTF-8. A malformed sentinel (bad
base64, non-canonical base64, or bad UTF-8) yields `None` so a corrupt
header never matches a body value by accident. `None` in â†’ `None` out so
callers can pass `headers.get(...)` directly.
NÚpayloadT)ÚvalidaterI   rH   )
rM   rK   ÚgrouprN   Ú	b64decodeÚbinasciiÚErrorrO   rQ   ÚUnicodeDecodeError)rE   ÚmrV   Údecodeds   &   r$   Údecode_header_valuer_   ¢   s­   € ð ‚}ÙÜ×Ñ Ó&€AØ‚yØˆØ�g‰g�iÓ €GðÜ×"Ò" 7°TÔ:ˆô
 ×Ò˜Ó ×'Ñ'¨Ó0°GÔ;ÙðØ�~‰~˜gÓ&Ð&øô �>‰>ô Úðûô ô Úðús#   ´B
 Á9B& Â
B#Â"B#Â&B5Â4B5c                ó>   € V ^8„  d   QhR\         R\        R,          /# )r   Úinput_schemar   N©r   r!   )r#   s   "r$   r%   r%   ¿   s   € ÷ (ñ (¬Cð (´C¸$µJñ (r&   c           	     óÊ  € / p\        V 4       EFP  w  r#\        V9  d   K  V'       g   \         R2u # RP                  V4      pV\        ,          p\        V\        4      '       g&   RV: R\         R\        V4      P                   2u # \        P                  V4      '       g   RV: R\         RV: R2u # VP                  R4      p\        V\        4      '       g'   RV: R\         R	\        V4      P                   R
2u # V\        9  d   RV: R\         RV: R2u # VP                  4       pWq9   d   \         RV: RV: RW,          : 2u # WAV&   EKS  	  R# )aæ  Return a reason string if any `x-mcp-header` annotation in `input_schema` is invalid; else `None`.

Walks every JSON Schema 2020-12 schema position. An annotation is valid
only when it sits on a property statically reachable from the root via a
chain of pure `properties` keys, names a non-empty RFC 9110 token, is on
an integer/string/boolean property, and is case-insensitively unique
across the whole schema. A `None` / non-mapping schema has no schema
positions and returns `None`.
zG found at a schema position not reachable via a pure `properties` chainÚ.z	property z: z must be a string, not Ú z is not an RFC 9110 tokenÚtypezM is only permitted on integer/string/boolean properties (the type keyword is z, not a string)z= is only permitted on integer/string/boolean properties (got Ú)z on property z duplicates property N)rC   ÚX_MCP_HEADER_KEYÚjoinr4   r!   rf   Ú__name__Ú_RFC9110_TOKENrK   ÚgetÚ_X_MCP_HEADER_PRIMITIVE_TYPESÚlower)ra   Úseenr>   r@   ÚwhereÚheaderÚ	prop_typern   s   &       r$   Úfind_invalid_x_mcp_headerrs   ¿   sx  € ð €DÜ.¨|×<‰ˆÜ 6Ô)ÙßÜ&Ð'Ð'nÐoÒoØ—‘˜“ˆØÔ(Õ)ˆô ˜&¤#×&Ò&Ø˜u™i rÔ*:Ð);Ð;RÔSWÐX^ÓS_×ShÑShÐRiÐjÒjÜ×'Ñ'¨×/Ò/Ø˜u™i rÔ*:Ð);¸1¸V¹JÐF_Ð`Ò`Ø—J‘J˜vÓ&ˆ	Ü˜)¤S×)Ò)à˜E™9 BÔ'7Ð&8ð 9JÜJNÈyË/×JbÑJbÐIcÐcrðtòð Ô9Ô9à˜E™9 BÔ'7Ð&8ð 9:Ø:C¹ÀaðIòð —‘“ˆØŒ=Ü&Ð' q¨©
°-À¹yÐH]Ð^bÕ^iÑ]lÐmÒmØˆUŒñ9 =ñ: r&   z
Mcp-Param-c                ól   € V ^8„  d   QhR\         R\        \        \        R3,          \        3,          /# ©r   ra   r   .)r   r"   r    r!   )r#   s   "r$   r%   r%   î   s0   € ÷ 	Rñ 	R¤3ð 	R¬4´´c¸3°hµÄÐ0DÕ+Eñ 	Rr&   c                óT   € \        V 4       UUUu/ uF  w  rq1VbK
  	  uppp# u upppi )a{  Map each property carrying a valid `x-mcp-header` to its annotation token, keyed by property path.

The key is the chain of `properties` keys from the schema root to the
annotated property; a top-level property has a one-element path, a nested
one a longer path. Call only on a schema that
:func:`find_invalid_x_mcp_header` accepts; an invalid schema yields an
undefined subset.
)Ú_annotated_positions)ra   r>   ÚtokenÚ_s   &   r$   Úx_mcp_header_maprz   î   s*   € ô /CÀ<Ô.PÕQÑ.P™N˜D¨�%ŠKÑ.PÓQÐQùÔQs   �#c          
      ó®   € V ^8„  d   QhR\         R\        \        \        \        R3,          \        \        \        \         3,          3,          ,          /# ru   r   )r#   s   "r$   r%   r%   ú   s@   € ÷ &ñ &¤sð &¬x¼¼eÄCÈÀH½oÌsÔTXÔY\Ô^aÐYaÕTbÐ>bÕ8cÕ/dñ &r&   c              #  ó°   "  € \        V 4       FB  w  rV'       g   K  \        VP                  \        4      ;p\        4      '       g   K<  WV3x € KD  	  R# 5i)z»Yield `(path, token, schema)` for every statically-reachable `x-mcp-header` annotation.

Shared by client emit and server validate so both ends agree on what counts as a declared header.
N)rC   r4   rl   rh   r!   )ra   r>   r@   rx   s   &   r$   rw   rw   ú   sC   é € ô
 /¨|Ö<‰ˆß‰4”J¨¯
©
Ô3CÓ(DÐD˜uÄc×JÔJØ˜vÐ%Ô%ó =ùs   ‚A�(AÁ
Ac                ó>   € V ^8„  d   QhR\         R\        R,          /# )r   rE   r   Nrb   )r#   s   "r$   r%   r%     s   € ÷ ñ ¤ð ¬¨t­ñ r&   c                óÞ   € \        V \        4      '       d   V '       d   R# R# \        V \        \        ,          \        ,          4      '       g   R#  \        V 4      #   \
         d     R# i ; i)zñRender `value` the way the client mirrors it into a header, or `None` when no rendering exists.

Shared by emit and validate so both sides agree on what is mirrorable:
non-primitives and ints beyond CPython's int-to-str digit limit are not.
ÚtrueÚfalseN)r4   Úboolr!   ÚintÚfloatÚ
ValueErrorrR   s   &r$   Ú_render_header_scalarr…     sX   € ô �%œ×ÒßˆvÐ+ GÐ+Ü�eœS¤3�Y¬Õ.×/Ò/ÙðÜ�5‹zÐøÜô Úðús   Á
A ÁA,Á+A,c                ó¼   € V ^8„  d   QhR\         \        \        R3,          \        3,          R\         \        \        3,          R\        \        \        3,          /# )r   Ú
header_map.Ú	argumentsr   )r   r    r!   r   r"   )r#   s   "r$   r%   r%     sL   € ÷ ñ ¤'¬%´°S°­/¼3Ð*>Õ"?ð ÌGÔTWÔY\ÐT\ÕL]ð ÔbfÔgjÔloÐgoÕbpñ r&   c                ó¨   € / pV P                  4        F;  w  r4\        W4      pVe   \        V4      ;pf   K%  \        V4      V\         V 2&   K=  	  V# )a,  Build the `Mcp-Param-*` headers a `tools/call` mirrors from its arguments.

For each `(path, token)` in `header_map`, read the value at that property
path in `arguments` and, when it is present and not `None`, emit
`Mcp-Param-<token>` carrying it: `bool` as `true`/`false`, other scalars via
`str`, each passed through :func:`encode_header_value` so a non-token value
is base64-wrapped. A path that hits a missing key or a non-mapping node is
skipped, matching the spec's "omit the header when no value is present",
as is a value with no header rendering.
)r5   Ú_value_at_pathr…   rS   ÚMCP_PARAM_HEADER_PREFIX)r‡   rˆ   Úheadersr>   rx   rE   Úrendereds   &&     r$   Úmcp_param_headersrŽ     sa   € ð !€GØ!×'Ñ'Ö)‰ˆÜ˜yÓ/ˆØŠ=Ô)>¸uÓ)EÐE˜XÒNÙÜ7JÈ8Ó7TˆÔ*Ð+¨E¨7Ð3Ó4ñ	 *ð
 €Nr&   c                óx   € V ^8„  d   QhR\         \        \        3,          R\        \        R3,          R\        /# )r   rˆ   r>   .r   )r   r!   r   r    )r#   s   "r$   r%   r%   (  s2   € ÷ ñ œg¤c¬3 hÕ/ð ´u¼SÀ#¸Xµð Ì3ñ r&   c                ó„   € T pV F7  p\        V\        4      '       g    R# \        RV4      P                  V4      pK9  	  V# )zjRead the value at a `properties`-key path in `arguments`, or `None` if any step is missing or non-mapping.NúMapping[str, Any])r4   r   r
   rl   )rˆ   r>   r?   Úkeys   &&  r$   rŠ   rŠ   (  s@   € à€DÛˆÜ˜$¤×(Ò(ÚÜÐ'¨Ó.×2Ñ2°3Ó7Šñ ð €Kr&   i�  i”  T)Úfrozenc                   ó0   a € ] tR tRt o RtV 3R ltRtV tR# )r   iG  uj  A modern-protocol request whose envelope passed every ladder rung.

`client_info` and `client_capabilities` are the raw envelope values; the
classifier checks presence only, not shape, and `client_info` is `None`
when the (optional, SHOULD-include) key is absent. Method existence is not
a ladder rung â€” kernel dispatch is the single source of truth for that.
c                ó>   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   S[;R&   # )r   Úprotocol_versionÚclient_infoÚclient_capabilities)r!   r   )r#   Ú__classdict__s   "€r$   r%   ÚInboundModernRoute.__annotate__G  s,   ø‡ ‚ ñ Ññ ñ Ññ ñ Ñò r&   r+   N)rj   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r™   s   @r$   r   r   G  s   ø‡ € ñ÷ ƒ r&   c                   ó4   a € ] tR tRt o RtRtV 3R ltRtV tR# )r   iV  z<The first ladder rung that failed, as JSON-RPC error fields.Nc                ó>   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   S[;R&   # )r   ÚcodeÚmessageÚdata)r‚   r!   r   )r#   r™   s   "€r$   r%   Ú#InboundLadderRejection.__annotate__V  s*   ø‡ ‚ ñ �Iñ	 ñ
 �Lñ ñ Ñò r&   r+   )	rj   r›   rœ   r�   rž   r§   rŸ   r    r¡   r¢   s   @r$   r   r   V  s   ø‡ € áFð €D÷ ƒ r&   c                óv   € V ^8„  d   QhR\         \        \        \        3,          ,          R\        R,          /# )r   rŒ   r   N)r   r    r!   )r#   s   "r$   r%   r%   b  s,   € ÷ ñ ¬H´U¼3Ä¸8µ_Õ,Eð Ì#ÐPTÍ*ñ r&   c                ó    € \        4       pV  F=  w  r#VP                  4       pV\        9   g   K"  WA9   d   Vu # VP                  V4       K?  	  R# )u1  Name of a routing header supplied more than once in raw header lines, or `None`.

Takes raw `(name, value)` pairs â€” a folded mapping hides duplicates. A
duplicate is rejected because first-copy and last-copy readers would
disagree. `Mcp-Param-*` duplicates are :func:`validate_mcp_param_headers`'s job.
N)Úsetrn   Ú_ROUTING_HEADER_NAMESÚadd)rŒ   ro   r   ry   r’   s   &    r$   Úfind_duplicated_routing_headerr®   b  sE   € ô “U€DÛ‰ˆØ�j‰j‹lˆØÔ'Ö'ØŒ{Ø’
Ø�H‰H�SŽMñ ñ r&   c                ó`   € V ^8„  d   QhR\         R\        \         ,          R\        R,          /# )r   Ú	requestedÚsupported_modern_versionsr   N)r!   r   r   )r#   s   "r$   r%   r%   s  s-   € ÷ ñ ÜðÜ/7¼­}ðä˜dÕ"ñr&   c           	     ó~   € W9   d   R# \        \        R\        \        V4      V R7      P	                  RR7      R7      # )zïThe `UNSUPPORTED_PROTOCOL_VERSION` rejection for `requested`, or `None` if it is served.

The request ladder's last rung, shared with the transport's notification arm
so both message kinds name the same `supported` list in the same words.
NzUnsupported protocol version)Ú	supportedr°   Újson)Úmode)r¥   r¦   r§   )r   r   r   r9   Ú
model_dump)r°   r±   s   &&r$   Ú&unsupported_protocol_version_rejectionr·   s  s?   € ð Ô-ÙÜ!Ü)Ø.Ü0ÜÐ4Ó5Àô
ç
‰*˜&ˆ*Ó
!ôð r&   rŒ   r±   c          	      óÆ   € V ^8„  d   QhR\         \        \        3,          R\         \        \        3,          R,          R\        \        ,          R\        \
        ,          /# )r   ÚbodyrŒ   Nr±   r   )r   r!   r   r   r   r   )r#   s   "r$   r%   r%   †  sY   € ÷ hñ hÜ
”#”s�(Õ
ðhô ”Sœ#�XÕ Õ%ðhô  (¬�}ð	hô
 Ô0Õ0ñhr&   c               ój  €  V R,          R,          p\        V\        4      '       g#   \	        \
        R\        : R\        : R2R7      # \        RV4      p\        \        3 Uu. uF  qUV9  g   K  VNK  	  up;p'       d$   \	        \
        R	R
P                  V4       2R7      # V\        ,          pVP                  \        4      pV\        ,          p	Veù   VP                  \        4      p
V
e   W§8w  d   \	        \        \         R2R7      # V P                  R4      pVP                  \        4      V8w  d   \	        \        \         R2R7      # \        P                  V4      pVef   \        RV R,          4      P                  V4      pVe@   \!        VP                  \"        4      4      V8w  d   \	        \        \"         RV: R2R7      # \        V\$        4      '       g   \	        \
        RR7      # \'        Wr4      ;pe   V# \)        VVV	R7      #   \         \        3 d    Rp ELi ; iu upi )uŸ  Run the modern-protocol validation ladder over a decoded JSON-RPC body.

Rungs, in order â€” first failure wins:

1. `params._meta` is a mapping carrying the required envelope pair
   (protocol version, client capabilities) â†’ else
   :data:`~mcp_types.jsonrpc.INVALID_PARAMS` naming the missing key(s)
   (basic/index.mdx "Per-request protocol fields"). Client info is
   optional (SHOULD-include, spec PR #3002); absent reads as `None`.
2. When `headers` is given, `MCP-Protocol-Version` equals the envelope's
   protocol version, `Mcp-Method` equals `body.method`, and â€” for the
   methods in :data:`NAME_BEARING_METHODS` â€” `Mcp-Name` equals the named
   body param â†’ else :data:`~mcp_types.jsonrpc.HEADER_MISMATCH`. Runs
   before the supported-version rung so a client that disagrees with itself
   is told so, rather than told the body's version is unsupported.
3. The envelope's protocol version is a string in
   `supported_modern_versions` â†’ non-string values are
   :data:`~mcp_types.jsonrpc.INVALID_PARAMS` (a shape defect, not a
   negotiation outcome), else
   :data:`~mcp_types.jsonrpc.UNSUPPORTED_PROTOCOL_VERSION` with
   `data = {"supported": [...], "requested": <value>}`.

Method existence is *not* a rung: kernel dispatch owns that decision so
custom-registered methods route and the answer lives in one place.

Args:
    body: The decoded JSON-RPC request mapping. Envelope shape
        (`jsonrpc` / `id`) is not checked here.
    headers: Transport headers keyed by lowercase name, or `None` to
        skip the header rung (non-HTTP callers).
    supported_modern_versions: Modern protocol revisions this server
        accepts on the per-request-envelope path.
ÚparamsÚ_metaNz5params._meta must be an object carrying the required z and z envelope keys©r¥   r¦   r‘   z6params._meta is missing the required envelope key(s): z, z> header does not match the request envelope's protocol versionÚmethodz0 header does not match the request body's methodú* header does not match the request body's z
 parameterz4the protocol-version envelope value must be a string)r–   r—   r˜   )ÚKeyErrorÚ	TypeErrorr4   r   r   r   r   r   r
   ri   rl   r   ÚMCP_PROTOCOL_VERSION_HEADERr   ÚMCP_METHOD_HEADERÚNAME_BEARING_METHODSr_   ÚMCP_NAME_HEADERr!   r·   r   )r¹   rŒ   r±   Ú
meta_valueÚmetar’   Úmissingr–   r—   r˜   Úversion_headerr¾   Úname_keyÚ
body_valueÚunsupporteds   &$$            r$   Úclassify_inbound_requestrÍ   †  s=  € ðNØ˜(•^ GÕ,ˆ
ô �j¤'×*Ò*Ü%ÜØKÜ(Ñ+¨5Ô1MÑ0PÐP^ð`ô
ð 	
ô
 Ð# ZÓ0€DÜ#<Ô>ZÑ"[ÓoÑ"[˜3ÐjnÑ_n—3�3Ñ"[ÑoÐo€wÖoÜ%ÜØLÈTÏYÉYÐW^ÓM_ÐL`Ðaô
ð 	
ð !Ô!:Õ;ÐØ—x‘xÔ 4Ó5€KØ#Ô$@ÕAÐØÒØ Ÿ™Ô%@ÓAˆð Ò! ^Ô%GÜ)Ü$Ü6Ð7Ð7uÐvôð ð —h‘h˜xÓ(ˆØ�;‰;Ô(Ó)¨VÔ3Ü)Ü$Ü,Ð-Ð-]Ð^ôð ô (×+Ñ+¨FÓ3ˆØÒäÐ1°4¸µ>ÓB×FÑFÀxÓPˆJØÒ%Ô*=¸g¿k¹kÌ/Ó>ZÓ*[Ð_iÔ*iÜ-Ü(Ü.Ð/Ð/YÐZbÑYeÐeoÐpôð ô
 Ð&¬×,Ò,ô &ÜØJô
ð 	
ô
 >Ð>NÓjÐjˆÒwØÐäØ)ØØ/ôð øôw ”iÐ ô Ø‹
ðüò ps   ‚H Á$H0Á1H0ÈH-È,H-z^-?[0-9]+(\.[0-9]+)?$c          
      óT   € V ^8„  d   QhR\         R\         R\        R\        R\        /# )r   rr   rE   r�   r^   r   )r   r!   r�   )r#   s   "r$   r%   r%   ö  s1   € ÷ ñ ¬ð ´Cð Ä3ð ÔQTð ÔY]ñ r&   c                ó¨  € V R8X  d·   \        V\        4      '       g¡   \        V\        4      '       g-   \        V\        4      '       du   VP	                  4       '       d_   \
        P                  V4      eH   VP                  R4      w  rEpV'       d   \        V4      R08w  d   R#  \        V4      \        V4      8H  # W28H  #   \         d     R# i ; i)u|  True when a decoded `Mcp-Param-*` header value agrees with the body argument.

Integer-typed declarations with an integral body value compare numerically
(`42` matches `42.0`, the spec's SHOULD) for canonical-decimal headers â€”
exact, no float round-trip, so values beyond the IEEE754 safe range still
compare. Anything else compares against `rendered`, the emit-side rendering.
Úintegerrd   Ú0F)
r4   r�   r‚   rƒ   Ú
is_integerÚ_CANONICAL_DECIMALrK   Ú	partitionr«   r„   )rr   rE   r�   r^   Úwholery   Úfractions   &&&&   r$   Ú_mcp_param_value_matchesr×   ö  s°   € ð 	�YÔÜ˜5¤$×'Ò'Ü˜œs×#Ò#¬
°5¼%×(@Ò(@ÀU×EUÑEU×EWÒEWÜ×(Ñ(¨Ó1Ò=à$×.Ñ.¨sÓ3Ñˆ�(ßœ˜H›¨#¨Ô.Ùð	Ü�u“:¤ U£Ñ+Ð+ð ÑÐøô ô 	Úð	ús   Â'C ÃCÃCc          	      óš   € V ^8„  d   QhR\         R\        \        \         3,          R\        \        \        3,          R\        R,          /# )r   ra   rˆ   rŒ   r   N)r   r   r!   r   )r#   s   "r$   r%   r%     sM   € ÷ Eñ EÜðEä”sœC�xÕ ðEô ”Sœ#�XÕðEô ˜dÕ"ñ	Er&   c                ód  € \        V 4      e   R# / p\        4       pVP                  4        F0  w  rVVP                  4       pWs9   d   VP	                  V4       WcV&   K2  	  \        V 4       EF@  w  r‰p
\         V	 2pVP                  4       pVP                  V4      p\        W4      pRP                  V4      pVe   Wt9   d   \        \        V R2R7      u # Vf!   Ve   \        \        V RV: R2R7      u # K’  \        V4      pVf!   Ve   \        \        V RV: R2R7      u # KÁ  Vf   \        \        V R	V: R
2R7      u # \        V4      pVf   \        \        V R2R7      u # \        V
P                  R4      WnV4      '       d   EK)  \        \        V RV: R2R7      u # 	  R# )uÂ  Compare a `tools/call` request's `Mcp-Param-*` headers against its body arguments.

Each annotated property's header and argument must agree: present together
and equal after sentinel decoding, or absent together (`null` counts as
absent). Returns the first failure as a `HEADER_MISMATCH` rejection, else `None`.

A header whose argument is absent or unrenderable is deliberately rejected:
the spec's purpose clause is exactly an intermediary routing on a value the
body never carried. A duplicated recognized header is rejected â€” first-copy
and last-copy readers would disagree. A schema :func:`find_invalid_x_mcp_header`
rejects validates nothing: conforming clients drop the tool and emit no headers.
Nrd   z header appears more than oncer½   z* header is present but the request body's z argument is absentr¿   z	 argumentz* header is missing but the request body's z argument is presentz1 header carries a malformed base64 sentinel valuerf   )rs   r«   r5   rn   r­   rw   r‹   rl   rŠ   ri   r   r   r…   r_   r×   )ra   rˆ   rŒ   ÚfoldedÚ
duplicatedr   rE   r’   r>   rx   r@   Úheader_nameÚrawÚargumentr�   r^   s   &&&             r$   Úvalidate_mcp_param_headersrß     sÝ  € ô" ! Ó.Ò:ÙØ€FÜ›5€JØ—}‘}–‰ˆØ�j‰j‹lˆØŒ=Ø�N‰N˜3ÔØˆs‹ñ	 'ô
  4°L×AÑˆ�VÜ0Ð1°%°Ð9ˆØ×ÑÓ!ˆØ�j‰j˜‹oˆÜ˜yÓ/ˆØ—8‘8˜D“>ˆØŠ?˜sÔ0Ü)Ü$Ø&˜-Ð'EÐFôò ð Š=ØŠÜ-Ü(Ø*˜mÐ+UÐV^ÑUaÐatÐuôò ñ Ü(¨Ó/ˆØÒàŠÜ-Ü(Ø*˜mÐ+UÐV^ÑUaÐajÐkôò ñ ØŠ;Ü)Ü$Ø&˜-Ð'QÐRZÑQ]Ð]qÐrôò ô & cÓ*ˆØŠ?Ü)Ü$Ø&˜-Ð'XÐYôò ô (¨¯
©
°6Ó(:¸EÈW×UÕUÜ)Ü$Ø&˜-Ð'QÐRZÑQ]Ð]fÐgôò ñO  BñV r&   c                óh  € V ^8„  d   Qh/ ^ \         9   d
   \        ;R&   ^\         9   d
   \        ;R&   ^\         9   d
   \        ;R&   ^\         9   d
   \        ;R&   ^\         9   d&   \        \        \        \        3,          ,          ;R&   ^\         9   d
   \        ;R&   ^\         9   d
   \        ;R&   ^\         9   d
   \        ;R&   ^\         9   d
   \        ;R	&   ^	\         9   d
   \        ;R
&   ^
\         9   d&   \        \        \        \        3,          ,          ;R&   ^\         9   d
   \        ;R&   # )r   rÂ   rÃ   rÅ   rh   rÄ   rm   r7   r8   r;   r‹   ÚERROR_CODE_HTTP_STATUSr¬   )Ú__conditional_annotations__r	   r   r!   r‚   )r#   s   "r$   r%   r%      s(  € ÷ ñ ÷v <Ò ;œUÑ ;ñw÷| (Ò '”5Ñ 'ñ}÷B $Ò #”Ñ #ñC÷H )Ò (”%Ñ (ñI÷Nò ”eœG¤C¬ HÕ-Õ.ñ ñO÷x SÒ RœuÑ Rñy÷Hò ”5ñ ñI÷f OÒ N”Ñ Nñg÷h eÒ d”Ñ dñi÷R .Ò -œÑ -ñS÷f	
ò 
œœg¤c¬3 hÕ/Õ0ñ 
ñg	÷|
 lÒ k”uÑ kò}
r&   )rá   r   r   rÃ   rÅ   r‹   rÂ   rÄ   rh   rÍ   r_   rS   r®   rs   rŽ   r·   rß   rz   >   ÚstringÚbooleanrÐ   >   ÚifÚnotÚelseÚthenr5   ÚcontainsÚcontentSchemaÚpropertyNamesÚunevaluatedItemsÚadditionalPropertiesÚunevaluatedProperties>   ÚallOfÚanyOfÚoneOfÚprefixItems>   ÚdefinitionsÚdependentSchemasÚpatternPropertiesú$defs)Erâ   rž   rN   rZ   ÚreÚcollections.abcr   r   r   r   Údataclassesr   Útypesr   Útypingr   r	   r
   Ú	mcp_typesr   r   r   r   Úmcp_types.jsonrpcr   r   r   r   r   r   r   Úmcp_types.versionr   Ú__all__rÂ   rÃ   rÅ   rh   rÄ   ÚcompilerM   rJ   rk   Ú	frozensetrm   r7   r8   r;   rC   rS   r_   rs   r‹   rz   rw   r…   rŽ   rŠ   rá   r   r   r¬   r®   r·   rÍ   rÓ   r×   rß   r%   )râ   s   @r$   Ú<module>r     s=  øðöó Û Û 	ß AÓ AÝ !Ý "ß #Ñ #÷ó ÷÷ ñ õ 7ò€ð* &<Ð Ó ;Ø Tà'Ð Ó 'Ø Oà#€Ó #Ø hà(Ð Ó (Ø Sá1Aà�fØ�vØ˜%ðó2Ð ó ðð —
’
Ð=Ó>€à�zŠzÐ+Ó,€à—’Ð=Ó>€ñ (1Ò1QÓ'RÐ Ó Rñ %òóÐ ó ñ #Ò#MÓN€Ó NÙ!Ò"cÓd€Ó dõXõ:
Sõõ:(ðV ".Ð Ó -Ø _õ	Rõ&õõ õ(ñ 4Dà�SØ˜Ø˜Ø˜Ø*¨CØ$ cØ˜#ðó
4Ð ó 
ðñ �$Ô÷ð ó ðñ �$Ô÷ð ó ðñ  )Ð*EÐGXÐZiÐ)jÓkÐ Ó kõð$ @X÷ð&hð )-ðhð 0H÷	hðZ —Z’ZÐ 8Ó9Ð õ÷0Er&   