<zapier-mcpembed-id="FILL_IN_YOUR_EMBED_ID"width="100%"height="600px"sign-up-email="email_of_your_user@example.com"sign-up-first-name="first_name_of_your_user"sign-up-last-name="last_name_of_your_user"> </zapier-mcp><script>document.querySelector('zapier-mcp').addEventListener('mcp-server-url', (event) => {// this is the URL of the MCP server for a specific userconsole.log('MCP Server URL:', event.detail.serverUrl);});document.querySelector('zapier-mcp').addEventListener('tools-changed', (event) => {// this is sent whenever a user adds/removes tools from their MCP serverconsole.log('Tools changed');});document.querySelector('zapier-mcp').addEventListener('close-requested', (event) => {// this is sent when the user clicks the close button in the embed});</script>
The Zapier MCP custom element can be used with vanilla JS. Use the JavaScript snippet to load the script and add a <zapier-mcp> element.
// Load the MCP embed scriptconst script = document.createElement("script");script.src = "https://mcp.zapier.com/embed/v1/mcp.js";document.head.appendChild(script);// Wait for script to load, then create and display zapier-mcpscript.onload = () => {const element = document.createElement("zapier-mcp");element.setAttribute("embed-id", "FILL_IN_YOUR_EMBED_ID");element.setAttribute("width", "100%");element.setAttribute("height", "600px");element.setAttribute("sign-up-email", "email_of_your_user@example.com");element.setAttribute("sign-up-first-name", "first_name_of_your_user");element.setAttribute("sign-up-last-name", "last_name_of_your_user");element.addEventListener('mcp-server-url', (event) => {// this is the URL of the MCP server for a specific userconsole.log('MCP Server URL:', event.detail.serverUrl);});element.addEventListener('tools-changed', (event) => {// this is sent whenever a user adds/removes tools from their MCP serverconsole.log('Tools changed');});element.addEventListener('close-requested', (event) => {// this is sent when the user clicks the close button in the embedconsole.log('Close requested');});const container = document.querySelector("#zapier-mcp-container") || document.body;container.appendChild(element);};
Custom elements (web components) can be used with React. The example shows a TypeScript wrapper component with typed props for handling callbacks. Add the jsx-types.d.ts snippet for proper TypeScript support.
<!-- See the "Vanilla JS" solution if you'd rather use JS to load these --><script src="https://mcp.zapier.com/embed/v1/mcp.js"></script>
And then use these components in your Vue application:
Copy
Ask AI
<template> <div> <h1>Zapier MCP Vue</h1> <zapier-mcp :embed-id.prop="'FILL_IN_YOUR_EMBED_ID'" :width.prop="'100%'" :height.prop="'600px'" :sign-up-email.prop="'email_of_your_user@example.com'" :sign-up-first-name.prop="'first_name_of_your_user'" :sign-up-last-name.prop="'last_name_of_your_user'" @mcp-server-url="onMcpServerUrl" @tools-changed="onToolsChanged" @close-requested="onCloseRequested" ></zapier-mcp> </div></template><script> export default { name: "App", methods: { onMcpServerUrl(event) { // this is the URL of the MCP server for a specific user console.log("MCP Server URL:", event.detail.serverUrl); }, onToolsChanged(event) { // this is sent whenever a user adds/removes tools from their MCP server console.log("Tools changed"); }, onCloseRequested(event) { // this is sent when the user clicks the close button in the embed console.log("Close requested"); }, }, };</script>