@tableau/mcp-server 2.24.0 → 3.0.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.
|
@@ -70,7 +70,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
70
70
|
- omitted: host decides border`)});h({method:u("ui/request-display-mode"),params:h({mode:lt.describe("The display mode being requested.")})});var gg=h({mode:lt.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),vg=C([u("model"),u("app")]).describe("Tool visibility scope - who can access the tool.");h({resourceUri:m().optional(),visibility:O(vg).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
71
71
|
- "model": Tool visible to and callable by the agent
|
|
72
72
|
- "app": Tool callable by the app from this server only`),csp:je().optional(),permissions:je().optional()});h({mimeTypes:O(m()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});h({method:u("ui/download-file"),params:h({contents:O(C([ed,td])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});h({method:u("ui/message"),params:h({role:u("user").describe('Message role, currently only "user" is supported.'),content:O(jt).describe("Message content blocks (text, image, etc.).")})});h({method:u("ui/notifications/sandbox-resource-ready"),params:h({html:m().describe("HTML content to load into the inner iframe."),sandbox:m().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Uo.optional().describe("CSP configuration from resource metadata."),permissions:Zo.optional().describe("Sandbox permissions from resource metadata.")})});var _g=h({method:u("ui/notifications/tool-result"),params:er.describe("Standard MCP tool execution result.")}),sd=h({toolInfo:h({id:xt.optional().describe("JSON-RPC id of the tools/call request."),tool:Po.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:ng.optional().describe("Current color theme preference."),styles:mg.optional().describe("Style configuration for theming the app."),displayMode:lt.optional().describe("How the UI is currently displayed."),availableDisplayModes:O(lt).optional().describe("Display modes the host supports."),containerDimensions:C([h({height:P().describe("Fixed container height in pixels.")}),h({maxHeight:C([P(),st()]).optional().describe("Maximum container height in pixels.")})]).and(C([h({width:P().describe("Fixed container width in pixels.")}),h({maxWidth:C([P(),st()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
73
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:m().optional().describe("User's language and region preference in BCP 47 format."),timeZone:m().optional().describe("User's timezone in IANA format."),userAgent:m().optional().describe("Host application identifier."),platform:C([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:h({touch:J().optional().describe("Whether the device supports touch input."),hover:J().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:h({top:P().describe("Top safe area inset in pixels."),right:P().describe("Right safe area inset in pixels."),bottom:P().describe("Bottom safe area inset in pixels."),left:P().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),yg=h({method:u("ui/notifications/host-context-changed"),params:sd.describe("Partial context update containing only changed fields.")});h({method:u("ui/update-model-context"),params:h({content:O(jt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:L(m(),B().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});h({method:u("ui/initialize"),params:h({appInfo:Yn.describe("App identification (name and version)."),appCapabilities:hg.describe("Features and capabilities this app provides."),protocolVersion:m().describe("Protocol version this app supports.")})});var bg=h({protocolVersion:m().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Yn.describe("Host application identification and version."),hostCapabilities:fg.describe("Features and capabilities provided by the host."),hostContext:sd.describe("Rich context about the host environment.")}).passthrough(),$g={target:"draft-2020-12"};async function Sa(n,e){let r=n["~standard"];if(r.jsonSchema)return r.jsonSchema[e]($g);if(r.vendor==="zod"){let{z:o}=await ld(()=>Promise.resolve().then(()=>uf),void 0,import.meta.url);return o.toJSONSchema(n,{io:e})}throw Error(`Schema (vendor: ${r.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 xa(n,e,r=""){let o=await n["~standard"].validate(e);if(o.issues){let t=o.issues.map(i=>{let a=i.path?.map(s=>typeof s=="object"?s.key:s).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(r+t)}return o.value}class Co extends Yh{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(e){if(this._initializedSent)return;let r=`[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(r);console.warn(`${r}. This will throw in a future release.`)}eventSchemas={toolinput:cg,toolinputpartial:ug,toolresult:_g,toolcancelled:lg,hostcontextchanged:yg};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!Co.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e)||(this._everHadListener.add(e),!this._initializedSent))return;let r=`[ext-apps] "${String(e)}" 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(r);console.warn(r)}setEventHandler(e,r){r&&this._assertHandlerTiming(e),super.setEventHandler(e,r)}addEventListener(e,r){this._assertHandlerTiming(e),super.addEventListener(e,r)}onEventDispatch(e,r){e==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...r})}constructor(e,r={},o={autoResize:!0}){super(o),this._appInfo=e,this._capabilities=r,this.options=o,o.allowUnsafeEval||ee({jitless:!0}),this.setRequestHandler(Xn,t=>(console.log("Received ping:",t.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=Qh(this._capabilities,e)}registerTool(e,r,o){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let t=this,i=()=>{t._initializedSent&&t._capabilities.tools?.listChanged&&t.sendToolListChanged()},a=r.inputSchema!==void 0,s={title:r.title,description:r.description,inputSchema:r.inputSchema,outputSchema:r.outputSchema,annotations:r.annotations,_meta:r._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(c){Object.assign(this,c),i()},remove(){t._registeredTools[e]===s&&(delete t._registeredTools[e],i())},handler:async(c,l)=>{if(!s.enabled)throw Error(`Tool ${e} is disabled`);let p;if(a){let f=s.inputSchema,b=f?await xa(f,c??{},`Invalid input for tool ${e}: `):c??{};p=await o(b,l)}else p=await o(l);return s.outputSchema&&!p.isError&&(p.structuredContent=await xa(s.outputSchema,p.structuredContent,`Invalid output for tool ${e}: `)),p}};return this._registeredTools[e]=s,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,r)=>{let o=this._registeredTools[e.name];if(!o)throw Error(`Tool ${e.name} not found`);return o.handler(e.arguments,r)},this.onlisttools=async(e,r)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,t])=>t.enabled).map(async([o,t])=>{let i={name:o,title:t.title,description:t.description,inputSchema:t.inputSchema?await Sa(t.inputSchema,"input"):{type:"object",properties:{}}};return t.outputSchema&&(i.outputSchema=await Sa(t.outputSchema,"output")),t.annotations&&(i.annotations=t.annotations),t._meta&&(i._meta=t._meta),i}))}))}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(pg,(r,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(r.params,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(rd,(r,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(r.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(nd,(r,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(r.params,o)})}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,r){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},er,{onprogress:()=>{},resetTimeoutOnProgress:!0,...r})}async readServerResource(e,r){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},Xl,r)}async listServerResources(e,r){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},Yl,r)}async createSamplingMessage(e,r){this._assertInitialized("createSamplingMessage");let o=e.tools?ad:od;return await this.request({method:"sampling/createMessage",params:e},o,r)}sendMessage(e,r){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},sg,r)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,r){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},_o,r)}openLink(e,r){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},og,r)}sendOpenLink=this.openLink;downloadFile(e,r){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},ag,r)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,r){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},gg,r)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,r=0,o=0,t=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let a=document.documentElement,s=a.style.height;a.style.height="max-content";let c=Math.ceil(a.getBoundingClientRect().height);a.style.height=s;let l=Math.ceil(window.innerWidth);(l!==r||c!==o)&&(r=l,o=c,this.sendSizeChanged({width:l,height:c}))}))};t();let i=new ResizeObserver(t);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new tg(window.parent,window.parent),r){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(e);try{let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:Xh}},bg,r);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"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}const kg="2.24.0",wg={version:kg},_r="tableauVizContainer";function Sg(n,e){const r=document.createElement("tableau-viz");return r.setAttribute("src",n),r.setAttribute("token",e),r.setAttribute("toolbar","hidden"),r}function xg(n,e,r){const o=document.getElementById(_r);if(!o){console.error(`[mcp-app] container element with id "${_r}" not found; cannot embed viz`);return}const t=Sg(n,e);t.addEventListener("firstvizsizeknown",i=>{const a=i.detail?.vizSize,s=a?.sheetSize?.maxSize?.height,c=a?.chromeHeight;if(typeof s!="number")return;const l=typeof c=="number"?c:0;t.style.height=`${s+l}px`}),t.addEventListener("vizloaderror",i=>{console.error("[mcp-app] tableau-viz reported a load error",i),r?.()}),o.replaceChildren(t)}const Ig=qe({content:Ua(qe({type:Za("text"),text:Gt()}))}),zg=qe({token:Gt()});async function Tg(n){if(!n.getHostCapabilities()?.serverTools)throw new Error("Cannot retrieve embed token: the MCP host does not support server tools (serverTools capability is unavailable).");const r=await n.callServerTool({name:"get-embed-token",arguments:{}});if(r.isError)throw new Error("Failed to get an embed token for the current authentication configuration.");const t=Ig.parse(r).content[0],i=JSON.parse(t.text);return zg.parse(i).token}function Og(n){return new Promise((e,r)=>{if(!("customElements"in window)){r(new Error("Custom elements are not available. Cannot access tableau-viz element"));return}if(customElements.get("tableau-viz")){e();return}const t=`${new URL(n).origin}/javascripts/api/tableau.embedding.3.latest.min.js`,i=document.createElement("script");i.type="module",i.src=t,i.onload=()=>{const a=customElements.whenDefined("tableau-viz"),s=new Promise((c,l)=>{setTimeout(()=>{l(new Error("Tableau Embedding API failed to load within 15 seconds"))},15e3)});Promise.race([a,s]).then(()=>e()).catch(c=>r(c))},i.onerror=()=>{console.error("Failed to load Tableau Embedding API from:",t),r(new Error(`Failed to load Tableau Embedding API from ${t}`))},document.head.appendChild(i)})}function Ia(n){if(n.querySelector(".open-in-tableau-error"))return;const e=document.createElement("div");e.className="open-in-tableau-error",e.textContent="The URL was unable to be opened.",n.appendChild(e)}function Ng(n){n.querySelector(".open-in-tableau-error")?.remove()}function jg(n,e,r){const o=r.querySelector("#openInTableauLink");o&&o.remove();const t=n.getHostCapabilities();if(!e||!t?.openLinks)return;const i=document.createElement("a");i.id="openInTableauLink",i.className="open-in-tableau",i.setAttribute("href",e),i.setAttribute("rel","noopener noreferrer"),i.setAttribute("aria-label","Open in Tableau (opens in a new browser tab)"),i.textContent="Open in Tableau ↗",i.onclick=async a=>{a.preventDefault();try{(await n.openLink({url:e})).isError?(console.warn("Open in Tableau link request denied by host",{url:e}),Ia(r)):Ng(r)}catch(s){console.warn("Open in Tableau link request failed",{url:e,error:s}),Ia(r)}},r.appendChild(i)}const Eg=`<svg width="171" height="165" viewBox="0 0 171 165" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
73
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:m().optional().describe("User's language and region preference in BCP 47 format."),timeZone:m().optional().describe("User's timezone in IANA format."),userAgent:m().optional().describe("Host application identifier."),platform:C([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:h({touch:J().optional().describe("Whether the device supports touch input."),hover:J().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:h({top:P().describe("Top safe area inset in pixels."),right:P().describe("Right safe area inset in pixels."),bottom:P().describe("Bottom safe area inset in pixels."),left:P().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),yg=h({method:u("ui/notifications/host-context-changed"),params:sd.describe("Partial context update containing only changed fields.")});h({method:u("ui/update-model-context"),params:h({content:O(jt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:L(m(),B().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});h({method:u("ui/initialize"),params:h({appInfo:Yn.describe("App identification (name and version)."),appCapabilities:hg.describe("Features and capabilities this app provides."),protocolVersion:m().describe("Protocol version this app supports.")})});var bg=h({protocolVersion:m().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Yn.describe("Host application identification and version."),hostCapabilities:fg.describe("Features and capabilities provided by the host."),hostContext:sd.describe("Rich context about the host environment.")}).passthrough(),$g={target:"draft-2020-12"};async function Sa(n,e){let r=n["~standard"];if(r.jsonSchema)return r.jsonSchema[e]($g);if(r.vendor==="zod"){let{z:o}=await ld(()=>Promise.resolve().then(()=>uf),void 0,import.meta.url);return o.toJSONSchema(n,{io:e})}throw Error(`Schema (vendor: ${r.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 xa(n,e,r=""){let o=await n["~standard"].validate(e);if(o.issues){let t=o.issues.map(i=>{let a=i.path?.map(s=>typeof s=="object"?s.key:s).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(r+t)}return o.value}class Co extends Yh{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(e){if(this._initializedSent)return;let r=`[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(r);console.warn(`${r}. This will throw in a future release.`)}eventSchemas={toolinput:cg,toolinputpartial:ug,toolresult:_g,toolcancelled:lg,hostcontextchanged:yg};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!Co.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e)||(this._everHadListener.add(e),!this._initializedSent))return;let r=`[ext-apps] "${String(e)}" 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(r);console.warn(r)}setEventHandler(e,r){r&&this._assertHandlerTiming(e),super.setEventHandler(e,r)}addEventListener(e,r){this._assertHandlerTiming(e),super.addEventListener(e,r)}onEventDispatch(e,r){e==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...r})}constructor(e,r={},o={autoResize:!0}){super(o),this._appInfo=e,this._capabilities=r,this.options=o,o.allowUnsafeEval||ee({jitless:!0}),this.setRequestHandler(Xn,t=>(console.log("Received ping:",t.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=Qh(this._capabilities,e)}registerTool(e,r,o){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let t=this,i=()=>{t._initializedSent&&t._capabilities.tools?.listChanged&&t.sendToolListChanged()},a=r.inputSchema!==void 0,s={title:r.title,description:r.description,inputSchema:r.inputSchema,outputSchema:r.outputSchema,annotations:r.annotations,_meta:r._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(c){Object.assign(this,c),i()},remove(){t._registeredTools[e]===s&&(delete t._registeredTools[e],i())},handler:async(c,l)=>{if(!s.enabled)throw Error(`Tool ${e} is disabled`);let p;if(a){let f=s.inputSchema,b=f?await xa(f,c??{},`Invalid input for tool ${e}: `):c??{};p=await o(b,l)}else p=await o(l);return s.outputSchema&&!p.isError&&(p.structuredContent=await xa(s.outputSchema,p.structuredContent,`Invalid output for tool ${e}: `)),p}};return this._registeredTools[e]=s,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,r)=>{let o=this._registeredTools[e.name];if(!o)throw Error(`Tool ${e.name} not found`);return o.handler(e.arguments,r)},this.onlisttools=async(e,r)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,t])=>t.enabled).map(async([o,t])=>{let i={name:o,title:t.title,description:t.description,inputSchema:t.inputSchema?await Sa(t.inputSchema,"input"):{type:"object",properties:{}}};return t.outputSchema&&(i.outputSchema=await Sa(t.outputSchema,"output")),t.annotations&&(i.annotations=t.annotations),t._meta&&(i._meta=t._meta),i}))}))}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(pg,(r,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(r.params,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(rd,(r,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(r.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(nd,(r,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(r.params,o)})}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,r){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},er,{onprogress:()=>{},resetTimeoutOnProgress:!0,...r})}async readServerResource(e,r){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},Xl,r)}async listServerResources(e,r){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},Yl,r)}async createSamplingMessage(e,r){this._assertInitialized("createSamplingMessage");let o=e.tools?ad:od;return await this.request({method:"sampling/createMessage",params:e},o,r)}sendMessage(e,r){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},sg,r)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,r){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},_o,r)}openLink(e,r){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},og,r)}sendOpenLink=this.openLink;downloadFile(e,r){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},ag,r)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,r){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},gg,r)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,r=0,o=0,t=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let a=document.documentElement,s=a.style.height;a.style.height="max-content";let c=Math.ceil(a.getBoundingClientRect().height);a.style.height=s;let l=Math.ceil(window.innerWidth);(l!==r||c!==o)&&(r=l,o=c,this.sendSizeChanged({width:l,height:c}))}))};t();let i=new ResizeObserver(t);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new tg(window.parent,window.parent),r){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(e);try{let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:Xh}},bg,r);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"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}const kg="3.0.0",wg={version:kg},_r="tableauVizContainer";function Sg(n,e){const r=document.createElement("tableau-viz");return r.setAttribute("src",n),r.setAttribute("token",e),r.setAttribute("toolbar","hidden"),r}function xg(n,e,r){const o=document.getElementById(_r);if(!o){console.error(`[mcp-app] container element with id "${_r}" not found; cannot embed viz`);return}const t=Sg(n,e);t.addEventListener("firstvizsizeknown",i=>{const a=i.detail?.vizSize,s=a?.sheetSize?.maxSize?.height,c=a?.chromeHeight;if(typeof s!="number")return;const l=typeof c=="number"?c:0;t.style.height=`${s+l}px`}),t.addEventListener("vizloaderror",i=>{console.error("[mcp-app] tableau-viz reported a load error",i),r?.()}),o.replaceChildren(t)}const Ig=qe({content:Ua(qe({type:Za("text"),text:Gt()}))}),zg=qe({token:Gt()});async function Tg(n){if(!n.getHostCapabilities()?.serverTools)throw new Error("Cannot retrieve embed token: the MCP host does not support server tools (serverTools capability is unavailable).");const r=await n.callServerTool({name:"get-embed-token",arguments:{}});if(r.isError)throw new Error("Failed to get an embed token for the current authentication configuration.");const t=Ig.parse(r).content[0],i=JSON.parse(t.text);return zg.parse(i).token}function Og(n){return new Promise((e,r)=>{if(!("customElements"in window)){r(new Error("Custom elements are not available. Cannot access tableau-viz element"));return}if(customElements.get("tableau-viz")){e();return}const t=`${new URL(n).origin}/javascripts/api/tableau.embedding.3.latest.min.js`,i=document.createElement("script");i.type="module",i.src=t,i.onload=()=>{const a=customElements.whenDefined("tableau-viz"),s=new Promise((c,l)=>{setTimeout(()=>{l(new Error("Tableau Embedding API failed to load within 15 seconds"))},15e3)});Promise.race([a,s]).then(()=>e()).catch(c=>r(c))},i.onerror=()=>{console.error("Failed to load Tableau Embedding API from:",t),r(new Error(`Failed to load Tableau Embedding API from ${t}`))},document.head.appendChild(i)})}function Ia(n){if(n.querySelector(".open-in-tableau-error"))return;const e=document.createElement("div");e.className="open-in-tableau-error",e.textContent="The URL was unable to be opened.",n.appendChild(e)}function Ng(n){n.querySelector(".open-in-tableau-error")?.remove()}function jg(n,e,r){const o=r.querySelector("#openInTableauLink");o&&o.remove();const t=n.getHostCapabilities();if(!e||!t?.openLinks)return;const i=document.createElement("a");i.id="openInTableauLink",i.className="open-in-tableau",i.setAttribute("href",e),i.setAttribute("rel","noopener noreferrer"),i.setAttribute("aria-label","Open in Tableau (opens in a new browser tab)"),i.textContent="Open in Tableau ↗",i.onclick=async a=>{a.preventDefault();try{(await n.openLink({url:e})).isError?(console.warn("Open in Tableau link request denied by host",{url:e}),Ia(r)):Ng(r)}catch(s){console.warn("Open in Tableau link request failed",{url:e,error:s}),Ia(r)}},r.appendChild(i)}const Eg=`<svg width="171" height="165" viewBox="0 0 171 165" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
74
74
|
<g clip-path="url(#clip0_1_26)">
|
|
75
75
|
<path d="M132.921 108.53C132.921 108.53 123.601 108.53 146.001 108.53C168.401 108.53 171 139.53 139 139.53C90.5 139.53 71.5 136.03 67 119.53C62.5 103.03 81.5 95.0303 89 105.03C96.5 115.03 90 124.03 83 133.53C76 143.03 79 157.53 95 157.53" stroke="#BEC7F6" stroke-width="2" stroke-linecap="round"/>
|
|
76
76
|
<path d="M92 127.53H120V89.53H92V127.53Z" fill="#1966FF"/>
|