@usex/mikrotik-mcp 3.57.0 → 3.58.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.
@@ -116,7 +116,7 @@ Boolean requesting whether a visible border and background is provided by the ho
116
116
  - omitted: host decides border`)}),I({method:V(`ui/request-display-mode`),params:I({mode:mv.describe(`The display mode being requested.`)})});var Av=I({mode:mv.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),jv=R([V(`model`),V(`app`)]).describe(`Tool visibility scope - who can access the tool.`);I({resourceUri:j().optional(),visibility:F(jv).optional().describe(`Who can access this tool. Default: ["model", "app"]
117
117
  - "model": Tool visible to and callable by the agent
118
118
  - "app": Tool callable by the app from this server only`),csp:Jf().optional(),permissions:Jf().optional()}),I({mimeTypes:F(j()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),I({method:V(`ui/download-file`),params:I({contents:F(R([r_,i_])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),I({method:V(`ui/message`),params:I({role:V(`user`).describe(`Message role, currently only "user" is supported.`),content:F(a_).describe(`Message content blocks (text, image, etc.).`)})}),I({method:V(`ui/notifications/sandbox-resource-ready`),params:I({html:j().describe(`HTML content to load into the inner iframe.`),sandbox:j().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:yv.optional().describe(`CSP configuration from resource metadata.`),permissions:bv.optional().describe(`Sandbox permissions from resource metadata.`)})});var Mv=I({method:V(`ui/notifications/tool-result`),params:m_.describe(`Standard MCP tool execution result.`)}),Nv=I({toolInfo:I({id:Ph.optional().describe(`JSON-RPC id of the tools/call request.`),tool:d_.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:pv.optional().describe(`Current color theme preference.`),styles:Tv.optional().describe(`Style configuration for theming the app.`),displayMode:mv.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:F(mv).optional().describe(`Display modes the host supports.`),containerDimensions:R([I({height:M().describe(`Fixed container height in pixels.`)}),I({maxHeight:R([M(),Gf()]).optional().describe(`Maximum container height in pixels.`)})]).and(R([I({width:M().describe(`Fixed container width in pixels.`)}),I({maxWidth:R([M(),Gf()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
119
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:j().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:j().optional().describe(`User's timezone in IANA format.`),userAgent:j().optional().describe(`Host application identifier.`),platform:R([V(`web`),V(`desktop`),V(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:I({touch:N().optional().describe(`Whether the device supports touch input.`),hover:N().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:I({top:M().describe(`Top safe area inset in pixels.`),right:M().describe(`Right safe area inset in pixels.`),bottom:M().describe(`Bottom safe area inset in pixels.`),left:M().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Pv=I({method:V(`ui/notifications/host-context-changed`),params:Nv.describe(`Partial context update containing only changed fields.`)});I({method:V(`ui/update-model-context`),params:I({content:F(a_).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:z(j(),P().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),I({method:V(`ui/initialize`),params:I({appInfo:Yh.describe(`App identification (name and version).`),appCapabilities:kv.describe(`Features and capabilities this app provides.`),protocolVersion:j().describe(`Protocol version this app supports.`)})});var Fv=I({protocolVersion:j().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Yh.describe(`Host application identification and version.`),hostCapabilities:Ov.describe(`Features and capabilities provided by the host.`),hostContext:Nv.describe(`Rich context about the host environment.`)}).passthrough(),Iv={target:`draft-2020-12`};async function Lv(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Iv);if(n.vendor===`zod`){let{z:n}=await lv(async()=>{let{z:e}=await Promise.resolve().then(()=>(Ch(),xh));return{z:e}},void 0,import.meta.url);return n.toJSONSchema(e,{io:t})}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 Rv(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 zv(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Bv(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Vv(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Hv(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)}var Uv=class e extends uv{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_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:xv,toolinputpartial:Sv,toolresult:Mv,toolcancelled:Cv,hostcontextchanged:Pv};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),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,n.allowUnsafeEval||a({jitless:!0}),this.setRequestHandler(ag,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._capabilities=av(this._capabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._capabilities.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 Rv(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Rv(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({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 Lv(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Lv(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(Ev,(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(g_,(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(f_,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}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},m_,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},zg,t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},Ng,t)}async createSamplingMessage(e,t){this._assertInitialized(`createSamplingMessage`);let n=e.tools?M_:j_;return await this.request({method:`sampling/createMessage`,params:e},n,t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},vv,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},Wh,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},gv,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},_v,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},Av,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 fv(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:dv}},Fv,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.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 Wv(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 Gv(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 Kv(e){e.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(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`}},Bv(zv())}var qv=document.getElementById(`app`),Jv=`http://www.w3.org/2000/svg`,Yv=40,Xv=2e3,Zv=null,Qv=null,$v=[],ey=null,ty=!1,ny=null,ry=null,iy=new Uv({name:`mikrotik-connected-devices`,version:`1.0.0`});function ay(e){return`${(e/1e6).toFixed(2)} Mbps`}function oy(){return Zv?.devices.find(e=>e.mac===Qv)}function sy(){ny&&clearInterval(ny),ny=null}function cy(e){sy(),$v=[],ey=null;let t=async()=>{try{let t=(await iy.callServerTool({name:`get_device_traffic`,arguments:{ip:e}})).structuredContent;if(!t||t.ip!==e)return;ey=t,$v.push({rx:t.rxBitsPerSec,tx:t.txBitsPerSec}),$v.length>Yv&&$v.shift(),uy()}catch(e){console.error(`[connected-devices] traffic poll failed`,e)}};t(),ny=setInterval(()=>void t(),Xv)}function ly(){let e=document.createElementNS(Jv,`svg`);e.setAttribute(`viewBox`,`0 0 460 140`),e.setAttribute(`class`,`traffic-chart`);let t=Math.max(1,...$v.flatMap(e=>[e.rx,e.tx])),n=e=>6+e*448/Math.max(1,Yv-1),r=e=>134-e/t*128,i=(t,i)=>{if($v.length<2)return;let a=$v.map((e,i)=>`${n(i).toFixed(1)},${r(t(e)).toFixed(1)}`).join(` `),o=document.createElementNS(Jv,`polygon`),s=n(0).toFixed(1),c=n($v.length-1).toFixed(1);o.setAttribute(`points`,`${s},134 ${a} ${c},134`),o.setAttribute(`class`,`${i} area`),e.appendChild(o);let l=document.createElementNS(Jv,`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 uy(){let e=document.getElementById(`detail`);if(!e)return;let t=oy();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}`)),ey&&ey.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`},`↓ ${ey?ay(ey.rxBitsPerSec):`…`}`),$(`span`,{class:`rate tx`},`↑ ${ey?ay(ey.txBitsPerSec):`…`}`))),e.appendChild(ly()),ey&&e.appendChild($(`div`,{class:`totals muted`},`total ↓ ${Gv(ey.rxBytes)} · ↑ ${Gv(ey.txBytes)}`)))}function dy(e){e&&typeof e==`object`&&e.__mikrotikView===`connected-devices`&&(Zv=e,my())}async function fy(e,t){if(!ty){ty=!0,my();try{dy((await iy.callServerTool({name:e,arguments:{mac:t}})).structuredContent)}catch(t){console.error(`[connected-devices] ${e} failed`,t)}finally{ty=!1,my()}}}async function py(){if(!ty){ty=!0,my();try{dy((await iy.callServerTool({name:`list_connected_devices`,arguments:{}})).structuredContent)}catch(e){console.error(`[connected-devices] refresh failed`,e)}finally{ty=!1,my()}}}function my(){if(!Zv){qv.replaceChildren($(`div`,{class:`muted loading`},`Loading connected devices…`));return}let e=Zv.counts,t=$(`div`,{class:`toolbar`},$(`div`,{class:`title`},`Connected Devices`),$(`div`,{class:`counts muted`},`${e.total} total · ${e.static} static · ${e.blocked} blocked`),Wv(`↻ Refresh`,()=>void py(),{class:ty?`is-busy`:``})),n=Zv.devices.map(e=>{let t=$(`div`,{class:`row${e.mac===Qv?` 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?Wv(`Allow`,()=>void fy(`allow_device`,e.mac),{class:`ok`}):Wv(`Block`,()=>void fy(`block_device`,e.mac),{class:`danger`}),e.static?null:Wv(`Pin IP`,()=>void fy(`make_device_static`,e.mac),{class:``})));return t.addEventListener(`click`,t=>{t.target.closest(`.actions`)||(Qv=e.mac,e.ip?cy(e.ip):sy(),my())}),t});qv.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`})),uy()}iy.ontoolresult=e=>dy(e.structuredContent),iy.ontoolinput=()=>{Zv||my()},Kv(iy),iy.onteardown=async()=>(sy(),ry&&clearInterval(ry),{}),my(),iy.connect().catch(e=>console.error(`[connected-devices] connect failed`,e)),ry=setInterval(()=>void py(),15e3);
119
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:j().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:j().optional().describe(`User's timezone in IANA format.`),userAgent:j().optional().describe(`Host application identifier.`),platform:R([V(`web`),V(`desktop`),V(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:I({touch:N().optional().describe(`Whether the device supports touch input.`),hover:N().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:I({top:M().describe(`Top safe area inset in pixels.`),right:M().describe(`Right safe area inset in pixels.`),bottom:M().describe(`Bottom safe area inset in pixels.`),left:M().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Pv=I({method:V(`ui/notifications/host-context-changed`),params:Nv.describe(`Partial context update containing only changed fields.`)});I({method:V(`ui/update-model-context`),params:I({content:F(a_).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:z(j(),P().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),I({method:V(`ui/initialize`),params:I({appInfo:Yh.describe(`App identification (name and version).`),appCapabilities:kv.describe(`Features and capabilities this app provides.`),protocolVersion:j().describe(`Protocol version this app supports.`)})});var Fv=I({protocolVersion:j().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Yh.describe(`Host application identification and version.`),hostCapabilities:Ov.describe(`Features and capabilities provided by the host.`),hostContext:Nv.describe(`Rich context about the host environment.`)}).passthrough(),Iv={target:`draft-2020-12`};async function Lv(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Iv);if(n.vendor===`zod`){let{z:n}=await lv(async()=>{let{z:e}=await Promise.resolve().then(()=>(Ch(),xh));return{z:e}},void 0,import.meta.url);return n.toJSONSchema(e,{io:t})}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 Rv(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 zv(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Bv(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Vv(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Hv(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)}var Uv=class e extends uv{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_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:xv,toolinputpartial:Sv,toolresult:Mv,toolcancelled:Cv,hostcontextchanged:Pv};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),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,n.allowUnsafeEval||a({jitless:!0}),this.setRequestHandler(ag,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._capabilities=av(this._capabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._capabilities.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 Rv(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Rv(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({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 Lv(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Lv(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(Ev,(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(g_,(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(f_,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}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},m_,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},zg,t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},Ng,t)}async createSamplingMessage(e,t){this._assertInitialized(`createSamplingMessage`);let n=e.tools?M_:j_;return await this.request({method:`sampling/createMessage`,params:e},n,t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},vv,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},Wh,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},gv,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},_v,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},Av,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 fv(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:dv}},Fv,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.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 Wv(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 Gv(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 Kv(e){e.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(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`}},Bv(zv())}var qv=document.getElementById(`app`),Jv=`http://www.w3.org/2000/svg`,Yv=40,Xv=2e3,Zv=null,Qv=null,$v=[],ey=null,ty=!1,ny=null,ry=null,iy=new Uv({name:`mikrotik-connected-devices`,version:`1.0.0`});function ay(e){return`${(e/1e6).toFixed(2)} Mbps`}function oy(){return Zv?.devices.find(e=>e.mac===Qv)}function sy(){ny&&clearInterval(ny),ny=null}function cy(e){sy(),$v=[],ey=null;let t=async()=>{try{let t=(await iy.callServerTool({name:`get_device_traffic`,arguments:{ip:e}})).structuredContent;if(!t||t.ip!==e)return;ey=t,$v.push({rx:t.rxBitsPerSec,tx:t.txBitsPerSec}),$v.length>Yv&&$v.shift(),uy()}catch(e){console.error(`[connected-devices] traffic poll failed`,e)}};t(),ny=setInterval(()=>void t(),Xv)}function ly(){let e=document.createElementNS(Jv,`svg`);e.setAttribute(`viewBox`,`0 0 460 140`),e.setAttribute(`class`,`traffic-chart`);let t=Math.max(1,...$v.flatMap(e=>[e.rx,e.tx])),n=e=>6+e*448/Math.max(1,Yv-1),r=e=>134-e/t*128,i=(t,i)=>{if($v.length<2)return;let a=$v.map((e,i)=>`${n(i).toFixed(1)},${r(t(e)).toFixed(1)}`).join(` `),o=document.createElementNS(Jv,`polygon`),s=n(0).toFixed(1),c=n($v.length-1).toFixed(1);o.setAttribute(`points`,`${s},134 ${a} ${c},134`),o.setAttribute(`class`,`${i} area`),e.appendChild(o);let l=document.createElementNS(Jv,`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 uy(){let e=document.getElementById(`detail`);if(!e)return;let t=oy();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}`)),ey&&ey.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`},`↓ ${ey?ay(ey.rxBitsPerSec):`…`}`),$(`span`,{class:`rate tx`},`↑ ${ey?ay(ey.txBitsPerSec):`…`}`))),e.appendChild(ly()),ey&&e.appendChild($(`div`,{class:`totals muted`},`total ↓ ${Gv(ey.rxBytes)} · ↑ ${Gv(ey.txBytes)}`)))}function dy(e){e&&typeof e==`object`&&e.__mikrotikView===`connected-devices`&&(Zv=e,my())}async function fy(e,t){if(!ty){ty=!0,my();try{dy((await iy.callServerTool({name:e,arguments:{mac:t}})).structuredContent)}catch(t){console.error(`[connected-devices] ${e} failed`,t)}finally{ty=!1,my()}}}async function py(){if(!ty){ty=!0,my();try{dy((await iy.callServerTool({name:`list_connected_devices`,arguments:{}})).structuredContent)}catch(e){console.error(`[connected-devices] refresh failed`,e)}finally{ty=!1,my()}}}function my(){if(!Zv){qv.replaceChildren($(`div`,{class:`muted loading`},`Loading connected devices…`));return}let e=Zv.counts,t=$(`div`,{class:`toolbar`},$(`div`,{class:`title`},`Connected Devices`),$(`div`,{class:`counts muted`},`${e.total} total · ${e.static} static · ${e.blocked} blocked`),Wv(`↻ Refresh`,()=>void py(),{class:ty?`is-busy`:``})),n=Zv.devices.map(e=>{let t=$(`div`,{class:`row${e.mac===Qv?` 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?Wv(`Allow`,()=>void fy(`allow_device`,e.mac),{class:`ok`}):Wv(`Block`,()=>void fy(`block_device`,e.mac),{class:`danger`}),e.static?null:Wv(`Pin IP`,()=>void fy(`make_device_static`,e.mac),{class:``})));return t.addEventListener(`click`,t=>{t.target.closest(`.actions`)||(Qv=e.mac,e.ip?cy(e.ip):sy(),my())}),t});qv.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`})),uy()}iy.ontoolresult=e=>{console.debug(`[connected-devices] ontoolresult fired`,e),dy(e.structuredContent)},iy.ontoolinput=()=>{Zv||my()},Kv(iy),iy.onteardown=async()=>(sy(),ry&&clearInterval(ry),{}),my(),iy.connect().then(()=>console.debug(`[connected-devices] connect OK`,{hostCaps:iy.getHostCapabilities()})).catch(e=>console.error(`[connected-devices] connect failed`,e)),ry=setInterval(()=>void py(),15e3);
120
120
  </script>
121
121
  <style>
122
122
  :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}
@@ -116,7 +116,7 @@ Boolean requesting whether a visible border and background is provided by the ho
116
116
  - omitted: host decides border`)}),I({method:V(`ui/request-display-mode`),params:I({mode:mv.describe(`The display mode being requested.`)})});var Av=I({mode:mv.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),jv=R([V(`model`),V(`app`)]).describe(`Tool visibility scope - who can access the tool.`);I({resourceUri:j().optional(),visibility:F(jv).optional().describe(`Who can access this tool. Default: ["model", "app"]
117
117
  - "model": Tool visible to and callable by the agent
118
118
  - "app": Tool callable by the app from this server only`),csp:Jf().optional(),permissions:Jf().optional()}),I({mimeTypes:F(j()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),I({method:V(`ui/download-file`),params:I({contents:F(R([r_,i_])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),I({method:V(`ui/message`),params:I({role:V(`user`).describe(`Message role, currently only "user" is supported.`),content:F(a_).describe(`Message content blocks (text, image, etc.).`)})}),I({method:V(`ui/notifications/sandbox-resource-ready`),params:I({html:j().describe(`HTML content to load into the inner iframe.`),sandbox:j().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:yv.optional().describe(`CSP configuration from resource metadata.`),permissions:bv.optional().describe(`Sandbox permissions from resource metadata.`)})});var Mv=I({method:V(`ui/notifications/tool-result`),params:m_.describe(`Standard MCP tool execution result.`)}),Nv=I({toolInfo:I({id:Ph.optional().describe(`JSON-RPC id of the tools/call request.`),tool:d_.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:pv.optional().describe(`Current color theme preference.`),styles:Tv.optional().describe(`Style configuration for theming the app.`),displayMode:mv.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:F(mv).optional().describe(`Display modes the host supports.`),containerDimensions:R([I({height:M().describe(`Fixed container height in pixels.`)}),I({maxHeight:R([M(),Gf()]).optional().describe(`Maximum container height in pixels.`)})]).and(R([I({width:M().describe(`Fixed container width in pixels.`)}),I({maxWidth:R([M(),Gf()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
119
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:j().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:j().optional().describe(`User's timezone in IANA format.`),userAgent:j().optional().describe(`Host application identifier.`),platform:R([V(`web`),V(`desktop`),V(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:I({touch:N().optional().describe(`Whether the device supports touch input.`),hover:N().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:I({top:M().describe(`Top safe area inset in pixels.`),right:M().describe(`Right safe area inset in pixels.`),bottom:M().describe(`Bottom safe area inset in pixels.`),left:M().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Pv=I({method:V(`ui/notifications/host-context-changed`),params:Nv.describe(`Partial context update containing only changed fields.`)});I({method:V(`ui/update-model-context`),params:I({content:F(a_).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:z(j(),P().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),I({method:V(`ui/initialize`),params:I({appInfo:Yh.describe(`App identification (name and version).`),appCapabilities:kv.describe(`Features and capabilities this app provides.`),protocolVersion:j().describe(`Protocol version this app supports.`)})});var Fv=I({protocolVersion:j().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Yh.describe(`Host application identification and version.`),hostCapabilities:Ov.describe(`Features and capabilities provided by the host.`),hostContext:Nv.describe(`Rich context about the host environment.`)}).passthrough(),Iv={target:`draft-2020-12`};async function Lv(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Iv);if(n.vendor===`zod`){let{z:n}=await lv(async()=>{let{z:e}=await Promise.resolve().then(()=>(Ch(),xh));return{z:e}},void 0,import.meta.url);return n.toJSONSchema(e,{io:t})}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 Rv(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 zv(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Bv(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Vv(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Hv(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)}var Uv=class e extends uv{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_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:xv,toolinputpartial:Sv,toolresult:Mv,toolcancelled:Cv,hostcontextchanged:Pv};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),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,n.allowUnsafeEval||a({jitless:!0}),this.setRequestHandler(ag,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._capabilities=av(this._capabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._capabilities.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 Rv(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Rv(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({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 Lv(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Lv(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(Ev,(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(g_,(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(f_,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}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},m_,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},zg,t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},Ng,t)}async createSamplingMessage(e,t){this._assertInitialized(`createSamplingMessage`);let n=e.tools?M_:j_;return await this.request({method:`sampling/createMessage`,params:e},n,t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},vv,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},Wh,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},gv,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},_v,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},Av,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 fv(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:dv}},Fv,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}},Wv=`show_system_dashboard`,Gv=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 Kv(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 qv(e){return e==null?``:e>=90?`is-bad`:e>=70?`is-warn`:`is-good`}var Jv=`http://www.w3.org/2000/svg`;function Yv(e,t){let n=document.createElementNS(Jv,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,String(r));return n}function Xv(e,t,n){let r=2*Math.PI*26,i=t==null?0:Math.max(0,Math.min(100,t))/100,a=Yv(`svg`,{width:64,height:64,viewBox:`0 0 64 64`}),o=Yv(`circle`,{cx:32,cy:32,r:26,fill:`none`,"stroke-width":7});o.setAttribute(`class`,`gauge__track`);let s=Yv(`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 ${qv(t)}`);let c=Yv(`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 Zv(e,t){return $(`div`,{class:`card`},$(`p`,{class:`card__label`},e),$(`div`,{class:`card__value`},t))}function Qv(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 $v=null,ey=!1;function ty(){if(!$v){Gv.replaceChildren($(`div`,{class:`skeleton`},`Waiting for device data…`));return}let e=$v,t=e.derived,n=e.resource.version??`?`,r=e.routerboard.model??e.resource[`board-name`]??`?`,i=[Xv(`CPU load`,t.cpuLoadPct,`${e.resource[`cpu-count`]??`?`} cores`),Xv(`Memory`,t.memUsedPct,`${Kv(t.memUsedBytes)} / ${Kv(t.memTotalBytes)}`),t.hddUsedPct!=null&&Xv(`Disk`,t.hddUsedPct,`${Kv(t.hddUsedBytes)} / ${Kv(t.hddTotalBytes)}`)].filter(Boolean),a=[Zv(`Uptime`,e.resource.uptime??`—`),t.temperatureC!=null&&Zv(`Temperature`,`${t.temperatureC} °C`),t.voltageV!=null&&Zv(`Voltage`,`${t.voltageV} V`),Zv(`Architecture`,e.resource[`architecture-name`]??`—`)].filter(Boolean),o=$(`button`,{class:`btn`},ey?`Refreshing…`:`↻ Refresh`);ey&&o.setAttribute(`disabled`,`true`),o.addEventListener(`click`,iy);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),Qv(`System resource`,e.resource),Qv(`RouterBOARD`,e.routerboard),l].filter(e=>e!=null);Gv.replaceChildren(...u)}var ny=new Uv({name:`mikrotik-dashboard`,version:`1.0.0`});function ry(e){e&&typeof e==`object`&&`device`in e&&($v=e,ty())}async function iy(){if(!ey){ey=!0,ty();try{ry((await ny.callServerTool({name:Wv,arguments:{}})).structuredContent)}catch(e){console.error(`[dashboard] refresh failed`,e)}finally{ey=!1,ty()}}}ny.ontoolresult=e=>ry(e.structuredContent),ny.ontoolinput=()=>{$v||ty()},ny.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(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`}},ny.onteardown=async()=>({}),Bv(zv()),ty(),ny.connect().catch(e=>console.error(`[dashboard] connect failed`,e));
119
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:j().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:j().optional().describe(`User's timezone in IANA format.`),userAgent:j().optional().describe(`Host application identifier.`),platform:R([V(`web`),V(`desktop`),V(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:I({touch:N().optional().describe(`Whether the device supports touch input.`),hover:N().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:I({top:M().describe(`Top safe area inset in pixels.`),right:M().describe(`Right safe area inset in pixels.`),bottom:M().describe(`Bottom safe area inset in pixels.`),left:M().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Pv=I({method:V(`ui/notifications/host-context-changed`),params:Nv.describe(`Partial context update containing only changed fields.`)});I({method:V(`ui/update-model-context`),params:I({content:F(a_).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:z(j(),P().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),I({method:V(`ui/initialize`),params:I({appInfo:Yh.describe(`App identification (name and version).`),appCapabilities:kv.describe(`Features and capabilities this app provides.`),protocolVersion:j().describe(`Protocol version this app supports.`)})});var Fv=I({protocolVersion:j().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Yh.describe(`Host application identification and version.`),hostCapabilities:Ov.describe(`Features and capabilities provided by the host.`),hostContext:Nv.describe(`Rich context about the host environment.`)}).passthrough(),Iv={target:`draft-2020-12`};async function Lv(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Iv);if(n.vendor===`zod`){let{z:n}=await lv(async()=>{let{z:e}=await Promise.resolve().then(()=>(Ch(),xh));return{z:e}},void 0,import.meta.url);return n.toJSONSchema(e,{io:t})}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 Rv(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 zv(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Bv(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Vv(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Hv(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)}var Uv=class e extends uv{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_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:xv,toolinputpartial:Sv,toolresult:Mv,toolcancelled:Cv,hostcontextchanged:Pv};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),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,n.allowUnsafeEval||a({jitless:!0}),this.setRequestHandler(ag,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._capabilities=av(this._capabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._capabilities.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 Rv(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Rv(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({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 Lv(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Lv(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(Ev,(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(g_,(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(f_,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}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},m_,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},zg,t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},Ng,t)}async createSamplingMessage(e,t){this._assertInitialized(`createSamplingMessage`);let n=e.tools?M_:j_;return await this.request({method:`sampling/createMessage`,params:e},n,t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},vv,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},Wh,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},gv,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},_v,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},Av,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 fv(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:dv}},Fv,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}},Wv=`show_system_dashboard`,Gv=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 Kv(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 qv(e){return e==null?``:e>=90?`is-bad`:e>=70?`is-warn`:`is-good`}var Jv=`http://www.w3.org/2000/svg`;function Yv(e,t){let n=document.createElementNS(Jv,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,String(r));return n}function Xv(e,t,n){let r=2*Math.PI*26,i=t==null?0:Math.max(0,Math.min(100,t))/100,a=Yv(`svg`,{width:64,height:64,viewBox:`0 0 64 64`}),o=Yv(`circle`,{cx:32,cy:32,r:26,fill:`none`,"stroke-width":7});o.setAttribute(`class`,`gauge__track`);let s=Yv(`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 ${qv(t)}`);let c=Yv(`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 Zv(e,t){return $(`div`,{class:`card`},$(`p`,{class:`card__label`},e),$(`div`,{class:`card__value`},t))}function Qv(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 $v=null,ey=!1;function ty(){if(!$v){Gv.replaceChildren($(`div`,{class:`skeleton`},`Waiting for device data…`));return}let e=$v,t=e.derived,n=e.resource.version??`?`,r=e.routerboard.model??e.resource[`board-name`]??`?`,i=[Xv(`CPU load`,t.cpuLoadPct,`${e.resource[`cpu-count`]??`?`} cores`),Xv(`Memory`,t.memUsedPct,`${Kv(t.memUsedBytes)} / ${Kv(t.memTotalBytes)}`),t.hddUsedPct!=null&&Xv(`Disk`,t.hddUsedPct,`${Kv(t.hddUsedBytes)} / ${Kv(t.hddTotalBytes)}`)].filter(Boolean),a=[Zv(`Uptime`,e.resource.uptime??`—`),t.temperatureC!=null&&Zv(`Temperature`,`${t.temperatureC} °C`),t.voltageV!=null&&Zv(`Voltage`,`${t.voltageV} V`),Zv(`Architecture`,e.resource[`architecture-name`]??`—`)].filter(Boolean),o=$(`button`,{class:`btn`},ey?`Refreshing…`:`↻ Refresh`);ey&&o.setAttribute(`disabled`,`true`),o.addEventListener(`click`,iy);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),Qv(`System resource`,e.resource),Qv(`RouterBOARD`,e.routerboard),l].filter(e=>e!=null);Gv.replaceChildren(...u)}var ny=new Uv({name:`mikrotik-dashboard`,version:`1.0.0`});function ry(e){e&&typeof e==`object`&&`device`in e&&($v=e,ty())}async function iy(){if(!ey){ey=!0,ty();try{ry((await ny.callServerTool({name:Wv,arguments:{}})).structuredContent)}catch(e){console.error(`[dashboard] refresh failed`,e)}finally{ey=!1,ty()}}}ny.ontoolresult=e=>{console.debug(`[dashboard] ontoolresult fired`,e),ry(e.structuredContent)},ny.ontoolinput=()=>{$v||ty()},ny.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(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`}},ny.onteardown=async()=>({}),Bv(zv()),ty(),ny.connect().then(()=>{console.debug(`[dashboard] connect OK`,{hostCaps:ny.getHostCapabilities(),hostCtx:ny.getHostContext()})}).catch(e=>console.error(`[dashboard] connect failed`,e));
120
120
  </script>
121
121
  <style>
122
122
  :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}
@@ -116,7 +116,7 @@ Boolean requesting whether a visible border and background is provided by the ho
116
116
  - omitted: host decides border`)}),I({method:V(`ui/request-display-mode`),params:I({mode:mv.describe(`The display mode being requested.`)})});var Av=I({mode:mv.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),jv=R([V(`model`),V(`app`)]).describe(`Tool visibility scope - who can access the tool.`);I({resourceUri:j().optional(),visibility:F(jv).optional().describe(`Who can access this tool. Default: ["model", "app"]
117
117
  - "model": Tool visible to and callable by the agent
118
118
  - "app": Tool callable by the app from this server only`),csp:Jf().optional(),permissions:Jf().optional()}),I({mimeTypes:F(j()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),I({method:V(`ui/download-file`),params:I({contents:F(R([r_,i_])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),I({method:V(`ui/message`),params:I({role:V(`user`).describe(`Message role, currently only "user" is supported.`),content:F(a_).describe(`Message content blocks (text, image, etc.).`)})}),I({method:V(`ui/notifications/sandbox-resource-ready`),params:I({html:j().describe(`HTML content to load into the inner iframe.`),sandbox:j().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:yv.optional().describe(`CSP configuration from resource metadata.`),permissions:bv.optional().describe(`Sandbox permissions from resource metadata.`)})});var Mv=I({method:V(`ui/notifications/tool-result`),params:m_.describe(`Standard MCP tool execution result.`)}),Nv=I({toolInfo:I({id:Ph.optional().describe(`JSON-RPC id of the tools/call request.`),tool:d_.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:pv.optional().describe(`Current color theme preference.`),styles:Tv.optional().describe(`Style configuration for theming the app.`),displayMode:mv.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:F(mv).optional().describe(`Display modes the host supports.`),containerDimensions:R([I({height:M().describe(`Fixed container height in pixels.`)}),I({maxHeight:R([M(),Gf()]).optional().describe(`Maximum container height in pixels.`)})]).and(R([I({width:M().describe(`Fixed container width in pixels.`)}),I({maxWidth:R([M(),Gf()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
119
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:j().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:j().optional().describe(`User's timezone in IANA format.`),userAgent:j().optional().describe(`Host application identifier.`),platform:R([V(`web`),V(`desktop`),V(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:I({touch:N().optional().describe(`Whether the device supports touch input.`),hover:N().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:I({top:M().describe(`Top safe area inset in pixels.`),right:M().describe(`Right safe area inset in pixels.`),bottom:M().describe(`Bottom safe area inset in pixels.`),left:M().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Pv=I({method:V(`ui/notifications/host-context-changed`),params:Nv.describe(`Partial context update containing only changed fields.`)});I({method:V(`ui/update-model-context`),params:I({content:F(a_).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:z(j(),P().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),I({method:V(`ui/initialize`),params:I({appInfo:Yh.describe(`App identification (name and version).`),appCapabilities:kv.describe(`Features and capabilities this app provides.`),protocolVersion:j().describe(`Protocol version this app supports.`)})});var Fv=I({protocolVersion:j().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Yh.describe(`Host application identification and version.`),hostCapabilities:Ov.describe(`Features and capabilities provided by the host.`),hostContext:Nv.describe(`Rich context about the host environment.`)}).passthrough(),Iv={target:`draft-2020-12`};async function Lv(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Iv);if(n.vendor===`zod`){let{z:n}=await lv(async()=>{let{z:e}=await Promise.resolve().then(()=>(Ch(),xh));return{z:e}},void 0,import.meta.url);return n.toJSONSchema(e,{io:t})}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 Rv(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 zv(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Bv(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Vv(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Hv(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)}var Uv=class e extends uv{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_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:xv,toolinputpartial:Sv,toolresult:Mv,toolcancelled:Cv,hostcontextchanged:Pv};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),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,n.allowUnsafeEval||a({jitless:!0}),this.setRequestHandler(ag,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._capabilities=av(this._capabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._capabilities.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 Rv(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Rv(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({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 Lv(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Lv(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(Ev,(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(g_,(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(f_,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}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},m_,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},zg,t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},Ng,t)}async createSamplingMessage(e,t){this._assertInitialized(`createSamplingMessage`);let n=e.tools?M_:j_;return await this.request({method:`sampling/createMessage`,params:e},n,t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},vv,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},Wh,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},gv,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},_v,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},Av,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 fv(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:dv}},Fv,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.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 Wv(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 Gv(e){e.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(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`}},Bv(zv())}var Kv=`show_interfaces`,qv=document.getElementById(`app`),Jv=null,Yv=``,Xv=!1;function Zv(e){return(e.flags??``).includes(`R`)||e.running===`true`}function Qv(e){return(e.flags??``).includes(`X`)||e.disabled===`true`}function $v(e,t){return!!t&&$(`div`,{class:`contents`},$(`span`,{},e),$(`b`,{},t))}function ey(e){let t=Qv(e),n=t?`dot is-down`:Zv(e)?`dot is-up`:`dot`,r=$(`div`,{class:`if-card__meta`},$v(`MTU`,e.mtu??e[`actual-mtu`]),$v(`MAC`,e[`mac-address`]),$v(`comment`,e.comment));return $(`div`,{class:`card if-card${t?` is-disabled`:``}`},$(`div`,{class:`if-card__top`},$(`span`,{class:n}),$(`span`,{class:`if-card__name`},e.name??`?`),$(`span`,{class:`badge`},e.type??`—`)),r)}function ty(e){let t=Yv.trim().toLowerCase();return t?e.rows.filter(e=>Object.values(e).some(e=>e.toLowerCase().includes(t))):e.rows}function ny(){if(!Jv){qv.replaceChildren($(`div`,{class:`skeleton`},`Waiting for interfaces…`));return}let e=Jv,t=ty(e),n=e.rows.filter(Zv).length,r=e.rows.filter(Qv).length,i=$(`input`,{class:`search`,type:`search`,placeholder:`Search ${e.rows.length} interface(s)…`,value:Yv});i.addEventListener(`input`,()=>{Yv=i.value,ny()});let a=$(`header`,{class:`hd`},$(`span`,{class:`hd__dot`}),$(`div`,{},$(`h1`,{class:`hd__title`},`Interfaces`),$(`p`,{class:`hd__sub`},`${n} running · ${r} disabled · ${e.rows.length} total`)),$(`span`,{class:`hd__spacer`}),$(`span`,{class:`pill`},`device `,$(`b`,{},e.device))),o=$(`div`,{class:`toolbar`},$(`div`,{class:`grow`},i),Wv(Xv?`Refreshing…`:`↻ Refresh`,ay,{disabled:Xv})),s=t.length?$(`section`,{class:`if-grid`},...t.map(ey)):$(`div`,{class:`empty`},`No interfaces match the search.`),c=$(`footer`,{class:`foot`},$(`span`,{class:`grow`}),$(`span`,{},`updated ${new Date(e.generatedAt).toLocaleTimeString()}`));qv.replaceChildren(a,o,s,c)}var ry=new Uv({name:`mikrotik-interfaces`,version:`1.0.0`});function iy(e){e&&typeof e==`object`&&e.__mikrotikView===`interfaces`&&(Jv=e,ny())}async function ay(){if(!Xv){Xv=!0,ny();try{iy((await ry.callServerTool({name:Kv,arguments:{}})).structuredContent)}catch(e){console.error(`[interfaces] refresh failed`,e)}finally{Xv=!1,ny()}}}ry.ontoolresult=e=>iy(e.structuredContent),ry.ontoolinput=()=>{Jv||ny()},Gv(ry),ry.onteardown=async()=>({}),ny(),ry.connect().catch(e=>console.error(`[interfaces] connect failed`,e));
119
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:j().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:j().optional().describe(`User's timezone in IANA format.`),userAgent:j().optional().describe(`Host application identifier.`),platform:R([V(`web`),V(`desktop`),V(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:I({touch:N().optional().describe(`Whether the device supports touch input.`),hover:N().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:I({top:M().describe(`Top safe area inset in pixels.`),right:M().describe(`Right safe area inset in pixels.`),bottom:M().describe(`Bottom safe area inset in pixels.`),left:M().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Pv=I({method:V(`ui/notifications/host-context-changed`),params:Nv.describe(`Partial context update containing only changed fields.`)});I({method:V(`ui/update-model-context`),params:I({content:F(a_).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:z(j(),P().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),I({method:V(`ui/initialize`),params:I({appInfo:Yh.describe(`App identification (name and version).`),appCapabilities:kv.describe(`Features and capabilities this app provides.`),protocolVersion:j().describe(`Protocol version this app supports.`)})});var Fv=I({protocolVersion:j().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Yh.describe(`Host application identification and version.`),hostCapabilities:Ov.describe(`Features and capabilities provided by the host.`),hostContext:Nv.describe(`Rich context about the host environment.`)}).passthrough(),Iv={target:`draft-2020-12`};async function Lv(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Iv);if(n.vendor===`zod`){let{z:n}=await lv(async()=>{let{z:e}=await Promise.resolve().then(()=>(Ch(),xh));return{z:e}},void 0,import.meta.url);return n.toJSONSchema(e,{io:t})}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 Rv(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 zv(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Bv(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Vv(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Hv(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)}var Uv=class e extends uv{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_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:xv,toolinputpartial:Sv,toolresult:Mv,toolcancelled:Cv,hostcontextchanged:Pv};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),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,n.allowUnsafeEval||a({jitless:!0}),this.setRequestHandler(ag,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._capabilities=av(this._capabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._capabilities.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 Rv(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Rv(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({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 Lv(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Lv(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(Ev,(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(g_,(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(f_,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}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},m_,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},zg,t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},Ng,t)}async createSamplingMessage(e,t){this._assertInitialized(`createSamplingMessage`);let n=e.tools?M_:j_;return await this.request({method:`sampling/createMessage`,params:e},n,t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},vv,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},Wh,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},gv,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},_v,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},Av,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 fv(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:dv}},Fv,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.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 Wv(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 Gv(e){e.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(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`}},Bv(zv())}var Kv=`show_interfaces`,qv=document.getElementById(`app`),Jv=null,Yv=``,Xv=!1;function Zv(e){return(e.flags??``).includes(`R`)||e.running===`true`}function Qv(e){return(e.flags??``).includes(`X`)||e.disabled===`true`}function $v(e,t){return!!t&&$(`div`,{class:`contents`},$(`span`,{},e),$(`b`,{},t))}function ey(e){let t=Qv(e),n=t?`dot is-down`:Zv(e)?`dot is-up`:`dot`,r=$(`div`,{class:`if-card__meta`},$v(`MTU`,e.mtu??e[`actual-mtu`]),$v(`MAC`,e[`mac-address`]),$v(`comment`,e.comment));return $(`div`,{class:`card if-card${t?` is-disabled`:``}`},$(`div`,{class:`if-card__top`},$(`span`,{class:n}),$(`span`,{class:`if-card__name`},e.name??`?`),$(`span`,{class:`badge`},e.type??`—`)),r)}function ty(e){let t=Yv.trim().toLowerCase();return t?e.rows.filter(e=>Object.values(e).some(e=>e.toLowerCase().includes(t))):e.rows}function ny(){if(!Jv){qv.replaceChildren($(`div`,{class:`skeleton`},`Waiting for interfaces…`));return}let e=Jv,t=ty(e),n=e.rows.filter(Zv).length,r=e.rows.filter(Qv).length,i=$(`input`,{class:`search`,type:`search`,placeholder:`Search ${e.rows.length} interface(s)…`,value:Yv});i.addEventListener(`input`,()=>{Yv=i.value,ny()});let a=$(`header`,{class:`hd`},$(`span`,{class:`hd__dot`}),$(`div`,{},$(`h1`,{class:`hd__title`},`Interfaces`),$(`p`,{class:`hd__sub`},`${n} running · ${r} disabled · ${e.rows.length} total`)),$(`span`,{class:`hd__spacer`}),$(`span`,{class:`pill`},`device `,$(`b`,{},e.device))),o=$(`div`,{class:`toolbar`},$(`div`,{class:`grow`},i),Wv(Xv?`Refreshing…`:`↻ Refresh`,ay,{disabled:Xv})),s=t.length?$(`section`,{class:`if-grid`},...t.map(ey)):$(`div`,{class:`empty`},`No interfaces match the search.`),c=$(`footer`,{class:`foot`},$(`span`,{class:`grow`}),$(`span`,{},`updated ${new Date(e.generatedAt).toLocaleTimeString()}`));qv.replaceChildren(a,o,s,c)}var ry=new Uv({name:`mikrotik-interfaces`,version:`1.0.0`});function iy(e){e&&typeof e==`object`&&e.__mikrotikView===`interfaces`&&(Jv=e,ny())}async function ay(){if(!Xv){Xv=!0,ny();try{iy((await ry.callServerTool({name:Kv,arguments:{}})).structuredContent)}catch(e){console.error(`[interfaces] refresh failed`,e)}finally{Xv=!1,ny()}}}ry.ontoolresult=e=>{console.debug(`[interfaces] ontoolresult fired`,e),iy(e.structuredContent)},ry.ontoolinput=()=>{Jv||ny()},Gv(ry),ry.onteardown=async()=>({}),ny(),ry.connect().then(()=>console.debug(`[interfaces] connect OK`,{hostCaps:ry.getHostCapabilities()})).catch(e=>console.error(`[interfaces] connect failed`,e));
120
120
  </script>
121
121
  <style>
122
122
  :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:960px;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}.toolbar{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.toolbar .grow{flex:1;min-width:140px}.search{appearance:none;border:1px solid var(--mt-border);background:var(--mt-surface);width:100%;color:var(--mt-text);font:inherit;border-radius:var(--mt-radius-sm);padding:7px 11px;font-size:13px}.search:focus{border-color:var(--mt-accent);outline:none}.search::placeholder{color:var(--mt-text-faint)}.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;white-space:nowrap;padding:6px 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}.btn.is-active{border-color:var(--mt-accent);color:var(--mt-accent)}.chip{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:4px;padding:1px 7px;font-size:11px;display:inline-flex}.chip.is-good{color:var(--mt-good);border-color:color-mix(in srgb, var(--mt-good) 45%, var(--mt-border))}.chip.is-warn{color:var(--mt-warn);border-color:color-mix(in srgb, var(--mt-warn) 45%, var(--mt-border))}.chip.is-bad{color:var(--mt-bad);border-color:color-mix(in srgb, var(--mt-bad) 45%, var(--mt-border))}.tablewrap{border:1px solid var(--mt-border);border-radius:var(--mt-radius);max-height:70vh;overflow:auto}table.tbl{border-collapse:collapse;width:100%;font-size:12px}table.tbl th,table.tbl td{text-align:left;border-bottom:1px solid color-mix(in srgb, var(--mt-border) 55%, transparent);white-space:nowrap;font-family:var(--mt-mono);padding:7px 12px}table.tbl thead th{z-index:1;background:var(--mt-surface-2);color:var(--mt-text-dim);cursor:pointer;-webkit-user-select:none;user-select:none;font-weight:600;position:sticky;top:0}table.tbl thead th:hover{color:var(--mt-text)}table.tbl thead th .arrow{color:var(--mt-accent);margin-left:4px}table.tbl tbody tr{cursor:pointer}table.tbl tbody tr:hover{background:color-mix(in srgb, var(--mt-accent) 8%, transparent)}table.tbl tbody tr.is-disabled td,table.tbl td.col-num{color:var(--mt-text-faint)}.kv__body{border:1px solid var(--mt-border);border-radius:var(--mt-radius);grid-template-columns:minmax(120px,.4fr) 1fr;display:grid;overflow:hidden}.kv__body>div{border-bottom:1px solid color-mix(in srgb, var(--mt-border) 55%, transparent);overflow-wrap:anywhere;min-width:0;font-size:12px;font-family:var(--mt-mono);padding:7px 14px}.kv__k{color:var(--mt-text-dim);background:color-mix(in srgb, var(--mt-surface) 60%, transparent)}.kv__v{color:var(--mt-text)}.drawer{border:1px solid var(--mt-accent);border-radius:var(--mt-radius);background:var(--mt-surface);gap:10px;padding:12px;display:grid}.drawer__hd{align-items:center;gap:8px;display:flex}.drawer__hd b{font-family:var(--mt-mono)}pre.raw{border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);color:var(--mt-text);font-family:var(--mt-mono);white-space:pre;max-height:70vh;margin:0;padding:14px;font-size:12px;overflow:auto}.foot{color:var(--mt-text-faint);font-size:11px;font-family:var(--mt-mono);flex-wrap:wrap;align-items:center;gap:10px;display:flex}.foot .grow{flex:1}.skeleton,.empty{color:var(--mt-text-faint);text-align:center;padding:40px 0}.if-grid{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px;display:grid}.if-card{gap:8px;display:grid}.if-card__top{align-items:center;gap:8px;display:flex}.if-card__name{font-family:var(--mt-mono);overflow-wrap:anywhere;font-size:14px;font-weight:650}.if-card.is-disabled{opacity:.6}.dot{background:var(--mt-text-faint);border-radius:50%;flex:none;width:9px;height:9px}.dot.is-up{background:var(--mt-good);box-shadow:0 0 0 4px color-mix(in srgb, var(--mt-good) 22%, transparent)}.dot.is-down{background:var(--mt-bad);box-shadow:0 0 0 4px color-mix(in srgb, var(--mt-bad) 18%, transparent)}.if-card__meta{font-family:var(--mt-mono);color:var(--mt-text-dim);grid-template-columns:auto 1fr;gap:2px 10px;font-size:11px;display:grid}.if-card__meta b{color:var(--mt-text);overflow-wrap:anywhere;font-weight:500}.if-card__meta .contents{display:contents}.badge{border:1px solid var(--mt-border);background:var(--mt-surface-2);color:var(--mt-text-dim);font-family:var(--mt-mono);text-transform:uppercase;letter-spacing:.04em;border-radius:999px;margin-left:auto;padding:1px 7px;font-size:10px}
@@ -117,7 +117,7 @@ Boolean requesting whether a visible border and background is provided by the ho
117
117
  - "model": Tool visible to and callable by the agent
118
118
  - "app": Tool callable by the app from this server only`),csp:Jf().optional(),permissions:Jf().optional()}),I({mimeTypes:F(j()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),I({method:V(`ui/download-file`),params:I({contents:F(R([r_,i_])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),I({method:V(`ui/message`),params:I({role:V(`user`).describe(`Message role, currently only "user" is supported.`),content:F(a_).describe(`Message content blocks (text, image, etc.).`)})}),I({method:V(`ui/notifications/sandbox-resource-ready`),params:I({html:j().describe(`HTML content to load into the inner iframe.`),sandbox:j().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:yv.optional().describe(`CSP configuration from resource metadata.`),permissions:bv.optional().describe(`Sandbox permissions from resource metadata.`)})});var Mv=I({method:V(`ui/notifications/tool-result`),params:m_.describe(`Standard MCP tool execution result.`)}),Nv=I({toolInfo:I({id:Ph.optional().describe(`JSON-RPC id of the tools/call request.`),tool:d_.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:pv.optional().describe(`Current color theme preference.`),styles:Tv.optional().describe(`Style configuration for theming the app.`),displayMode:mv.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:F(mv).optional().describe(`Display modes the host supports.`),containerDimensions:R([I({height:M().describe(`Fixed container height in pixels.`)}),I({maxHeight:R([M(),Gf()]).optional().describe(`Maximum container height in pixels.`)})]).and(R([I({width:M().describe(`Fixed container width in pixels.`)}),I({maxWidth:R([M(),Gf()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
119
119
  container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:j().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:j().optional().describe(`User's timezone in IANA format.`),userAgent:j().optional().describe(`Host application identifier.`),platform:R([V(`web`),V(`desktop`),V(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:I({touch:N().optional().describe(`Whether the device supports touch input.`),hover:N().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:I({top:M().describe(`Top safe area inset in pixels.`),right:M().describe(`Right safe area inset in pixels.`),bottom:M().describe(`Bottom safe area inset in pixels.`),left:M().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Pv=I({method:V(`ui/notifications/host-context-changed`),params:Nv.describe(`Partial context update containing only changed fields.`)});I({method:V(`ui/update-model-context`),params:I({content:F(a_).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:z(j(),P().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),I({method:V(`ui/initialize`),params:I({appInfo:Yh.describe(`App identification (name and version).`),appCapabilities:kv.describe(`Features and capabilities this app provides.`),protocolVersion:j().describe(`Protocol version this app supports.`)})});var Fv=I({protocolVersion:j().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Yh.describe(`Host application identification and version.`),hostCapabilities:Ov.describe(`Features and capabilities provided by the host.`),hostContext:Nv.describe(`Rich context about the host environment.`)}).passthrough(),Iv={target:`draft-2020-12`};async function Lv(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Iv);if(n.vendor===`zod`){let{z:n}=await lv(async()=>{let{z:e}=await Promise.resolve().then(()=>(Ch(),xh));return{z:e}},void 0,import.meta.url);return n.toJSONSchema(e,{io:t})}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 Rv(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 zv(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Bv(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Vv(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Hv(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)}var Uv=class e extends uv{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_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:xv,toolinputpartial:Sv,toolresult:Mv,toolcancelled:Cv,hostcontextchanged:Pv};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),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,n.allowUnsafeEval||a({jitless:!0}),this.setRequestHandler(ag,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._capabilities=av(this._capabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._capabilities.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 Rv(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Rv(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({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 Lv(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Lv(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(Ev,(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(g_,(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(f_,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}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},m_,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},zg,t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},Ng,t)}async createSamplingMessage(e,t){this._assertInitialized(`createSamplingMessage`);let n=e.tools?M_:j_;return await this.request({method:`sampling/createMessage`,params:e},n,t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},vv,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},Wh,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},gv,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},_v,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},Av,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 fv(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:dv}},Fv,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.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 Wv(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}async function Gv(e){try{await navigator.clipboard.writeText(e)}catch{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.append(t),t.select();try{document.execCommand(`copy`)}finally{t.remove()}}}function Kv(e,t,n=`text/plain`){let r=new Blob([t],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=$(`a`,{href:i,download:e});document.body.append(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function qv(e,t){let n=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e;return`${e.map(n).join(`,`)}\n${t.map(t=>e.map(e=>n(t[e]??``)).join(`,`)).join(`
120
- `)}\n`}function Jv(e){e.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(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`}},Bv(zv())}var Yv=document.getElementById(`app`),Xv=null,Zv=``,Qv=null,$v=1,ey=new Set,ty=null,ny=!1,ry=0,iy=null,ay={};function oy(e){let t=[`#`,`flags`].filter(t=>e.columns.includes(t));return[...t,...e.columns.filter(e=>!t.includes(e))]}function sy(e){let t=Zv.trim().toLowerCase(),n=e.rows;if(t&&(n=n.filter(e=>Object.values(e).some(e=>e.toLowerCase().includes(t)))),ey.size&&(n=n.filter(e=>{let t=e.flags??``;return[...ey].every(e=>t.includes(e))})),Qv){let e=Qv;n=[...n].sort((t,n)=>{let r=t[e]??``,i=n[e]??``,a=Number(r),o=Number(i);return(r!==``&&i!==``&&!Number.isNaN(a)&&!Number.isNaN(o)?a-o:r.localeCompare(i))*$v})}return n}function cy(e){let t=new Set;for(let n of e.rows)for(let e of n.flags??``)t.add(e);return[...t].sort()}function ly(e){return Object.entries(e).filter(([e])=>e!==`#`&&e!==`flags`).map(([e,t])=>/\s/.test(t)?`${e}="${t}"`:`${e}=${t}`).join(` `)}function uy(e){let t=cy(e);return t.length?$(`div`,{class:`toolbar`},...t.map(t=>{let n=e.flags[t]??t,r=ey.has(t);return Wv(`${t} · ${n}`,()=>{r?ey.delete(t):ey.add(t),yy()},{class:r?`is-active`:``,title:`Filter rows flagged "${n}"`})})):!1}function dy(e){let t=$(`th`,e===`#`?{class:`col-num`}:{},e);return Qv===e&&t.append($(`span`,{class:`arrow`},$v===1?`▲`:`▼`)),t.addEventListener(`click`,()=>{Qv===e?$v=$v===1?-1:1:(Qv=e,$v=1),yy()}),t}function fy(e,t){let n=oy(e),r=$(`thead`,{},$(`tr`,{},...n.map(dy))),i=$(`tbody`);return t.forEach(t=>{let r=$(`tr`,(t.flags??``).includes(`X`)?{class:`is-disabled`}:{});for(let e of n)r.append($(`td`,e===`#`?{class:`col-num`}:{},t[e]??`—`));r.addEventListener(`click`,()=>{ty=e.rows.indexOf(t),yy()}),i.append(r)}),$(`div`,{class:`tablewrap`},$(`table`,{class:`tbl`},r,i))}function py(e){let t=$(`div`,{class:`kv__body`});for(let[n,r]of Object.entries(e))t.append($(`div`,{class:`kv__k`},n),$(`div`,{class:`kv__v`},r||`—`));return t}function my(e){if(ty==null||!e.rows[ty])return!1;let t=e.rows[ty],n=t.name??t[`#`]??`record`;return $(`div`,{class:`drawer`},$(`div`,{class:`drawer__hd`},$(`span`,{},`Row `),$(`b`,{},String(n)),$(`span`,{class:`hd__spacer`}),Wv(`Copy as CLI`,()=>void Gv(ly(t)),{title:`Copy key=value pairs`}),Wv(`Close`,()=>{ty=null,yy()})),py(t))}function hy(e,t){let n=$(`input`,{class:`search`,type:`search`,placeholder:`Search ${e.count} row${e.count===1?``:`s`}…`,value:Zv});n.addEventListener(`input`,()=>{Zv=n.value,ty=null,_y()});let r=$(`select`,{class:`btn`,title:`Auto-refresh interval`});for(let[e,t]of[[`Auto: off`,`0`],[`Auto: 5s`,`5000`],[`Auto: 15s`,`15000`],[`Auto: 60s`,`60000`]]){let n=$(`option`,{value:t},e);Number(t)===ry&&(n.selected=!0),r.append(n)}r.addEventListener(`change`,()=>Cy(Number(r.value)));let i=()=>sy(e),a=oy(e);return $(`div`,{class:`toolbar`},$(`div`,{class:`grow`},n),Wv(ny?`Refreshing…`:`↻ Refresh`,Sy,{disabled:ny}),r,Wv(`CSV`,()=>Kv(`${e.tool}.csv`,qv(a,i()),`text/csv`),{title:`Export visible rows as CSV`}),Wv(`JSON`,()=>Kv(`${e.tool}.json`,JSON.stringify(i(),null,2),`application/json`),{title:`Export visible rows as JSON`}),Wv(`Copy`,()=>void Gv(JSON.stringify(i(),null,2)),{title:`Copy visible rows as JSON`}),$(`span`,{class:`pill count-pill`},`showing `,$(`b`,{},`${t}/${e.count}`)))}function gy(e){return $(`header`,{class:`hd`},$(`span`,{class:`hd__dot`}),$(`div`,{},$(`h1`,{class:`hd__title`},e.title),$(`p`,{class:`hd__sub`},e.tool)),$(`span`,{class:`hd__spacer`}))}function _y(){if(!Xv)return;let e=document.getElementById(`results`);if(!e){yy();return}e.replaceChildren(vy(Xv));let t=document.querySelector(`.count-pill b`);t&&(t.textContent=`${sy(Xv).length}/${Xv.count}`)}function vy(e){let t=sy(e);return e.rows.length===0?e.raw?$(`pre`,{class:`raw`},e.raw):$(`div`,{class:`empty`},`No records returned.`):e.kind===`record`&&e.rows.length===1?py(e.rows[0]):t.length===0?$(`div`,{class:`empty`},`No rows match the current filter.`):fy(e,t)}function yy(){if(!Xv){Yv.replaceChildren($(`div`,{class:`skeleton`},`Waiting for data…`));return}let e=Xv,t=sy(e).length,n=e.kind===`list`&&e.rows.length>0,r=[gy(e),n&&hy(e,t),n&&uy(e),$(`div`,{id:`results`},vy(e)),my(e),$(`footer`,{class:`foot`},$(`span`,{},`format: ${e.format}`),$(`span`,{class:`grow`}),$(`span`,{},`updated ${new Date(e.generatedAt).toLocaleTimeString()}`))];Yv.replaceChildren(...r.filter(Boolean))}var by=new Uv({name:`mikrotik-records`,version:`1.0.0`});function xy(e){e&&typeof e==`object`&&e.__mikrotikView===`records`&&(Xv=e,ty=null,yy())}async function Sy(){if(!(ny||!Xv)){ny=!0,yy();try{xy((await by.callServerTool({name:Xv.tool,arguments:ay})).structuredContent)}catch(e){console.error(`[records] refresh failed`,e)}finally{ny=!1,yy()}}}function Cy(e){ry=e,iy&&=(clearInterval(iy),null),e>0&&(iy=setInterval(()=>void Sy(),e)),yy()}by.ontoolresult=e=>xy(e.structuredContent),by.ontoolinput=e=>{e&&typeof e==`object`&&`arguments`in e&&(ay=e.arguments??{}),Xv||yy()},Jv(by),by.onteardown=async()=>(iy&&clearInterval(iy),{}),yy(),by.connect().catch(e=>console.error(`[records] connect failed`,e));
120
+ `)}\n`}function Jv(e){e.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(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`}},Bv(zv())}var Yv=document.getElementById(`app`),Xv=null,Zv=``,Qv=null,$v=1,ey=new Set,ty=null,ny=!1,ry=0,iy=null,ay={};function oy(e){let t=[`#`,`flags`].filter(t=>e.columns.includes(t));return[...t,...e.columns.filter(e=>!t.includes(e))]}function sy(e){let t=Zv.trim().toLowerCase(),n=e.rows;if(t&&(n=n.filter(e=>Object.values(e).some(e=>e.toLowerCase().includes(t)))),ey.size&&(n=n.filter(e=>{let t=e.flags??``;return[...ey].every(e=>t.includes(e))})),Qv){let e=Qv;n=[...n].sort((t,n)=>{let r=t[e]??``,i=n[e]??``,a=Number(r),o=Number(i);return(r!==``&&i!==``&&!Number.isNaN(a)&&!Number.isNaN(o)?a-o:r.localeCompare(i))*$v})}return n}function cy(e){let t=new Set;for(let n of e.rows)for(let e of n.flags??``)t.add(e);return[...t].sort()}function ly(e){return Object.entries(e).filter(([e])=>e!==`#`&&e!==`flags`).map(([e,t])=>/\s/.test(t)?`${e}="${t}"`:`${e}=${t}`).join(` `)}function uy(e){let t=cy(e);return t.length?$(`div`,{class:`toolbar`},...t.map(t=>{let n=e.flags[t]??t,r=ey.has(t);return Wv(`${t} · ${n}`,()=>{r?ey.delete(t):ey.add(t),yy()},{class:r?`is-active`:``,title:`Filter rows flagged "${n}"`})})):!1}function dy(e){let t=$(`th`,e===`#`?{class:`col-num`}:{},e);return Qv===e&&t.append($(`span`,{class:`arrow`},$v===1?`▲`:`▼`)),t.addEventListener(`click`,()=>{Qv===e?$v=$v===1?-1:1:(Qv=e,$v=1),yy()}),t}function fy(e,t){let n=oy(e),r=$(`thead`,{},$(`tr`,{},...n.map(dy))),i=$(`tbody`);return t.forEach(t=>{let r=$(`tr`,(t.flags??``).includes(`X`)?{class:`is-disabled`}:{});for(let e of n)r.append($(`td`,e===`#`?{class:`col-num`}:{},t[e]??`—`));r.addEventListener(`click`,()=>{ty=e.rows.indexOf(t),yy()}),i.append(r)}),$(`div`,{class:`tablewrap`},$(`table`,{class:`tbl`},r,i))}function py(e){let t=$(`div`,{class:`kv__body`});for(let[n,r]of Object.entries(e))t.append($(`div`,{class:`kv__k`},n),$(`div`,{class:`kv__v`},r||`—`));return t}function my(e){if(ty==null||!e.rows[ty])return!1;let t=e.rows[ty],n=t.name??t[`#`]??`record`;return $(`div`,{class:`drawer`},$(`div`,{class:`drawer__hd`},$(`span`,{},`Row `),$(`b`,{},String(n)),$(`span`,{class:`hd__spacer`}),Wv(`Copy as CLI`,()=>void Gv(ly(t)),{title:`Copy key=value pairs`}),Wv(`Close`,()=>{ty=null,yy()})),py(t))}function hy(e,t){let n=$(`input`,{class:`search`,type:`search`,placeholder:`Search ${e.count} row${e.count===1?``:`s`}…`,value:Zv});n.addEventListener(`input`,()=>{Zv=n.value,ty=null,_y()});let r=$(`select`,{class:`btn`,title:`Auto-refresh interval`});for(let[e,t]of[[`Auto: off`,`0`],[`Auto: 5s`,`5000`],[`Auto: 15s`,`15000`],[`Auto: 60s`,`60000`]]){let n=$(`option`,{value:t},e);Number(t)===ry&&(n.selected=!0),r.append(n)}r.addEventListener(`change`,()=>Cy(Number(r.value)));let i=()=>sy(e),a=oy(e);return $(`div`,{class:`toolbar`},$(`div`,{class:`grow`},n),Wv(ny?`Refreshing…`:`↻ Refresh`,Sy,{disabled:ny}),r,Wv(`CSV`,()=>Kv(`${e.tool}.csv`,qv(a,i()),`text/csv`),{title:`Export visible rows as CSV`}),Wv(`JSON`,()=>Kv(`${e.tool}.json`,JSON.stringify(i(),null,2),`application/json`),{title:`Export visible rows as JSON`}),Wv(`Copy`,()=>void Gv(JSON.stringify(i(),null,2)),{title:`Copy visible rows as JSON`}),$(`span`,{class:`pill count-pill`},`showing `,$(`b`,{},`${t}/${e.count}`)))}function gy(e){return $(`header`,{class:`hd`},$(`span`,{class:`hd__dot`}),$(`div`,{},$(`h1`,{class:`hd__title`},e.title),$(`p`,{class:`hd__sub`},e.tool)),$(`span`,{class:`hd__spacer`}))}function _y(){if(!Xv)return;let e=document.getElementById(`results`);if(!e){yy();return}e.replaceChildren(vy(Xv));let t=document.querySelector(`.count-pill b`);t&&(t.textContent=`${sy(Xv).length}/${Xv.count}`)}function vy(e){let t=sy(e);return e.rows.length===0?e.raw?$(`pre`,{class:`raw`},e.raw):$(`div`,{class:`empty`},`No records returned.`):e.kind===`record`&&e.rows.length===1?py(e.rows[0]):t.length===0?$(`div`,{class:`empty`},`No rows match the current filter.`):fy(e,t)}function yy(){if(!Xv){Yv.replaceChildren($(`div`,{class:`skeleton`},`Waiting for data…`));return}let e=Xv,t=sy(e).length,n=e.kind===`list`&&e.rows.length>0,r=[gy(e),n&&hy(e,t),n&&uy(e),$(`div`,{id:`results`},vy(e)),my(e),$(`footer`,{class:`foot`},$(`span`,{},`format: ${e.format}`),$(`span`,{class:`grow`}),$(`span`,{},`updated ${new Date(e.generatedAt).toLocaleTimeString()}`))];Yv.replaceChildren(...r.filter(Boolean))}var by=new Uv({name:`mikrotik-records`,version:`1.0.0`});function xy(e){e&&typeof e==`object`&&e.__mikrotikView===`records`&&(Xv=e,ty=null,yy())}async function Sy(){if(!(ny||!Xv)){ny=!0,yy();try{xy((await by.callServerTool({name:Xv.tool,arguments:ay})).structuredContent)}catch(e){console.error(`[records] refresh failed`,e)}finally{ny=!1,yy()}}}function Cy(e){ry=e,iy&&=(clearInterval(iy),null),e>0&&(iy=setInterval(()=>void Sy(),e)),yy()}by.ontoolresult=e=>{console.debug(`[records] ontoolresult fired`,e),xy(e.structuredContent)},by.ontoolinput=e=>{e&&typeof e==`object`&&`arguments`in e&&(ay=e.arguments??{}),Xv||yy()},Jv(by),by.onteardown=async()=>(iy&&clearInterval(iy),{}),yy(),by.connect().then(()=>console.debug(`[records] connect OK`,{hostCaps:by.getHostCapabilities()})).catch(e=>console.error(`[records] connect failed`,e));
121
121
  </script>
122
122
  <style>
123
123
  :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:960px;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}.toolbar{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.toolbar .grow{flex:1;min-width:140px}.search{appearance:none;border:1px solid var(--mt-border);background:var(--mt-surface);width:100%;color:var(--mt-text);font:inherit;border-radius:var(--mt-radius-sm);padding:7px 11px;font-size:13px}.search:focus{border-color:var(--mt-accent);outline:none}.search::placeholder{color:var(--mt-text-faint)}.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;white-space:nowrap;padding:6px 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}.btn.is-active{border-color:var(--mt-accent);color:var(--mt-accent)}.chip{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:4px;padding:1px 7px;font-size:11px;display:inline-flex}.chip.is-good{color:var(--mt-good);border-color:color-mix(in srgb, var(--mt-good) 45%, var(--mt-border))}.chip.is-warn{color:var(--mt-warn);border-color:color-mix(in srgb, var(--mt-warn) 45%, var(--mt-border))}.chip.is-bad{color:var(--mt-bad);border-color:color-mix(in srgb, var(--mt-bad) 45%, var(--mt-border))}.tablewrap{border:1px solid var(--mt-border);border-radius:var(--mt-radius);max-height:70vh;overflow:auto}table.tbl{border-collapse:collapse;width:100%;font-size:12px}table.tbl th,table.tbl td{text-align:left;border-bottom:1px solid color-mix(in srgb, var(--mt-border) 55%, transparent);white-space:nowrap;font-family:var(--mt-mono);padding:7px 12px}table.tbl thead th{z-index:1;background:var(--mt-surface-2);color:var(--mt-text-dim);cursor:pointer;-webkit-user-select:none;user-select:none;font-weight:600;position:sticky;top:0}table.tbl thead th:hover{color:var(--mt-text)}table.tbl thead th .arrow{color:var(--mt-accent);margin-left:4px}table.tbl tbody tr{cursor:pointer}table.tbl tbody tr:hover{background:color-mix(in srgb, var(--mt-accent) 8%, transparent)}table.tbl tbody tr.is-disabled td,table.tbl td.col-num{color:var(--mt-text-faint)}.kv__body{border:1px solid var(--mt-border);border-radius:var(--mt-radius);grid-template-columns:minmax(120px,.4fr) 1fr;display:grid;overflow:hidden}.kv__body>div{border-bottom:1px solid color-mix(in srgb, var(--mt-border) 55%, transparent);overflow-wrap:anywhere;min-width:0;font-size:12px;font-family:var(--mt-mono);padding:7px 14px}.kv__k{color:var(--mt-text-dim);background:color-mix(in srgb, var(--mt-surface) 60%, transparent)}.kv__v{color:var(--mt-text)}.drawer{border:1px solid var(--mt-accent);border-radius:var(--mt-radius);background:var(--mt-surface);gap:10px;padding:12px;display:grid}.drawer__hd{align-items:center;gap:8px;display:flex}.drawer__hd b{font-family:var(--mt-mono)}pre.raw{border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);color:var(--mt-text);font-family:var(--mt-mono);white-space:pre;max-height:70vh;margin:0;padding:14px;font-size:12px;overflow:auto}.foot{color:var(--mt-text-faint);font-size:11px;font-family:var(--mt-mono);flex-wrap:wrap;align-items:center;gap:10px;display:flex}.foot .grow{flex:1}.skeleton,.empty{color:var(--mt-text-faint);text-align:center;padding:40px 0}.count-pill b{color:var(--mt-accent)}table.tbl td.col-num,table.tbl th.col-num{width:1%}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usex/mikrotik-mcp",
3
- "version": "3.57.0",
3
+ "version": "3.58.0",
4
4
  "description": "MCP server for MikroTik RouterOS — 660+ tools over SSH for firewall, NAT, routing, DHCP, DNS, WireGuard, wireless, QoS and more.",
5
5
  "keywords": [
6
6
  "ai",