@tableau/mcp-server 2.18.0 → 2.18.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/build/index.js +2 -2
- package/build/index.js.map +2 -2
- package/build/web/apps/dist/mcp-app.html +1 -1
- package/package.json +2 -2
|
@@ -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:ut.describe("The display mode being requested.")})});var fg=h({mode:ut.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),pg=R([u("model"),u("app")]).describe("Tool visibility scope - who can access the tool.");h({resourceUri:d().optional(),visibility:N(pg).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:Oe().optional(),permissions:Oe().optional()});h({mimeTypes:N(d()).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:N(R([Ql,Yl])).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:N(jt).describe("Message content blocks (text, image, etc.).")})});h({method:u("ui/notifications/sandbox-resource-ready"),params:h({html:d().describe("HTML content to load into the inner iframe."),sandbox:d().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Po.optional().describe("CSP configuration from resource metadata."),permissions:Uo.optional().describe("Sandbox permissions from resource metadata.")})});var hg=h({method:u("ui/notifications/tool-result"),params:Xn.describe("Standard MCP tool execution result.")}),id=h({toolInfo:h({id:St.optional().describe("JSON-RPC id of the tools/call request."),tool:Oo.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Xh.optional().describe("Current color theme preference."),styles:ug.optional().describe("Style configuration for theming the app."),displayMode:ut.optional().describe("How the UI is currently displayed."),availableDisplayModes:N(ut).optional().describe("Display modes the host supports."),containerDimensions:R([h({height:U().describe("Fixed container height in pixels.")}),h({maxHeight:R([U(),at()]).optional().describe("Maximum container height in pixels.")})]).and(R([h({width:U().describe("Fixed container width in pixels.")}),h({maxWidth:R([U(),at()]).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:d().optional().describe("User's language and region preference in BCP 47 format."),timeZone:d().optional().describe("User's timezone in IANA format."),userAgent:d().optional().describe("Host application identifier."),platform:R([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:U().describe("Top safe area inset in pixels."),right:U().describe("Right safe area inset in pixels."),bottom:U().describe("Bottom safe area inset in pixels."),left:U().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),gg=h({method:u("ui/notifications/host-context-changed"),params:id.describe("Partial context update containing only changed fields.")});h({method:u("ui/update-model-context"),params:h({content:N(jt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:M(d(),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:Qn.describe("App identification (name and version)."),appCapabilities:mg.describe("Features and capabilities this app provides."),protocolVersion:d().describe("Protocol version this app supports.")})});var vg=h({protocolVersion:d().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Qn.describe("Host application identification and version."),hostCapabilities:dg.describe("Features and capabilities provided by the host."),hostContext:id.describe("Rich context about the host environment.")}).passthrough(),_g={target:"draft-2020-12"};async function ka(n,e){let r=n["~standard"];if(r.jsonSchema)return r.jsonSchema[e](_g);if(r.vendor==="zod"){let{z:o}=await sd(()=>Promise.resolve().then(()=>ap),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 wa(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 Eo extends Gh{_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:og,toolinputpartial:ag,toolresult:hg,toolcancelled:sg,hostcontextchanged:gg};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!Eo.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(Yn,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=Wh(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,m)=>{if(!s.enabled)throw Error(`Tool ${e} is disabled`);let f;if(a){let p=s.inputSchema,b=p?await wa(p,c??{},`Invalid input for tool ${e}: `):c??{};f=await o(b,m)}else f=await o(m);return s.outputSchema&&!f.isError&&(f.structuredContent=await wa(s.outputSchema,f.structuredContent,`Invalid output for tool ${e}: `)),f}};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 ka(t.inputSchema,"input"):{type:"object",properties:{}}};return t.outputSchema&&(i.outputSchema=await ka(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(lg,(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(ed,(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(Xl,(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},Xn,{onprogress:()=>{},resetTimeoutOnProgress:!0,...r})}async readServerResource(e,r){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},Kl,r)}async listServerResources(e,r){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},Gl,r)}async createSamplingMessage(e,r){this._assertInitialized("createSamplingMessage");let o=e.tools?rd:nd;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},ig,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},go,r)}openLink(e,r){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},ng,r)}sendOpenLink=this.openLink;downloadFile(e,r){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},rg,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},fg,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 m=Math.ceil(window.innerWidth);(m!==r||c!==o)&&(r=m,o=c,this.sendSizeChanged({width:m,height:c}))}))};t();let i=new ResizeObserver(t);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new Yh(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:Kh}},vg,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 yg="2.18.0",bg={version:yg},Sa="tableauVizContainer";function $g(n,e){const r=document.createElement("tableau-viz");return r.setAttribute("src",n),r.setAttribute("token",e),r}function kg(n,e){const r=document.getElementById(Sa);if(!r)throw new Error(`Container element with id "${Sa}" not found`);const o=$g(n,e);r.appendChild(o)}const wg=qe({content:Oa(qe({type:Pa("text"),text:Wt()}))}),Sg=qe({token:Wt()});async function xg(n){const e=await n.callServerTool({name:"get-oauth-token",arguments:{}}),o=wg.parse(e).content[0],t=JSON.parse(o.text);return Sg.parse(t).token}const Ig=qe({url:Wt().url()}),zg=qe({content:Oa(qe({type:Pa("text"),text:Wt()})).nonempty(),isError:Ed().optional()});function Tg(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,m)=>{setTimeout(()=>{m(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)})}const vr=new Eo({name:"Tableau MCP App",version:bg.version});function Ng(n){const r=zg.parse(n).content[0],o=JSON.parse(r.text),{url:t}=Ig.parse(o);return t}vr.ontoolresult=async n=>{try{const e=Ng(n);await Tg(e);const r=await xg(vr);kg(e,r)}catch(e){console.error("Error embedding viz:",e)}};vr.connect();</script>
|
|
73
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:d().optional().describe("User's language and region preference in BCP 47 format."),timeZone:d().optional().describe("User's timezone in IANA format."),userAgent:d().optional().describe("Host application identifier."),platform:R([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:U().describe("Top safe area inset in pixels."),right:U().describe("Right safe area inset in pixels."),bottom:U().describe("Bottom safe area inset in pixels."),left:U().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),gg=h({method:u("ui/notifications/host-context-changed"),params:id.describe("Partial context update containing only changed fields.")});h({method:u("ui/update-model-context"),params:h({content:N(jt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:M(d(),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:Qn.describe("App identification (name and version)."),appCapabilities:mg.describe("Features and capabilities this app provides."),protocolVersion:d().describe("Protocol version this app supports.")})});var vg=h({protocolVersion:d().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Qn.describe("Host application identification and version."),hostCapabilities:dg.describe("Features and capabilities provided by the host."),hostContext:id.describe("Rich context about the host environment.")}).passthrough(),_g={target:"draft-2020-12"};async function ka(n,e){let r=n["~standard"];if(r.jsonSchema)return r.jsonSchema[e](_g);if(r.vendor==="zod"){let{z:o}=await sd(()=>Promise.resolve().then(()=>ap),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 wa(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 Eo extends Gh{_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:og,toolinputpartial:ag,toolresult:hg,toolcancelled:sg,hostcontextchanged:gg};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!Eo.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(Yn,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=Wh(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,m)=>{if(!s.enabled)throw Error(`Tool ${e} is disabled`);let f;if(a){let p=s.inputSchema,b=p?await wa(p,c??{},`Invalid input for tool ${e}: `):c??{};f=await o(b,m)}else f=await o(m);return s.outputSchema&&!f.isError&&(f.structuredContent=await wa(s.outputSchema,f.structuredContent,`Invalid output for tool ${e}: `)),f}};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 ka(t.inputSchema,"input"):{type:"object",properties:{}}};return t.outputSchema&&(i.outputSchema=await ka(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(lg,(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(ed,(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(Xl,(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},Xn,{onprogress:()=>{},resetTimeoutOnProgress:!0,...r})}async readServerResource(e,r){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},Kl,r)}async listServerResources(e,r){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},Gl,r)}async createSamplingMessage(e,r){this._assertInitialized("createSamplingMessage");let o=e.tools?rd:nd;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},ig,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},go,r)}openLink(e,r){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},ng,r)}sendOpenLink=this.openLink;downloadFile(e,r){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},rg,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},fg,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 m=Math.ceil(window.innerWidth);(m!==r||c!==o)&&(r=m,o=c,this.sendSizeChanged({width:m,height:c}))}))};t();let i=new ResizeObserver(t);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new Yh(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:Kh}},vg,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 yg="2.18.1",bg={version:yg},Sa="tableauVizContainer";function $g(n,e){const r=document.createElement("tableau-viz");return r.setAttribute("src",n),r.setAttribute("token",e),r}function kg(n,e){const r=document.getElementById(Sa);if(!r)throw new Error(`Container element with id "${Sa}" not found`);const o=$g(n,e);r.appendChild(o)}const wg=qe({content:Oa(qe({type:Pa("text"),text:Wt()}))}),Sg=qe({token:Wt()});async function xg(n){const e=await n.callServerTool({name:"get-oauth-token",arguments:{}}),o=wg.parse(e).content[0],t=JSON.parse(o.text);return Sg.parse(t).token}const Ig=qe({url:Wt().url()}),zg=qe({content:Oa(qe({type:Pa("text"),text:Wt()})).nonempty(),isError:Ed().optional()});function Tg(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,m)=>{setTimeout(()=>{m(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)})}const vr=new Eo({name:"Tableau MCP App",version:bg.version});function Ng(n){const r=zg.parse(n).content[0],o=JSON.parse(r.text),{url:t}=Ig.parse(o);return t}vr.ontoolresult=async n=>{try{const e=Ng(n);await Tg(e);const r=await xg(vr);kg(e,r)}catch(e){console.error("Error embedding viz:",e)}};vr.connect();</script>
|
|
74
74
|
<style rel="stylesheet" crossorigin>*{box-sizing:border-box}html,body{height:100%;margin:0;padding:0}body{font-family:system-ui,-apple-system,sans-serif}.main{width:100%;height:100vh;margin:0;padding:0}.viz-container{width:100%;height:100%}tableau-viz{width:100%;height:100%;display:block}</style>
|
|
75
75
|
</head>
|
|
76
76
|
<body>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tableau/mcp-server",
|
|
3
3
|
"description": "Helping agents see and understand data.",
|
|
4
|
-
"version": "2.18.
|
|
4
|
+
"version": "2.18.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/tableau/tableau-mcp.git"
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"zod-validation-error": "^4.0.1"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@anthropic-ai/mcpb": "^1.
|
|
76
|
+
"@anthropic-ai/mcpb": "^2.1.2",
|
|
77
77
|
"@eslint/eslintrc": "^3.3.1",
|
|
78
78
|
"@eslint/js": "^9.25.1",
|
|
79
79
|
"@openai/agents": "^0.1.9",
|