@modelcontextprotocol/server-budget-allocator 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp-app.html +2 -2
- package/dist/server.js +43 -39
- package/package.json +1 -1
package/dist/mcp-app.html
CHANGED
|
@@ -64,7 +64,7 @@ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Rec
|
|
|
64
64
|
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);v({method:_("ui/open-link"),params:v({url:y().describe("URL to open in the host's browser")})});var nm=v({isError:K().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),im=v({isError:K().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),sm=v({isError:K().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();v({method:_("ui/notifications/sandbox-proxy-ready"),params:v({})});var Ws=v({connectDomains:A(y()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
65
65
|
|
|
66
66
|
- Maps to CSP \`connect-src\` directive
|
|
67
|
-
- Empty or omitted → no network connections (secure default)`),resourceDomains:A(y()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:A(y()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:A(y()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),qs=v({camera:v({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:v({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:v({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:v({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});v({method:_("ui/notifications/size-changed"),params:v({width:$().optional().describe("New width in pixels."),height:$().optional().describe("New height in pixels.")})});var om=v({method:_("ui/notifications/tool-input"),params:v({arguments:Y(y(),J().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),rm=v({method:_("ui/notifications/tool-input-partial"),params:v({arguments:Y(y(),J().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),am=v({method:_("ui/notifications/tool-cancelled"),params:v({reason:y().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),cm=v({fonts:y().optional()}),lm=v({variables:em.optional().describe("CSS variables for theming the app."),css:cm.optional().describe("CSS blocks that apps can inject.")}),um=v({method:_("ui/resource-teardown"),params:v({})});Y(y(),J());var Lo=v({text:v({}).optional().describe("Host supports text content blocks."),image:v({}).optional().describe("Host supports image content blocks."),audio:v({}).optional().describe("Host supports audio content blocks."),resource:v({}).optional().describe("Host supports resource content blocks."),resourceLink:v({}).optional().describe("Host supports resource link content blocks."),structuredContent:v({}).optional().describe("Host supports structured content.")}),hm=v({experimental:v({}).optional().describe("Experimental features (structure TBD)."),openLinks:v({}).optional().describe("Host supports opening external URLs."),downloadFile:v({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:v({listChanged:K().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:v({listChanged:K().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:v({}).optional().describe("Host accepts log messages."),sandbox:v({permissions:qs.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Ws.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Lo.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Lo.optional().describe("Host supports receiving content messages (ui/message) from the view.")}),dm=v({experimental:v({}).optional().describe("Experimental features (structure TBD)."),tools:v({listChanged:K().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:A(un).optional().describe("Display modes the app supports.")});v({method:_("ui/notifications/initialized"),params:v({}).optional()});v({csp:Ws.optional().describe("Content Security Policy configuration for UI resources."),permissions:qs.optional().describe("Sandbox permissions requested by the UI resource."),domain:y().optional().describe(`Dedicated origin for view sandbox.
|
|
67
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:A(y()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:A(y()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:A(y()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),qs=v({camera:v({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:v({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:v({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:v({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});v({method:_("ui/notifications/size-changed"),params:v({width:$().optional().describe("New width in pixels."),height:$().optional().describe("New height in pixels.")})});var om=v({method:_("ui/notifications/tool-input"),params:v({arguments:Y(y(),J().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),rm=v({method:_("ui/notifications/tool-input-partial"),params:v({arguments:Y(y(),J().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),am=v({method:_("ui/notifications/tool-cancelled"),params:v({reason:y().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),cm=v({fonts:y().optional()}),lm=v({variables:em.optional().describe("CSS variables for theming the app."),css:cm.optional().describe("CSS blocks that apps can inject.")}),um=v({method:_("ui/resource-teardown"),params:v({})});Y(y(),J());var Lo=v({text:v({}).optional().describe("Host supports text content blocks."),image:v({}).optional().describe("Host supports image content blocks."),audio:v({}).optional().describe("Host supports audio content blocks."),resource:v({}).optional().describe("Host supports resource content blocks."),resourceLink:v({}).optional().describe("Host supports resource link content blocks."),structuredContent:v({}).optional().describe("Host supports structured content.")});v({method:_("ui/notifications/request-teardown"),params:v({}).optional()});var hm=v({experimental:v({}).optional().describe("Experimental features (structure TBD)."),openLinks:v({}).optional().describe("Host supports opening external URLs."),downloadFile:v({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:v({listChanged:K().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:v({listChanged:K().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:v({}).optional().describe("Host accepts log messages."),sandbox:v({permissions:qs.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Ws.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Lo.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Lo.optional().describe("Host supports receiving content messages (ui/message) from the view.")}),dm=v({experimental:v({}).optional().describe("Experimental features (structure TBD)."),tools:v({listChanged:K().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:A(un).optional().describe("Display modes the app supports.")});v({method:_("ui/notifications/initialized"),params:v({}).optional()});v({csp:Ws.optional().describe("Content Security Policy configuration for UI resources."),permissions:qs.optional().describe("Sandbox permissions requested by the UI resource."),domain:y().optional().describe(`Dedicated origin for view sandbox.
|
|
68
68
|
|
|
69
69
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
70
70
|
|
|
@@ -81,7 +81,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
81
81
|
- omitted: host decides border`)});v({method:_("ui/request-display-mode"),params:v({mode:un.describe("The display mode being requested.")})});var fm=v({mode:un.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),pm=F([_("model"),_("app")]).describe("Tool visibility scope - who can access the tool.");v({resourceUri:y().optional(),visibility:A(pm).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
82
82
|
- "model": Tool visible to and callable by the agent
|
|
83
83
|
- "app": Tool callable by the app from this server only`)});v({mimeTypes:A(y()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});v({method:_("ui/download-file"),params:v({contents:A(F([oc,rc])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});v({method:_("ui/message"),params:v({role:_("user").describe('Message role, currently only "user" is supported.'),content:A(Tn).describe("Message content blocks (text, image, etc.).")})});v({method:_("ui/notifications/sandbox-resource-ready"),params:v({html:y().describe("HTML content to load into the inner iframe."),sandbox:y().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Ws.optional().describe("CSP configuration from resource metadata."),permissions:qs.optional().describe("Sandbox permissions from resource metadata.")})});var gm=v({method:_("ui/notifications/tool-result"),params:Pi.describe("Standard MCP tool execution result.")}),uc=v({toolInfo:v({id:vn.optional().describe("JSON-RPC id of the tools/call request."),tool:Vs.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Qg.optional().describe("Current color theme preference."),styles:lm.optional().describe("Style configuration for theming the app."),displayMode:un.optional().describe("How the UI is currently displayed."),availableDisplayModes:A(un).optional().describe("Display modes the host supports."),containerDimensions:F([v({height:$().describe("Fixed container height in pixels.")}),v({maxHeight:F([$(),Gi()]).optional().describe("Maximum container height in pixels.")})]).and(F([v({width:$().describe("Fixed container width in pixels.")}),v({maxWidth:F([$(),Gi()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
84
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:y().optional().describe("User's language and region preference in BCP 47 format."),timeZone:y().optional().describe("User's timezone in IANA format."),userAgent:y().optional().describe("Host application identifier."),platform:F([_("web"),_("desktop"),_("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:v({touch:K().optional().describe("Whether the device supports touch input."),hover:K().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:v({top:$().describe("Top safe area inset in pixels."),right:$().describe("Right safe area inset in pixels."),bottom:$().describe("Bottom safe area inset in pixels."),left:$().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),mm=v({method:_("ui/notifications/host-context-changed"),params:uc.describe("Partial context update containing only changed fields.")});v({method:_("ui/update-model-context"),params:v({content:A(Tn).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:Y(y(),J().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});v({method:_("ui/initialize"),params:v({appInfo:Si.describe("App identification (name and version)."),appCapabilities:dm.describe("Features and capabilities this app provides."),protocolVersion:y().describe("Protocol version this app supports.")})});var bm=v({protocolVersion:y().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Si.describe("Host application identification and version."),hostCapabilities:hm.describe("Features and capabilities provided by the host."),hostContext:uc.describe("Rich context about the host environment.")}).passthrough();class _m extends Jg{constructor(n,i={},s={autoResize:!0}){super(s);T(this,"_appInfo");T(this,"_capabilities");T(this,"options");T(this,"_hostCapabilities");T(this,"_hostInfo");T(this,"_hostContext");T(this,"sendOpenLink",this.openLink);this._appInfo=n,this._capabilities=i,this.options=s,this.setRequestHandler(Mi,o=>(console.log("Received ping:",o.params),{})),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(n){this.setNotificationHandler(om,i=>n(i.params))}set ontoolinputpartial(n){this.setNotificationHandler(rm,i=>n(i.params))}set ontoolresult(n){this.setNotificationHandler(gm,i=>n(i.params))}set ontoolcancelled(n){this.setNotificationHandler(am,i=>n(i.params))}set onhostcontextchanged(n){this.setNotificationHandler(mm,i=>{this._hostContext={...this._hostContext,...i.params},n(i.params)})}set onteardown(n){this.setRequestHandler(um,(i,s)=>n(i.params,s))}set oncalltool(n){this.setRequestHandler(cc,(i,s)=>n(i.params,s))}set onlisttools(n){this.setRequestHandler(ac,(i,s)=>n(i.params,s))}assertCapabilityForMethod(n){}assertRequestHandlerCapability(n){switch(n){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${n})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${n} registered`)}}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(n,i){if(typeof n=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${n}"). Did you mean: callServerTool({ name: "${n}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:n},Pi,i)}async readServerResource(n,i){return await this.request({method:"resources/read",params:n},sc,i)}async listServerResources(n,i){return await this.request({method:"resources/list",params:n},ic,i)}sendMessage(n,i){return this.request({method:"ui/message",params:n},sm,i)}sendLog(n){return this.notification({method:"notifications/message",params:n})}updateModelContext(n,i){return this.request({method:"ui/update-model-context",params:n},Os,i)}openLink(n,i){return this.request({method:"ui/open-link",params:n},nm,i)}downloadFile(n,i){return this.request({method:"ui/download-file",params:n},im,i)}requestDisplayMode(n,i){return this.request({method:"ui/request-display-mode",params:n},fm,i)}sendSizeChanged(n){return this.notification({method:"ui/notifications/size-changed",params:n})}setupSizeChangedNotifications(){let n=!1,i=0,s=0,o=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1;let a=document.documentElement,c=a.style.width,l=a.style.height;a.style.width="fit-content",a.style.height="max-content";let u=a.getBoundingClientRect();a.style.width=c,a.style.height=l;let h=window.innerWidth-a.clientWidth,d=Math.ceil(u.width+h),f=Math.ceil(u.height);(d!==i||f!==s)&&(i=d,s=f,this.sendSizeChanged({width:d,height:f}))}))};o();let r=new ResizeObserver(o);return r.observe(document.documentElement),r.observe(document.body),()=>r.disconnect()}async connect(n=new Gg(window.parent,window.parent),i){var s;if(this.transport)throw Error("App is already connected. Call close() before connecting again.");await super.connect(n);try{let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:Xg}},bm,i);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),(s=this.options)!=null&&s.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}/*!
|
|
84
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:y().optional().describe("User's language and region preference in BCP 47 format."),timeZone:y().optional().describe("User's timezone in IANA format."),userAgent:y().optional().describe("Host application identifier."),platform:F([_("web"),_("desktop"),_("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:v({touch:K().optional().describe("Whether the device supports touch input."),hover:K().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:v({top:$().describe("Top safe area inset in pixels."),right:$().describe("Right safe area inset in pixels."),bottom:$().describe("Bottom safe area inset in pixels."),left:$().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),mm=v({method:_("ui/notifications/host-context-changed"),params:uc.describe("Partial context update containing only changed fields.")});v({method:_("ui/update-model-context"),params:v({content:A(Tn).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:Y(y(),J().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});v({method:_("ui/initialize"),params:v({appInfo:Si.describe("App identification (name and version)."),appCapabilities:dm.describe("Features and capabilities this app provides."),protocolVersion:y().describe("Protocol version this app supports.")})});var bm=v({protocolVersion:y().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Si.describe("Host application identification and version."),hostCapabilities:hm.describe("Features and capabilities provided by the host."),hostContext:uc.describe("Rich context about the host environment.")}).passthrough();class _m extends Jg{constructor(n,i={},s={autoResize:!0}){super(s);T(this,"_appInfo");T(this,"_capabilities");T(this,"options");T(this,"_hostCapabilities");T(this,"_hostInfo");T(this,"_hostContext");T(this,"sendOpenLink",this.openLink);this._appInfo=n,this._capabilities=i,this.options=s,this.setRequestHandler(Mi,o=>(console.log("Received ping:",o.params),{})),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(n){this.setNotificationHandler(om,i=>n(i.params))}set ontoolinputpartial(n){this.setNotificationHandler(rm,i=>n(i.params))}set ontoolresult(n){this.setNotificationHandler(gm,i=>n(i.params))}set ontoolcancelled(n){this.setNotificationHandler(am,i=>n(i.params))}set onhostcontextchanged(n){this.setNotificationHandler(mm,i=>{this._hostContext={...this._hostContext,...i.params},n(i.params)})}set onteardown(n){this.setRequestHandler(um,(i,s)=>n(i.params,s))}set oncalltool(n){this.setRequestHandler(cc,(i,s)=>n(i.params,s))}set onlisttools(n){this.setRequestHandler(ac,(i,s)=>n(i.params,s))}assertCapabilityForMethod(n){}assertRequestHandlerCapability(n){switch(n){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${n})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${n} registered`)}}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(n,i){if(typeof n=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${n}"). Did you mean: callServerTool({ name: "${n}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:n},Pi,i)}async readServerResource(n,i){return await this.request({method:"resources/read",params:n},sc,i)}async listServerResources(n,i){return await this.request({method:"resources/list",params:n},ic,i)}sendMessage(n,i){return this.request({method:"ui/message",params:n},sm,i)}sendLog(n){return this.notification({method:"notifications/message",params:n})}updateModelContext(n,i){return this.request({method:"ui/update-model-context",params:n},Os,i)}openLink(n,i){return this.request({method:"ui/open-link",params:n},nm,i)}downloadFile(n,i){return this.request({method:"ui/download-file",params:n},im,i)}requestTeardown(n={}){return this.notification({method:"ui/notifications/request-teardown",params:n})}requestDisplayMode(n,i){return this.request({method:"ui/request-display-mode",params:n},fm,i)}sendSizeChanged(n){return this.notification({method:"ui/notifications/size-changed",params:n})}setupSizeChangedNotifications(){let n=!1,i=0,s=0,o=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1;let a=document.documentElement,c=a.style.width,l=a.style.height;a.style.width="fit-content",a.style.height="max-content";let u=a.getBoundingClientRect();a.style.width=c,a.style.height=l;let h=window.innerWidth-a.clientWidth,d=Math.ceil(u.width+h),f=Math.ceil(u.height);(d!==i||f!==s)&&(i=d,s=f,this.sendSizeChanged({width:d,height:f}))}))};o();let r=new ResizeObserver(o);return r.observe(document.documentElement),r.observe(document.body),()=>r.disconnect()}async connect(n=new Gg(window.parent,window.parent),i){var s;if(this.transport)throw Error("App is already connected. Call close() before connecting again.");await super.connect(n);try{let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:Xg}},bm,i);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),(s=this.options)!=null&&s.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}/*!
|
|
85
85
|
* @kurkle/color v0.3.4
|
|
86
86
|
* https://github.com/kurkle/color#readme
|
|
87
87
|
* (c) 2024 Jukka Kurkela
|
package/dist/server.js
CHANGED
|
@@ -28265,8 +28265,8 @@ class j {
|
|
|
28265
28265
|
sessionId;
|
|
28266
28266
|
setProtocolVersion;
|
|
28267
28267
|
}
|
|
28268
|
-
var
|
|
28269
|
-
var
|
|
28268
|
+
var g = exports_external.union([exports_external.literal("light"), exports_external.literal("dark")]).describe("Color theme preference for the host environment.");
|
|
28269
|
+
var G = exports_external.union([exports_external.literal("inline"), exports_external.literal("fullscreen"), exports_external.literal("pip")]).describe("Display mode for UI presentation.");
|
|
28270
28270
|
var i = exports_external.union([exports_external.literal("--color-background-primary"), exports_external.literal("--color-background-secondary"), exports_external.literal("--color-background-tertiary"), exports_external.literal("--color-background-inverse"), exports_external.literal("--color-background-ghost"), exports_external.literal("--color-background-info"), exports_external.literal("--color-background-danger"), exports_external.literal("--color-background-success"), exports_external.literal("--color-background-warning"), exports_external.literal("--color-background-disabled"), exports_external.literal("--color-text-primary"), exports_external.literal("--color-text-secondary"), exports_external.literal("--color-text-tertiary"), exports_external.literal("--color-text-inverse"), exports_external.literal("--color-text-ghost"), exports_external.literal("--color-text-info"), exports_external.literal("--color-text-danger"), exports_external.literal("--color-text-success"), exports_external.literal("--color-text-warning"), exports_external.literal("--color-text-disabled"), exports_external.literal("--color-border-primary"), exports_external.literal("--color-border-secondary"), exports_external.literal("--color-border-tertiary"), exports_external.literal("--color-border-inverse"), exports_external.literal("--color-border-ghost"), exports_external.literal("--color-border-info"), exports_external.literal("--color-border-danger"), exports_external.literal("--color-border-success"), exports_external.literal("--color-border-warning"), exports_external.literal("--color-border-disabled"), exports_external.literal("--color-ring-primary"), exports_external.literal("--color-ring-secondary"), exports_external.literal("--color-ring-inverse"), exports_external.literal("--color-ring-info"), exports_external.literal("--color-ring-danger"), exports_external.literal("--color-ring-success"), exports_external.literal("--color-ring-warning"), exports_external.literal("--font-sans"), exports_external.literal("--font-mono"), exports_external.literal("--font-weight-normal"), exports_external.literal("--font-weight-medium"), exports_external.literal("--font-weight-semibold"), exports_external.literal("--font-weight-bold"), exports_external.literal("--font-text-xs-size"), exports_external.literal("--font-text-sm-size"), exports_external.literal("--font-text-md-size"), exports_external.literal("--font-text-lg-size"), exports_external.literal("--font-heading-xs-size"), exports_external.literal("--font-heading-sm-size"), exports_external.literal("--font-heading-md-size"), exports_external.literal("--font-heading-lg-size"), exports_external.literal("--font-heading-xl-size"), exports_external.literal("--font-heading-2xl-size"), exports_external.literal("--font-heading-3xl-size"), exports_external.literal("--font-text-xs-line-height"), exports_external.literal("--font-text-sm-line-height"), exports_external.literal("--font-text-md-line-height"), exports_external.literal("--font-text-lg-line-height"), exports_external.literal("--font-heading-xs-line-height"), exports_external.literal("--font-heading-sm-line-height"), exports_external.literal("--font-heading-md-line-height"), exports_external.literal("--font-heading-lg-line-height"), exports_external.literal("--font-heading-xl-line-height"), exports_external.literal("--font-heading-2xl-line-height"), exports_external.literal("--font-heading-3xl-line-height"), exports_external.literal("--border-radius-xs"), exports_external.literal("--border-radius-sm"), exports_external.literal("--border-radius-md"), exports_external.literal("--border-radius-lg"), exports_external.literal("--border-radius-xl"), exports_external.literal("--border-radius-full"), exports_external.literal("--border-width-regular"), exports_external.literal("--shadow-hairline"), exports_external.literal("--shadow-sm"), exports_external.literal("--shadow-md"), exports_external.literal("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming.");
|
|
28271
28271
|
var o = exports_external.record(i.describe(`Style variables for theming MCP apps.
|
|
28272
28272
|
|
|
@@ -28301,15 +28301,16 @@ var t = exports_external.object({ method: exports_external.literal("ui/notificat
|
|
|
28301
28301
|
var A = exports_external.object({ method: exports_external.literal("ui/notifications/tool-input"), params: exports_external.object({ arguments: exports_external.record(exports_external.string(), exports_external.unknown().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.") }) });
|
|
28302
28302
|
var P = exports_external.object({ method: exports_external.literal("ui/notifications/tool-input-partial"), params: exports_external.object({ arguments: exports_external.record(exports_external.string(), exports_external.unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).") }) });
|
|
28303
28303
|
var H = exports_external.object({ method: exports_external.literal("ui/notifications/tool-cancelled"), params: exports_external.object({ reason: exports_external.string().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").') }) });
|
|
28304
|
-
var
|
|
28305
|
-
var
|
|
28304
|
+
var S = exports_external.object({ fonts: exports_external.string().optional() });
|
|
28305
|
+
var y = exports_external.object({ variables: o.optional().describe("CSS variables for theming the app."), css: S.optional().describe("CSS blocks that apps can inject.") });
|
|
28306
28306
|
var _ = exports_external.object({ method: exports_external.literal("ui/resource-teardown"), params: exports_external.object({}) });
|
|
28307
28307
|
var e = exports_external.record(exports_external.string(), exports_external.unknown());
|
|
28308
28308
|
var q = exports_external.object({ text: exports_external.object({}).optional().describe("Host supports text content blocks."), image: exports_external.object({}).optional().describe("Host supports image content blocks."), audio: exports_external.object({}).optional().describe("Host supports audio content blocks."), resource: exports_external.object({}).optional().describe("Host supports resource content blocks."), resourceLink: exports_external.object({}).optional().describe("Host supports resource link content blocks."), structuredContent: exports_external.object({}).optional().describe("Host supports structured content.") });
|
|
28309
|
-
var
|
|
28310
|
-
var
|
|
28311
|
-
var
|
|
28312
|
-
var ZQ = exports_external.object({
|
|
28309
|
+
var QQ = exports_external.object({ method: exports_external.literal("ui/notifications/request-teardown"), params: exports_external.object({}).optional() });
|
|
28310
|
+
var C = exports_external.object({ experimental: exports_external.object({}).optional().describe("Experimental features (structure TBD)."), openLinks: exports_external.object({}).optional().describe("Host supports opening external URLs."), downloadFile: exports_external.object({}).optional().describe("Host supports file downloads via ui/download-file."), serverTools: exports_external.object({ listChanged: exports_external.boolean().optional().describe("Host supports tools/list_changed notifications.") }).optional().describe("Host can proxy tool calls to the MCP server."), serverResources: exports_external.object({ listChanged: exports_external.boolean().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."), logging: exports_external.object({}).optional().describe("Host accepts log messages."), sandbox: exports_external.object({ permissions: K.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."), csp: B.optional().describe("CSP domains approved by the host.") }).optional().describe("Sandbox configuration applied by the host."), updateModelContext: q.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."), message: q.optional().describe("Host supports receiving content messages (ui/message) from the view.") });
|
|
28311
|
+
var f = exports_external.object({ experimental: exports_external.object({}).optional().describe("Experimental features (structure TBD)."), tools: exports_external.object({ listChanged: exports_external.boolean().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."), availableDisplayModes: exports_external.array(G).optional().describe("Display modes the app supports.") });
|
|
28312
|
+
var ZQ = exports_external.object({ method: exports_external.literal("ui/notifications/initialized"), params: exports_external.object({}).optional() });
|
|
28313
|
+
var $Q = exports_external.object({ csp: B.optional().describe("Content Security Policy configuration for UI resources."), permissions: K.optional().describe("Sandbox permissions requested by the UI resource."), domain: exports_external.string().optional().describe(`Dedicated origin for view sandbox.
|
|
28313
28314
|
|
|
28314
28315
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
28315
28316
|
|
|
@@ -28324,27 +28325,27 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
28324
28325
|
- \`true\`: request visible border + background
|
|
28325
28326
|
- \`false\`: request no visible border + background
|
|
28326
28327
|
- omitted: host decides border`) });
|
|
28327
|
-
var
|
|
28328
|
-
var T = exports_external.object({ mode:
|
|
28329
|
-
var
|
|
28330
|
-
var
|
|
28328
|
+
var JQ = exports_external.object({ method: exports_external.literal("ui/request-display-mode"), params: exports_external.object({ mode: G.describe("The display mode being requested.") }) });
|
|
28329
|
+
var T = exports_external.object({ mode: G.describe("The display mode that was actually set. May differ from requested if not supported.") }).passthrough();
|
|
28330
|
+
var u = exports_external.union([exports_external.literal("model"), exports_external.literal("app")]).describe("Tool visibility scope - who can access the tool.");
|
|
28331
|
+
var XQ = exports_external.object({ resourceUri: exports_external.string().optional(), visibility: exports_external.array(u).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
28331
28332
|
- "model": Tool visible to and callable by the agent
|
|
28332
28333
|
- "app": Tool callable by the app from this server only`) });
|
|
28333
|
-
var
|
|
28334
|
-
var
|
|
28335
|
-
var
|
|
28336
|
-
var
|
|
28337
|
-
var
|
|
28338
|
-
var k = exports_external.object({ toolInfo: exports_external.object({ id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."), tool: ToolSchema.describe("Tool definition including name, inputSchema, etc.") }).optional().describe("Metadata of the tool call that instantiated this App."), theme:
|
|
28334
|
+
var RQ = exports_external.object({ mimeTypes: exports_external.array(exports_external.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.') });
|
|
28335
|
+
var VQ = exports_external.object({ method: exports_external.literal("ui/download-file"), params: exports_external.object({ contents: exports_external.array(exports_external.union([EmbeddedResourceSchema, ResourceLinkSchema])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.") }) });
|
|
28336
|
+
var DQ = exports_external.object({ method: exports_external.literal("ui/message"), params: exports_external.object({ role: exports_external.literal("user").describe('Message role, currently only "user" is supported.'), content: exports_external.array(ContentBlockSchema).describe("Message content blocks (text, image, etc.).") }) });
|
|
28337
|
+
var GQ = exports_external.object({ method: exports_external.literal("ui/notifications/sandbox-resource-ready"), params: exports_external.object({ html: exports_external.string().describe("HTML content to load into the inner iframe."), sandbox: exports_external.string().optional().describe("Optional override for the inner iframe's sandbox attribute."), csp: B.optional().describe("CSP configuration from resource metadata."), permissions: K.optional().describe("Sandbox permissions from resource metadata.") }) });
|
|
28338
|
+
var E = exports_external.object({ method: exports_external.literal("ui/notifications/tool-result"), params: CallToolResultSchema.describe("Standard MCP tool execution result.") });
|
|
28339
|
+
var k = exports_external.object({ toolInfo: exports_external.object({ id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."), tool: ToolSchema.describe("Tool definition including name, inputSchema, etc.") }).optional().describe("Metadata of the tool call that instantiated this App."), theme: g.optional().describe("Current color theme preference."), styles: y.optional().describe("Style configuration for theming the app."), displayMode: G.optional().describe("How the UI is currently displayed."), availableDisplayModes: exports_external.array(G).optional().describe("Display modes the host supports."), containerDimensions: exports_external.union([exports_external.object({ height: exports_external.number().describe("Fixed container height in pixels.") }), exports_external.object({ maxHeight: exports_external.union([exports_external.number(), exports_external.undefined()]).optional().describe("Maximum container height in pixels.") })]).and(exports_external.union([exports_external.object({ width: exports_external.number().describe("Fixed container width in pixels.") }), exports_external.object({ maxWidth: exports_external.union([exports_external.number(), exports_external.undefined()]).optional().describe("Maximum container width in pixels.") })])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
28339
28340
|
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`), locale: exports_external.string().optional().describe("User's language and region preference in BCP 47 format."), timeZone: exports_external.string().optional().describe("User's timezone in IANA format."), userAgent: exports_external.string().optional().describe("Host application identifier."), platform: exports_external.union([exports_external.literal("web"), exports_external.literal("desktop"), exports_external.literal("mobile")]).optional().describe("Platform type for responsive design decisions."), deviceCapabilities: exports_external.object({ touch: exports_external.boolean().optional().describe("Whether the device supports touch input."), hover: exports_external.boolean().optional().describe("Whether the device supports hover interactions.") }).optional().describe("Device input capabilities."), safeAreaInsets: exports_external.object({ top: exports_external.number().describe("Top safe area inset in pixels."), right: exports_external.number().describe("Right safe area inset in pixels."), bottom: exports_external.number().describe("Bottom safe area inset in pixels."), left: exports_external.number().describe("Left safe area inset in pixels.") }).optional().describe("Mobile safe area boundaries in pixels.") }).passthrough();
|
|
28340
|
-
var
|
|
28341
|
+
var R = exports_external.object({ method: exports_external.literal("ui/notifications/host-context-changed"), params: k.describe("Partial context update containing only changed fields.") });
|
|
28341
28342
|
var LQ = exports_external.object({ method: exports_external.literal("ui/update-model-context"), params: exports_external.object({ content: exports_external.array(ContentBlockSchema).optional().describe("Context content blocks (text, image, etc.)."), structuredContent: exports_external.record(exports_external.string(), exports_external.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.") }) });
|
|
28342
|
-
var
|
|
28343
|
-
var
|
|
28343
|
+
var WQ = exports_external.object({ method: exports_external.literal("ui/initialize"), params: exports_external.object({ appInfo: ImplementationSchema.describe("App identification (name and version)."), appCapabilities: f.describe("Features and capabilities this app provides."), protocolVersion: exports_external.string().describe("Protocol version this app supports.") }) });
|
|
28344
|
+
var U = exports_external.object({ protocolVersion: exports_external.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'), hostInfo: ImplementationSchema.describe("Host application identification and version."), hostCapabilities: C.describe("Features and capabilities provided by the host."), hostContext: k.describe("Rich context about the host environment.") }).passthrough();
|
|
28344
28345
|
var v = "ui/resourceUri";
|
|
28345
28346
|
var d = "text/html;profile=mcp-app";
|
|
28346
28347
|
|
|
28347
|
-
class
|
|
28348
|
+
class OQ extends Protocol {
|
|
28348
28349
|
_appInfo;
|
|
28349
28350
|
_capabilities;
|
|
28350
28351
|
options;
|
|
@@ -28376,13 +28377,13 @@ class qQ extends Protocol {
|
|
|
28376
28377
|
this.setNotificationHandler(P, ($) => Z($.params));
|
|
28377
28378
|
}
|
|
28378
28379
|
set ontoolresult(Z) {
|
|
28379
|
-
this.setNotificationHandler(
|
|
28380
|
+
this.setNotificationHandler(E, ($) => Z($.params));
|
|
28380
28381
|
}
|
|
28381
28382
|
set ontoolcancelled(Z) {
|
|
28382
28383
|
this.setNotificationHandler(H, ($) => Z($.params));
|
|
28383
28384
|
}
|
|
28384
28385
|
set onhostcontextchanged(Z) {
|
|
28385
|
-
this.setNotificationHandler(
|
|
28386
|
+
this.setNotificationHandler(R, ($) => {
|
|
28386
28387
|
this._hostContext = { ...this._hostContext, ...$.params }, Z($.params);
|
|
28387
28388
|
});
|
|
28388
28389
|
}
|
|
@@ -28444,6 +28445,9 @@ class qQ extends Protocol {
|
|
|
28444
28445
|
downloadFile(Z, $) {
|
|
28445
28446
|
return this.request({ method: "ui/download-file", params: Z }, I, $);
|
|
28446
28447
|
}
|
|
28448
|
+
requestTeardown(Z = {}) {
|
|
28449
|
+
return this.notification({ method: "ui/notifications/request-teardown", params: Z });
|
|
28450
|
+
}
|
|
28447
28451
|
requestDisplayMode(Z, $) {
|
|
28448
28452
|
return this.request({ method: "ui/request-display-mode", params: Z }, T, $);
|
|
28449
28453
|
}
|
|
@@ -28456,11 +28460,11 @@ class qQ extends Protocol {
|
|
|
28456
28460
|
return;
|
|
28457
28461
|
Z = true, requestAnimationFrame(() => {
|
|
28458
28462
|
Z = false;
|
|
28459
|
-
let V = document.documentElement,
|
|
28463
|
+
let V = document.documentElement, L = V.style.width, W = V.style.height;
|
|
28460
28464
|
V.style.width = "fit-content", V.style.height = "max-content";
|
|
28461
|
-
let
|
|
28462
|
-
V.style.width =
|
|
28463
|
-
let h = window.innerWidth - V.clientWidth, N = Math.ceil(
|
|
28465
|
+
let x = V.getBoundingClientRect();
|
|
28466
|
+
V.style.width = L, V.style.height = W;
|
|
28467
|
+
let h = window.innerWidth - V.clientWidth, N = Math.ceil(x.width + h), Y = Math.ceil(x.height);
|
|
28464
28468
|
if (N !== $ || Y !== J)
|
|
28465
28469
|
$ = N, J = Y, this.sendSizeChanged({ width: N, height: Y });
|
|
28466
28470
|
});
|
|
@@ -28474,7 +28478,7 @@ class qQ extends Protocol {
|
|
|
28474
28478
|
throw Error("App is already connected. Call close() before connecting again.");
|
|
28475
28479
|
await super.connect(Z);
|
|
28476
28480
|
try {
|
|
28477
|
-
let J = await this.request({ method: "ui/initialize", params: { appCapabilities: this._capabilities, appInfo: this._appInfo, protocolVersion: F } },
|
|
28481
|
+
let J = await this.request({ method: "ui/initialize", params: { appCapabilities: this._capabilities, appInfo: this._appInfo, protocolVersion: F } }, U, $);
|
|
28478
28482
|
if (J === undefined)
|
|
28479
28483
|
throw Error(`Server sent invalid initialize result: ${J}`);
|
|
28480
28484
|
if (this._hostCapabilities = J.hostCapabilities, this._hostInfo = J.hostInfo, this._hostContext = J.hostContext, await this.notification({ method: "ui/notifications/initialized" }), this.options?.autoResize)
|
|
@@ -28484,15 +28488,15 @@ class qQ extends Protocol {
|
|
|
28484
28488
|
}
|
|
28485
28489
|
}
|
|
28486
28490
|
}
|
|
28487
|
-
function
|
|
28488
|
-
let D = J._meta, V = D.ui,
|
|
28489
|
-
if (V?.resourceUri && !
|
|
28491
|
+
function hZ(Z, $, J, X) {
|
|
28492
|
+
let D = J._meta, V = D.ui, L = D[v], W = D;
|
|
28493
|
+
if (V?.resourceUri && !L)
|
|
28490
28494
|
W = { ...D, [v]: V.resourceUri };
|
|
28491
|
-
else if (
|
|
28492
|
-
W = { ...D, ui: { ...V, resourceUri:
|
|
28495
|
+
else if (L && !V?.resourceUri)
|
|
28496
|
+
W = { ...D, ui: { ...V, resourceUri: L } };
|
|
28493
28497
|
return Z.registerTool($, { ...J, _meta: W }, X);
|
|
28494
28498
|
}
|
|
28495
|
-
function
|
|
28499
|
+
function mZ(Z, $, J, X, D) {
|
|
28496
28500
|
return Z.registerResource($, J, { mimeType: d, ...X }, D);
|
|
28497
28501
|
}
|
|
28498
28502
|
|
|
@@ -28634,7 +28638,7 @@ function generateHistory(categories) {
|
|
|
28634
28638
|
const noise = (random() - 0.5) * 3;
|
|
28635
28639
|
rawAllocations[cat.id] = Math.max(0, Math.min(100, cat.defaultPercent + trend + noise));
|
|
28636
28640
|
}
|
|
28637
|
-
const total = Object.values(rawAllocations).reduce((a2,
|
|
28641
|
+
const total = Object.values(rawAllocations).reduce((a2, b) => a2 + b, 0);
|
|
28638
28642
|
const allocations = {};
|
|
28639
28643
|
for (const id of Object.keys(rawAllocations)) {
|
|
28640
28644
|
allocations[id] = Math.round(rawAllocations[id] / total * 1000) / 10;
|
|
@@ -28649,7 +28653,7 @@ function formatBudgetSummary(data) {
|
|
|
28649
28653
|
"==============================",
|
|
28650
28654
|
"",
|
|
28651
28655
|
`Default Budget: ${data.config.currencySymbol}${data.config.defaultBudget.toLocaleString()}`,
|
|
28652
|
-
`Available Presets: ${data.config.presetBudgets.map((
|
|
28656
|
+
`Available Presets: ${data.config.presetBudgets.map((b) => `${data.config.currencySymbol}${b.toLocaleString()}`).join(", ")}`,
|
|
28653
28657
|
"",
|
|
28654
28658
|
"Categories:",
|
|
28655
28659
|
...data.config.categories.map((c) => ` - ${c.name}: ${c.defaultPercent}% default`),
|
|
@@ -28667,7 +28671,7 @@ function createServer() {
|
|
|
28667
28671
|
name: "Budget Allocator Server",
|
|
28668
28672
|
version: "1.0.0"
|
|
28669
28673
|
});
|
|
28670
|
-
|
|
28674
|
+
hZ(server, "get-budget-data", {
|
|
28671
28675
|
title: "Get Budget Data",
|
|
28672
28676
|
description: "Returns budget configuration with 24 months of historical allocations and industry benchmarks by company stage",
|
|
28673
28677
|
inputSchema: {},
|
|
@@ -28704,7 +28708,7 @@ function createServer() {
|
|
|
28704
28708
|
structuredContent: response
|
|
28705
28709
|
};
|
|
28706
28710
|
});
|
|
28707
|
-
|
|
28711
|
+
mZ(server, resourceUri, resourceUri, {
|
|
28708
28712
|
mimeType: d,
|
|
28709
28713
|
description: "Interactive Budget Allocator UI"
|
|
28710
28714
|
}, async () => {
|