@usex/mikrotik-mcp 5.9.0 → 5.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui/aaa.html CHANGED
@@ -106,10 +106,13 @@ Boolean requesting whether a visible border and background is provided by the ho
106
106
  - omitted: host decides border`)}),R({method:U(`ui/request-display-mode`),params:R({mode:vh.describe(`The display mode being requested.`)})});var Fh=R({mode:vh.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),Ih=B([U(`model`),U(`app`)]).describe(`Tool visibility scope - who can access the tool.`);R({resourceUri:M().optional(),visibility:L(Ih).optional().describe(`Who can access this tool. Default: ["model", "app"]
107
107
  - "model": Tool visible to and callable by the agent
108
108
  - "app": Tool callable by the app from this server only`),csp:fc().optional(),permissions:fc().optional()}),R({mimeTypes:L(M()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),R({method:U(`ui/download-file`),params:R({contents:L(B([Lu,Ru])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),R({method:U(`ui/message`),params:R({role:U(`user`).describe(`Message role, currently only "user" is supported.`),content:L(zu).describe(`Message content blocks (text, image, etc.).`)})}),R({method:U(`ui/notifications/sandbox-resource-ready`),params:R({html:M().describe(`HTML content to load into the inner iframe.`),sandbox:M().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:Ch.optional().describe(`CSP configuration from resource metadata.`),permissions:wh.optional().describe(`Sandbox permissions from resource metadata.`)})});var Lh=R({method:U(`ui/notifications/tool-result`),params:Ju.describe(`Standard MCP tool execution result.`)}),Rh=R({toolInfo:R({id:yl.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Gu.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:_h.optional().describe(`Current color theme preference.`),styles:kh.optional().describe(`Style configuration for theming the app.`),displayMode:vh.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:L(vh).optional().describe(`Display modes the host supports.`),containerDimensions:B([R({height:P().describe(`Fixed container height in pixels.`)}),R({maxHeight:B([P(),ac()]).optional().describe(`Maximum container height in pixels.`)})]).and(B([R({width:P().describe(`Fixed container width in pixels.`)}),R({maxWidth:B([P(),ac()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
109
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:M().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:M().optional().describe(`User's timezone in IANA format.`),userAgent:M().optional().describe(`Host application identifier.`),platform:B([U(`web`),U(`desktop`),U(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:R({touch:F().optional().describe(`Whether the device supports touch input.`),hover:F().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:R({top:P().describe(`Top safe area inset in pixels.`),right:P().describe(`Right safe area inset in pixels.`),bottom:P().describe(`Bottom safe area inset in pixels.`),left:P().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),zh=R({method:U(`ui/notifications/host-context-changed`),params:Rh.describe(`Partial context update containing only changed fields.`)});R({method:U(`ui/update-model-context`),params:R({content:L(zu).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:V(M(),I().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),R({method:U(`ui/initialize`),params:R({appInfo:Ml.describe(`App identification (name and version).`),appCapabilities:Ph.describe(`Features and capabilities this app provides.`),protocolVersion:M().describe(`Protocol version this app supports.`)})});var Bh=R({protocolVersion:M().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Ml.describe(`Host application identification and version.`),hostCapabilities:Nh.describe(`Features and capabilities provided by the host.`),hostContext:Rh.describe(`Rich context about the host environment.`)}).passthrough(),Vh={target:`draft-2020-12`};async function Hh(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Vh);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Uh(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function Wh(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Gh(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Kh(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function qh(e){if(document.getElementById(`__mcp-host-fonts`))return;let t=document.createElement(`style`);t.id=`__mcp-host-fonts`,t.textContent=e,document.head.appendChild(t)}function Jh(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Yh=class e extends Gm{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new uh;_methods=new dh;setRequestHandler=(...e)=>{let[t,...n]=ph(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=ph(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:Th,toolinputpartial:Eh,toolresult:Lh,toolcancelled:Dh,hostcontextchanged:zh};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},t=>{let n=t;e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...n}),this._events.dispatch(e,n)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._appCapabilities=t,this.options=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),!n.allowUnsafeEval&&w({jitless:!0}),this.replaceRequestHandler(`ping`,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._appCapabilities=Jh(this._appCapabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Uh(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Uh(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Hh(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Hh(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(`ui/resource-teardown`,{params:Ah.shape.params,result:jh},(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(`tools/list`,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if(e===`sampling/createMessage`&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized(`createSamplingMessage`),await this.request({method:`sampling/createMessage`,params:e},t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},Sh,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},El,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},bh,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},xh,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Fh,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new gh(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1;try{await super.connect(e);let n=await this.request({method:`ui/initialize`,params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:hh}},Bh,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function $(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e!==!1&&e!=null&&r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}function Xh(e,t,n={}){let r=$(`button`,{class:`btn${n.class?` ${n.class}`:``}`,...n.title?{title:n.title}:{}});return r.textContent=e,n.disabled&&(r.disabled=!0),r.addEventListener(`click`,t),r}function Zh(e){e.onhostcontextchanged=e=>{if(e.theme&&Gh(e.theme),e.styles?.variables&&Kh(e.styles.variables),e.styles?.css?.fonts&&qh(e.styles.css.fonts),e.safeAreaInsets){let{top:t,right:n,bottom:r,left:i}=e.safeAreaInsets;document.body.style.padding=`${t+16}px ${n+16}px ${r+16}px ${i+16}px`}},Gh(Wh())}var Qh=1e4;async function $h(e,t,n){try{return await e.connect(void 0,{timeout:Qh}),console.warn(`[${t}] connected`,{host:e.getHostVersion(),caps:e.getHostCapabilities()}),!0}catch(e){console.error(`[${t}] connect failed`,e);let r=e instanceof Error&&/timed?\s*out/i.test(e.message)?`The MCP App host did not respond — make sure your client supports MCP Apps (ext-apps).`:`Connection failed: ${e instanceof Error?e.message:String(e)}`;return n.replaceChildren($(`div`,{class:`skeleton`},r)),!1}}var eg=[{slug:`radius`,label:`RADIUS Servers`,idKey:`.id`,toggle:!0,columns:[{key:`address`,label:`Address`},{key:`service`,label:`Service`},{key:`authentication-port`,label:`Auth`},{key:`accounting-port`,label:`Acct`},{key:`_status`,label:`Status`}],fields:[{key:`address`,label:`Address`,required:!0},{key:`secret`,label:`Secret`,type:`password`,required:!0},{key:`service`,label:`Service`,required:!0,placeholder:`login,ppp,hotspot,…`},{key:`authentication-port`,label:`Auth port`,type:`number`,placeholder:`1812`},{key:`accounting-port`,label:`Acct port`,type:`number`,placeholder:`1813`},{key:`timeout`,label:`Timeout`,placeholder:`300ms`},{key:`src-address`,label:`Src address`},{key:`realm`,label:`Realm`},{key:`called-id`,label:`Called ID`},{key:`domain`,label:`Domain`},{key:`protocol`,label:`Protocol`,type:`select`,options:[`udp`,`radsec`]},{key:`certificate`,label:`Certificate`},{key:`accounting-backup`,label:`Acct backup`,type:`bool`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},{slug:`um-users`,label:`Users`,idKey:`name`,toggle:!0,columns:[{key:`name`,label:`Name`},{key:`group`,label:`Group`},{key:`shared-users`,label:`Shared`},{key:`comment`,label:`Comment`},{key:`_status`,label:`Status`}],fields:[{key:`name`,label:`Name`,required:!0},{key:`password`,label:`Password`,type:`password`,required:!0},{key:`group`,label:`Group`},{key:`shared-users`,label:`Shared users`,type:`number`},{key:`attributes`,label:`Attributes`},{key:`caller-id`,label:`Caller ID`},{key:`otp-secret`,label:`OTP secret`,type:`password`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},{slug:`um-profiles`,label:`Profiles`,idKey:`name`,columns:[{key:`name`,label:`Name`},{key:`validity`,label:`Validity`},{key:`price`,label:`Price`},{key:`starts-when`,label:`Starts`}],fields:[{key:`name`,label:`Name`,required:!0},{key:`name-for-users`,label:`Display name`},{key:`validity`,label:`Validity`,placeholder:`30d`},{key:`price`,label:`Price`,type:`number`},{key:`starts-when`,label:`Starts when`,type:`select`,options:[`assigned`,`first-auth`]},{key:`override-shared-users`,label:`Override shared`},{key:`comment`,label:`Comment`}]},{slug:`um-limitations`,label:`Limitations`,idKey:`name`,columns:[{key:`name`,label:`Name`},{key:`rate-limit-rx`,label:`Rate ↓`},{key:`rate-limit-tx`,label:`Rate ↑`},{key:`transfer-limit`,label:`Transfer`},{key:`uptime-limit`,label:`Uptime`}],fields:[{key:`name`,label:`Name`,required:!0},{key:`rate-limit-rx`,label:`Download rate`,placeholder:`10M`},{key:`rate-limit-tx`,label:`Upload rate`,placeholder:`10M`},{key:`rate-limit-min-rx`,label:`Min ↓ (CIR)`},{key:`rate-limit-min-tx`,label:`Min ↑ (CIR)`},{key:`rate-limit-burst-rx`,label:`Burst ↓`},{key:`rate-limit-burst-tx`,label:`Burst ↑`},{key:`rate-limit-priority`,label:`Priority`,type:`number`},{key:`transfer-limit`,label:`Transfer cap`,placeholder:`10G`},{key:`uptime-limit`,label:`Uptime cap`,placeholder:`1d`},{key:`comment`,label:`Comment`}]},{slug:`um-routers`,label:`NAS Clients`,idKey:`name`,toggle:!0,columns:[{key:`name`,label:`Name`},{key:`address`,label:`Address`},{key:`coa-port`,label:`CoA`},{key:`_status`,label:`Status`}],fields:[{key:`name`,label:`Name`,required:!0},{key:`address`,label:`Address`,required:!0},{key:`shared-secret`,label:`Shared secret`,type:`password`,required:!0},{key:`coa-port`,label:`CoA port`,type:`number`},{key:`protocol`,label:`Protocol`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},{slug:`um-user-profiles`,label:`Assignments`,idKey:`.id`,addOnly:!0,columns:[{key:`user`,label:`User`},{key:`profile`,label:`Profile`},{key:`state`,label:`State`}],fields:[{key:`user`,label:`User`,required:!0},{key:`profile`,label:`Profile`,required:!0}]},{slug:`um-sessions`,label:`Sessions`,idKey:`.id`,readonly:!0,columns:[{key:`user`,label:`User`},{key:`calling-station-id`,label:`Caller`},{key:`started`,label:`Started`},{key:`uptime`,label:`Uptime`},{key:`status`,label:`Status`}],fields:[]}],tg={slug:`settings`,label:`Settings`},ng=e=>eg.find(t=>t.slug===e),rg=e=>(e.flags??``).includes(`X`)||e.disabled===`yes`,ig=document.getElementById(`app`),ag=new Yh({name:`mikrotik-aaa`,version:`1.0.0`}),og=`radius`,sg=!0,cg=[],lg=null,ug={},dg=null,fg=!1,pg=null;function mg(e){return e?.structuredContent}function hg(e){if(!e||e.__mikrotikView!==`aaa-section`)return;typeof e.slug==`string`&&(og=e.slug),sg=e.available!==!1,cg=e.rows??[];let t=e.lastOp;pg=t&&!t.ok?t.message:null}function gg(e){if(!e||e.__mikrotikView!==`aaa-settings`)return;dg={radiusIncoming:e.radiusIncoming??{},umAvailable:e.umAvailable!==!1,umSettings:e.umSettings??{}};let t=e.lastOp;pg=t&&!t.ok?t.message:null}async function _g(e){og=e,lg=null,pg=null,fg=!0,Dg();try{hg(mg(await ag.callServerTool({name:`get_aaa_section`,arguments:{slug:e}})))}catch(e){pg=String(e)}finally{fg=!1,Dg()}}async function vg(){og=`settings`,pg=null,fg=!0,Dg();try{gg(mg(await ag.callServerTool({name:`get_aaa_settings`,arguments:{}})))}catch(e){pg=String(e)}finally{fg=!1,Dg()}}async function yg(e,t){if(!fg){fg=!0,pg=null,Dg();try{hg(mg(await ag.callServerTool({name:`aaa_mutate`,arguments:{op:e,slug:og,...t}}))),lg=null}catch(e){pg=String(e)}finally{fg=!1,Dg()}}}async function bg(e,t){if(!fg){fg=!0,pg=null,Dg();try{gg(mg(await ag.callServerTool({name:`set_aaa_settings`,arguments:{target:e,fields:t}})))}catch(e){pg=String(e)}finally{fg=!1,Dg()}}}function xg(e){if(e.type===`bool`||e.type===`select`){let t=$(`select`,{class:`aaa-input`}),n=e.type===`bool`?[``,`no`,`yes`]:[``,...e.options??[]];for(let e of n){let n=$(`option`,{value:e},e||`—`);t.append(n)}return t.value=ug[e.key]??``,t.addEventListener(`change`,()=>{ug[e.key]=t.value}),t}let t=$(`input`,{class:`aaa-input`,type:e.type===`password`?`password`:e.type===`number`?`number`:`text`,placeholder:e.placeholder??(e.type===`password`?`(unchanged)`:``)});return t.value=ug[e.key]??``,t.addEventListener(`input`,()=>{ug[e.key]=t.value}),t}function Sg(e){let t=$(`div`,{class:`aaa-form-grid`},...e.fields.map(e=>$(`label`,{class:`aaa-field`},$(`span`,{class:`aaa-field-label`},`${e.label}${e.required&&lg===`new`?` *`:``}`),xg(e)))),n=Xh(lg===`new`?`Create`:`Save`,()=>{lg===`new`?yg(`add`,{fields:{...ug}}):yg(`update`,{id:lg,fields:{...ug}})},{class:`primary`}),r=Xh(`Cancel`,()=>{lg=null,Dg()});return $(`div`,{class:`aaa-form`},$(`div`,{class:`aaa-form-title`},lg===`new`?`New ${e.label}`:`Edit ${lg}`),t,$(`div`,{class:`aaa-form-actions`},n,r))}function Cg(e,t){lg=t[e.idKey],ug={};for(let n of e.fields)n.type!==`password`&&(n.key===`disabled`?ug.disabled=rg(t)?`yes`:`no`:t[n.key]!=null&&(ug[n.key]=t[n.key]));Dg()}function wg(e){let t=$(`div`,{class:`aaa-row aaa-head`},...e.columns.map(e=>$(`span`,{},e.label)),$(`span`,{class:`aaa-actions`},e.readonly?``:`Actions`)),n=cg.map(t=>{let n=t[e.idKey],r=rg(t),i=e.columns.map(e=>e.key===`_status`?$(`span`,{},$(`span`,{class:`aaa-badge ${r?`off`:`on`}`},r?`disabled`:`enabled`)):$(`span`,{class:`aaa-cell`,title:t[e.key]??``},t[e.key]??``)),a=[];return e.readonly||(e.toggle&&a.push(Xh(r?`Enable`:`Disable`,()=>void yg(`toggle`,{id:n,enable:r}))),e.addOnly||a.push(Xh(`Edit`,()=>Cg(e,t))),a.push(Xh(`Remove`,()=>void yg(`remove`,{id:n}),{class:`danger`}))),$(`div`,{class:`aaa-row${r?` is-off`:``}`},...i,$(`span`,{class:`aaa-actions`},...a))});return $(`div`,{class:`aaa-table`,style:`--cols:${e.columns.length}`},t,...n)}function Tg(e,t,n,r,i){let a={},o=$(`div`,{class:`aaa-form-grid`},...n.map(e=>{let n=$(`label`,{class:`aaa-field`},$(`span`,{class:`aaa-field-label`},e.label)),r;if(e.type===`bool`){let t=$(`select`,{class:`aaa-input`});for(let e of[``,`no`,`yes`])t.append($(`option`,{value:e},e||`(unchanged)`));t.addEventListener(`change`,()=>{a[e.key]=t.value}),r=t}else{let n=$(`input`,{class:`aaa-input`,type:e.type===`number`?`number`:`text`,placeholder:t[e.key]??e.placeholder??``});n.addEventListener(`input`,()=>{a[e.key]=n.value}),r=n}return n.append(r),n})),s=$(`div`,{class:`aaa-current`},n.map(e=>`${e.label}: ${t[e.key]??`—`}`).join(` · `)),c=$(`div`,{class:`aaa-form-actions`},Xh(`Save`,()=>void bg(r,a),{class:`primary`}),i??null);return $(`div`,{class:`aaa-card`},$(`div`,{class:`aaa-form-title`},e),s,o,c)}function Eg(){return dg?$(`div`,{class:`aaa-settings`},Tg(`RADIUS Incoming (CoA listener)`,dg.radiusIncoming,[{key:`accept`,label:`Accept CoA`,type:`bool`},{key:`port`,label:`CoA port`,type:`number`,placeholder:`3799`}],`radius-incoming`,Xh(`Reset counters`,()=>void bg(`radius-reset-counters`,{}))),dg.umAvailable?Tg(`User Manager (built-in RADIUS server)`,dg.umSettings,[{key:`enabled`,label:`Enabled`,type:`bool`},{key:`use-profiles`,label:`Use profiles`,type:`bool`},{key:`certificate`,label:`Certificate`},{key:`authentication-port`,label:`Auth port`,type:`number`},{key:`accounting-port`,label:`Acct port`,type:`number`}],`um-settings`):$(`div`,{class:`aaa-card`},$(`div`,{class:`aaa-form-title`},`User Manager`),$(`div`,{class:`muted`},`The user-manager package is not installed on this device.`))):$(`div`,{class:`muted`},`Loading settings…`)}function Dg(){let e=$(`div`,{class:`aaa-tabs`},...[...eg,tg].map(e=>$(`button`,{class:`aaa-tab${og===e.slug?` is-active`:``}`},e.label)));[...e.children].forEach((e,t)=>{let n=[...eg,tg][t];e.addEventListener(`click`,()=>{n.slug===`settings`?vg():_g(n.slug)})});let t=[$(`div`,{class:`aaa-titlebar`},$(`div`,{class:`aaa-title`},`RADIUS & User Manager`)),e];if(pg&&t.push($(`div`,{class:`aaa-error`},pg)),og===`settings`)t.push(Eg());else{let e=ng(og);if(!e)t.push($(`div`,{class:`muted`},`Unknown section.`));else if(!sg)t.push($(`div`,{class:`aaa-notice`},`User Manager is not installed on this device. Install the user-manager package (System → Packages) and reboot.`));else{let n=$(`div`,{class:`aaa-bar`});n.append($(`span`,{class:`muted`},`${cg.length} row(s)`)),n.append($(`span`,{class:`spacer`})),n.append(Xh(`↻ Refresh`,()=>void _g(og))),e.readonly||n.append(Xh(`+ Add`,()=>{lg=`new`,ug={},Dg()},{class:`primary`})),t.push(n),lg&&t.push(Sg(e)),t.push(cg.length||!e?wg(e):$(`div`,{class:`muted`},`No rows.`))}}ig.replaceChildren($(`div`,{class:`aaa-wrap`},...t))}ag.ontoolresult=e=>{let t=e.structuredContent;t?.__mikrotikView===`aaa-settings`?gg(t):hg(t),Dg()},ag.ontoolinput=()=>Dg(),Zh(ag),Dg(),$h(ag,`aaa`,ig);
109
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:M().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:M().optional().describe(`User's timezone in IANA format.`),userAgent:M().optional().describe(`Host application identifier.`),platform:B([U(`web`),U(`desktop`),U(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:R({touch:F().optional().describe(`Whether the device supports touch input.`),hover:F().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:R({top:P().describe(`Top safe area inset in pixels.`),right:P().describe(`Right safe area inset in pixels.`),bottom:P().describe(`Bottom safe area inset in pixels.`),left:P().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),zh=R({method:U(`ui/notifications/host-context-changed`),params:Rh.describe(`Partial context update containing only changed fields.`)});R({method:U(`ui/update-model-context`),params:R({content:L(zu).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:V(M(),I().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),R({method:U(`ui/initialize`),params:R({appInfo:Ml.describe(`App identification (name and version).`),appCapabilities:Ph.describe(`Features and capabilities this app provides.`),protocolVersion:M().describe(`Protocol version this app supports.`)})});var Bh=R({protocolVersion:M().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Ml.describe(`Host application identification and version.`),hostCapabilities:Nh.describe(`Features and capabilities provided by the host.`),hostContext:Rh.describe(`Rich context about the host environment.`)}).passthrough(),Vh={target:`draft-2020-12`};async function Hh(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Vh);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Uh(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function Wh(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Gh(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Kh(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function qh(e){if(document.getElementById(`__mcp-host-fonts`))return;let t=document.createElement(`style`);t.id=`__mcp-host-fonts`,t.textContent=e,document.head.appendChild(t)}function Jh(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Yh=class e extends Gm{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new uh;_methods=new dh;setRequestHandler=(...e)=>{let[t,...n]=ph(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=ph(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:Th,toolinputpartial:Eh,toolresult:Lh,toolcancelled:Dh,hostcontextchanged:zh};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},t=>{let n=t;e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...n}),this._events.dispatch(e,n)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._appCapabilities=t,this.options=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),!n.allowUnsafeEval&&w({jitless:!0}),this.replaceRequestHandler(`ping`,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._appCapabilities=Jh(this._appCapabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Uh(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Uh(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Hh(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Hh(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(`ui/resource-teardown`,{params:Ah.shape.params,result:jh},(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(`tools/list`,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if(e===`sampling/createMessage`&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized(`createSamplingMessage`),await this.request({method:`sampling/createMessage`,params:e},t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},Sh,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},El,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},bh,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},xh,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Fh,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new gh(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1;try{await super.connect(e);let n=await this.request({method:`ui/initialize`,params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:hh}},Bh,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function $(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e!==!1&&e!=null&&r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}function Xh(e,t,n={}){let r=$(`button`,{class:`btn${n.class?` ${n.class}`:``}`,type:`button`,...n.title?{title:n.title}:{}});return r.textContent=e,n.disabled&&(r.disabled=!0),r.addEventListener(`click`,t),r}function Zh(e){e.onhostcontextchanged=e=>{if(e.theme&&Gh(e.theme),e.styles?.variables&&Kh(e.styles.variables),e.styles?.css?.fonts&&qh(e.styles.css.fonts),e.safeAreaInsets){let{top:t,right:n,bottom:r,left:i}=e.safeAreaInsets;document.body.style.padding=`${t+16}px ${n+16}px ${r+16}px ${i+16}px`}},Gh(Wh())}var Qh=1e4;function $h(){let e=`http://www.w3.org/2000/svg`,t=document.createElementNS(e,`svg`);for(let[e,n]of Object.entries({viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`}))t.setAttribute(e,n);let n=document.createElementNS(e,`path`);return n.setAttribute(`d`,`M6 7v4a6 6 0 0 0 6 6m6-10v4a6 6 0 0 1-6 6m0 0v3M4 3h4v4H4zm12 0h4v4h-4zM10 20h4v3h-4z`),t.append(n),t}function eg(e,t){document.documentElement.dataset.mcpView=t,e.classList.add(`app`),document.getElementById(`mcp-app-masthead`)?.remove(),e.before($(`header`,{id:`mcp-app-masthead`,class:`mcp-masthead`},$(`span`,{class:`mcp-mark`},$h()),$(`div`,{},$(`span`,{class:`mcp-brand`},`MikroTik `,$(`b`,{},`MCP`)),$(`p`,{class:`mcp-context`},{dashboard:`Device health`,records:`Data explorer`,interfaces:`Interface inventory`,firewall:`Firewall policy`,"firewall-audit":`Security findings`,"connected-devices":`Client inventory`,aaa:`Identity & access`,investigations:`Client investigations`,"round-trip":`Round-trip lab`,"service-health":`Service health`,fabric:`Layer-2 fabric`,operations:`Change operations`,reports:`Evidence reports`}[t]??`Tool workspace`)),$(`span`,{class:`mcp-response-label`},`TOOL RESPONSE`)))}async function tg(e,t,n,r){eg(n,t);let i=!1,a=!1,o,s=()=>{o!==void 0&&clearTimeout(o),o=void 0},c=(e,t,r,i=!1)=>{n.replaceChildren($(`section`,{class:`app-result`,role:i?`alert`:`status`},$(`h2`,{class:`app-result__title`},e),$(`p`,{class:`app-result__message`},t),r?$(`pre`,{class:`app-result__detail`},r):null))};e.ontoolresult=e=>{if(a)return;i=!0,s();let t=(e.content??[]).flatMap(e=>e.type===`text`?[e.text]:[]).join(`
110
+ `).trim();if(e.isError){c(`Tool failed`,`The tool returned an error. No successful result is available.`,t,!0);return}try{if(r(e.structuredContent,e))return;let n=e.structuredContent;t||n?c(`Tool result`,`The response is shown below; it does not use this view's interactive format.`,[t,n?JSON.stringify(n,null,2):``].filter(Boolean).join(`
111
+
112
+ `)):c(`No data returned`,e.content?.some(e=>e.type!==`text`)?`The tool returned non-text content. Open the original tool response in your client.`:`The tool completed without text or structured data.`)}catch{c(`Unable to display result`,`The tool returned an invalid view payload.`,t,!0)}},e.ontoolcancelled=e=>{a||(i=!0,s(),c(`Tool cancelled`,e.reason||`The host cancelled this tool call.`))};let l=e.onteardown;e.onteardown=(e,t)=>(a=!0,s(),l?.(e,t)??{});let u=e.onclose;e.onclose=()=>{!a&&!i&&c(`Host disconnected`,`The connection closed before a tool result arrived.`,void 0,!0),a=!0,s(),u?.()};try{if(await e.connect(void 0,{timeout:Qh}),a)return!1;let n=e.getHostContext?.();return n&&e.onhostcontextchanged?.(n),i||(o=setTimeout(()=>{c(`Still awaiting the tool result`,`The host is connected, but has not delivered a result. Check the original tool response or your client's MCP connection. Do not repeat a configuration-changing call just to refresh this view. Late results will still appear here.`)},15e3)),console.warn(`[${t}] connected`,{host:e.getHostVersion(),caps:e.getHostCapabilities()}),!0}catch(e){return s(),!a&&(a=!0,console.error(`[${t}] connect failed`,e),c(`Cannot connect to the host`,e instanceof Error&&/timed?\s*out/i.test(e.message)?`The MCP App host did not respond — make sure your client supports MCP Apps (ext-apps).`:`Connection failed: ${e instanceof Error?e.message:String(e)}`,void 0,!0),!1)}}var ng=[{slug:`radius`,label:`RADIUS Servers`,idKey:`.id`,toggle:!0,columns:[{key:`address`,label:`Address`},{key:`service`,label:`Service`},{key:`authentication-port`,label:`Auth`},{key:`accounting-port`,label:`Acct`},{key:`_status`,label:`Status`}],fields:[{key:`address`,label:`Address`,required:!0},{key:`secret`,label:`Secret`,type:`password`,required:!0},{key:`service`,label:`Service`,required:!0,placeholder:`login,ppp,hotspot,…`},{key:`authentication-port`,label:`Auth port`,type:`number`,placeholder:`1812`},{key:`accounting-port`,label:`Acct port`,type:`number`,placeholder:`1813`},{key:`timeout`,label:`Timeout`,placeholder:`300ms`},{key:`src-address`,label:`Src address`},{key:`realm`,label:`Realm`},{key:`called-id`,label:`Called ID`},{key:`domain`,label:`Domain`},{key:`protocol`,label:`Protocol`,type:`select`,options:[`udp`,`radsec`]},{key:`certificate`,label:`Certificate`},{key:`accounting-backup`,label:`Acct backup`,type:`bool`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},{slug:`um-users`,label:`Users`,idKey:`name`,toggle:!0,columns:[{key:`name`,label:`Name`},{key:`group`,label:`Group`},{key:`shared-users`,label:`Shared`},{key:`comment`,label:`Comment`},{key:`_status`,label:`Status`}],fields:[{key:`name`,label:`Name`,required:!0},{key:`password`,label:`Password`,type:`password`,required:!0},{key:`group`,label:`Group`},{key:`shared-users`,label:`Shared users`,type:`number`},{key:`attributes`,label:`Attributes`},{key:`caller-id`,label:`Caller ID`},{key:`otp-secret`,label:`OTP secret`,type:`password`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},{slug:`um-profiles`,label:`Profiles`,idKey:`name`,columns:[{key:`name`,label:`Name`},{key:`validity`,label:`Validity`},{key:`price`,label:`Price`},{key:`starts-when`,label:`Starts`}],fields:[{key:`name`,label:`Name`,required:!0},{key:`name-for-users`,label:`Display name`},{key:`validity`,label:`Validity`,placeholder:`30d`},{key:`price`,label:`Price`,type:`number`},{key:`starts-when`,label:`Starts when`,type:`select`,options:[`assigned`,`first-auth`]},{key:`override-shared-users`,label:`Override shared`},{key:`comment`,label:`Comment`}]},{slug:`um-limitations`,label:`Limitations`,idKey:`name`,columns:[{key:`name`,label:`Name`},{key:`rate-limit-rx`,label:`Rate ↓`},{key:`rate-limit-tx`,label:`Rate ↑`},{key:`transfer-limit`,label:`Transfer`},{key:`uptime-limit`,label:`Uptime`}],fields:[{key:`name`,label:`Name`,required:!0},{key:`rate-limit-rx`,label:`Download rate`,placeholder:`10M`},{key:`rate-limit-tx`,label:`Upload rate`,placeholder:`10M`},{key:`rate-limit-min-rx`,label:`Min ↓ (CIR)`},{key:`rate-limit-min-tx`,label:`Min ↑ (CIR)`},{key:`rate-limit-burst-rx`,label:`Burst ↓`},{key:`rate-limit-burst-tx`,label:`Burst ↑`},{key:`rate-limit-priority`,label:`Priority`,type:`number`},{key:`transfer-limit`,label:`Transfer cap`,placeholder:`10G`},{key:`uptime-limit`,label:`Uptime cap`,placeholder:`1d`},{key:`comment`,label:`Comment`}]},{slug:`um-routers`,label:`NAS Clients`,idKey:`name`,toggle:!0,columns:[{key:`name`,label:`Name`},{key:`address`,label:`Address`},{key:`coa-port`,label:`CoA`},{key:`_status`,label:`Status`}],fields:[{key:`name`,label:`Name`,required:!0},{key:`address`,label:`Address`,required:!0},{key:`shared-secret`,label:`Shared secret`,type:`password`,required:!0},{key:`coa-port`,label:`CoA port`,type:`number`},{key:`protocol`,label:`Protocol`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},{slug:`um-user-profiles`,label:`Assignments`,idKey:`.id`,addOnly:!0,columns:[{key:`user`,label:`User`},{key:`profile`,label:`Profile`},{key:`state`,label:`State`}],fields:[{key:`user`,label:`User`,required:!0},{key:`profile`,label:`Profile`,required:!0}]},{slug:`um-sessions`,label:`Sessions`,idKey:`.id`,readonly:!0,columns:[{key:`user`,label:`User`},{key:`calling-station-id`,label:`Caller`},{key:`started`,label:`Started`},{key:`uptime`,label:`Uptime`},{key:`status`,label:`Status`}],fields:[]}],rg={slug:`settings`,label:`Settings`},ig=e=>ng.find(t=>t.slug===e),ag=e=>(e.flags??``).includes(`X`)||e.disabled===`yes`,og=document.getElementById(`app`),sg=new Yh({name:`mikrotik-aaa`,version:`1.0.0`}),cg=`radius`,lg=!0,ug=[],dg=null,fg={},pg=null,mg=!1,hg=null;function gg(e){return e?.structuredContent}function _g(e){if(!e||e.__mikrotikView!==`aaa-section`)return;typeof e.slug==`string`&&(cg=e.slug),lg=e.available!==!1,ug=e.rows??[];let t=e.lastOp;hg=t&&!t.ok?t.message:null}function vg(e){if(!e||e.__mikrotikView!==`aaa-settings`)return;pg={radiusIncoming:e.radiusIncoming??{},umAvailable:e.umAvailable!==!1,umSettings:e.umSettings??{}};let t=e.lastOp;hg=t&&!t.ok?t.message:null}async function yg(e){cg=e,dg=null,hg=null,mg=!0,kg();try{_g(gg(await sg.callServerTool({name:`get_aaa_section`,arguments:{slug:e}})))}catch(e){hg=String(e)}finally{mg=!1,kg()}}async function bg(){cg=`settings`,hg=null,mg=!0,kg();try{vg(gg(await sg.callServerTool({name:`get_aaa_settings`,arguments:{}})))}catch(e){hg=String(e)}finally{mg=!1,kg()}}async function xg(e,t){if(!mg){mg=!0,hg=null,kg();try{_g(gg(await sg.callServerTool({name:`aaa_mutate`,arguments:{op:e,slug:cg,...t}}))),dg=null}catch(e){hg=String(e)}finally{mg=!1,kg()}}}async function Sg(e,t){if(!mg){mg=!0,hg=null,kg();try{vg(gg(await sg.callServerTool({name:`set_aaa_settings`,arguments:{target:e,fields:t}})))}catch(e){hg=String(e)}finally{mg=!1,kg()}}}function Cg(e){if(e.type===`bool`||e.type===`select`){let t=$(`select`,{class:`aaa-input`}),n=e.type===`bool`?[``,`no`,`yes`]:[``,...e.options??[]];for(let e of n){let n=$(`option`,{value:e},e||`—`);t.append(n)}return t.value=fg[e.key]??``,t.addEventListener(`change`,()=>{fg[e.key]=t.value}),t}let t=$(`input`,{class:`aaa-input`,type:e.type===`password`?`password`:e.type===`number`?`number`:`text`,placeholder:e.placeholder??(e.type===`password`?`(unchanged)`:``)});return t.value=fg[e.key]??``,t.addEventListener(`input`,()=>{fg[e.key]=t.value}),t}function wg(e){let t=$(`div`,{class:`aaa-form-grid`},...e.fields.map(e=>$(`label`,{class:`aaa-field`},$(`span`,{class:`aaa-field-label`},`${e.label}${e.required&&dg===`new`?` *`:``}`),Cg(e)))),n=Xh(dg===`new`?`Create`:`Save`,()=>{dg===`new`?xg(`add`,{fields:{...fg}}):xg(`update`,{id:dg,fields:{...fg}})},{class:`primary`}),r=Xh(`Cancel`,()=>{dg=null,kg()});return $(`div`,{class:`aaa-form`},$(`div`,{class:`aaa-form-title`},dg===`new`?`New ${e.label}`:`Edit ${dg}`),t,$(`div`,{class:`aaa-form-actions`},n,r))}function Tg(e,t){dg=t[e.idKey],fg={};for(let n of e.fields)n.type!==`password`&&(n.key===`disabled`?fg.disabled=ag(t)?`yes`:`no`:t[n.key]!=null&&(fg[n.key]=t[n.key]));kg()}function Eg(e){let t=$(`div`,{class:`aaa-row aaa-head`},...e.columns.map(e=>$(`span`,{},e.label)),$(`span`,{class:`aaa-actions`},e.readonly?``:`Actions`)),n=ug.map(t=>{let n=t[e.idKey],r=ag(t),i=e.columns.map(e=>e.key===`_status`?$(`span`,{},$(`span`,{class:`aaa-badge ${r?`off`:`on`}`},r?`disabled`:`enabled`)):$(`span`,{class:`aaa-cell`,title:t[e.key]??``},t[e.key]??``)),a=[];return e.readonly||(e.toggle&&a.push(Xh(r?`Enable`:`Disable`,()=>void xg(`toggle`,{id:n,enable:r}))),e.addOnly||a.push(Xh(`Edit`,()=>Tg(e,t))),a.push(Xh(`Remove`,()=>void xg(`remove`,{id:n}),{class:`danger`}))),$(`div`,{class:`aaa-row${r?` is-off`:``}`},...i,$(`span`,{class:`aaa-actions`},...a))});return $(`div`,{class:`aaa-table`,style:`--cols:${e.columns.length}`},t,...n)}function Dg(e,t,n,r,i){let a={},o=$(`div`,{class:`aaa-form-grid`},...n.map(e=>{let n=$(`label`,{class:`aaa-field`},$(`span`,{class:`aaa-field-label`},e.label)),r;if(e.type===`bool`){let t=$(`select`,{class:`aaa-input`});for(let e of[``,`no`,`yes`])t.append($(`option`,{value:e},e||`(unchanged)`));t.addEventListener(`change`,()=>{a[e.key]=t.value}),r=t}else{let n=$(`input`,{class:`aaa-input`,type:e.type===`number`?`number`:`text`,placeholder:t[e.key]??e.placeholder??``});n.addEventListener(`input`,()=>{a[e.key]=n.value}),r=n}return n.append(r),n})),s=$(`div`,{class:`aaa-current`},n.map(e=>`${e.label}: ${t[e.key]??`—`}`).join(` · `)),c=$(`div`,{class:`aaa-form-actions`},Xh(`Save`,()=>void Sg(r,a),{class:`primary`}),i??null);return $(`div`,{class:`aaa-card`},$(`div`,{class:`aaa-form-title`},e),s,o,c)}function Og(){return pg?$(`div`,{class:`aaa-settings`},Dg(`RADIUS Incoming (CoA listener)`,pg.radiusIncoming,[{key:`accept`,label:`Accept CoA`,type:`bool`},{key:`port`,label:`CoA port`,type:`number`,placeholder:`3799`}],`radius-incoming`,Xh(`Reset counters`,()=>void Sg(`radius-reset-counters`,{}))),pg.umAvailable?Dg(`User Manager (built-in RADIUS server)`,pg.umSettings,[{key:`enabled`,label:`Enabled`,type:`bool`},{key:`use-profiles`,label:`Use profiles`,type:`bool`},{key:`certificate`,label:`Certificate`},{key:`authentication-port`,label:`Auth port`,type:`number`},{key:`accounting-port`,label:`Acct port`,type:`number`}],`um-settings`):$(`div`,{class:`aaa-card`},$(`div`,{class:`aaa-form-title`},`User Manager`),$(`div`,{class:`muted`},`The user-manager package is not installed on this device.`))):$(`div`,{class:`muted`},`Loading settings…`)}function kg(){let e=$(`div`,{class:`aaa-tabs`},...[...ng,rg].map(e=>$(`button`,{class:`aaa-tab${cg===e.slug?` is-active`:``}`},e.label)));[...e.children].forEach((e,t)=>{let n=[...ng,rg][t];e.addEventListener(`click`,()=>{n.slug===`settings`?bg():yg(n.slug)})});let t=[$(`header`,{class:`aaa-titlebar`},$(`h1`,{class:`aaa-title`},`RADIUS & User Manager`)),e];if(hg&&t.push($(`div`,{class:`aaa-error`},hg)),cg===`settings`)t.push(Og());else{let e=ig(cg);if(!e)t.push($(`div`,{class:`muted`},`Unknown section.`));else if(!lg)t.push($(`div`,{class:`aaa-notice`},`User Manager is not installed on this device. Install the user-manager package (System → Packages) and reboot.`));else{let n=$(`div`,{class:`aaa-bar`});n.append($(`span`,{class:`muted`},`${ug.length} row(s)`)),n.append($(`span`,{class:`spacer`})),n.append(Xh(`↻ Refresh`,()=>void yg(cg))),e.readonly||n.append(Xh(`+ Add`,()=>{dg=`new`,fg={},kg()},{class:`primary`})),t.push(n),dg&&t.push(wg(e)),t.push(ug.length||!e?Eg(e):$(`div`,{class:`muted`},`No rows.`))}}og.replaceChildren($(`div`,{class:`aaa-wrap`},...t))}function Ag(e){if(!e||typeof e!=`object`)return!1;let t=e;if(t?.__mikrotikView===`aaa-settings`)vg(t);else if(t.__mikrotikView===`aaa-section`)_g(t);else return!1;return kg(),!0}Zh(sg),kg(),tg(sg,`aaa`,og,Ag);
110
113
  </script>
111
114
  <style>
112
- :root{--bg:#0b0d10;--surface:#14181d;--surface-2:#1b2027;--border:#2a313a;--text:#e8eaed;--text-dim:#9aa0a6;--accent:#7c9cff;--danger:#f2685a;--ok:#4ade80}@media (prefers-color-scheme:light){:root{--bg:#fff;--surface:#f6f8fa;--surface-2:#eef1f4;--border:#d8dee4;--text:#1c2024;--text-dim:#5b6470;--accent:#3b5bdb}}*{box-sizing:border-box}body{background:var(--bg);color:var(--text);margin:0;font:13px/1.5 system-ui,-apple-system,Segoe UI,sans-serif}.muted{color:var(--text-dim)}.aaa-wrap{padding:4px 2px 16px}.aaa-titlebar{padding:6px 8px 10px}.aaa-title{font-size:15px;font-weight:600}.aaa-tabs{border-bottom:1px solid var(--border);flex-wrap:wrap;gap:2px;margin-bottom:12px;display:flex}.aaa-tab{appearance:none;color:var(--text-dim);font:inherit;cursor:pointer;background:0 0;border:none;border-bottom:2px solid #0000;margin-bottom:-1px;padding:7px 11px;font-size:12.5px}.aaa-tab:hover{color:var(--text)}.aaa-tab.is-active{color:var(--text);border-bottom-color:var(--accent)}.aaa-bar{align-items:center;gap:8px;padding:0 8px 10px;display:flex}.aaa-bar .spacer{flex:1}.btn{font:inherit;color:var(--text);background:var(--surface-2);border:1px solid var(--border);cursor:pointer;border-radius:8px;padding:4px 10px;font-size:12px}.btn:hover{border-color:var(--accent)}.btn.primary{border-color:color-mix(in srgb, var(--accent) 55%, var(--border));color:var(--accent)}.btn.danger{border-color:color-mix(in srgb, var(--danger) 45%, var(--border));color:var(--danger)}.aaa-error{color:var(--danger);background:color-mix(in srgb, var(--danger) 12%, transparent);border:1px solid color-mix(in srgb, var(--danger) 35%, var(--border));border-radius:8px;margin:0 8px 10px;padding:8px 10px;font-size:12px}.aaa-notice{color:var(--text-dim);background:var(--surface);border:1px solid var(--border);border-radius:10px;margin:0 8px;padding:14px;font-size:12.5px}.aaa-table{padding:0 8px}.aaa-row{grid-template-columns:repeat(var(--cols), minmax(70px, 1fr)) minmax(150px, auto);border-radius:8px;align-items:center;gap:8px;padding:7px 8px;font-size:12.5px;display:grid}.aaa-row.aaa-head{color:var(--text-dim);text-transform:uppercase;letter-spacing:.04em;font-size:10.5px}.aaa-row:not(.aaa-head):hover{background:var(--surface)}.aaa-row.is-off .aaa-cell{color:var(--text-dim)}.aaa-cell{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.aaa-actions{justify-content:flex-end;gap:5px;display:flex}.aaa-actions .btn{padding:3px 8px}.aaa-badge{border-radius:100px;padding:1px 7px;font-size:10.5px;display:inline-block}.aaa-badge.on{background:color-mix(in srgb, var(--ok) 20%, transparent);color:var(--ok)}.aaa-badge.off{background:color-mix(in srgb, var(--text-dim) 22%, transparent);color:var(--text-dim)}.aaa-form,.aaa-card{border:1px solid var(--border);background:var(--surface-2);border-radius:10px;margin:0 8px 12px;padding:12px}.aaa-form-title{margin-bottom:10px;font-size:12.5px;font-weight:600}.aaa-current{color:var(--text-dim);margin-bottom:10px;font-size:11.5px}.aaa-form-grid{grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:9px 12px;display:grid}.aaa-field{flex-direction:column;gap:3px;display:flex}.aaa-field-label{color:var(--text-dim);font-size:11px}.aaa-input{font:inherit;color:var(--text);background:var(--bg);border:1px solid var(--border);border-radius:7px;padding:5px 8px;font-size:12.5px}.aaa-input:focus{border-color:var(--accent);outline:none}.aaa-form-actions{align-items:center;gap:8px;margin-top:12px;display:flex}.aaa-settings{flex-direction:column;gap:4px;display:flex}
115
+ .app-result{border:1px solid var(--color-border-primary,#8886);background:var(--color-background-secondary,transparent);color:var(--color-text-primary,inherit);border-radius:12px;padding:20px}.app-result__title{margin:0 0 8px;font-size:16px;font-weight:600}.app-result__message{margin:0;font-size:13px;line-height:1.6}.app-result__detail{border:1px solid var(--color-border-primary,#8886);max-height:420px;font:12px/1.6 var(--font-mono,monospace);white-space:pre-wrap;overflow-wrap:anywhere;border-radius:8px;margin:16px 0 0;padding:12px;overflow:auto}html[data-mcp-view]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--mt-bg:var(--color-background-primary,#101c2e);--mt-surface:var(--color-background-secondary,#17263b);--mt-surface-2:var(--color-background-tertiary,#20324a);--mt-border:var(--color-border-primary,#304660);--mt-text:var(--color-text-primary,#dae6f4);--mt-text-dim:var(--color-text-secondary,#a6b9ce);--mt-text-faint:var(--color-text-tertiary,#91a8c1);--mt-accent:var(--color-accent-primary,#9ebfee);--mt-good:#69d6c3;--mt-warn:#e5b56f;--mt-bad:#f18b94;--mt-radius:16px;--mt-radius-sm:10px;--mt-sans:var(--font-sans,"Avenir Next", "Segoe UI", sans-serif);--mt-display:var(--font-sans,"Avenir Next", "Segoe UI", sans-serif);--mt-mono:var(--font-mono,"SFMono-Regular", Consolas, monospace);--bg:var(--mt-bg);--surface:var(--mt-surface);--surface-2:var(--mt-surface-2);--border:var(--mt-border);--text:var(--mt-text);--text-dim:var(--mt-text-dim);--accent:var(--mt-accent);--danger:var(--mt-bad);--ok:var(--mt-good);--rx:var(--mt-good);--tx:var(--mt-accent)}html[data-mcp-view][data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--mt-bg:var(--color-background-primary,#f3f6fa);--mt-surface:var(--color-background-secondary,#fff);--mt-surface-2:var(--color-background-tertiary,#e9eff6);--mt-border:var(--color-border-primary,#c8d5e3);--mt-text:var(--color-text-primary,#20334d);--mt-text-dim:var(--color-text-secondary,#4b6480);--mt-text-faint:var(--color-text-tertiary,#5b728c);--mt-accent:var(--color-accent-primary,#325f9c);--mt-good:#157d6b;--mt-warn:#956313;--mt-bad:#b53446}html[data-mcp-view] body{background:var(--mt-bg);color:var(--mt-text);font:13px/1.6 var(--mt-sans);-webkit-font-smoothing:antialiased;margin:0;padding:20px}html[data-mcp-view] :where(*){box-sizing:border-box}html[data-mcp-view] body #app{gap:20px;width:100%;min-width:0;max-width:1120px;margin:0 auto;animation:.22s ease-out both workspace-arrive;display:grid}html[data-mcp-view] body #app>*{min-width:0}.mcp-masthead{border-bottom:1px solid var(--mt-border);align-items:center;gap:12px;width:100%;max-width:1120px;margin:0 auto 22px;padding-bottom:18px;display:flex}.mcp-mark{border:1px solid var(--mt-border);background:var(--mt-surface);width:38px;height:38px;color:var(--mt-accent);border-radius:12px;flex:none;place-items:center;display:grid}.mcp-brand{letter-spacing:-.02em;font-size:13px;font-weight:650}.mcp-brand b{color:var(--mt-accent)}.mcp-context{color:var(--mt-text-dim);margin:0;font-size:11px}.mcp-response-label{font:9px var(--mt-mono);letter-spacing:.12em;color:var(--mt-text-faint);margin-left:auto}body #app :where(.hd,.aaa-titlebar){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background-color:var(--mt-surface);background-image:radial-gradient(color-mix(in srgb, var(--mt-border) 60%, transparent) .7px, transparent .7px);overflow-wrap:anywhere;background-size:16px 16px;flex-wrap:wrap;align-items:center;gap:16px;padding:22px;display:flex;position:relative}body #app :where(.hd__title,.aaa-title,.toolbar .title){font:650 clamp(19px, 3.8vw, 25px)/1.25 var(--mt-display);letter-spacing:-.035em;margin:0}body #app .hd__sub{color:var(--mt-text-dim);font:11px/1.7 var(--mt-mono);margin:6px 0 0}body #app .hd__dot{background:var(--mt-accent);box-shadow:0 0 0 6px color-mix(in srgb, var(--mt-accent) 10%, transparent)}body #app :where(.grid,.if-grid,.aaa-form-grid){grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr));gap:16px;display:grid}body #app :where(.card,.aaa-card,.aaa-form,.f-card){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);min-width:0;margin:0;padding:20px}body #app .card__label{color:var(--mt-text-dim);font:11px/1.5 var(--mt-sans);letter-spacing:.03em;text-transform:none;margin:0 0 10px}body #app .card__value{font:550 27px/1.3 var(--mt-mono);letter-spacing:-.04em;overflow-wrap:anywhere}body #app .card__value small{font-size:12px}body #app :where(.toolbar,.aaa-bar){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);flex-wrap:wrap;align-items:center;gap:10px;margin:0;padding:12px;display:flex}body #app .toolbar .grow{flex:200px;min-width:min(100%,200px)}body #app :where(.btn,.aaa-tab){border:1px solid var(--mt-border);background:var(--mt-surface-2);min-height:34px;color:var(--mt-text);font:500 12px/1.4 var(--mt-sans);cursor:pointer;border-radius:10px;justify-content:center;align-items:center;gap:7px;margin:0;padding:7px 12px;transition:background .14s,border-color .14s,transform .14s;display:inline-flex}body #app :where(.btn,.aaa-tab):hover:not(:disabled){border-color:var(--mt-accent);background:color-mix(in srgb, var(--mt-accent) 14%, var(--mt-surface));transform:translateY(-1px)}body #app :where(.btn,.aaa-tab):active:not(:disabled){transform:translateY(0)}body #app :where(.btn,.aaa-tab):disabled{opacity:.5;cursor:not-allowed}body #app :where(.btn.is-active,.btn.primary,.aaa-tab.is-active){border-color:color-mix(in srgb, var(--mt-accent) 70%, var(--mt-border));color:var(--mt-accent);background:color-mix(in srgb, var(--mt-accent) 12%, var(--mt-surface))}body #app :where(.btn-danger,.btn.danger){color:var(--mt-bad);border-color:color-mix(in srgb, var(--mt-bad) 50%, var(--mt-border));background:color-mix(in srgb, var(--mt-bad) 8%, var(--mt-surface))}body #app .btn.ok{color:var(--mt-good)}body #app :where(.search,.aaa-input){border:1px solid var(--mt-border);background:var(--mt-bg);width:100%;min-width:0;min-height:36px;color:var(--mt-text);font:12px/1.5 var(--mt-sans);border-radius:10px;padding:8px 12px}body #app :where(button,input,select,textarea,summary,[tabindex]):focus-visible{outline:2px solid var(--mt-accent);outline-offset:3px}body #app :where(.pill,.chip,.badge,.aaa-badge,.act){font:10px/1.4 var(--mt-mono);overflow-wrap:anywhere;border-radius:7px;max-width:100%;padding:4px 9px}body #app :where(.tablewrap,.table,.aaa-table){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);width:100%;min-width:0;padding:0;overflow:auto}body #app :where(table.tbl th,table.tbl td){border-bottom:1px solid color-mix(in srgb, var(--mt-border) 65%, transparent);padding:12px 16px;font-size:11px;line-height:1.6}body #app table.tbl thead th{background:var(--mt-surface-2);font:600 11px var(--mt-sans);height:42px}body #app table.tbl tbody tr:nth-child(2n){background:color-mix(in srgb, var(--mt-surface-2) 30%, transparent)}body #app table.tbl tbody tr:hover{background:color-mix(in srgb, var(--mt-accent) 12%, var(--mt-surface))}body #app :where(.kv__body,details.kv){background:var(--mt-surface);border:1px solid var(--mt-border);border-radius:var(--mt-radius);overflow:hidden}body #app .kv__body{grid-template-columns:minmax(100px,.45fr) minmax(0,1fr)}body #app .kv__body>div{padding:12px 16px;font-size:11px;line-height:1.6}body #app details.kv .kv__body{border:0;border-top:1px solid var(--mt-border);border-radius:0}body #app details.kv>summary{padding:16px 20px;font-size:12px}body #app :where(.foot,.totals){color:var(--mt-text-faint);border-top:1px solid var(--mt-border);gap:12px;padding:12px 0;font-size:10px}body #app :where(.skeleton,.empty,.loading,.aaa-notice){border:1px dashed var(--mt-border);border-radius:var(--mt-radius);color:var(--mt-text-dim);background:var(--mt-surface);text-align:center;padding:36px 24px;font-size:12px}body #app pre.raw{white-space:pre-wrap;overflow-wrap:anywhere;padding:20px;font-size:11px;line-height:1.85}body #app .drawer{gap:16px;padding:20px}body #app .drawer__hd{flex-wrap:wrap}body #app .if-card{border-top:3px solid var(--mt-border);gap:20px}body #app .if-card:has(.dot.is-up){border-top-color:var(--mt-good)}body #app .if-card__top{flex-wrap:wrap;gap:10px}body #app .if-card__name{font-size:15px}body #app .if-card__meta{grid-template-columns:minmax(45px,.3fr) minmax(0,1fr);gap:8px 14px}body #app .f-list{grid-template-columns:repeat(auto-fit,minmax(min(100%,340px),1fr));gap:16px;margin:0;display:grid}body #app .f-card{border-top-width:3px}body #app .f-card.is-bad{border-top-color:var(--mt-bad)}body #app .f-card.is-warn{border-top-color:var(--mt-warn)}body #app .f-body{margin-top:14px}body #app .f-detail{font-size:12px;line-height:1.7}body #app .f-fix{margin-top:10px;font-size:11px}body #app .f-actions{margin-top:18px}body #app .aaa-wrap{gap:18px;min-width:0;padding:0;display:grid}body #app .aaa-tabs{border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);gap:8px;margin:0;padding:8px}body #app .aaa-tab{font-size:11px}body #app .aaa-row{min-width:max(100%, calc(var(--cols) * 105px + 190px));border-bottom:1px solid var(--mt-border);border-radius:0;gap:12px;padding:12px 16px;font-size:11px}body #app .aaa-head{background:var(--mt-surface-2)}body #app .aaa-actions,body #app .aaa-field{gap:8px}body #app .aaa-form-title{margin-bottom:16px;font-size:14px}body #app .aaa-settings{gap:16px}body #app .aaa-error{margin:0;padding:16px}body #app .row{border-bottom:1px solid var(--mt-border);border-radius:0;grid-template-columns:105px minmax(150px,1.4fr) 145px 85px 100px 165px;gap:14px;min-width:840px;padding:13px 16px;font-size:11px}body #app .row.header{background:var(--mt-surface-2);font:600 10px var(--mt-sans)}body #app .detail{border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);padding:22px}body #app .detail-title{margin-bottom:6px;font-size:19px}body #app .detail-sub{margin-bottom:22px}body #app .rates{font:15px var(--mt-mono);flex-wrap:wrap;gap:24px;margin:0 0 18px}body #app .traffic-chart{background-image:radial-gradient(var(--mt-border) .75px, transparent .75px);background-size:16px 16px;max-width:none;height:200px}body #app .app-result{border-color:var(--mt-border);background:var(--mt-surface);color:var(--mt-text);padding:26px}body #app .app-result[role=alert]{border-top:3px solid var(--mt-bad)}body #app .app-result__title{font-family:var(--mt-display);letter-spacing:-.025em;font-size:20px}body #app .app-result__message{color:var(--mt-text-dim);font-size:12px}body #app .app-result__detail{background:var(--mt-bg);border-color:var(--mt-border);font:11px/1.8 var(--mt-mono)}@keyframes workspace-arrive{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}@media (width<=520px){html[data-mcp-view] body{padding:12px}html[data-mcp-view] body #app{gap:16px}.mcp-masthead{gap:10px;margin-bottom:16px}.mcp-response-label{letter-spacing:.04em;font-size:8px}body #app :where(.hd,.aaa-titlebar,.card,.f-card,.aaa-card,.aaa-form){padding:16px}body #app .kv__body{grid-template-columns:minmax(80px,.4fr) minmax(0,1fr)}body #app .kv__body>div{padding:10px 12px}body #app .if-grid{grid-template-columns:minmax(0,1fr)}}@media (prefers-reduced-motion:reduce){html[data-mcp-view] body #app,body #app *,body #app :before,body #app :after{scroll-behavior:auto!important;transition:none!important;animation:none!important}}:root{--bg:#0b0d10;--surface:#14181d;--surface-2:#1b2027;--border:#2a313a;--text:#e8eaed;--text-dim:#9aa0a6;--accent:#7c9cff;--danger:#f2685a;--ok:#4ade80}@media (prefers-color-scheme:light){:root{--bg:#fff;--surface:#f6f8fa;--surface-2:#eef1f4;--border:#d8dee4;--text:#1c2024;--text-dim:#5b6470;--accent:#3b5bdb}}*{box-sizing:border-box}body{background:var(--bg);color:var(--text);margin:0;font:13px/1.5 system-ui,-apple-system,Segoe UI,sans-serif}.muted{color:var(--text-dim)}.aaa-wrap{padding:4px 2px 16px}.aaa-titlebar{padding:6px 8px 10px}.aaa-title{font-size:15px;font-weight:600}.aaa-tabs{border-bottom:1px solid var(--border);flex-wrap:wrap;gap:2px;margin-bottom:12px;display:flex}.aaa-tab{appearance:none;color:var(--text-dim);font:inherit;cursor:pointer;background:0 0;border:none;border-bottom:2px solid #0000;margin-bottom:-1px;padding:7px 11px;font-size:12.5px}.aaa-tab:hover{color:var(--text)}.aaa-tab.is-active{color:var(--text);border-bottom-color:var(--accent)}.aaa-bar{align-items:center;gap:8px;padding:0 8px 10px;display:flex}.aaa-bar .spacer{flex:1}.btn{font:inherit;color:var(--text);background:var(--surface-2);border:1px solid var(--border);cursor:pointer;border-radius:8px;padding:4px 10px;font-size:12px}.btn:hover{border-color:var(--accent)}.btn.primary{border-color:color-mix(in srgb, var(--accent) 55%, var(--border));color:var(--accent)}.btn.danger{border-color:color-mix(in srgb, var(--danger) 45%, var(--border));color:var(--danger)}.aaa-error{color:var(--danger);background:color-mix(in srgb, var(--danger) 12%, transparent);border:1px solid color-mix(in srgb, var(--danger) 35%, var(--border));border-radius:8px;margin:0 8px 10px;padding:8px 10px;font-size:12px}.aaa-notice{color:var(--text-dim);background:var(--surface);border:1px solid var(--border);border-radius:10px;margin:0 8px;padding:14px;font-size:12.5px}.aaa-table{padding:0 8px}.aaa-row{grid-template-columns:repeat(var(--cols), minmax(70px, 1fr)) minmax(150px, auto);border-radius:8px;align-items:center;gap:8px;padding:7px 8px;font-size:12.5px;display:grid}.aaa-row.aaa-head{color:var(--text-dim);text-transform:uppercase;letter-spacing:.04em;font-size:10.5px}.aaa-row:not(.aaa-head):hover{background:var(--surface)}.aaa-row.is-off .aaa-cell{color:var(--text-dim)}.aaa-cell{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.aaa-actions{justify-content:flex-end;gap:5px;display:flex}.aaa-actions .btn{padding:3px 8px}.aaa-badge{border-radius:100px;padding:1px 7px;font-size:10.5px;display:inline-block}.aaa-badge.on{background:color-mix(in srgb, var(--ok) 20%, transparent);color:var(--ok)}.aaa-badge.off{background:color-mix(in srgb, var(--text-dim) 22%, transparent);color:var(--text-dim)}.aaa-form,.aaa-card{border:1px solid var(--border);background:var(--surface-2);border-radius:10px;margin:0 8px 12px;padding:12px}.aaa-form-title{margin-bottom:10px;font-size:12.5px;font-weight:600}.aaa-current{color:var(--text-dim);margin-bottom:10px;font-size:11.5px}.aaa-form-grid{grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:9px 12px;display:grid}.aaa-field{flex-direction:column;gap:3px;display:flex}.aaa-field-label{color:var(--text-dim);font-size:11px}.aaa-input{font:inherit;color:var(--text);background:var(--bg);border:1px solid var(--border);border-radius:7px;padding:5px 8px;font-size:12.5px}.aaa-input:focus{border-color:var(--accent);outline:none}.aaa-form-actions{align-items:center;gap:8px;margin-top:12px;display:flex}.aaa-settings{flex-direction:column;gap:4px;display:flex}
113
116
  /*$vite$:1*/
114
117
  </style>
115
118
  </head>
@@ -106,10 +106,13 @@ Boolean requesting whether a visible border and background is provided by the ho
106
106
  - omitted: host decides border`)}),R({method:U(`ui/request-display-mode`),params:R({mode:vh.describe(`The display mode being requested.`)})});var Fh=R({mode:vh.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),Ih=B([U(`model`),U(`app`)]).describe(`Tool visibility scope - who can access the tool.`);R({resourceUri:M().optional(),visibility:L(Ih).optional().describe(`Who can access this tool. Default: ["model", "app"]
107
107
  - "model": Tool visible to and callable by the agent
108
108
  - "app": Tool callable by the app from this server only`),csp:fc().optional(),permissions:fc().optional()}),R({mimeTypes:L(M()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),R({method:U(`ui/download-file`),params:R({contents:L(B([Lu,Ru])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),R({method:U(`ui/message`),params:R({role:U(`user`).describe(`Message role, currently only "user" is supported.`),content:L(zu).describe(`Message content blocks (text, image, etc.).`)})}),R({method:U(`ui/notifications/sandbox-resource-ready`),params:R({html:M().describe(`HTML content to load into the inner iframe.`),sandbox:M().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:Ch.optional().describe(`CSP configuration from resource metadata.`),permissions:wh.optional().describe(`Sandbox permissions from resource metadata.`)})});var Lh=R({method:U(`ui/notifications/tool-result`),params:Ju.describe(`Standard MCP tool execution result.`)}),Rh=R({toolInfo:R({id:yl.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Gu.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:_h.optional().describe(`Current color theme preference.`),styles:kh.optional().describe(`Style configuration for theming the app.`),displayMode:vh.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:L(vh).optional().describe(`Display modes the host supports.`),containerDimensions:B([R({height:P().describe(`Fixed container height in pixels.`)}),R({maxHeight:B([P(),ac()]).optional().describe(`Maximum container height in pixels.`)})]).and(B([R({width:P().describe(`Fixed container width in pixels.`)}),R({maxWidth:B([P(),ac()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
109
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:M().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:M().optional().describe(`User's timezone in IANA format.`),userAgent:M().optional().describe(`Host application identifier.`),platform:B([U(`web`),U(`desktop`),U(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:R({touch:F().optional().describe(`Whether the device supports touch input.`),hover:F().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:R({top:P().describe(`Top safe area inset in pixels.`),right:P().describe(`Right safe area inset in pixels.`),bottom:P().describe(`Bottom safe area inset in pixels.`),left:P().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),zh=R({method:U(`ui/notifications/host-context-changed`),params:Rh.describe(`Partial context update containing only changed fields.`)});R({method:U(`ui/update-model-context`),params:R({content:L(zu).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:V(M(),I().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),R({method:U(`ui/initialize`),params:R({appInfo:Ml.describe(`App identification (name and version).`),appCapabilities:Ph.describe(`Features and capabilities this app provides.`),protocolVersion:M().describe(`Protocol version this app supports.`)})});var Bh=R({protocolVersion:M().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Ml.describe(`Host application identification and version.`),hostCapabilities:Nh.describe(`Features and capabilities provided by the host.`),hostContext:Rh.describe(`Rich context about the host environment.`)}).passthrough(),Vh={target:`draft-2020-12`};async function Hh(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Vh);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Uh(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function Wh(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Gh(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Kh(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function qh(e){if(document.getElementById(`__mcp-host-fonts`))return;let t=document.createElement(`style`);t.id=`__mcp-host-fonts`,t.textContent=e,document.head.appendChild(t)}function Jh(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Yh=class e extends Gm{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new uh;_methods=new dh;setRequestHandler=(...e)=>{let[t,...n]=ph(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=ph(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:Th,toolinputpartial:Eh,toolresult:Lh,toolcancelled:Dh,hostcontextchanged:zh};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},t=>{let n=t;e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...n}),this._events.dispatch(e,n)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._appCapabilities=t,this.options=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),!n.allowUnsafeEval&&w({jitless:!0}),this.replaceRequestHandler(`ping`,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._appCapabilities=Jh(this._appCapabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Uh(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Uh(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Hh(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Hh(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(`ui/resource-teardown`,{params:Ah.shape.params,result:jh},(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(`tools/list`,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if(e===`sampling/createMessage`&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized(`createSamplingMessage`),await this.request({method:`sampling/createMessage`,params:e},t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},Sh,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},El,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},bh,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},xh,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Fh,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new gh(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1;try{await super.connect(e);let n=await this.request({method:`ui/initialize`,params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:hh}},Bh,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function $(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e!==!1&&e!=null&&r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}function Xh(e,t,n={}){let r=$(`button`,{class:`btn${n.class?` ${n.class}`:``}`,...n.title?{title:n.title}:{}});return r.textContent=e,n.disabled&&(r.disabled=!0),r.addEventListener(`click`,t),r}function Zh(e){if(e==null)return`—`;let t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(+(r<10&&n>0))} ${t[n]}`}function Qh(e){e.onhostcontextchanged=e=>{if(e.theme&&Gh(e.theme),e.styles?.variables&&Kh(e.styles.variables),e.styles?.css?.fonts&&qh(e.styles.css.fonts),e.safeAreaInsets){let{top:t,right:n,bottom:r,left:i}=e.safeAreaInsets;document.body.style.padding=`${t+16}px ${n+16}px ${r+16}px ${i+16}px`}},Gh(Wh())}var $h=1e4;async function eg(e,t,n){try{return await e.connect(void 0,{timeout:$h}),console.warn(`[${t}] connected`,{host:e.getHostVersion(),caps:e.getHostCapabilities()}),!0}catch(e){console.error(`[${t}] connect failed`,e);let r=e instanceof Error&&/timed?\s*out/i.test(e.message)?`The MCP App host did not respond — make sure your client supports MCP Apps (ext-apps).`:`Connection failed: ${e instanceof Error?e.message:String(e)}`;return n.replaceChildren($(`div`,{class:`skeleton`},r)),!1}}var tg=document.getElementById(`app`),ng=`http://www.w3.org/2000/svg`,rg=40,ig=2e3,ag=null,og=null,sg=[],cg=null,lg=!1,ug=null,dg=null,fg=new Yh({name:`mikrotik-connected-devices`,version:`1.0.0`});function pg(e){return`${(e/1e6).toFixed(2)} Mbps`}function mg(){return ag?.devices.find(e=>e.mac===og)}function hg(){ug&&clearInterval(ug),ug=null}function gg(e){hg(),sg=[],cg=null;let t=async()=>{try{let t=(await fg.callServerTool({name:`get_device_traffic`,arguments:{ip:e}})).structuredContent;if(!t||t.ip!==e)return;cg=t,sg.push({rx:t.rxBitsPerSec,tx:t.txBitsPerSec}),sg.length>rg&&sg.shift(),vg()}catch(e){console.error(`[connected-devices] traffic poll failed`,e)}};t(),ug=setInterval(()=>void t(),ig)}function _g(){let e=document.createElementNS(ng,`svg`);e.setAttribute(`viewBox`,`0 0 460 140`),e.setAttribute(`class`,`traffic-chart`);let t=Math.max(1,...sg.flatMap(e=>[e.rx,e.tx])),n=e=>6+e*448/39,r=e=>134-e/t*128,i=(t,i)=>{if(sg.length<2)return;let a=sg.map((e,i)=>`${n(i).toFixed(1)},${r(t(e)).toFixed(1)}`).join(` `),o=document.createElementNS(ng,`polygon`),s=n(0).toFixed(1),c=n(sg.length-1).toFixed(1);o.setAttribute(`points`,`${s},134 ${a} ${c},134`),o.setAttribute(`class`,`${i} area`),e.appendChild(o);let l=document.createElementNS(ng,`polyline`);l.setAttribute(`points`,a),l.setAttribute(`class`,`${i} line`),e.appendChild(l)};return i(e=>e.rx,`rx`),i(e=>e.tx,`tx`),e}function vg(){let e=document.getElementById(`detail`);if(!e)return;let t=mg();if(e.replaceChildren(),!t){e.appendChild($(`div`,{class:`muted`},`Select a device to see its traffic.`));return}e.appendChild($(`div`,{class:`detail-title`},t.host||t.comment||t.ip)),e.appendChild($(`div`,{class:`detail-sub`},`${t.ip} · ${t.mac} · ${t.iface||`?`} · ${t.status}`)),cg&&cg.source===`none`?e.appendChild($(`div`,{class:`muted note`},`No per-device counter. Ask: “create a simple queue for this device” to enable Download/Upload tracking.`)):(e.appendChild($(`div`,{class:`rates`},$(`span`,{class:`rate rx`},`↓ ${cg?pg(cg.rxBitsPerSec):`…`}`),$(`span`,{class:`rate tx`},`↑ ${cg?pg(cg.txBitsPerSec):`…`}`))),e.appendChild(_g()),cg&&e.appendChild($(`div`,{class:`totals muted`},`total ↓ ${Zh(cg.rxBytes)} · ↑ ${Zh(cg.txBytes)}`)))}function yg(e){e&&typeof e==`object`&&e.__mikrotikView===`connected-devices`&&(ag=e,Sg())}async function bg(e,t){if(!lg){lg=!0,Sg();try{yg((await fg.callServerTool({name:e,arguments:{mac:t}})).structuredContent)}catch(t){console.error(`[connected-devices] ${e} failed`,t)}finally{lg=!1,Sg()}}}async function xg(){if(!lg){lg=!0,Sg();try{yg((await fg.callServerTool({name:`list_connected_devices`,arguments:{}})).structuredContent)}catch(e){console.error(`[connected-devices] refresh failed`,e)}finally{lg=!1,Sg()}}}function Sg(){if(!ag){tg.replaceChildren($(`div`,{class:`muted loading`},`Loading connected devices…`));return}let e=ag.counts,t=$(`div`,{class:`toolbar`},$(`div`,{class:`title`},`Connected Devices`),$(`div`,{class:`counts muted`},`${e.total} total · ${e.static} static · ${e.blocked} blocked`),Xh(`↻ Refresh`,()=>void xg(),{class:lg?`is-busy`:``})),n=ag.devices.map(e=>{let t=$(`div`,{class:`row${e.mac===og?` is-selected`:``}${e.blocked?` is-blocked`:``}`},$(`span`,{class:`cell ip`},e.ip||`—`),$(`span`,{class:`cell name`},e.host||e.comment||`(unknown)`),$(`span`,{class:`cell mac mono`},e.mac),$(`span`,{class:`cell iface`},e.iface||``),$(`span`,{class:`cell badges`},e.static?$(`span`,{class:`badge static`},`static`):null,e.blocked?$(`span`,{class:`badge blocked`},`blocked`):null),$(`span`,{class:`cell actions`},e.blocked?Xh(`Allow`,()=>void bg(`allow_device`,e.mac),{class:`ok`}):Xh(`Block`,()=>void bg(`block_device`,e.mac),{class:`danger`}),e.static?null:Xh(`Pin IP`,()=>void bg(`make_device_static`,e.mac),{class:``})));return t.addEventListener(`click`,t=>{t.target.closest(`.actions`)||(og=e.mac,e.ip?gg(e.ip):hg(),Sg())}),t});tg.replaceChildren(t,$(`div`,{class:`table`},$(`div`,{class:`row header`},$(`span`,{class:`cell ip`},`IP`),$(`span`,{class:`cell name`},`Name`),$(`span`,{class:`cell mac`},`MAC`),$(`span`,{class:`cell iface`},`Iface`),$(`span`,{class:`cell badges`},``),$(`span`,{class:`cell actions`},``)),...n),$(`div`,{id:`detail`,class:`detail`})),vg()}fg.ontoolresult=e=>{console.warn(`[connected-devices] ontoolresult`,e),yg(e.structuredContent)},fg.ontoolinput=()=>{ag||Sg()},Qh(fg),fg.onteardown=async()=>(hg(),dg&&clearInterval(dg),{}),Sg(),eg(fg,`connected-devices`,tg).then(e=>{e&&(dg=setInterval(()=>void xg(),15e3))});
109
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:M().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:M().optional().describe(`User's timezone in IANA format.`),userAgent:M().optional().describe(`Host application identifier.`),platform:B([U(`web`),U(`desktop`),U(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:R({touch:F().optional().describe(`Whether the device supports touch input.`),hover:F().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:R({top:P().describe(`Top safe area inset in pixels.`),right:P().describe(`Right safe area inset in pixels.`),bottom:P().describe(`Bottom safe area inset in pixels.`),left:P().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),zh=R({method:U(`ui/notifications/host-context-changed`),params:Rh.describe(`Partial context update containing only changed fields.`)});R({method:U(`ui/update-model-context`),params:R({content:L(zu).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:V(M(),I().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),R({method:U(`ui/initialize`),params:R({appInfo:Ml.describe(`App identification (name and version).`),appCapabilities:Ph.describe(`Features and capabilities this app provides.`),protocolVersion:M().describe(`Protocol version this app supports.`)})});var Bh=R({protocolVersion:M().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Ml.describe(`Host application identification and version.`),hostCapabilities:Nh.describe(`Features and capabilities provided by the host.`),hostContext:Rh.describe(`Rich context about the host environment.`)}).passthrough(),Vh={target:`draft-2020-12`};async function Hh(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Vh);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Uh(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function Wh(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Gh(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Kh(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function qh(e){if(document.getElementById(`__mcp-host-fonts`))return;let t=document.createElement(`style`);t.id=`__mcp-host-fonts`,t.textContent=e,document.head.appendChild(t)}function Jh(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Yh=class e extends Gm{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new uh;_methods=new dh;setRequestHandler=(...e)=>{let[t,...n]=ph(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=ph(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:Th,toolinputpartial:Eh,toolresult:Lh,toolcancelled:Dh,hostcontextchanged:zh};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},t=>{let n=t;e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...n}),this._events.dispatch(e,n)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._appCapabilities=t,this.options=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),!n.allowUnsafeEval&&w({jitless:!0}),this.replaceRequestHandler(`ping`,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._appCapabilities=Jh(this._appCapabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Uh(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Uh(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Hh(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Hh(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(`ui/resource-teardown`,{params:Ah.shape.params,result:jh},(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(`tools/list`,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if(e===`sampling/createMessage`&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized(`createSamplingMessage`),await this.request({method:`sampling/createMessage`,params:e},t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},Sh,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},El,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},bh,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},xh,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Fh,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new gh(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1;try{await super.connect(e);let n=await this.request({method:`ui/initialize`,params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:hh}},Bh,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function $(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e!==!1&&e!=null&&r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}function Xh(e,t,n={}){let r=$(`button`,{class:`btn${n.class?` ${n.class}`:``}`,type:`button`,...n.title?{title:n.title}:{}});return r.textContent=e,n.disabled&&(r.disabled=!0),r.addEventListener(`click`,t),r}function Zh(e){if(e==null)return`—`;let t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(+(r<10&&n>0))} ${t[n]}`}function Qh(e){e.onhostcontextchanged=e=>{if(e.theme&&Gh(e.theme),e.styles?.variables&&Kh(e.styles.variables),e.styles?.css?.fonts&&qh(e.styles.css.fonts),e.safeAreaInsets){let{top:t,right:n,bottom:r,left:i}=e.safeAreaInsets;document.body.style.padding=`${t+16}px ${n+16}px ${r+16}px ${i+16}px`}},Gh(Wh())}var $h=1e4;function eg(){let e=`http://www.w3.org/2000/svg`,t=document.createElementNS(e,`svg`);for(let[e,n]of Object.entries({viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`}))t.setAttribute(e,n);let n=document.createElementNS(e,`path`);return n.setAttribute(`d`,`M6 7v4a6 6 0 0 0 6 6m6-10v4a6 6 0 0 1-6 6m0 0v3M4 3h4v4H4zm12 0h4v4h-4zM10 20h4v3h-4z`),t.append(n),t}function tg(e,t){document.documentElement.dataset.mcpView=t,e.classList.add(`app`),document.getElementById(`mcp-app-masthead`)?.remove(),e.before($(`header`,{id:`mcp-app-masthead`,class:`mcp-masthead`},$(`span`,{class:`mcp-mark`},eg()),$(`div`,{},$(`span`,{class:`mcp-brand`},`MikroTik `,$(`b`,{},`MCP`)),$(`p`,{class:`mcp-context`},{dashboard:`Device health`,records:`Data explorer`,interfaces:`Interface inventory`,firewall:`Firewall policy`,"firewall-audit":`Security findings`,"connected-devices":`Client inventory`,aaa:`Identity & access`,investigations:`Client investigations`,"round-trip":`Round-trip lab`,"service-health":`Service health`,fabric:`Layer-2 fabric`,operations:`Change operations`,reports:`Evidence reports`}[t]??`Tool workspace`)),$(`span`,{class:`mcp-response-label`},`TOOL RESPONSE`)))}async function ng(e,t,n,r){tg(n,t);let i=!1,a=!1,o,s=()=>{o!==void 0&&clearTimeout(o),o=void 0},c=(e,t,r,i=!1)=>{n.replaceChildren($(`section`,{class:`app-result`,role:i?`alert`:`status`},$(`h2`,{class:`app-result__title`},e),$(`p`,{class:`app-result__message`},t),r?$(`pre`,{class:`app-result__detail`},r):null))};e.ontoolresult=e=>{if(a)return;i=!0,s();let t=(e.content??[]).flatMap(e=>e.type===`text`?[e.text]:[]).join(`
110
+ `).trim();if(e.isError){c(`Tool failed`,`The tool returned an error. No successful result is available.`,t,!0);return}try{if(r(e.structuredContent,e))return;let n=e.structuredContent;t||n?c(`Tool result`,`The response is shown below; it does not use this view's interactive format.`,[t,n?JSON.stringify(n,null,2):``].filter(Boolean).join(`
111
+
112
+ `)):c(`No data returned`,e.content?.some(e=>e.type!==`text`)?`The tool returned non-text content. Open the original tool response in your client.`:`The tool completed without text or structured data.`)}catch{c(`Unable to display result`,`The tool returned an invalid view payload.`,t,!0)}},e.ontoolcancelled=e=>{a||(i=!0,s(),c(`Tool cancelled`,e.reason||`The host cancelled this tool call.`))};let l=e.onteardown;e.onteardown=(e,t)=>(a=!0,s(),l?.(e,t)??{});let u=e.onclose;e.onclose=()=>{!a&&!i&&c(`Host disconnected`,`The connection closed before a tool result arrived.`,void 0,!0),a=!0,s(),u?.()};try{if(await e.connect(void 0,{timeout:$h}),a)return!1;let n=e.getHostContext?.();return n&&e.onhostcontextchanged?.(n),i||(o=setTimeout(()=>{c(`Still awaiting the tool result`,`The host is connected, but has not delivered a result. Check the original tool response or your client's MCP connection. Do not repeat a configuration-changing call just to refresh this view. Late results will still appear here.`)},15e3)),console.warn(`[${t}] connected`,{host:e.getHostVersion(),caps:e.getHostCapabilities()}),!0}catch(e){return s(),!a&&(a=!0,console.error(`[${t}] connect failed`,e),c(`Cannot connect to the host`,e instanceof Error&&/timed?\s*out/i.test(e.message)?`The MCP App host did not respond — make sure your client supports MCP Apps (ext-apps).`:`Connection failed: ${e instanceof Error?e.message:String(e)}`,void 0,!0),!1)}}var rg=document.getElementById(`app`),ig=`http://www.w3.org/2000/svg`,ag=40,og=2e3,sg=null,cg=null,lg=[],ug=null,dg=!1,fg=null,pg=null,mg=new Yh({name:`mikrotik-connected-devices`,version:`1.0.0`});function hg(e){return`${(e/1e6).toFixed(2)} Mbps`}function gg(){return sg?.devices.find(e=>e.mac===cg)}function _g(){fg&&clearInterval(fg),fg=null}function vg(e){_g(),lg=[],ug=null;let t=async()=>{try{let t=(await mg.callServerTool({name:`get_device_traffic`,arguments:{ip:e}})).structuredContent;if(!t||t.ip!==e)return;ug=t,lg.push({rx:t.rxBitsPerSec,tx:t.txBitsPerSec}),lg.length>ag&&lg.shift(),bg()}catch(e){console.error(`[connected-devices] traffic poll failed`,e)}};t(),fg=setInterval(()=>void t(),og)}function yg(){let e=document.createElementNS(ig,`svg`);e.setAttribute(`viewBox`,`0 0 460 140`),e.setAttribute(`class`,`traffic-chart`);let t=Math.max(1,...lg.flatMap(e=>[e.rx,e.tx])),n=e=>6+e*448/39,r=e=>134-e/t*128,i=(t,i)=>{if(lg.length<2)return;let a=lg.map((e,i)=>`${n(i).toFixed(1)},${r(t(e)).toFixed(1)}`).join(` `),o=document.createElementNS(ig,`polygon`),s=n(0).toFixed(1),c=n(lg.length-1).toFixed(1);o.setAttribute(`points`,`${s},134 ${a} ${c},134`),o.setAttribute(`class`,`${i} area`),e.appendChild(o);let l=document.createElementNS(ig,`polyline`);l.setAttribute(`points`,a),l.setAttribute(`class`,`${i} line`),e.appendChild(l)};return i(e=>e.rx,`rx`),i(e=>e.tx,`tx`),e}function bg(){let e=document.getElementById(`detail`);if(!e)return;let t=gg();if(e.replaceChildren(),!t){e.appendChild($(`div`,{class:`muted`},`Select a device to see its traffic.`));return}e.appendChild($(`div`,{class:`detail-title`},t.host||t.comment||t.ip)),e.appendChild($(`div`,{class:`detail-sub`},`${t.ip} · ${t.mac} · ${t.iface||`?`} · ${t.status}`)),ug&&ug.source===`none`?e.appendChild($(`div`,{class:`muted note`},`No per-device counter. Ask: “create a simple queue for this device” to enable Download/Upload tracking.`)):(e.appendChild($(`div`,{class:`rates`},$(`span`,{class:`rate rx`},`↓ ${ug?hg(ug.rxBitsPerSec):`…`}`),$(`span`,{class:`rate tx`},`↑ ${ug?hg(ug.txBitsPerSec):`…`}`))),e.appendChild(yg()),ug&&e.appendChild($(`div`,{class:`totals muted`},`total ↓ ${Zh(ug.rxBytes)} · ↑ ${Zh(ug.txBytes)}`)))}function xg(e){return e&&typeof e==`object`&&e.__mikrotikView===`connected-devices`?(sg=e,wg(),!0):!1}async function Sg(e,t){if(!dg){dg=!0,wg();try{xg((await mg.callServerTool({name:e,arguments:{mac:t}})).structuredContent)}catch(t){console.error(`[connected-devices] ${e} failed`,t)}finally{dg=!1,wg()}}}async function Cg(){if(!dg){dg=!0,wg();try{xg((await mg.callServerTool({name:`list_connected_devices`,arguments:{}})).structuredContent)}catch(e){console.error(`[connected-devices] refresh failed`,e)}finally{dg=!1,wg()}}}function wg(){if(!sg){rg.replaceChildren($(`div`,{class:`muted loading`},`Loading connected devices…`));return}let e=sg.counts,t=$(`div`,{class:`toolbar`},$(`h1`,{class:`title`},`Connected Devices`),$(`div`,{class:`counts muted`},`${e.total} total · ${e.static} static · ${e.blocked} blocked`),Xh(`↻ Refresh`,()=>void Cg(),{class:dg?`is-busy`:``})),n=sg.devices.map(e=>{let t=$(`div`,{class:`row${e.mac===cg?` is-selected`:``}${e.blocked?` is-blocked`:``}`},$(`span`,{class:`cell ip`},e.ip||`—`),$(`span`,{class:`cell name`},e.host||e.comment||`(unknown)`),$(`span`,{class:`cell mac mono`},e.mac),$(`span`,{class:`cell iface`},e.iface||``),$(`span`,{class:`cell badges`},e.static?$(`span`,{class:`badge static`},`static`):null,e.blocked?$(`span`,{class:`badge blocked`},`blocked`):null),$(`span`,{class:`cell actions`},e.blocked?Xh(`Allow`,()=>void Sg(`allow_device`,e.mac),{class:`ok`}):Xh(`Block`,()=>void Sg(`block_device`,e.mac),{class:`danger`}),e.static?null:Xh(`Pin IP`,()=>void Sg(`make_device_static`,e.mac),{class:``})));return t.addEventListener(`click`,t=>{t.target.closest(`.actions`)||(cg=e.mac,e.ip?vg(e.ip):_g(),wg())}),t});rg.replaceChildren(t,$(`div`,{class:`table`},$(`div`,{class:`row header`},$(`span`,{class:`cell ip`},`IP`),$(`span`,{class:`cell name`},`Name`),$(`span`,{class:`cell mac`},`MAC`),$(`span`,{class:`cell iface`},`Iface`),$(`span`,{class:`cell badges`},``),$(`span`,{class:`cell actions`},``)),...n),$(`div`,{id:`detail`,class:`detail`})),bg()}Qh(mg),mg.onteardown=async()=>(_g(),pg&&clearInterval(pg),{}),wg(),ng(mg,`connected-devices`,rg,xg).then(e=>{e&&(pg=setInterval(()=>{sg&&Cg()},15e3))});
110
113
  </script>
111
114
  <style>
112
- :root{--bg:#0b0d10;--surface:#14181d;--surface-2:#1b2027;--border:#2a313a;--text:#e8eaed;--text-dim:#9aa0a6;--accent:#7c9cff;--rx:#4ade80;--tx:#f59e0b;--danger:#f2685a;--ok:#4ade80}@media (prefers-color-scheme:light){:root{--bg:#fff;--surface:#f6f8fa;--surface-2:#eef1f4;--border:#d8dee4;--text:#1c2024;--text-dim:#5b6470;--accent:#3b5bdb}}*{box-sizing:border-box}body{background:var(--bg);color:var(--text);margin:0;font:13px/1.5 system-ui,-apple-system,Segoe UI,sans-serif}.mono{font-family:ui-monospace,SF Mono,Menlo,monospace}.muted{color:var(--text-dim)}.loading{padding:24px}.toolbar{border-bottom:1px solid var(--border);align-items:center;gap:12px;padding:12px 14px;display:flex}.toolbar .title{font-size:15px;font-weight:600}.toolbar .counts{font-size:12px}.btn{font:inherit;color:var(--text);background:var(--surface-2);border:1px solid var(--border);cursor:pointer;border-radius:8px;margin-left:auto;padding:5px 10px}.toolbar .btn{margin-left:auto}.btn:hover{border-color:var(--accent)}.btn.is-busy{opacity:.5;pointer-events:none}.table{padding:6px 8px 14px}.row{cursor:pointer;border-radius:8px;grid-template-columns:110px 1.4fr 150px 90px 110px 150px;align-items:center;gap:8px;padding:7px 8px;display:grid}.row.header{cursor:default;color:var(--text-dim);text-transform:uppercase;letter-spacing:.04em;font-size:11px}.row:not(.header):hover{background:var(--surface)}.row.is-selected{background:color-mix(in srgb, var(--accent) 16%, var(--surface))}.row.is-blocked .name,.row.is-blocked .ip{color:var(--text-dim);text-decoration:line-through}.cell{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.cell.mac{color:var(--text-dim);font-family:ui-monospace,monospace;font-size:11.5px}.badge{border-radius:100px;margin-right:4px;padding:1px 7px;font-size:10.5px;display:inline-block}.badge.static{background:color-mix(in srgb, var(--accent) 22%, transparent);color:var(--accent)}.badge.blocked{background:color-mix(in srgb, var(--danger) 22%, transparent);color:var(--danger)}.cell.actions{justify-content:flex-end;gap:6px;display:flex}.cell.actions .btn{margin:0;padding:3px 9px;font-size:12px}.btn.danger{border-color:color-mix(in srgb, var(--danger) 45%, var(--border));color:var(--danger)}.btn.ok{border-color:color-mix(in srgb, var(--ok) 45%, var(--border));color:var(--ok)}.detail{border-top:1px solid var(--border);padding:14px}.detail-title{font-size:14px;font-weight:600}.detail-sub{color:var(--text-dim);margin-bottom:10px;font-size:12px}.note{max-width:460px;font-size:12px}.rates{font-variant-numeric:tabular-nums;gap:16px;margin-bottom:6px;display:flex}.rate{font-weight:600}.rate.rx{color:var(--rx)}.rate.tx{color:var(--tx)}.traffic-chart{background:var(--surface);border:1px solid var(--border);border-radius:10px;width:100%;max-width:460px;height:140px;display:block}.traffic-chart .line{fill:none;stroke-width:2px}.traffic-chart .rx.line{stroke:var(--rx)}.traffic-chart .tx.line{stroke:var(--tx)}.traffic-chart .rx.area{fill:color-mix(in srgb, var(--rx) 18%, transparent);stroke:none}.traffic-chart .tx.area{fill:color-mix(in srgb, var(--tx) 14%, transparent);stroke:none}.totals{font-variant-numeric:tabular-nums;margin-top:6px;font-size:12px}
115
+ .app-result{border:1px solid var(--color-border-primary,#8886);background:var(--color-background-secondary,transparent);color:var(--color-text-primary,inherit);border-radius:12px;padding:20px}.app-result__title{margin:0 0 8px;font-size:16px;font-weight:600}.app-result__message{margin:0;font-size:13px;line-height:1.6}.app-result__detail{border:1px solid var(--color-border-primary,#8886);max-height:420px;font:12px/1.6 var(--font-mono,monospace);white-space:pre-wrap;overflow-wrap:anywhere;border-radius:8px;margin:16px 0 0;padding:12px;overflow:auto}html[data-mcp-view]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--mt-bg:var(--color-background-primary,#101c2e);--mt-surface:var(--color-background-secondary,#17263b);--mt-surface-2:var(--color-background-tertiary,#20324a);--mt-border:var(--color-border-primary,#304660);--mt-text:var(--color-text-primary,#dae6f4);--mt-text-dim:var(--color-text-secondary,#a6b9ce);--mt-text-faint:var(--color-text-tertiary,#91a8c1);--mt-accent:var(--color-accent-primary,#9ebfee);--mt-good:#69d6c3;--mt-warn:#e5b56f;--mt-bad:#f18b94;--mt-radius:16px;--mt-radius-sm:10px;--mt-sans:var(--font-sans,"Avenir Next", "Segoe UI", sans-serif);--mt-display:var(--font-sans,"Avenir Next", "Segoe UI", sans-serif);--mt-mono:var(--font-mono,"SFMono-Regular", Consolas, monospace);--bg:var(--mt-bg);--surface:var(--mt-surface);--surface-2:var(--mt-surface-2);--border:var(--mt-border);--text:var(--mt-text);--text-dim:var(--mt-text-dim);--accent:var(--mt-accent);--danger:var(--mt-bad);--ok:var(--mt-good);--rx:var(--mt-good);--tx:var(--mt-accent)}html[data-mcp-view][data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--mt-bg:var(--color-background-primary,#f3f6fa);--mt-surface:var(--color-background-secondary,#fff);--mt-surface-2:var(--color-background-tertiary,#e9eff6);--mt-border:var(--color-border-primary,#c8d5e3);--mt-text:var(--color-text-primary,#20334d);--mt-text-dim:var(--color-text-secondary,#4b6480);--mt-text-faint:var(--color-text-tertiary,#5b728c);--mt-accent:var(--color-accent-primary,#325f9c);--mt-good:#157d6b;--mt-warn:#956313;--mt-bad:#b53446}html[data-mcp-view] body{background:var(--mt-bg);color:var(--mt-text);font:13px/1.6 var(--mt-sans);-webkit-font-smoothing:antialiased;margin:0;padding:20px}html[data-mcp-view] :where(*){box-sizing:border-box}html[data-mcp-view] body #app{gap:20px;width:100%;min-width:0;max-width:1120px;margin:0 auto;animation:.22s ease-out both workspace-arrive;display:grid}html[data-mcp-view] body #app>*{min-width:0}.mcp-masthead{border-bottom:1px solid var(--mt-border);align-items:center;gap:12px;width:100%;max-width:1120px;margin:0 auto 22px;padding-bottom:18px;display:flex}.mcp-mark{border:1px solid var(--mt-border);background:var(--mt-surface);width:38px;height:38px;color:var(--mt-accent);border-radius:12px;flex:none;place-items:center;display:grid}.mcp-brand{letter-spacing:-.02em;font-size:13px;font-weight:650}.mcp-brand b{color:var(--mt-accent)}.mcp-context{color:var(--mt-text-dim);margin:0;font-size:11px}.mcp-response-label{font:9px var(--mt-mono);letter-spacing:.12em;color:var(--mt-text-faint);margin-left:auto}body #app :where(.hd,.aaa-titlebar){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background-color:var(--mt-surface);background-image:radial-gradient(color-mix(in srgb, var(--mt-border) 60%, transparent) .7px, transparent .7px);overflow-wrap:anywhere;background-size:16px 16px;flex-wrap:wrap;align-items:center;gap:16px;padding:22px;display:flex;position:relative}body #app :where(.hd__title,.aaa-title,.toolbar .title){font:650 clamp(19px, 3.8vw, 25px)/1.25 var(--mt-display);letter-spacing:-.035em;margin:0}body #app .hd__sub{color:var(--mt-text-dim);font:11px/1.7 var(--mt-mono);margin:6px 0 0}body #app .hd__dot{background:var(--mt-accent);box-shadow:0 0 0 6px color-mix(in srgb, var(--mt-accent) 10%, transparent)}body #app :where(.grid,.if-grid,.aaa-form-grid){grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr));gap:16px;display:grid}body #app :where(.card,.aaa-card,.aaa-form,.f-card){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);min-width:0;margin:0;padding:20px}body #app .card__label{color:var(--mt-text-dim);font:11px/1.5 var(--mt-sans);letter-spacing:.03em;text-transform:none;margin:0 0 10px}body #app .card__value{font:550 27px/1.3 var(--mt-mono);letter-spacing:-.04em;overflow-wrap:anywhere}body #app .card__value small{font-size:12px}body #app :where(.toolbar,.aaa-bar){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);flex-wrap:wrap;align-items:center;gap:10px;margin:0;padding:12px;display:flex}body #app .toolbar .grow{flex:200px;min-width:min(100%,200px)}body #app :where(.btn,.aaa-tab){border:1px solid var(--mt-border);background:var(--mt-surface-2);min-height:34px;color:var(--mt-text);font:500 12px/1.4 var(--mt-sans);cursor:pointer;border-radius:10px;justify-content:center;align-items:center;gap:7px;margin:0;padding:7px 12px;transition:background .14s,border-color .14s,transform .14s;display:inline-flex}body #app :where(.btn,.aaa-tab):hover:not(:disabled){border-color:var(--mt-accent);background:color-mix(in srgb, var(--mt-accent) 14%, var(--mt-surface));transform:translateY(-1px)}body #app :where(.btn,.aaa-tab):active:not(:disabled){transform:translateY(0)}body #app :where(.btn,.aaa-tab):disabled{opacity:.5;cursor:not-allowed}body #app :where(.btn.is-active,.btn.primary,.aaa-tab.is-active){border-color:color-mix(in srgb, var(--mt-accent) 70%, var(--mt-border));color:var(--mt-accent);background:color-mix(in srgb, var(--mt-accent) 12%, var(--mt-surface))}body #app :where(.btn-danger,.btn.danger){color:var(--mt-bad);border-color:color-mix(in srgb, var(--mt-bad) 50%, var(--mt-border));background:color-mix(in srgb, var(--mt-bad) 8%, var(--mt-surface))}body #app .btn.ok{color:var(--mt-good)}body #app :where(.search,.aaa-input){border:1px solid var(--mt-border);background:var(--mt-bg);width:100%;min-width:0;min-height:36px;color:var(--mt-text);font:12px/1.5 var(--mt-sans);border-radius:10px;padding:8px 12px}body #app :where(button,input,select,textarea,summary,[tabindex]):focus-visible{outline:2px solid var(--mt-accent);outline-offset:3px}body #app :where(.pill,.chip,.badge,.aaa-badge,.act){font:10px/1.4 var(--mt-mono);overflow-wrap:anywhere;border-radius:7px;max-width:100%;padding:4px 9px}body #app :where(.tablewrap,.table,.aaa-table){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);width:100%;min-width:0;padding:0;overflow:auto}body #app :where(table.tbl th,table.tbl td){border-bottom:1px solid color-mix(in srgb, var(--mt-border) 65%, transparent);padding:12px 16px;font-size:11px;line-height:1.6}body #app table.tbl thead th{background:var(--mt-surface-2);font:600 11px var(--mt-sans);height:42px}body #app table.tbl tbody tr:nth-child(2n){background:color-mix(in srgb, var(--mt-surface-2) 30%, transparent)}body #app table.tbl tbody tr:hover{background:color-mix(in srgb, var(--mt-accent) 12%, var(--mt-surface))}body #app :where(.kv__body,details.kv){background:var(--mt-surface);border:1px solid var(--mt-border);border-radius:var(--mt-radius);overflow:hidden}body #app .kv__body{grid-template-columns:minmax(100px,.45fr) minmax(0,1fr)}body #app .kv__body>div{padding:12px 16px;font-size:11px;line-height:1.6}body #app details.kv .kv__body{border:0;border-top:1px solid var(--mt-border);border-radius:0}body #app details.kv>summary{padding:16px 20px;font-size:12px}body #app :where(.foot,.totals){color:var(--mt-text-faint);border-top:1px solid var(--mt-border);gap:12px;padding:12px 0;font-size:10px}body #app :where(.skeleton,.empty,.loading,.aaa-notice){border:1px dashed var(--mt-border);border-radius:var(--mt-radius);color:var(--mt-text-dim);background:var(--mt-surface);text-align:center;padding:36px 24px;font-size:12px}body #app pre.raw{white-space:pre-wrap;overflow-wrap:anywhere;padding:20px;font-size:11px;line-height:1.85}body #app .drawer{gap:16px;padding:20px}body #app .drawer__hd{flex-wrap:wrap}body #app .if-card{border-top:3px solid var(--mt-border);gap:20px}body #app .if-card:has(.dot.is-up){border-top-color:var(--mt-good)}body #app .if-card__top{flex-wrap:wrap;gap:10px}body #app .if-card__name{font-size:15px}body #app .if-card__meta{grid-template-columns:minmax(45px,.3fr) minmax(0,1fr);gap:8px 14px}body #app .f-list{grid-template-columns:repeat(auto-fit,minmax(min(100%,340px),1fr));gap:16px;margin:0;display:grid}body #app .f-card{border-top-width:3px}body #app .f-card.is-bad{border-top-color:var(--mt-bad)}body #app .f-card.is-warn{border-top-color:var(--mt-warn)}body #app .f-body{margin-top:14px}body #app .f-detail{font-size:12px;line-height:1.7}body #app .f-fix{margin-top:10px;font-size:11px}body #app .f-actions{margin-top:18px}body #app .aaa-wrap{gap:18px;min-width:0;padding:0;display:grid}body #app .aaa-tabs{border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);gap:8px;margin:0;padding:8px}body #app .aaa-tab{font-size:11px}body #app .aaa-row{min-width:max(100%, calc(var(--cols) * 105px + 190px));border-bottom:1px solid var(--mt-border);border-radius:0;gap:12px;padding:12px 16px;font-size:11px}body #app .aaa-head{background:var(--mt-surface-2)}body #app .aaa-actions,body #app .aaa-field{gap:8px}body #app .aaa-form-title{margin-bottom:16px;font-size:14px}body #app .aaa-settings{gap:16px}body #app .aaa-error{margin:0;padding:16px}body #app .row{border-bottom:1px solid var(--mt-border);border-radius:0;grid-template-columns:105px minmax(150px,1.4fr) 145px 85px 100px 165px;gap:14px;min-width:840px;padding:13px 16px;font-size:11px}body #app .row.header{background:var(--mt-surface-2);font:600 10px var(--mt-sans)}body #app .detail{border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);padding:22px}body #app .detail-title{margin-bottom:6px;font-size:19px}body #app .detail-sub{margin-bottom:22px}body #app .rates{font:15px var(--mt-mono);flex-wrap:wrap;gap:24px;margin:0 0 18px}body #app .traffic-chart{background-image:radial-gradient(var(--mt-border) .75px, transparent .75px);background-size:16px 16px;max-width:none;height:200px}body #app .app-result{border-color:var(--mt-border);background:var(--mt-surface);color:var(--mt-text);padding:26px}body #app .app-result[role=alert]{border-top:3px solid var(--mt-bad)}body #app .app-result__title{font-family:var(--mt-display);letter-spacing:-.025em;font-size:20px}body #app .app-result__message{color:var(--mt-text-dim);font-size:12px}body #app .app-result__detail{background:var(--mt-bg);border-color:var(--mt-border);font:11px/1.8 var(--mt-mono)}@keyframes workspace-arrive{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}@media (width<=520px){html[data-mcp-view] body{padding:12px}html[data-mcp-view] body #app{gap:16px}.mcp-masthead{gap:10px;margin-bottom:16px}.mcp-response-label{letter-spacing:.04em;font-size:8px}body #app :where(.hd,.aaa-titlebar,.card,.f-card,.aaa-card,.aaa-form){padding:16px}body #app .kv__body{grid-template-columns:minmax(80px,.4fr) minmax(0,1fr)}body #app .kv__body>div{padding:10px 12px}body #app .if-grid{grid-template-columns:minmax(0,1fr)}}@media (prefers-reduced-motion:reduce){html[data-mcp-view] body #app,body #app *,body #app :before,body #app :after{scroll-behavior:auto!important;transition:none!important;animation:none!important}}:root{--bg:#0b0d10;--surface:#14181d;--surface-2:#1b2027;--border:#2a313a;--text:#e8eaed;--text-dim:#9aa0a6;--accent:#7c9cff;--rx:#4ade80;--tx:#f59e0b;--danger:#f2685a;--ok:#4ade80}@media (prefers-color-scheme:light){:root{--bg:#fff;--surface:#f6f8fa;--surface-2:#eef1f4;--border:#d8dee4;--text:#1c2024;--text-dim:#5b6470;--accent:#3b5bdb}}*{box-sizing:border-box}body{background:var(--bg);color:var(--text);margin:0;font:13px/1.5 system-ui,-apple-system,Segoe UI,sans-serif}.mono{font-family:ui-monospace,SF Mono,Menlo,monospace}.muted{color:var(--text-dim)}.loading{padding:24px}.toolbar{border-bottom:1px solid var(--border);align-items:center;gap:12px;padding:12px 14px;display:flex}.toolbar .title{font-size:15px;font-weight:600}.toolbar .counts{font-size:12px}.btn{font:inherit;color:var(--text);background:var(--surface-2);border:1px solid var(--border);cursor:pointer;border-radius:8px;margin-left:auto;padding:5px 10px}.toolbar .btn{margin-left:auto}.btn:hover{border-color:var(--accent)}.btn.is-busy{opacity:.5;pointer-events:none}.table{padding:6px 8px 14px}.row{cursor:pointer;border-radius:8px;grid-template-columns:110px 1.4fr 150px 90px 110px 150px;align-items:center;gap:8px;padding:7px 8px;display:grid}.row.header{cursor:default;color:var(--text-dim);text-transform:uppercase;letter-spacing:.04em;font-size:11px}.row:not(.header):hover{background:var(--surface)}.row.is-selected{background:color-mix(in srgb, var(--accent) 16%, var(--surface))}.row.is-blocked .name,.row.is-blocked .ip{color:var(--text-dim);text-decoration:line-through}.cell{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.cell.mac{color:var(--text-dim);font-family:ui-monospace,monospace;font-size:11.5px}.badge{border-radius:100px;margin-right:4px;padding:1px 7px;font-size:10.5px;display:inline-block}.badge.static{background:color-mix(in srgb, var(--accent) 22%, transparent);color:var(--accent)}.badge.blocked{background:color-mix(in srgb, var(--danger) 22%, transparent);color:var(--danger)}.cell.actions{justify-content:flex-end;gap:6px;display:flex}.cell.actions .btn{margin:0;padding:3px 9px;font-size:12px}.btn.danger{border-color:color-mix(in srgb, var(--danger) 45%, var(--border));color:var(--danger)}.btn.ok{border-color:color-mix(in srgb, var(--ok) 45%, var(--border));color:var(--ok)}.detail{border-top:1px solid var(--border);padding:14px}.detail-title{font-size:14px;font-weight:600}.detail-sub{color:var(--text-dim);margin-bottom:10px;font-size:12px}.note{max-width:460px;font-size:12px}.rates{font-variant-numeric:tabular-nums;gap:16px;margin-bottom:6px;display:flex}.rate{font-weight:600}.rate.rx{color:var(--rx)}.rate.tx{color:var(--tx)}.traffic-chart{background:var(--surface);border:1px solid var(--border);border-radius:10px;width:100%;max-width:460px;height:140px;display:block}.traffic-chart .line{fill:none;stroke-width:2px}.traffic-chart .rx.line{stroke:var(--rx)}.traffic-chart .tx.line{stroke:var(--tx)}.traffic-chart .rx.area{fill:color-mix(in srgb, var(--rx) 18%, transparent);stroke:none}.traffic-chart .tx.area{fill:color-mix(in srgb, var(--tx) 14%, transparent);stroke:none}.totals{font-variant-numeric:tabular-nums;margin-top:6px;font-size:12px}
113
116
  /*$vite$:1*/
114
117
  </style>
115
118
  </head>
@@ -106,10 +106,13 @@ Boolean requesting whether a visible border and background is provided by the ho
106
106
  - omitted: host decides border`)}),R({method:U(`ui/request-display-mode`),params:R({mode:vh.describe(`The display mode being requested.`)})});var Fh=R({mode:vh.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),Ih=B([U(`model`),U(`app`)]).describe(`Tool visibility scope - who can access the tool.`);R({resourceUri:M().optional(),visibility:L(Ih).optional().describe(`Who can access this tool. Default: ["model", "app"]
107
107
  - "model": Tool visible to and callable by the agent
108
108
  - "app": Tool callable by the app from this server only`),csp:fc().optional(),permissions:fc().optional()}),R({mimeTypes:L(M()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),R({method:U(`ui/download-file`),params:R({contents:L(B([Lu,Ru])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),R({method:U(`ui/message`),params:R({role:U(`user`).describe(`Message role, currently only "user" is supported.`),content:L(zu).describe(`Message content blocks (text, image, etc.).`)})}),R({method:U(`ui/notifications/sandbox-resource-ready`),params:R({html:M().describe(`HTML content to load into the inner iframe.`),sandbox:M().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:Ch.optional().describe(`CSP configuration from resource metadata.`),permissions:wh.optional().describe(`Sandbox permissions from resource metadata.`)})});var Lh=R({method:U(`ui/notifications/tool-result`),params:Ju.describe(`Standard MCP tool execution result.`)}),Rh=R({toolInfo:R({id:yl.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Gu.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:_h.optional().describe(`Current color theme preference.`),styles:kh.optional().describe(`Style configuration for theming the app.`),displayMode:vh.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:L(vh).optional().describe(`Display modes the host supports.`),containerDimensions:B([R({height:P().describe(`Fixed container height in pixels.`)}),R({maxHeight:B([P(),ac()]).optional().describe(`Maximum container height in pixels.`)})]).and(B([R({width:P().describe(`Fixed container width in pixels.`)}),R({maxWidth:B([P(),ac()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
109
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:M().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:M().optional().describe(`User's timezone in IANA format.`),userAgent:M().optional().describe(`Host application identifier.`),platform:B([U(`web`),U(`desktop`),U(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:R({touch:F().optional().describe(`Whether the device supports touch input.`),hover:F().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:R({top:P().describe(`Top safe area inset in pixels.`),right:P().describe(`Right safe area inset in pixels.`),bottom:P().describe(`Bottom safe area inset in pixels.`),left:P().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),zh=R({method:U(`ui/notifications/host-context-changed`),params:Rh.describe(`Partial context update containing only changed fields.`)});R({method:U(`ui/update-model-context`),params:R({content:L(zu).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:V(M(),I().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),R({method:U(`ui/initialize`),params:R({appInfo:Ml.describe(`App identification (name and version).`),appCapabilities:Ph.describe(`Features and capabilities this app provides.`),protocolVersion:M().describe(`Protocol version this app supports.`)})});var Bh=R({protocolVersion:M().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Ml.describe(`Host application identification and version.`),hostCapabilities:Nh.describe(`Features and capabilities provided by the host.`),hostContext:Rh.describe(`Rich context about the host environment.`)}).passthrough(),Vh={target:`draft-2020-12`};async function Hh(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Vh);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Uh(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function Wh(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Gh(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Kh(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function qh(e){if(document.getElementById(`__mcp-host-fonts`))return;let t=document.createElement(`style`);t.id=`__mcp-host-fonts`,t.textContent=e,document.head.appendChild(t)}function Jh(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Yh=class e extends Gm{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new uh;_methods=new dh;setRequestHandler=(...e)=>{let[t,...n]=ph(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=ph(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:Th,toolinputpartial:Eh,toolresult:Lh,toolcancelled:Dh,hostcontextchanged:zh};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},t=>{let n=t;e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...n}),this._events.dispatch(e,n)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._appCapabilities=t,this.options=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),!n.allowUnsafeEval&&w({jitless:!0}),this.replaceRequestHandler(`ping`,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._appCapabilities=Jh(this._appCapabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Uh(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Uh(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Hh(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Hh(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(`ui/resource-teardown`,{params:Ah.shape.params,result:jh},(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(`tools/list`,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if(e===`sampling/createMessage`&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized(`createSamplingMessage`),await this.request({method:`sampling/createMessage`,params:e},t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},Sh,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},El,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},bh,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},xh,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Fh,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new gh(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1;try{await super.connect(e);let n=await this.request({method:`ui/initialize`,params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:hh}},Bh,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function Xh(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e!==!1&&e!=null&&r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}var Zh=1e4;async function Qh(e,t,n){try{return await e.connect(void 0,{timeout:Zh}),console.warn(`[${t}] connected`,{host:e.getHostVersion(),caps:e.getHostCapabilities()}),!0}catch(e){console.error(`[${t}] connect failed`,e);let r=e instanceof Error&&/timed?\s*out/i.test(e.message)?`The MCP App host did not respond — make sure your client supports MCP Apps (ext-apps).`:`Connection failed: ${e instanceof Error?e.message:String(e)}`;return n.replaceChildren(Xh(`div`,{class:`skeleton`},r)),!1}}var $h=`show_system_dashboard`,eg=document.getElementById(`app`);function $(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e!==!1&&e!=null&&r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}function tg(e){if(e==null)return`—`;let t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(+(r<10&&n>0))} ${t[n]}`}function ng(e){return e==null?``:e>=90?`is-bad`:e>=70?`is-warn`:`is-good`}var rg=`http://www.w3.org/2000/svg`;function ig(e,t){let n=document.createElementNS(rg,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,String(r));return n}function ag(e,t,n){let r=2*Math.PI*26,i=t==null?0:Math.max(0,Math.min(100,t))/100,a=ig(`svg`,{width:64,height:64,viewBox:`0 0 64 64`}),o=ig(`circle`,{cx:32,cy:32,r:26,fill:`none`,"stroke-width":7});o.setAttribute(`class`,`gauge__track`);let s=ig(`circle`,{cx:32,cy:32,r:26,fill:`none`,"stroke-width":7,"stroke-dasharray":r,"stroke-dashoffset":r*(1-i)});s.setAttribute(`class`,`gauge__bar ${ng(t)}`);let c=ig(`text`,{x:32,y:37,"text-anchor":`middle`});return c.setAttribute(`class`,`gauge__pct`),c.textContent=t==null?`—`:`${Math.round(t)}%`,a.replaceChildren(o,s,c),$(`div`,{class:`card gauge`},a,$(`div`,{class:`gauge__meta`},$(`p`,{class:`card__label`},e),$(`small`,{},n)))}function og(e,t){return $(`div`,{class:`card`},$(`p`,{class:`card__label`},e),$(`div`,{class:`card__value`},t))}function sg(e,t){let n=Object.entries(t);if(n.length===0)return null;let r=$(`div`,{class:`kv__body`},...n.flatMap(([e,t])=>[$(`div`,{class:`kv__k`},e),$(`div`,{class:`kv__v`},t||`—`)]));return $(`details`,{class:`kv`},$(`summary`,{},`${e} (${n.length})`),r)}var cg=null,lg=!1;function ug(){if(!cg){eg.replaceChildren($(`div`,{class:`skeleton`},`Waiting for device data…`));return}let e=cg,t=e.derived,n=e.resource.version??`?`,r=e.routerboard.model??e.resource[`board-name`]??`?`,i=[ag(`CPU load`,t.cpuLoadPct,`${e.resource[`cpu-count`]??`?`} cores`),ag(`Memory`,t.memUsedPct,`${tg(t.memUsedBytes)} / ${tg(t.memTotalBytes)}`),t.hddUsedPct!=null&&ag(`Disk`,t.hddUsedPct,`${tg(t.hddUsedBytes)} / ${tg(t.hddTotalBytes)}`)].filter(Boolean),a=[og(`Uptime`,e.resource.uptime??`—`),t.temperatureC!=null&&og(`Temperature`,`${t.temperatureC} °C`),t.voltageV!=null&&og(`Voltage`,`${t.voltageV} V`),og(`Architecture`,e.resource[`architecture-name`]??`—`)].filter(Boolean),o=$(`button`,{class:`btn`},lg?`Refreshing…`:`↻ Refresh`);lg&&o.setAttribute(`disabled`,`true`),o.addEventListener(`click`,pg);let s=$(`span`,{class:`pill`},`device `,$(`b`,{},e.device)),c=$(`header`,{class:`hd`},$(`span`,{class:`hd__dot`}),$(`div`,{},$(`h1`,{class:`hd__title`},e.identity),$(`p`,{class:`hd__sub`},`${r} · RouterOS ${n}`)),$(`span`,{class:`hd__spacer`}),s),l=$(`footer`,{class:`foot`},o,$(`span`,{},`updated ${new Date(e.generatedAt).toLocaleTimeString()}`)),u=[c,$(`section`,{class:`grid`},...i),$(`section`,{class:`grid`},...a),sg(`System resource`,e.resource),sg(`RouterBOARD`,e.routerboard),l].filter(e=>e!=null);eg.replaceChildren(...u)}var dg=new Yh({name:`mikrotik-dashboard`,version:`1.0.0`});function fg(e){e&&typeof e==`object`&&`device`in e&&(cg=e,ug())}async function pg(){if(!lg){lg=!0,ug();try{fg((await dg.callServerTool({name:$h,arguments:{}})).structuredContent)}catch(e){console.error(`[dashboard] refresh failed`,e)}finally{lg=!1,ug()}}}dg.ontoolresult=e=>{console.warn(`[dashboard] ontoolresult`,e),fg(e.structuredContent)},dg.ontoolinput=()=>{cg||ug()},dg.onhostcontextchanged=e=>{if(e.theme&&Gh(e.theme),e.styles?.variables&&Kh(e.styles.variables),e.styles?.css?.fonts&&qh(e.styles.css.fonts),e.safeAreaInsets){let{top:t,right:n,bottom:r,left:i}=e.safeAreaInsets;document.body.style.padding=`${t+16}px ${n+16}px ${r+16}px ${i+16}px`}},dg.onteardown=async()=>({}),Gh(Wh()),ug(),Qh(dg,`dashboard`,eg);
109
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:M().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:M().optional().describe(`User's timezone in IANA format.`),userAgent:M().optional().describe(`Host application identifier.`),platform:B([U(`web`),U(`desktop`),U(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:R({touch:F().optional().describe(`Whether the device supports touch input.`),hover:F().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:R({top:P().describe(`Top safe area inset in pixels.`),right:P().describe(`Right safe area inset in pixels.`),bottom:P().describe(`Bottom safe area inset in pixels.`),left:P().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),zh=R({method:U(`ui/notifications/host-context-changed`),params:Rh.describe(`Partial context update containing only changed fields.`)});R({method:U(`ui/update-model-context`),params:R({content:L(zu).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:V(M(),I().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),R({method:U(`ui/initialize`),params:R({appInfo:Ml.describe(`App identification (name and version).`),appCapabilities:Ph.describe(`Features and capabilities this app provides.`),protocolVersion:M().describe(`Protocol version this app supports.`)})});var Bh=R({protocolVersion:M().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Ml.describe(`Host application identification and version.`),hostCapabilities:Nh.describe(`Features and capabilities provided by the host.`),hostContext:Rh.describe(`Rich context about the host environment.`)}).passthrough(),Vh={target:`draft-2020-12`};async function Hh(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Vh);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Uh(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function Wh(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Gh(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Kh(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function qh(e){if(document.getElementById(`__mcp-host-fonts`))return;let t=document.createElement(`style`);t.id=`__mcp-host-fonts`,t.textContent=e,document.head.appendChild(t)}function Jh(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Yh=class e extends Gm{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new uh;_methods=new dh;setRequestHandler=(...e)=>{let[t,...n]=ph(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=ph(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:Th,toolinputpartial:Eh,toolresult:Lh,toolcancelled:Dh,hostcontextchanged:zh};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},t=>{let n=t;e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...n}),this._events.dispatch(e,n)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._appCapabilities=t,this.options=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),!n.allowUnsafeEval&&w({jitless:!0}),this.replaceRequestHandler(`ping`,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._appCapabilities=Jh(this._appCapabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Uh(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Uh(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Hh(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Hh(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(`ui/resource-teardown`,{params:Ah.shape.params,result:jh},(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(`tools/list`,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if(e===`sampling/createMessage`&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized(`createSamplingMessage`),await this.request({method:`sampling/createMessage`,params:e},t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},Sh,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},El,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},bh,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},xh,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Fh,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new gh(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1;try{await super.connect(e);let n=await this.request({method:`ui/initialize`,params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:hh}},Bh,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function Xh(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e!==!1&&e!=null&&r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}var Zh=1e4;function Qh(){let e=`http://www.w3.org/2000/svg`,t=document.createElementNS(e,`svg`);for(let[e,n]of Object.entries({viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`}))t.setAttribute(e,n);let n=document.createElementNS(e,`path`);return n.setAttribute(`d`,`M6 7v4a6 6 0 0 0 6 6m6-10v4a6 6 0 0 1-6 6m0 0v3M4 3h4v4H4zm12 0h4v4h-4zM10 20h4v3h-4z`),t.append(n),t}function $h(e,t){document.documentElement.dataset.mcpView=t,e.classList.add(`app`),document.getElementById(`mcp-app-masthead`)?.remove(),e.before(Xh(`header`,{id:`mcp-app-masthead`,class:`mcp-masthead`},Xh(`span`,{class:`mcp-mark`},Qh()),Xh(`div`,{},Xh(`span`,{class:`mcp-brand`},`MikroTik `,Xh(`b`,{},`MCP`)),Xh(`p`,{class:`mcp-context`},{dashboard:`Device health`,records:`Data explorer`,interfaces:`Interface inventory`,firewall:`Firewall policy`,"firewall-audit":`Security findings`,"connected-devices":`Client inventory`,aaa:`Identity & access`,investigations:`Client investigations`,"round-trip":`Round-trip lab`,"service-health":`Service health`,fabric:`Layer-2 fabric`,operations:`Change operations`,reports:`Evidence reports`}[t]??`Tool workspace`)),Xh(`span`,{class:`mcp-response-label`},`TOOL RESPONSE`)))}async function eg(e,t,n,r){$h(n,t);let i=!1,a=!1,o,s=()=>{o!==void 0&&clearTimeout(o),o=void 0},c=(e,t,r,i=!1)=>{n.replaceChildren(Xh(`section`,{class:`app-result`,role:i?`alert`:`status`},Xh(`h2`,{class:`app-result__title`},e),Xh(`p`,{class:`app-result__message`},t),r?Xh(`pre`,{class:`app-result__detail`},r):null))};e.ontoolresult=e=>{if(a)return;i=!0,s();let t=(e.content??[]).flatMap(e=>e.type===`text`?[e.text]:[]).join(`
110
+ `).trim();if(e.isError){c(`Tool failed`,`The tool returned an error. No successful result is available.`,t,!0);return}try{if(r(e.structuredContent,e))return;let n=e.structuredContent;t||n?c(`Tool result`,`The response is shown below; it does not use this view's interactive format.`,[t,n?JSON.stringify(n,null,2):``].filter(Boolean).join(`
111
+
112
+ `)):c(`No data returned`,e.content?.some(e=>e.type!==`text`)?`The tool returned non-text content. Open the original tool response in your client.`:`The tool completed without text or structured data.`)}catch{c(`Unable to display result`,`The tool returned an invalid view payload.`,t,!0)}},e.ontoolcancelled=e=>{a||(i=!0,s(),c(`Tool cancelled`,e.reason||`The host cancelled this tool call.`))};let l=e.onteardown;e.onteardown=(e,t)=>(a=!0,s(),l?.(e,t)??{});let u=e.onclose;e.onclose=()=>{!a&&!i&&c(`Host disconnected`,`The connection closed before a tool result arrived.`,void 0,!0),a=!0,s(),u?.()};try{if(await e.connect(void 0,{timeout:Zh}),a)return!1;let n=e.getHostContext?.();return n&&e.onhostcontextchanged?.(n),i||(o=setTimeout(()=>{c(`Still awaiting the tool result`,`The host is connected, but has not delivered a result. Check the original tool response or your client's MCP connection. Do not repeat a configuration-changing call just to refresh this view. Late results will still appear here.`)},15e3)),console.warn(`[${t}] connected`,{host:e.getHostVersion(),caps:e.getHostCapabilities()}),!0}catch(e){return s(),!a&&(a=!0,console.error(`[${t}] connect failed`,e),c(`Cannot connect to the host`,e instanceof Error&&/timed?\s*out/i.test(e.message)?`The MCP App host did not respond — make sure your client supports MCP Apps (ext-apps).`:`Connection failed: ${e instanceof Error?e.message:String(e)}`,void 0,!0),!1)}}var tg=`show_system_dashboard`,ng=document.getElementById(`app`);function $(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e!==!1&&e!=null&&r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}function rg(e){if(e==null)return`—`;let t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(+(r<10&&n>0))} ${t[n]}`}function ig(e){return e==null?``:e>=90?`is-bad`:e>=70?`is-warn`:`is-good`}var ag=`http://www.w3.org/2000/svg`;function og(e,t){let n=document.createElementNS(ag,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,String(r));return n}function sg(e,t,n){let r=2*Math.PI*26,i=t==null?0:Math.max(0,Math.min(100,t))/100,a=og(`svg`,{width:64,height:64,viewBox:`0 0 64 64`}),o=og(`circle`,{cx:32,cy:32,r:26,fill:`none`,"stroke-width":7});o.setAttribute(`class`,`gauge__track`);let s=og(`circle`,{cx:32,cy:32,r:26,fill:`none`,"stroke-width":7,"stroke-dasharray":r,"stroke-dashoffset":r*(1-i)});s.setAttribute(`class`,`gauge__bar ${ig(t)}`);let c=og(`text`,{x:32,y:37,"text-anchor":`middle`});return c.setAttribute(`class`,`gauge__pct`),c.textContent=t==null?`—`:`${Math.round(t)}%`,a.replaceChildren(o,s,c),$(`div`,{class:`card gauge`},a,$(`div`,{class:`gauge__meta`},$(`p`,{class:`card__label`},e),$(`small`,{},n)))}function cg(e,t){return $(`div`,{class:`card`},$(`p`,{class:`card__label`},e),$(`div`,{class:`card__value`},t))}function lg(e,t){let n=Object.entries(t);if(n.length===0)return null;let r=$(`div`,{class:`kv__body`},...n.flatMap(([e,t])=>[$(`div`,{class:`kv__k`},e),$(`div`,{class:`kv__v`},t||`—`)]));return $(`details`,{class:`kv`},$(`summary`,{},`${e} (${n.length})`),r)}var ug=null,dg=!1;function fg(){if(!ug){ng.replaceChildren($(`div`,{class:`skeleton`},`Waiting for device data…`));return}let e=ug,t=e.derived,n=e.resource.version??`?`,r=e.routerboard.model??e.resource[`board-name`]??`?`,i=[sg(`CPU load`,t.cpuLoadPct,`${e.resource[`cpu-count`]??`?`} cores`),sg(`Memory`,t.memUsedPct,`${rg(t.memUsedBytes)} / ${rg(t.memTotalBytes)}`),t.hddUsedPct!=null&&sg(`Disk`,t.hddUsedPct,`${rg(t.hddUsedBytes)} / ${rg(t.hddTotalBytes)}`)].filter(Boolean),a=[cg(`Uptime`,e.resource.uptime??`—`),t.temperatureC!=null&&cg(`Temperature`,`${t.temperatureC} °C`),t.voltageV!=null&&cg(`Voltage`,`${t.voltageV} V`),cg(`Architecture`,e.resource[`architecture-name`]??`—`)].filter(Boolean),o=$(`button`,{class:`btn`},dg?`Refreshing…`:`↻ Refresh`);dg&&o.setAttribute(`disabled`,`true`),o.addEventListener(`click`,hg);let s=$(`span`,{class:`pill`},`device `,$(`b`,{},e.device)),c=$(`header`,{class:`hd`},$(`span`,{class:`hd__dot`}),$(`div`,{},$(`h1`,{class:`hd__title`},e.identity),$(`p`,{class:`hd__sub`},`${r} · RouterOS ${n}`)),$(`span`,{class:`hd__spacer`}),s),l=$(`footer`,{class:`foot`},o,$(`span`,{},`updated ${new Date(e.generatedAt).toLocaleTimeString()}`)),u=[c,$(`section`,{class:`grid`},...i),$(`section`,{class:`grid`},...a),lg(`System resource`,e.resource),lg(`RouterBOARD`,e.routerboard),l].filter(e=>e!=null);ng.replaceChildren(...u)}var pg=new Yh({name:`mikrotik-dashboard`,version:`1.0.0`});function mg(e){return e&&typeof e==`object`&&`device`in e?(ug=e,fg(),!0):!1}async function hg(){if(!dg){dg=!0,fg();try{mg((await pg.callServerTool({name:tg,arguments:{}})).structuredContent)}catch(e){console.error(`[dashboard] refresh failed`,e)}finally{dg=!1,fg()}}}pg.onhostcontextchanged=e=>{if(e.theme&&Gh(e.theme),e.styles?.variables&&Kh(e.styles.variables),e.styles?.css?.fonts&&qh(e.styles.css.fonts),e.safeAreaInsets){let{top:t,right:n,bottom:r,left:i}=e.safeAreaInsets;document.body.style.padding=`${t+16}px ${n+16}px ${r+16}px ${i+16}px`}},pg.onteardown=async()=>({}),Gh(Wh()),fg(),eg(pg,`dashboard`,ng,mg);
110
113
  </script>
111
114
  <style>
112
- :root{--mt-bg:var(--color-background-primary,#0b0d10);--mt-surface:var(--color-background-secondary,#14171c);--mt-surface-2:var(--color-background-tertiary,#1b1f26);--mt-border:var(--color-border-primary,#262b33);--mt-text:var(--color-text-primary,#e8eaed);--mt-text-dim:var(--color-text-secondary,#9aa3af);--mt-text-faint:var(--color-text-tertiary,#6b7280);--mt-accent:var(--color-accent-primary,#6ea8fe);--mt-good:#34d399;--mt-warn:#fbbf24;--mt-bad:#f87171;--mt-radius:var(--border-radius-md,14px);--mt-radius-sm:var(--border-radius-sm,9px);--mt-mono:var(--font-mono,ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace);--mt-sans:var(--font-sans,system-ui, -apple-system, "Segoe UI", sans-serif);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial}}*{box-sizing:border-box}body{background:var(--mt-bg);color:var(--mt-text);font-family:var(--mt-sans);-webkit-font-smoothing:antialiased;margin:0;padding:16px;font-size:13px;line-height:1.5}.app{gap:14px;max-width:860px;margin:0 auto;display:grid}.hd{flex-wrap:wrap;align-items:center;gap:12px;display:flex}.hd__dot{background:var(--mt-good);width:9px;height:9px;box-shadow:0 0 0 4px color-mix(in srgb, var(--mt-good) 22%, transparent);border-radius:50%}.hd__title{letter-spacing:-.01em;margin:0;font-size:17px;font-weight:650}.hd__sub{color:var(--mt-text-dim);font-family:var(--mt-mono);margin:0;font-size:12px}.hd__spacer{flex:1}.pill{border:1px solid var(--mt-border);background:var(--mt-surface);color:var(--mt-text-dim);font-family:var(--mt-mono);border-radius:999px;align-items:center;gap:6px;padding:3px 9px;font-size:11px;display:inline-flex}.pill b{color:var(--mt-text);font-weight:600}.grid{grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;display:grid}.card{background:linear-gradient(180deg, var(--mt-surface), var(--mt-surface-2));border:1px solid var(--mt-border);border-radius:var(--mt-radius);padding:14px}.card__label{color:var(--mt-text-dim);text-transform:uppercase;letter-spacing:.06em;margin:0 0 8px;font-size:11px}.card__value{font-family:var(--mt-mono);letter-spacing:-.01em;font-size:20px;font-weight:600}.card__value small{color:var(--mt-text-dim);font-size:12px;font-weight:400}.gauge{align-items:center;gap:14px;display:flex}.gauge svg{flex:none}.gauge__track{stroke:var(--mt-surface-2)}.gauge__bar{stroke:var(--mt-accent);stroke-linecap:round;transform-origin:50%;transition:stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1);transform:rotate(-90deg)}.gauge__pct{font-family:var(--mt-mono);fill:var(--mt-text);font-size:16px;font-weight:650}.gauge__meta{min-width:0}.gauge__meta .card__label{margin-bottom:4px}.gauge__meta small{color:var(--mt-text-faint);font-family:var(--mt-mono);font-size:11px}.is-good{stroke:var(--mt-good)}.is-warn{stroke:var(--mt-warn)}.is-bad{stroke:var(--mt-bad)}details.kv{background:var(--mt-surface);border:1px solid var(--mt-border);border-radius:var(--mt-radius);overflow:hidden}details.kv>summary{cursor:pointer;color:var(--mt-text-dim);-webkit-user-select:none;user-select:none;padding:12px 14px;font-weight:600;list-style:none}details.kv>summary::-webkit-details-marker{display:none}details.kv>summary:after{content:"▸";float:right;color:var(--mt-text-faint);transition:transform .2s}details.kv[open]>summary:after{transform:rotate(90deg)}.kv__body{border-top:1px solid var(--mt-border);grid-template-columns:minmax(120px,.4fr) 1fr;display:grid}.kv__body>div{border-bottom:1px solid color-mix(in srgb, var(--mt-border) 55%, transparent);overflow-wrap:anywhere;min-width:0;padding:7px 14px;font-size:12px}.kv__k{color:var(--mt-text-dim);font-family:var(--mt-mono)}.kv__v{font-family:var(--mt-mono);color:var(--mt-text)}.foot{color:var(--mt-text-faint);font-size:11px;font-family:var(--mt-mono);align-items:center;gap:10px;display:flex}.btn{appearance:none;border:1px solid var(--mt-border);background:var(--mt-surface);color:var(--mt-text);font:inherit;border-radius:var(--mt-radius-sm);cursor:pointer;padding:5px 11px;font-size:12px;transition:border-color .15s,background .15s}.btn:hover{border-color:var(--mt-accent);background:var(--mt-surface-2)}.btn:disabled{opacity:.5;cursor:default}.skeleton{color:var(--mt-text-faint);text-align:center;padding:40px 0}
115
+ .app-result{border:1px solid var(--color-border-primary,#8886);background:var(--color-background-secondary,transparent);color:var(--color-text-primary,inherit);border-radius:12px;padding:20px}.app-result__title{margin:0 0 8px;font-size:16px;font-weight:600}.app-result__message{margin:0;font-size:13px;line-height:1.6}.app-result__detail{border:1px solid var(--color-border-primary,#8886);max-height:420px;font:12px/1.6 var(--font-mono,monospace);white-space:pre-wrap;overflow-wrap:anywhere;border-radius:8px;margin:16px 0 0;padding:12px;overflow:auto}html[data-mcp-view]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--mt-bg:var(--color-background-primary,#101c2e);--mt-surface:var(--color-background-secondary,#17263b);--mt-surface-2:var(--color-background-tertiary,#20324a);--mt-border:var(--color-border-primary,#304660);--mt-text:var(--color-text-primary,#dae6f4);--mt-text-dim:var(--color-text-secondary,#a6b9ce);--mt-text-faint:var(--color-text-tertiary,#91a8c1);--mt-accent:var(--color-accent-primary,#9ebfee);--mt-good:#69d6c3;--mt-warn:#e5b56f;--mt-bad:#f18b94;--mt-radius:16px;--mt-radius-sm:10px;--mt-sans:var(--font-sans,"Avenir Next", "Segoe UI", sans-serif);--mt-display:var(--font-sans,"Avenir Next", "Segoe UI", sans-serif);--mt-mono:var(--font-mono,"SFMono-Regular", Consolas, monospace);--bg:var(--mt-bg);--surface:var(--mt-surface);--surface-2:var(--mt-surface-2);--border:var(--mt-border);--text:var(--mt-text);--text-dim:var(--mt-text-dim);--accent:var(--mt-accent);--danger:var(--mt-bad);--ok:var(--mt-good);--rx:var(--mt-good);--tx:var(--mt-accent)}html[data-mcp-view][data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--mt-bg:var(--color-background-primary,#f3f6fa);--mt-surface:var(--color-background-secondary,#fff);--mt-surface-2:var(--color-background-tertiary,#e9eff6);--mt-border:var(--color-border-primary,#c8d5e3);--mt-text:var(--color-text-primary,#20334d);--mt-text-dim:var(--color-text-secondary,#4b6480);--mt-text-faint:var(--color-text-tertiary,#5b728c);--mt-accent:var(--color-accent-primary,#325f9c);--mt-good:#157d6b;--mt-warn:#956313;--mt-bad:#b53446}html[data-mcp-view] body{background:var(--mt-bg);color:var(--mt-text);font:13px/1.6 var(--mt-sans);-webkit-font-smoothing:antialiased;margin:0;padding:20px}html[data-mcp-view] :where(*){box-sizing:border-box}html[data-mcp-view] body #app{gap:20px;width:100%;min-width:0;max-width:1120px;margin:0 auto;animation:.22s ease-out both workspace-arrive;display:grid}html[data-mcp-view] body #app>*{min-width:0}.mcp-masthead{border-bottom:1px solid var(--mt-border);align-items:center;gap:12px;width:100%;max-width:1120px;margin:0 auto 22px;padding-bottom:18px;display:flex}.mcp-mark{border:1px solid var(--mt-border);background:var(--mt-surface);width:38px;height:38px;color:var(--mt-accent);border-radius:12px;flex:none;place-items:center;display:grid}.mcp-brand{letter-spacing:-.02em;font-size:13px;font-weight:650}.mcp-brand b{color:var(--mt-accent)}.mcp-context{color:var(--mt-text-dim);margin:0;font-size:11px}.mcp-response-label{font:9px var(--mt-mono);letter-spacing:.12em;color:var(--mt-text-faint);margin-left:auto}body #app :where(.hd,.aaa-titlebar){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background-color:var(--mt-surface);background-image:radial-gradient(color-mix(in srgb, var(--mt-border) 60%, transparent) .7px, transparent .7px);overflow-wrap:anywhere;background-size:16px 16px;flex-wrap:wrap;align-items:center;gap:16px;padding:22px;display:flex;position:relative}body #app :where(.hd__title,.aaa-title,.toolbar .title){font:650 clamp(19px, 3.8vw, 25px)/1.25 var(--mt-display);letter-spacing:-.035em;margin:0}body #app .hd__sub{color:var(--mt-text-dim);font:11px/1.7 var(--mt-mono);margin:6px 0 0}body #app .hd__dot{background:var(--mt-accent);box-shadow:0 0 0 6px color-mix(in srgb, var(--mt-accent) 10%, transparent)}body #app :where(.grid,.if-grid,.aaa-form-grid){grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr));gap:16px;display:grid}body #app :where(.card,.aaa-card,.aaa-form,.f-card){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);min-width:0;margin:0;padding:20px}body #app .card__label{color:var(--mt-text-dim);font:11px/1.5 var(--mt-sans);letter-spacing:.03em;text-transform:none;margin:0 0 10px}body #app .card__value{font:550 27px/1.3 var(--mt-mono);letter-spacing:-.04em;overflow-wrap:anywhere}body #app .card__value small{font-size:12px}body #app :where(.toolbar,.aaa-bar){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);flex-wrap:wrap;align-items:center;gap:10px;margin:0;padding:12px;display:flex}body #app .toolbar .grow{flex:200px;min-width:min(100%,200px)}body #app :where(.btn,.aaa-tab){border:1px solid var(--mt-border);background:var(--mt-surface-2);min-height:34px;color:var(--mt-text);font:500 12px/1.4 var(--mt-sans);cursor:pointer;border-radius:10px;justify-content:center;align-items:center;gap:7px;margin:0;padding:7px 12px;transition:background .14s,border-color .14s,transform .14s;display:inline-flex}body #app :where(.btn,.aaa-tab):hover:not(:disabled){border-color:var(--mt-accent);background:color-mix(in srgb, var(--mt-accent) 14%, var(--mt-surface));transform:translateY(-1px)}body #app :where(.btn,.aaa-tab):active:not(:disabled){transform:translateY(0)}body #app :where(.btn,.aaa-tab):disabled{opacity:.5;cursor:not-allowed}body #app :where(.btn.is-active,.btn.primary,.aaa-tab.is-active){border-color:color-mix(in srgb, var(--mt-accent) 70%, var(--mt-border));color:var(--mt-accent);background:color-mix(in srgb, var(--mt-accent) 12%, var(--mt-surface))}body #app :where(.btn-danger,.btn.danger){color:var(--mt-bad);border-color:color-mix(in srgb, var(--mt-bad) 50%, var(--mt-border));background:color-mix(in srgb, var(--mt-bad) 8%, var(--mt-surface))}body #app .btn.ok{color:var(--mt-good)}body #app :where(.search,.aaa-input){border:1px solid var(--mt-border);background:var(--mt-bg);width:100%;min-width:0;min-height:36px;color:var(--mt-text);font:12px/1.5 var(--mt-sans);border-radius:10px;padding:8px 12px}body #app :where(button,input,select,textarea,summary,[tabindex]):focus-visible{outline:2px solid var(--mt-accent);outline-offset:3px}body #app :where(.pill,.chip,.badge,.aaa-badge,.act){font:10px/1.4 var(--mt-mono);overflow-wrap:anywhere;border-radius:7px;max-width:100%;padding:4px 9px}body #app :where(.tablewrap,.table,.aaa-table){border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);width:100%;min-width:0;padding:0;overflow:auto}body #app :where(table.tbl th,table.tbl td){border-bottom:1px solid color-mix(in srgb, var(--mt-border) 65%, transparent);padding:12px 16px;font-size:11px;line-height:1.6}body #app table.tbl thead th{background:var(--mt-surface-2);font:600 11px var(--mt-sans);height:42px}body #app table.tbl tbody tr:nth-child(2n){background:color-mix(in srgb, var(--mt-surface-2) 30%, transparent)}body #app table.tbl tbody tr:hover{background:color-mix(in srgb, var(--mt-accent) 12%, var(--mt-surface))}body #app :where(.kv__body,details.kv){background:var(--mt-surface);border:1px solid var(--mt-border);border-radius:var(--mt-radius);overflow:hidden}body #app .kv__body{grid-template-columns:minmax(100px,.45fr) minmax(0,1fr)}body #app .kv__body>div{padding:12px 16px;font-size:11px;line-height:1.6}body #app details.kv .kv__body{border:0;border-top:1px solid var(--mt-border);border-radius:0}body #app details.kv>summary{padding:16px 20px;font-size:12px}body #app :where(.foot,.totals){color:var(--mt-text-faint);border-top:1px solid var(--mt-border);gap:12px;padding:12px 0;font-size:10px}body #app :where(.skeleton,.empty,.loading,.aaa-notice){border:1px dashed var(--mt-border);border-radius:var(--mt-radius);color:var(--mt-text-dim);background:var(--mt-surface);text-align:center;padding:36px 24px;font-size:12px}body #app pre.raw{white-space:pre-wrap;overflow-wrap:anywhere;padding:20px;font-size:11px;line-height:1.85}body #app .drawer{gap:16px;padding:20px}body #app .drawer__hd{flex-wrap:wrap}body #app .if-card{border-top:3px solid var(--mt-border);gap:20px}body #app .if-card:has(.dot.is-up){border-top-color:var(--mt-good)}body #app .if-card__top{flex-wrap:wrap;gap:10px}body #app .if-card__name{font-size:15px}body #app .if-card__meta{grid-template-columns:minmax(45px,.3fr) minmax(0,1fr);gap:8px 14px}body #app .f-list{grid-template-columns:repeat(auto-fit,minmax(min(100%,340px),1fr));gap:16px;margin:0;display:grid}body #app .f-card{border-top-width:3px}body #app .f-card.is-bad{border-top-color:var(--mt-bad)}body #app .f-card.is-warn{border-top-color:var(--mt-warn)}body #app .f-body{margin-top:14px}body #app .f-detail{font-size:12px;line-height:1.7}body #app .f-fix{margin-top:10px;font-size:11px}body #app .f-actions{margin-top:18px}body #app .aaa-wrap{gap:18px;min-width:0;padding:0;display:grid}body #app .aaa-tabs{border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);gap:8px;margin:0;padding:8px}body #app .aaa-tab{font-size:11px}body #app .aaa-row{min-width:max(100%, calc(var(--cols) * 105px + 190px));border-bottom:1px solid var(--mt-border);border-radius:0;gap:12px;padding:12px 16px;font-size:11px}body #app .aaa-head{background:var(--mt-surface-2)}body #app .aaa-actions,body #app .aaa-field{gap:8px}body #app .aaa-form-title{margin-bottom:16px;font-size:14px}body #app .aaa-settings{gap:16px}body #app .aaa-error{margin:0;padding:16px}body #app .row{border-bottom:1px solid var(--mt-border);border-radius:0;grid-template-columns:105px minmax(150px,1.4fr) 145px 85px 100px 165px;gap:14px;min-width:840px;padding:13px 16px;font-size:11px}body #app .row.header{background:var(--mt-surface-2);font:600 10px var(--mt-sans)}body #app .detail{border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);padding:22px}body #app .detail-title{margin-bottom:6px;font-size:19px}body #app .detail-sub{margin-bottom:22px}body #app .rates{font:15px var(--mt-mono);flex-wrap:wrap;gap:24px;margin:0 0 18px}body #app .traffic-chart{background-image:radial-gradient(var(--mt-border) .75px, transparent .75px);background-size:16px 16px;max-width:none;height:200px}body #app .app-result{border-color:var(--mt-border);background:var(--mt-surface);color:var(--mt-text);padding:26px}body #app .app-result[role=alert]{border-top:3px solid var(--mt-bad)}body #app .app-result__title{font-family:var(--mt-display);letter-spacing:-.025em;font-size:20px}body #app .app-result__message{color:var(--mt-text-dim);font-size:12px}body #app .app-result__detail{background:var(--mt-bg);border-color:var(--mt-border);font:11px/1.8 var(--mt-mono)}@keyframes workspace-arrive{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}@media (width<=520px){html[data-mcp-view] body{padding:12px}html[data-mcp-view] body #app{gap:16px}.mcp-masthead{gap:10px;margin-bottom:16px}.mcp-response-label{letter-spacing:.04em;font-size:8px}body #app :where(.hd,.aaa-titlebar,.card,.f-card,.aaa-card,.aaa-form){padding:16px}body #app .kv__body{grid-template-columns:minmax(80px,.4fr) minmax(0,1fr)}body #app .kv__body>div{padding:10px 12px}body #app .if-grid{grid-template-columns:minmax(0,1fr)}}@media (prefers-reduced-motion:reduce){html[data-mcp-view] body #app,body #app *,body #app :before,body #app :after{scroll-behavior:auto!important;transition:none!important;animation:none!important}}:root{--mt-bg:var(--color-background-primary,#0b0d10);--mt-surface:var(--color-background-secondary,#14171c);--mt-surface-2:var(--color-background-tertiary,#1b1f26);--mt-border:var(--color-border-primary,#262b33);--mt-text:var(--color-text-primary,#e8eaed);--mt-text-dim:var(--color-text-secondary,#9aa3af);--mt-text-faint:var(--color-text-tertiary,#6b7280);--mt-accent:var(--color-accent-primary,#6ea8fe);--mt-good:#34d399;--mt-warn:#fbbf24;--mt-bad:#f87171;--mt-radius:var(--border-radius-md,14px);--mt-radius-sm:var(--border-radius-sm,9px);--mt-mono:var(--font-mono,ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace);--mt-sans:var(--font-sans,system-ui, -apple-system, "Segoe UI", sans-serif);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial}}*{box-sizing:border-box}body{background:var(--mt-bg);color:var(--mt-text);font-family:var(--mt-sans);-webkit-font-smoothing:antialiased;margin:0;padding:16px;font-size:13px;line-height:1.5}.app{gap:14px;max-width:860px;margin:0 auto;display:grid}.hd{flex-wrap:wrap;align-items:center;gap:12px;display:flex}.hd__dot{background:var(--mt-good);width:9px;height:9px;box-shadow:0 0 0 4px color-mix(in srgb, var(--mt-good) 22%, transparent);border-radius:50%}.hd__title{letter-spacing:-.01em;margin:0;font-size:17px;font-weight:650}.hd__sub{color:var(--mt-text-dim);font-family:var(--mt-mono);margin:0;font-size:12px}.hd__spacer{flex:1}.pill{border:1px solid var(--mt-border);background:var(--mt-surface);color:var(--mt-text-dim);font-family:var(--mt-mono);border-radius:999px;align-items:center;gap:6px;padding:3px 9px;font-size:11px;display:inline-flex}.pill b{color:var(--mt-text);font-weight:600}.grid{grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;display:grid}.card{background:linear-gradient(180deg, var(--mt-surface), var(--mt-surface-2));border:1px solid var(--mt-border);border-radius:var(--mt-radius);padding:14px}.card__label{color:var(--mt-text-dim);text-transform:uppercase;letter-spacing:.06em;margin:0 0 8px;font-size:11px}.card__value{font-family:var(--mt-mono);letter-spacing:-.01em;font-size:20px;font-weight:600}.card__value small{color:var(--mt-text-dim);font-size:12px;font-weight:400}.gauge{align-items:center;gap:14px;display:flex}.gauge svg{flex:none}.gauge__track{stroke:var(--mt-surface-2)}.gauge__bar{stroke:var(--mt-accent);stroke-linecap:round;transform-origin:50%;transition:stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1);transform:rotate(-90deg)}.gauge__pct{font-family:var(--mt-mono);fill:var(--mt-text);font-size:16px;font-weight:650}.gauge__meta{min-width:0}.gauge__meta .card__label{margin-bottom:4px}.gauge__meta small{color:var(--mt-text-faint);font-family:var(--mt-mono);font-size:11px}.is-good{stroke:var(--mt-good)}.is-warn{stroke:var(--mt-warn)}.is-bad{stroke:var(--mt-bad)}details.kv{background:var(--mt-surface);border:1px solid var(--mt-border);border-radius:var(--mt-radius);overflow:hidden}details.kv>summary{cursor:pointer;color:var(--mt-text-dim);-webkit-user-select:none;user-select:none;padding:12px 14px;font-weight:600;list-style:none}details.kv>summary::-webkit-details-marker{display:none}details.kv>summary:after{content:"▸";float:right;color:var(--mt-text-faint);transition:transform .2s}details.kv[open]>summary:after{transform:rotate(90deg)}.kv__body{border-top:1px solid var(--mt-border);grid-template-columns:minmax(120px,.4fr) 1fr;display:grid}.kv__body>div{border-bottom:1px solid color-mix(in srgb, var(--mt-border) 55%, transparent);overflow-wrap:anywhere;min-width:0;padding:7px 14px;font-size:12px}.kv__k{color:var(--mt-text-dim);font-family:var(--mt-mono)}.kv__v{font-family:var(--mt-mono);color:var(--mt-text)}.foot{color:var(--mt-text-faint);font-size:11px;font-family:var(--mt-mono);align-items:center;gap:10px;display:flex}.btn{appearance:none;border:1px solid var(--mt-border);background:var(--mt-surface);color:var(--mt-text);font:inherit;border-radius:var(--mt-radius-sm);cursor:pointer;padding:5px 11px;font-size:12px;transition:border-color .15s,background .15s}.btn:hover{border-color:var(--mt-accent);background:var(--mt-surface-2)}.btn:disabled{opacity:.5;cursor:default}.skeleton{color:var(--mt-text-faint);text-align:center;padding:40px 0}
113
116
  /*$vite$:1*/
114
117
  </style>
115
118
  </head>