Skip to main content

Module widgets

Module widgets 

Source
Expand description

Widget HTML bundle serving + asset discovery.

MCP servers can expose UI resources at ui://widget/<name>. This module serves the bundled HTML either from a local directory (WidgetSource::Static) or by reverse-proxying a dev server (WidgetSource::Proxy). Asset URLs in the served HTML are rewritten to point at the proxy so they resolve through the tunnel instead of the sandbox origin.

Used by the pipeline’s WidgetOverlayMiddleware (for resources/read overlays) and by the widget static routes (/widgets/<name>.html, /widgets, and arbitrary asset GETs).

Enums§

WidgetSource

Functions§

discover_widget_names
Discover available widget names from the widget source.
fetch_widget_html
Fetch widget HTML for a given widget name (used by resources/read interception). Asset URLs are made absolute so they resolve through the tunnel, not the sandbox origin.
list_widgets
JSON list of available widgets at /widgets.
serve_widget_asset
Serve a widget asset by path. Called from proxy’s catch-all handler for static asset requests.
serve_widget_html
Serve raw widget HTML at /widgets/{name}.html.