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
- Go to your Lemonado dashboard
- Navigate to AI Connectors
- Create a new AI Connector or select an existing one
- Choose which data sources the connector can access
Step 2: Generate Bearer Token in Lemonado
- In your AI Connector settings, click on the n8n tab in the left sidebar
- At the bottom of the page, select Expires in: 1 Year (recommended)
- Click Generate Token
- Copy the generated bearer token
Step 3: Configure n8n Workflow
- Open your n8n workflow editor
- Add an HTTP Request node or MCP node (if available)
- Configure the node with these settings:
- Method: POST
- URL:
https://mcp.lemonado.io/mcp - Authentication: Bearer Token
- Add your generated bearer token to the Authorization header
- 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:
- Trigger: Schedule, webhook, or manual trigger
- MCP Client Tool: Query Lemonado data using execute_sql
- Process: Transform or filter the data
- Output: Send to Slack, email, or another service
Example Workflows
Daily Sales Report
- Schedule Trigger: Run daily at 9 AM
- 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) - Format: Convert to table or chart
- Email: Send report to team
Customer Data Monitoring
- Schedule Trigger: Every hour
- MCP Client Tool: List new customers
SELECT * FROM customers WHERE created_at > NOW() - INTERVAL '1 hour' - IF Node: Check if new customers exist
- Slack: Notify sales team of new signups
Inventory Alerts
- Schedule Trigger: Every 30 minutes
- MCP Client Tool: Check inventory levels
SELECT product_name, quantity, reorder_point FROM inventory WHERE quantity < reorder_point - IF Node: Check if any items are low
- 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:
- MCP Client Tool: Fetch data from Lemonado
- AI Agent: Analyze data with Claude, GPT, etc.
- Decision Node: Route based on AI analysis
- 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:
- Use Split In Batches node
- Execute MCP queries in parallel
- Merge results with Merge node
- Process combined data
Pro Tip: Use n8n's built-in variables and expressions to make your MCP queries dynamic and responsive to workflow context.