/** * The God's Eye View panel: an MCP Apps view (`io.modelcontextprotocol/ui`) that shows * God's Eye View inside a conversation. The panel is a small page that runs * the app inside itself in embed mode and sends it each view the * show_in_gods_eye_view tool returns; see docs/TOOLS.md. */ export const GLOBE_PANEL_URI = 'ui://gods-eye-view/globe'; /** * Sites the app's browser code loads from directly: map imagery, 3D tiles, * terrain and fonts. Everything else goes through the app's own server. */ const PROVIDER_ORIGINS = Object.freeze([ 'https://tile.googleapis.com', 'https://maps.googleapis.com', 'https://api.cesium.com', 'https://assets.ion.cesium.com', 'https://assets.cesium.com', 'https://dev.virtualearth.net', 'https://ecn.t0.tiles.virtualearth.net', 'https://ecn.t1.tiles.virtualearth.net', 'https://ecn.t2.tiles.virtualearth.net', 'https://ecn.t3.tiles.virtualearth.net', 'https://services.arcgisonline.com', 'https://server.arcgisonline.com', 'https://tile.openstreetmap.org', 'https://tiles.openfreemap.org', 'https://gibs.earthdata.nasa.gov', 'https://fonts.googleapis.com', 'https://fonts.gstatic.com', ]); /** The WebSocket origin matching an http(s) origin, for live-reload. */ const socketOrigin = (origin) => origin.replace(/^http/, 'ws'); export const MCP_APP_MIME_TYPE = 'text/html;profile=mcp-app'; const MCP_APPS_PROTOCOL_VERSION = '2026-01-26'; const PANEL_HEIGHT_PX = 520; /** * The panel page. It completes the MCP Apps handshake with its host, then * for each tool result that carries a view: loads the app in embed mode the * first time, and posts the view to the app once it is ready, so later views * change the globe without reloading. */ function panelHtml(appOrigin) { return ` God's Eye View
Waiting for a view…
`; } /** * The panel as an MCP resource for an app served at `appUrl`. Its security * policy lets the panel load the app's code from that origin and reach the * map and imagery providers the app uses directly. */ export function createGlobePanelResource({ appUrl }) { const appOrigin = new URL(appUrl).origin; return Object.freeze({ uri: GLOBE_PANEL_URI, name: 'globe', title: "God's Eye View globe", description: "Live God's Eye View, showing the view a tool returns.", mimeType: MCP_APP_MIME_TYPE, text: panelHtml(appOrigin), _meta: { ui: { csp: { resourceDomains: [appOrigin, ...PROVIDER_ORIGINS], connectDomains: [ appOrigin, socketOrigin(appOrigin), ...PROVIDER_ORIGINS, ], }, prefersBorder: true, }, // The same policy under the key OpenAI's clients read. 'openai/widgetCSP': { connect_domains: [ appOrigin, socketOrigin(appOrigin), ...PROVIDER_ORIGINS, ], resource_domains: [appOrigin, ...PROVIDER_ORIGINS], }, }, }); }