
    kKj                        d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddl	mZ dZ G d d	e      Z G d
 de      Z G d de      Z G d de      ZddZddZy)u  MCP Apps support — extension negotiation and typed UI metadata models.

Provides constants and Pydantic models for the MCP Apps extension
(io.modelcontextprotocol/ui), enabling tools and resources to carry
UI metadata for clients that support interactive app rendering.
    )annotations)AnyLiteral)	BaseModelField)UI_MIME_TYPE)resolve_ui_mime_typezio.modelcontextprotocol/uic                      e Zd ZU dZ edddd      Zded<    edddd	      Zded
<    edddd      Zded<    edddd      Z	ded<   dddZ
y)ResourceCSPa  Content Security Policy for MCP App resources.

    Declares which external origins the app is allowed to connect to or
    load resources from.  Hosts use these declarations to build the
    ``Content-Security-Policy`` header for the sandboxed iframe.
    NconnectDomainsz5Origins allowed for fetch/XHR/WebSocket (connect-src)defaultvalidation_aliasserialization_aliasdescriptionlist[str] | Noneconnect_domainsresourceDomainszDOrigins allowed for scripts, images, styles, fonts (script-src etc.)resource_domainsframeDomainsz.Origins allowed for nested iframes (frame-src)frame_domainsbaseUriDomainsz-Allowed base URIs for the document (base-uri)base_uri_domainsTallowpopulate_by_nameextra)__name__
__module____qualname____doc__r   r   __annotations__r   r   r   model_config     d/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/fastmcp/apps/config.pyr   r      s     ).),K	)O%  */*-Z	*&  ','*D	'M#  */),C	*&  )-w?Lr%   r   c                      e Zd ZU dZ edd      Zded<    edd      Zded<    edd	      Zded
<    edddd      Z	ded<   dddZ
y)ResourcePermissionsa"  Iframe sandbox permissions for MCP App resources.

    Each field, when set (typically to ``{}``), requests that the host
    grant the corresponding Permission Policy feature to the sandboxed
    iframe.  Hosts MAY honour these; apps should use JS feature detection
    as a fallback.
    NzRequest camera accessr   r   zdict[str, Any] | NonecamerazRequest microphone access
microphonezRequest geolocation accessgeolocationclipboardWritezRequest clipboard-write accessr   clipboard_writeTr   r   )r   r   r    r!   r   r*   r"   r+   r,   r.   r#   r$   r%   r&   r(   r(   8   s     %*"9%F!  )."=)J%  */">*K&  .3),4	.O*  )-w?Lr%   r(   c                      e Zd ZU dZ edddd      Zded<    edd	      Zd
ed<    edd	      Zded<    edd	      Z	ded<    edd	      Z
ded<    edddd      Zded<   dddZy)	AppConfiga  Configuration for MCP App tools and resources.

    Controls how a tool or resource participates in the MCP Apps extension.
    On tools, ``resource_uri`` and ``visibility`` specify which UI resource
    to render and where the tool appears.  On resources, those fields must
    be left unset (the resource itself is the UI).

    All fields use ``exclude_none`` serialization so only explicitly-set
    values appear on the wire.  Aliases match the MCP Apps wire format
    (camelCase).
    NresourceUriz<URI of the UI resource (typically ui:// scheme). Tools only.r   z
str | Noneresource_uriz@Where this tool is visible: 'app', 'model', or both. Tools only.r)   z$list[Literal['app', 'model']] | None
visibilityz*Content Security Policy for the app iframezResourceCSP | NonecspzIframe sandbox permissionszResourcePermissions | NonepermissionszDomain for the iframedomainprefersBorderz'Whether the UI prefers a visible borderzbool | Noneprefers_borderTr   r   )r   r   r    r!   r   r2   r"   r3   r4   r5   r6   r8   r#   r$   r%   r&   r0   r0   T   s    
  %&)R	 L*  8=V8J4  $"NC	  /4">/K+  t9PQFJQ"'(+=	#NK  )-w?Lr%   r0   c                      e Zd ZdZddZy)PrefabAppConfiga  App configuration for Prefab tools with sensible defaults.

    Like ``app=True`` but customizable. Auto-wires the Prefab renderer
    URI and merges the renderer's CSP with any additional domains you
    specify.  The renderer resource is registered automatically.

    Example::

        @mcp.tool(app=PrefabAppConfig())  # same as app=True

        @mcp.tool(app=PrefabAppConfig(
            csp=ResourceCSP(frame_domains=["https://example.com"]),
        ))
    c                   | j                   d| _         	 ddlm}  |       }|r| j                  xs
 t               }|j                  d      }t        |j                  d      |j                        |d<   t        |j                  d      |j                        |d<   t        di || _        y y # t        $ r i }Y w xY w)	Nzui://prefab/renderer.htmlr   )get_renderer_cspT)exclude_noner   r   r$   )r2   prefab_ui.rendererr<   ImportErrorr4   r   
model_dump_merge_domainsgetr   r   )self_PrefabAppConfig__contextr<   renderer_cspuser_cspmerged_datas         r&   model_post_initzPrefabAppConfig.model_post_init   s    $ ;D	;+-L xx0;=H #--4-@K-;  !23((.K)* /=  !34))/K*+ #1[1DH   	L	s   B0 0B>=B>N)rD   r   returnNone)r   r   r    r!   rH   r$   r%   r&   r:   r:   |   s    2r%   r:   c                x    | |yt        | xs g       }|xs g D ]  }||vs|j                  |        |xs dS )z&Merge two domain lists, deduplicating.N)listappend)baser   combinedds       r&   rA   rA      sM    |DJBH[b[HOOA  tr%   c                L    t        | t              r| j                  dd      S | S )zHConvert an AppConfig or dict to the wire-format dict for ``meta["ui"]``.T)by_aliasr=   )
isinstancer0   r@   )apps    r&   app_config_to_meta_dictrU      s$    #y!~~t$~??Jr%   N)rN   r   r   r   rI   r   )rT   zAppConfig | dict[str, Any]rI   zdict[str, Any])r!   
__future__r   typingr   r   pydanticr   r   fastmcp.utilities.mimer   r	   UI_EXTENSION_IDr   r(   r0   r:   rA   rU   r$   r%   r&   <module>r[      sc    #  % ? O.!@) !@H@) @8%@	 %@P*2i *2Zr%   