The html_window.py module#
Summary#
Outcome of an attempt to open a detached HTML window. |
Build the wrapper page that sandboxes the supplied HTML. |
|
Find Microsoft Edge or Google Chrome to open |
|
Return why a local window cannot be shown, or |
|
Open HTML in a detached window on the machine running the MCP server. |
Environment variable with the path of the Edge or Chrome executable to use. |
|
Description#
Detached HTML window for clients without MCP Apps support.
The HTML is written to a temporary wrapper file and opened in a chromeless application window of an installed Microsoft Edge or Google Chrome browser. If neither is found, the default browser is used. Only the Python standard library is required.
The supplied HTML runs inside an iframe sandbox with an opaque origin and
a Content Security Policy that blocks network access, external resources,
forms, popups, and access to local files.
Module detail#
- html_window.build_window_document(html: str, title: str, width: int | None = None, height: int | None = None) str#
Build the wrapper page that sandboxes the supplied HTML.
The wrapper resizes its window to fit the rendered content. Dimensions given explicitly are kept fixed instead of being fitted.
- html_window.find_app_browser() str | None#
Find Microsoft Edge or Google Chrome to open
--appwindows.The
PYAEDT_MCP_HTML_BROWSERenvironment variable takes precedence.
Return why a local window cannot be shown, or
Noneif it can.
- html_window.open_html_window(html: str, title: str, width: int | None = None, height: int | None = None) WindowResult#
Open HTML in a detached window on the machine running the MCP server.
The window adjusts to the size of the rendered HTML, limited to the available screen area. Explicit dimensions override the fitted ones.
- html_window.BROWSER_ENV_VAR = 'PYAEDT_MCP_HTML_BROWSER'#
Environment variable with the path of the Edge or Chrome executable to use.
- html_window.VIEW_DIR_NAME = 'pyaedt-mcp-html-views'#
- html_window.CONTENT_POLICY = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:;...#
- html_window.logger#