{"title":"n8n","description":"Connect n8n’s built-in MCP Client to Altertable with read-only OAuth, run a SQL query, and ask the Altertable Agent a question.","order":300,"askSuggestions":["How do I connect n8n Cloud to one Altertable environment?","How do I use the agent’s answer in the next workflow step?"],"navigation":true,"body":{"code":"var Component=(()=>{var p=Object.create;var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var b=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),y=(t,e)=>{for(var o in e)l(t,o,{get:e[o],enumerable:!0})},a=(t,e,o,r)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let i of f(e))!w.call(t,i)&&i!==o&&l(t,i,{get:()=>e[i],enumerable:!(r=m(e,i))||r.enumerable});return t};var k=(t,e,o)=>(o=t!=null?p(g(t)):{},a(e||!t||!t.__esModule?l(o,\"default\",{value:t,enumerable:!0}):o,t)),C=t=>a(l({},\"__esModule\",{value:!0}),t);var d=b((T,s)=>{s.exports=_jsx_runtime});var x={};y(x,{default:()=>u,frontmatter:()=>A});var n=k(d()),A={title:\"n8n\",description:\"Connect n8n\\u2019s built-in MCP Client to Altertable with read-only OAuth, run a SQL query, and ask the Altertable Agent a question.\",order:300,askSuggestions:[\"How do I connect n8n Cloud to one Altertable environment?\",\"How do I use the agent\\u2019s answer in the next workflow step?\"]};function h(t){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",h3:\"h3\",li:\"li\",ol:\"ol\",p:\"p\",pre:\"pre\",strong:\"strong\",table:\"table\",tbody:\"tbody\",td:\"td\",th:\"th\",thead:\"thead\",tr:\"tr\",ul:\"ul\",...t.components},{DocsPreviewDocument:o,DocsPreviewSection:r,DocsTable:i}=e;return o||c(\"DocsPreviewDocument\",!0),r||c(\"DocsPreviewSection\",!0),i||c(\"DocsTable\",!0),(0,n.jsxs)(o,{anchors:\"n8n connection-setup import-the-example-workflow configure-the-connection verify-the-connection ask-the-altertable-agent notes\",children:[(0,n.jsxs)(r,{sectionId:\"n8n\",sectionTitle:\"n8n\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,n.jsx)(e.h1,{id:\"n8n\",children:\"n8n\"}),`\n`,(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.a,{href:\"https://n8n.io/\",children:\"n8n\"}),\" is a workflow automation tool. Its built-in \",(0,n.jsx)(e.strong,{children:\"MCP Client\"}),\" node can run read-only SQL against your Altertable lakehouse or ask the Altertable Agent a question.\"]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"connection-setup\",sectionTitle:\"Connection setup\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,n.jsx)(e.h2,{id:\"connection-setup\",children:\"Connection setup\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Use n8n Cloud or a self-hosted instance with \",(0,n.jsx)(e.strong,{children:\"MCP Client\"}),\" and \",(0,n.jsx)(e.strong,{children:\"MCP OAuth2\"}),\" support. You need an Altertable account with access to the environment you want to query.\"]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"import-the-example-workflow\",sectionTitle:\"Import the example workflow\",anchors:\"\",ancestors:\"connection-setup\",index:\"2\",children:[(0,n.jsx)(e.h3,{id:\"import-the-example-workflow\",children:\"Import the example workflow\"}),`\n`,(0,n.jsxs)(e.ol,{children:[`\n`,(0,n.jsxs)(e.li,{children:[\"Create a workflow in n8n and choose \",(0,n.jsx)(e.strong,{children:\"Import from URL\"}),\" from the workflow menu.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[\"Paste \",(0,n.jsx)(e.code,{children:\"https://altertable.ai/assets/workflows/n8n-altertable-mcp.json\"}),\" and import it. You can also \",(0,n.jsx)(e.a,{href:\"/assets/workflows/n8n-altertable-mcp.json\",children:\"download the workflow JSON\"}),\" and choose \",(0,n.jsx)(e.strong,{children:\"Import from File\"}),\".\"]}),`\n`]}),`\n`,(0,n.jsxs)(e.p,{children:[\"The workflow includes two MCP Client nodes. \",(0,n.jsx)(e.strong,{children:\"Initialize Altertable\"}),\" calls \",(0,n.jsx)(e.code,{children:\"initialize\"}),\" with \",(0,n.jsx)(e.code,{children:\"{}\"}),\" to identify the connected environment. \",(0,n.jsx)(e.strong,{children:\"Run sample query\"}),\" calls \",(0,n.jsx)(e.code,{children:\"query_lakehouse\"}),\" to test SQL access.\"]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"configure-the-connection\",sectionTitle:\"Configure the connection\",anchors:\"\",ancestors:\"connection-setup\",index:\"3\",children:[(0,n.jsx)(e.h3,{id:\"configure-the-connection\",children:\"Configure the connection\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Open \",(0,n.jsx)(e.strong,{children:\"Initialize Altertable\"}),\" and create an \",(0,n.jsx)(e.strong,{children:\"MCP OAuth2 API\"}),\" credential. Use these settings for the node and its credential.\"]}),`\n`,(0,n.jsx)(i,{columns:[\"Field\",\"Value\"],data:[{Field:\"Transport\",Value:\"HTTP Streamable\"},{Field:\"MCP Endpoint URL\",Value:\"`https://mcp.altertable.ai/mcp`\"},{Field:\"Authentication\",Value:\"MCP OAuth2\"},{Field:\"Register Client Automatically\",Value:\"Enabled\"},{Field:\"Server URL (credential)\",Value:\"`https://mcp.altertable.ai/mcp`\"}]}),`\n`,(0,n.jsxs)(e.ol,{children:[`\n`,(0,n.jsxs)(e.li,{children:[\"Select \",(0,n.jsx)(e.strong,{children:\"Connect my account\"}),\", sign in to Altertable, and approve read-only access for the organization and environment you want to query.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[\"Name the credential, for example \",(0,n.jsx)(e.code,{children:\"Altertable production read-only\"}),\", and save it.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[\"Open \",(0,n.jsx)(e.strong,{children:\"Run sample query\"}),\" and select the same credential.\"]}),`\n`]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"verify-the-connection\",sectionTitle:\"Verify the connection\",anchors:\"\",ancestors:\"\",index:\"4\",children:[(0,n.jsx)(e.h2,{id:\"verify-the-connection\",children:\"Verify the connection\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Select \",(0,n.jsx)(e.strong,{children:\"Execute workflow\"}),\". Open the output of \",(0,n.jsx)(e.strong,{children:\"Initialize Altertable\"}),\" and check the organization and environment names. Then open \",(0,n.jsx)(e.strong,{children:\"Run sample query\"}),\". Its \",(0,n.jsx)(e.strong,{children:\"Input Mode\"}),\" is \",(0,n.jsx)(e.strong,{children:\"JSON\"}),\", with this tool input:\"]}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-json\",children:`{ \"statement\": \"SELECT 1 AS ok\" }\n`})}),`\n`,(0,n.jsxs)(e.p,{children:[\"Open \",(0,n.jsx)(e.strong,{children:\"Format query result\"}),\" and select \",(0,n.jsx)(e.strong,{children:\"Table\"}),\". Each SQL row becomes one n8n item, and each SQL column name becomes a field. The sample query produces:\"]}),`\n`,(0,n.jsxs)(e.table,{children:[(0,n.jsx)(e.thead,{children:(0,n.jsx)(e.tr,{children:(0,n.jsx)(e.th,{children:\"ok\"})})}),(0,n.jsx)(e.tbody,{children:(0,n.jsx)(e.tr,{children:(0,n.jsx)(e.td,{children:\"1\"})})})]}),`\n`,(0,n.jsxs)(e.p,{children:[\"Replace the statement with your own read-only DuckDB query. Use a unique name or alias for each column. In the next node, reference fields by name, for example \",(0,n.jsx)(e.code,{children:\"{{ $json.ok }}\"}),\". A query with zero rows produces zero items.\"]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"ask-the-altertable-agent\",sectionTitle:\"Ask the Altertable Agent\",anchors:\"\",ancestors:\"\",index:\"5\",children:[(0,n.jsx)(e.h2,{id:\"ask-the-altertable-agent\",children:\"Ask the Altertable Agent\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"For a question that needs more than one query, keep \",(0,n.jsx)(e.strong,{children:\"Initialize Altertable\"}),\" as the first MCP step. Disconnect \",(0,n.jsx)(e.strong,{children:\"Format query result\"}),\" from \",(0,n.jsx)(e.strong,{children:\"Run sample query\"}),\". In \",(0,n.jsx)(e.strong,{children:\"Run sample query\"}),\", change \",(0,n.jsx)(e.strong,{children:\"Tool\"}),\" to \",(0,n.jsx)(e.code,{children:\"ask\"}),\", keep \",(0,n.jsx)(e.strong,{children:\"Input Mode\"}),\" set to \",(0,n.jsx)(e.strong,{children:\"JSON\"}),\", and replace the SQL input with a prompt:\"]}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-json\",children:`{\n  \"prompt\": \"How did new signups change last week compared with the previous week?\"\n}\n`})}),`\n`,(0,n.jsxs)(e.p,{children:[\"Run the workflow and inspect the node\\u2019s output. The tool waits for the final answer. Map the \",(0,n.jsx)(e.code,{children:\"answer\"}),\" field from the result into the next node, for example as the body of an email. With only \",(0,n.jsx)(e.code,{children:\"prompt\"}),\", each execution starts a new conversation in your Altertable chat history.\"]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"notes\",sectionTitle:\"Notes\",anchors:\"\",ancestors:\"\",index:\"6\",children:[(0,n.jsx)(e.h2,{id:\"notes\",children:\"Notes\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"The node asks for an AI Agent connection.\"}),\" Choose \",(0,n.jsx)(e.strong,{children:\"MCP Client\"}),\" when adding a workflow step. \",(0,n.jsx)(e.strong,{children:\"MCP Client Tool\"}),\" attaches tools to an n8n AI Agent.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsxs)(e.strong,{children:[\"A node returns \",(0,n.jsx)(e.code,{children:\"401 invalid_token\"}),\".\"]}),\" Open the MCP OAuth2 credential and connect your account. Select the connected credential on both MCP Client nodes.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"The workflow sees the wrong catalogs.\"}),\" Check the environment in the \",(0,n.jsx)(e.code,{children:\"initialize\"}),\" output. Create a credential for the intended environment and select it on both nodes.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"The SQL test succeeds but an agent question times out.\"}),\" Increase \",(0,n.jsx)(e.strong,{children:\"Options \\u2192 Timeout\"}),\" on the \",(0,n.jsx)(e.code,{children:\"ask\"}),\" node. The value is in milliseconds. For example, \",(0,n.jsx)(e.code,{children:\"300000\"}),\" allows five minutes.\"]}),`\n`]}),`\n`,(0,n.jsxs)(e.p,{children:[\"See \",(0,n.jsx)(e.a,{href:\"/docs/agents/mcp\",children:\"Altertable MCP authorization\"}),\" for access scopes and \",(0,n.jsx)(e.a,{href:\"/docs/api-references/mcp-tools\",children:\"MCP tools\"}),\" for tool inputs and outputs.\"]})]})]})}function u(t={}){let{wrapper:e}=t.components||{};return e?(0,n.jsx)(e,{...t,children:(0,n.jsx)(h,{...t})}):h(t)}function c(t,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+t+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return C(x);})();\n;return Component;"},"_id":"docs/integrations/n8n.mdx","_raw":{"sourceFilePath":"docs/integrations/n8n.mdx","sourceFileName":"n8n.mdx","sourceFileDir":"docs/integrations","contentType":"mdx","flattenedPath":"docs/integrations/n8n"},"type":"Docs","path":"/integrations/n8n","level":2,"parent":"integrations"}