VOOZH about

URL: https://www.cdata.com/kb/tech/lakebase-cloud-n8n.rst

⇱ How to Connect to Live Lakebase Data in n8n Workflows and Agents (via CData Connect AI)


How to Connect to Live Lakebase Data in n8n Workflows and Agents (via CData Connect AI)

πŸ‘ Yazhini G
Yazhini G
Technical Marketing Engineer
Leverage the CData Connect AI Remote MCP Server to enable n8n to securely read and take actions on your Lakebase data for you.

n8n is an open-source workflow automation tool that allows you to connect various applications and services to automate tasks and processes. When combined with CData Connect AI Remote MCP, you can leverage n8n to interact with your Lakebase data in real-time. This article outlines the process of connecting to Lakebase using Connect AI Remote MCP and creating a basic workflow in n8n to interact with your Lakebase data.

CData Connect AI offers a dedicated cloud-to-cloud interface for connecting to Lakebase data. The CData Connect AI Remote MCP Server enables secure communication between n8n and Lakebase. This allows you to ask questions and take actions on your Lakebase data using n8n, all without the need for data replication to a natively supported database. With its inherent optimized data processing capabilities, CData Connect AI efficiently channels all supported SQL operations, including filters and JOINs, directly to Lakebase. This leverages server-side processing to swiftly deliver the requested Lakebase data.

In this article, we show how to build a simple chat agent in n8n to conversational explore (or Vibe Query) your data. The connectivity principals apply to any n8n workflow. With Connect AI you can build workflows and agents with access to live Lakebase data, plus hundreds of other sources.

Step 1: Configure Lakebase Connectivity for n8n

Connectivity to Lakebase from n8n is made possible through CData Connect AI Remote MCP. To interact with Lakebase data from n8n, we start by creating and configuring a Lakebase connection in CData Connect AI.

  1. Log into Connect AI, click Sources, and then click Add Connection
  2. πŸ‘ Adding a Connection
  3. Select "Lakebase" from the Add Connection panel
  4. πŸ‘ Selecting a data source
  5. Enter the necessary authentication properties to connect to Lakebase. To connect to Databricks Lakebase, start by setting the following properties:
    • DatabricksInstance: The Databricks instance or server hostname, provided in the format instance-abcdef12-3456-7890-abcd-abcdef123456.database.cloud.databricks.com.
    • Server: The host name or IP address of the server hosting the Lakebase database.
    • Port (optional): The port of the server hosting the Lakebase database, set to 5432 by default.
    • Database (optional): The database to connect to after authenticating to the Lakebase Server, set to the authenticating user's default database by default.

    OAuth Client Authentication

    To authenicate using OAuth client credentials, you need to configure an OAuth client in your service principal. In short, you need to do the following:

    1. Create and configure a new service principal
    2. Assign permissions to the service principal
    3. Create an OAuth secret for the service principal

    For more information, refer to the Setting Up OAuthClient Authentication section in the Help documentation.

    OAuth PKCE Authentication

    To authenticate using the OAuth code type with PKCE (Proof Key for Code Exchange), set the following properties:

    • AuthScheme: OAuthPKCE.
    • User: The authenticating user's user ID.

    For more information, refer to the Help documentation.

    πŸ‘ Configuring a connection (Salesforce is shown)
  6. Click Save & Test
  7. Navigate to the Permissions tab in the Add Lakebase Connection page and update the User-based permissions. πŸ‘ Updating permissions

Add a Personal Access Token

A Personal Access Token (PAT) is used to authenticate the connection to Connect AI from n8n. It is best practice to create a separate PAT for each service to maintain granularity of access.

  1. Click on the Gear icon () at the top right of the Connect AI app to open the settings page.
  2. On the Settings page, go to the Access Tokens section and click Create PAT.
  3. Give the PAT a name and click Create. πŸ‘ Creating a new PAT
  4. The personal access token is only visible at creation, so be sure to copy it and store it securely for future use.

With the connection configured and a PAT generated, we are ready to connect to Lakebase data from n8n.

Step 2: Connect n8n to CData Connect AI

Follow these steps to connect to CData Connect AI in n8n:

  1. Sign in to n8n.io or create a new account.
  2. Create a Workflow in n8n that uses the MCP Client tool. The example Workflow below acts as a chatbot. OpenAI was used as the Chat Model, and Simple Memory was used for the Memory. πŸ‘ Example n8n Workflow using MCP Client
  3. Configure the MCP Client node in the Workflow:
    • Set Endpoint to https://mcp.cloud.cdata.com/mcp (found in the "Connect Data to AI" ribbon in Connect AI)
    • Set Server Transport to HTTP Streamable
    • Set Authentication to Header Auth and set the following properties to use Basic authentication:
      • Set Name to Authorization
      • Set Value to Basic EMAIL:PAT, replacing the EMAIL and PAT with your Connect AI email address and the PAT created previously. For example: Basic [email protected]:Uu90pt5vEO..."
      πŸ‘ Configure Header Auth
    πŸ‘ Configure MCP Client Node

Optional Step: Give the AI Agent context

This step establishes the AI Agent's role and provides context for the conversation through the System Message parameter in the AI Agent node. By providing a system message that explicitly informs the agent about its role as an MCP Server expert and lists the available tools, you can enhance the agent's understanding and response accuracy. For example, you can set the System Message to:

You are an expert at using the MCP Client tool connected which is the CData Connect AI MCP Server. Always search thoroughly and use the most relevant MCP Client tool for each query. Below are the available tools and a description of each:
queryData: Execute SQL queries against connected data sources and retrieve results. When you use the queryData tool, ensure you use the following format for the table name: catalog.schema.tableName
getCatalogs: Retrieve a list of available connections from CData Connect AI. The connection names should be used as catalog names in other tools and in any queries to CData Connect AI. Use the `getSchemas` tool to get a list of available schemas for a specific catalog.
getSchemas: Retrieve a list of available database schemas from CData Connect AI for a specific catalog. Use the `getTables` tool to get a list of available tables for a specific catalog and schema.
getTables: Retrieve a list of available database tables from CData Connect AI for a specific catalog and schema. Use the `getColumns` tool to get a list of available columns for a specific table.
getColumns: Retrieve a list of available database columns from CData Connect AI for a specific catalog, schema, and table.
getProcedures: Retrieve a list of stored procedures from CData Connect AI for a specific catalog and schema
getProcedureParameters: Retrieve a list of stored procedure parameters from CData Connect AI for a specific catalog, schema, and procedure.
executeProcedure: Execute stored procedures with parameters against connected data sources
 

Step 3: Explore Live Lakebase Data with n8n

With the Workflow created in n8n and the MCP Client connected, you can now interact with your Lakebase data using n8n. The MCP Client node allows you to send queries and receive responses from the Lakebase data source in real-time.

Open the Workflow in n8n and execute it to start interacting with your Lakebase data. You can ask questions, retrieve data, and perform actions on your Lakebase data using the MCP Client node: πŸ‘ Example n8n Workflow Execution

Get CData Connect AI

To get live data access to hundreds of SaaS, Big Data, and NoSQL sources directly from your cloud applications, try CData Connect AI today!