Logo
AI connectors

n8n Automation

Connect Lemonado to n8n workflows using Model Context Protocol

Important: Make sure you are on the latest stable version of n8n for the best compatibility with MCP.

Overview

n8n is a powerful workflow automation tool that can connect to Lemonado through the Model Context Protocol (MCP) using the MCP Client Tool node. This enables you to query and analyze your Lemonado data within automated workflows.

Prerequisites

  • n8n instance (latest version with MCP support)
  • Lemonado account with at least one data source connected
  • Active AI Connector in Lemonado

Setup Instructions

Step 1: Create an AI Connector in Lemonado

  1. Go to your Lemonado dashboard
  2. Navigate to AI Connectors
  3. Create a new AI Connector or select an existing one
  4. Choose which data sources the connector can access

Step 2: Generate Bearer Token in Lemonado

  1. In your AI Connector settings, click on the n8n tab in the left sidebar
  2. At the bottom of the page, select Expires in: 1 Year (recommended)
  3. Click Generate Token
  4. Copy the generated bearer token

Step 3: Configure n8n Workflow

  1. Open your n8n workflow editor
  2. Add an HTTP Request node or MCP node (if available)
  3. Configure the node with these settings:
    • Method: POST
    • URL: https://mcp.lemonado.io/mcp
    • Authentication: Bearer Token
  4. Add your generated bearer token to the Authorization header
  5. Test the connection and save your workflow

Step 4: Use MCP Tools

Once connected, you can use Lemonado's MCP tools:

  • execute_sql - Run SQL queries on your connected data sources
  • list_objects - List available tables and data objects
  • get_object_details - Get schema information for tables

Step 6: Build Your Workflow

Example workflow components:

  1. Trigger: Schedule, webhook, or manual trigger
  2. MCP Client Tool: Query Lemonado data using execute_sql
  3. Process: Transform or filter the data
  4. Output: Send to Slack, email, or another service

Example Workflows

Daily Sales Report

  1. Schedule Trigger: Run daily at 9 AM
  2. MCP Client Tool: Execute SQL query
    SELECT
      DATE(created_at) as date,
      COUNT(*) as orders,
      SUM(amount) as total_revenue
    FROM orders
    WHERE created_at >= CURRENT_DATE - INTERVAL '1 day'
    GROUP BY DATE(created_at)
  3. Format: Convert to table or chart
  4. Email: Send report to team

Customer Data Monitoring

  1. Schedule Trigger: Every hour
  2. MCP Client Tool: List new customers
    SELECT * FROM customers
    WHERE created_at > NOW() - INTERVAL '1 hour'
  3. IF Node: Check if new customers exist
  4. Slack: Notify sales team of new signups

Inventory Alerts

  1. Schedule Trigger: Every 30 minutes
  2. MCP Client Tool: Check inventory levels
    SELECT product_name, quantity, reorder_point
    FROM inventory
    WHERE quantity < reorder_point
  3. IF Node: Check if any items are low
  4. Create Task: Generate purchase orders

Using MCP Tools in n8n

execute_sql Tool

Use this to run SQL queries:

  • Supports SELECT queries (read-only)
  • Returns results as JSON
  • Can query any connected data source

list_objects Tool

Use this to explore available data:

  • Lists all tables and views
  • Shows data source information
  • Useful for discovery and documentation

get_object_details Tool

Use this to understand data structure:

  • Returns column names and types
  • Shows relationships and constraints
  • Helps with query building

Integration with AI Agents

n8n can combine MCP with AI agents:

  1. MCP Client Tool: Fetch data from Lemonado
  2. AI Agent: Analyze data with Claude, GPT, etc.
  3. Decision Node: Route based on AI analysis
  4. Action Nodes: Trigger appropriate actions

Best Practices

Performance Optimization

  • Cache frequently accessed data
  • Use specific queries with filters
  • Implement pagination for large datasets
  • Schedule heavy queries during off-peak hours

Error Handling

  • Add error trigger nodes to workflows
  • Implement retry logic for failed queries
  • Log errors for debugging
  • Set up alerting for critical failures

Security

  • Use n8n's credential management
  • Enable workflow execution logging
  • Restrict access to sensitive workflows
  • Regularly review workflow permissions

Troubleshooting

Connection Issues

  • Verify n8n is on the latest version
  • Check OAuth authentication is complete
  • Ensure AI Connector is active in Lemonado
  • Test with simple queries first

Query Errors

  • Verify SQL syntax is correct
  • Check table and column names exist
  • Ensure you have permission to access the data
  • Use list_objects to discover available tables

Performance Issues

  • Optimize SQL queries with indexes
  • Reduce data volume with filters
  • Use pagination for large results
  • Consider caching for repeated queries

Advanced Features

Workflow Variables

Use n8n variables in your queries:

SELECT * FROM orders
WHERE customer_id = {{ $json.customerId }}
AND created_at > '{{ $json.startDate }}'

Dynamic Queries

Build queries based on conditions:

const table = $json.dataSource;
const limit = $json.limit || 100;
return {
  tool: 'execute_sql',
  query: `SELECT * FROM ${table} LIMIT ${limit}`
};

Parallel Processing

Run multiple MCP queries concurrently:

  1. Use Split In Batches node
  2. Execute MCP queries in parallel
  3. Merge results with Merge node
  4. Process combined data

Pro Tip: Use n8n's built-in variables and expressions to make your MCP queries dynamic and responsive to workflow context.