Build your own SQLite MCP server
This template is for Self-Hosted N8N Instances only.
This n8n demonstrates how to build a simple SQLite MCP server to perform local database operations as well as use it for Business Intelligence.
This MCP example is based off an official MCP reference implementation which can be found here -https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite
How it works
- A MCP server trigger is used and connected to 5 tools: 2 Code Node and 3 Custom Workflow.
- The 2 Code Node tools use the SQLLite3 library and are simple read-only queries and as such, the Code Node tool can be simply used.
- The 3 custom workflow tools are used for select, insert and update queries as these are operations which require a bit more discretion.
- Whilst it may be easier to allow the agent to use raw SQL queries, we may find it a little safer to just allow for the parameters instead. The custom workflow tool allows us to define this restricted schema for tool input which we'll use to construct the SQL statement ourselves.
- All 3 custom workflow tools trigger the same "Execute workflow" trigger in this very template which has a switch to route the operation to the correct handler.
- Finally, we use our Code nodes to handle select, insert and update operations. The responses are then sent back to the the MCP client.
How to use
- This SQLite MCP server allows any compatible MCP client to manage a SQLite database by supporting select, create and update operations. You will need to have a SQLite database available before you can use this server.
- Connect your MCP client by following the n8n guidelines here - https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger/#integrating-with-claude-desktop
- Try the following queries in your MCP client:
- "Please create a table to store business insights and add the following..."
- "what business insights do we have on current retail trends?"
- "Who has contributed the most business insights in the past week?"
Requirements
- SQLite for database.
- MCP Client or Agent for usage such as Claude Desktop - https://claude.ai/download
Customising this workflow
- If the scope of schemas or tables is too open, try restrict it so the MCP serves a specific purpose for business operations. eg. Confine the querying and editing to HR only tables before providing access to people in that department.
- Remember to set the MCP server to require credentials before going to production and sharing this MCP server with others!
n8n MCP Server Workflow for Custom SQLite Interactions
This n8n workflow sets up a Model Context Protocol (MCP) server, designed to provide a flexible interface for AI models to interact with custom code and other n8n workflows. It acts as a router, allowing an AI to dynamically choose between executing custom JavaScript logic or triggering another n8n workflow based on the AI's intent.
What it does
This workflow simplifies the process of integrating AI models with custom logic and other n8n workflows by:
- Listening for MCP Requests: It starts an MCP server that listens for incoming requests from AI models.
- Routing AI Actions: It uses a
Switchnode to route the AI's intended action to one of two paths:- Custom Code Execution: If the AI requests a specific code-based action, it executes custom JavaScript provided within a
Code Toolnode. - External Workflow Trigger: If the AI requests a workflow-based action, it triggers another n8n workflow via a
Call n8n Workflow Toolnode.
- Custom Code Execution: If the AI requests a specific code-based action, it executes custom JavaScript provided within a
- Providing Context: A
Sticky Noteis included for documentation or temporary notes within the workflow. - Placeholder for Code: A
Codenode is present, likely as a general utility or a placeholder for more complex JavaScript logic that might be invoked directly or indirectly. - External Workflow Trigger: An
Execute Workflow Triggernode is available, indicating that this workflow can also be invoked by other n8n workflows.
Prerequisites/Requirements
- n8n Instance: An active n8n instance where this workflow can be imported and run.
- AI Model Integration: An AI model configured to communicate using the Model Context Protocol (MCP) and capable of sending requests to this n8n MCP server.
- Custom Code (Optional): Any specific JavaScript logic you intend to execute within the
Code Toolnode. - Other n8n Workflows (Optional): If you plan to use the
Call n8n Workflow Tool, you will need the target n8n workflows already set up and configured.
Setup/Usage
- Import the Workflow: Import the provided JSON into your n8n instance.
- Activate the Workflow: Ensure the workflow is activated to start the MCP server.
- Configure MCP Server Trigger: The
MCP Server Triggernode will automatically expose an endpoint for your AI model to interact with. - Customize Routing Logic:
SwitchNode: Modify the conditions in theSwitchnode (ID 112) to define how incoming MCP requests are routed to either theCode ToolorCall n8n Workflow Tool. This typically involves checking specific parameters or intents from the AI's request.Code ToolNode: Add your custom JavaScript logic to theCode Toolnode (ID 1197) to perform specific actions when that path is taken.Call n8n Workflow ToolNode: Configure theCall n8n Workflow Toolnode (ID 1205) to specify which other n8n workflow should be triggered and what data should be passed to it.
- Integrate with AI Model: Configure your AI model to send MCP requests to the endpoint exposed by the
MCP Server Triggernode, ensuring the requests align with the routing logic defined in theSwitchnode. - Optional: Code Node: The standalone
Codenode (ID 834) can be used for general-purpose JavaScript execution within the workflow if needed, though theCode Toolis typically used for AI-driven code execution. - Optional: Execute Workflow Trigger: If this workflow is intended to be called by other n8n workflows, ensure the
Execute Workflow Triggernode (ID 837) is configured as needed.
Related Templates
Generate song lyrics and music from text prompts using OpenAI and Fal.ai Minimax
Spark your creativity instantly in any chat—turn a simple prompt like "heartbreak ballad" into original, full-length lyrics and a professional AI-generated music track, all without leaving your conversation. 📋 What This Template Does This chat-triggered workflow harnesses AI to generate detailed, genre-matched song lyrics (at least 600 characters) from user messages, then queues them for music synthesis via Fal.ai's minimax-music model. It polls asynchronously until the track is ready, delivering lyrics and audio URL back in chat. Crafts original, structured lyrics with verses, choruses, and bridges using OpenAI Submits to Fal.ai for melody, instrumentation, and vocals aligned to the style Handles long-running generations with smart looping and status checks Returns complete song package (lyrics + audio link) for seamless sharing 🔧 Prerequisites n8n account (self-hosted or cloud with chat integration enabled) OpenAI account with API access for GPT models Fal.ai account for AI music generation 🔑 Required Credentials OpenAI API Setup Go to platform.openai.com → API keys (sidebar) Click "Create new secret key" → Name it (e.g., "n8n Songwriter") Copy the key and add to n8n as "OpenAI API" credential type Test by sending a simple chat completion request Fal.ai HTTP Header Auth Setup Sign up at fal.ai → Dashboard → API Keys Generate a new API key → Copy it In n8n, create "HTTP Header Auth" credential: Name="Fal.ai", Header Name="Authorization", Header Value="Key [Your API Key]" Test with a simple GET to their queue endpoint (e.g., /status) ⚙️ Configuration Steps Import the workflow JSON into your n8n instance Assign OpenAI API credentials to the "OpenAI Chat Model" node Assign Fal.ai HTTP Header Auth to the "Generate Music Track", "Check Generation Status", and "Fetch Final Result" nodes Activate the workflow—chat trigger will appear in your n8n chat interface Test by messaging: "Create an upbeat pop song about road trips" 🎯 Use Cases Content Creators: YouTubers generating custom jingles for videos on the fly, streamlining production from idea to audio export Educators: Music teachers using chat prompts to create era-specific folk tunes for classroom discussions, fostering interactive learning Gift Personalization: Friends crafting anniversary R&B tracks from shared memories via quick chats, delivering emotional audio surprises Artist Brainstorming: Songwriters prototyping hip-hop beats in real-time during sessions, accelerating collaboration and iteration ⚠️ Troubleshooting Invalid JSON from AI Agent: Ensure the system prompt stresses valid JSON; test the agent standalone with a sample query Music Generation Fails (401/403): Verify Fal.ai API key has minimax-music access; check usage quotas in dashboard Status Polling Loops Indefinitely: Bump wait time to 45-60s for complex tracks; inspect fal.ai queue logs for bottlenecks Lyrics Under 600 Characters: Tweak agent prompt to enforce fuller structures like [V1][C][V2][B][C]; verify output length in executions
Automate Dutch Public Procurement Data Collection with TenderNed
TenderNed Public Procurement What This Workflow Does This workflow automates the collection of public procurement data from TenderNed (the official Dutch tender platform). It: Fetches the latest tender publications from the TenderNed API Retrieves detailed information in both XML and JSON formats for each tender Parses and extracts key information like organization names, titles, descriptions, and reference numbers Filters results based on your custom criteria Stores the data in a database for easy querying and analysis Setup Instructions This template comes with sticky notes providing step-by-step instructions in Dutch and various query options you can customize. Prerequisites TenderNed API Access - Register at TenderNed for API credentials Configuration Steps Set up TenderNed credentials: Add HTTP Basic Auth credentials with your TenderNed API username and password Apply these credentials to the three HTTP Request nodes: "Tenderned Publicaties" "Haal XML Details" "Haal JSON Details" Customize filters: Modify the "Filter op ..." node to match your specific requirements Examples: specific organizations, contract values, regions, etc. How It Works Step 1: Trigger The workflow can be triggered either manually for testing or automatically on a daily schedule. Step 2: Fetch Publications Makes an API call to TenderNed to retrieve a list of recent publications (up to 100 per request). Step 3: Process & Split Extracts the tender array from the response and splits it into individual items for processing. Step 4: Fetch Details For each tender, the workflow makes two parallel API calls: XML endpoint - Retrieves the complete tender documentation in XML format JSON endpoint - Fetches metadata including reference numbers and keywords Step 5: Parse & Merge Parses the XML data and merges it with the JSON metadata and batch information into a single data structure. Step 6: Extract Fields Maps the raw API data to clean, structured fields including: Publication ID and date Organization name Tender title and description Reference numbers (kenmerk, TED number) Step 7: Filter Applies your custom filter criteria to focus on relevant tenders only. Step 8: Store Inserts the processed data into your database for storage and future analysis. Customization Tips Modify API Parameters In the "Tenderned Publicaties" node, you can adjust: offset: Starting position for pagination size: Number of results per request (max 100) Add query parameters for date ranges, status filters, etc. Add More Fields Extend the "Splits Alle Velden" node to extract additional fields from the XML/JSON data, such as: Contract value estimates Deadline dates CPV codes (procurement classification) Contact information Integrate Notifications Add a Slack, Email, or Discord node after the filter to get notified about new matching tenders. Incremental Updates Modify the workflow to only fetch new tenders by: Storing the last execution timestamp Adding date filters to the API query Only processing publications newer than the last run Troubleshooting No data returned? Verify your TenderNed API credentials are correct Check that you have setup youre filter proper Need help setting this up or interested in a complete tender analysis solution? Get in touch 🔗 LinkedIn – Wessel Bulte
Auto-reply & create Linear tickets from Gmail with GPT-5, gotoHuman & human review
This workflow automatically classifies every new email from your linked mailbox, drafts a personalized reply, and creates Linear tickets for bugs or feature requests. It uses a human-in-the-loop with gotoHuman and continuously improves itself by learning from approved examples. How it works The workflow triggers on every new email from your linked mailbox. Self-learning Email Classifier: an AI model categorizes the email into defined categories (e.g., Bug Report, Feature Request, Sales Opportunity, etc.). It fetches previously approved classification examples from gotoHuman to refine decisions. Self-learning Email Writer: the AI drafts a reply to the email. It learns over time by using previously approved replies from gotoHuman, with per-classification context to tailor tone and style (e.g., different style for sales vs. bug reports). Human Review in gotoHuman: review the classification and the drafted reply. Drafts can be edited or retried. Approved values are used to train the self-learning agents. Send approved Reply: the approved response is sent as a reply to the email thread. Create ticket: if the classification is Bug or Feature Request, a ticket is created by another AI agent in Linear. Human Review in gotoHuman: How to set up Most importantly, install the gotoHuman node before importing this template! (Just add the node to a blank canvas before importing) Set up credentials for gotoHuman, OpenAI, your email provider (e.g. Gmail), and Linear. In gotoHuman, select and create the pre-built review template "Support email agent" or import the ID: 6fzuCJlFYJtlu9mGYcVT. Select this template in the gotoHuman node. In the "gotoHuman: Fetch approved examples" http nodes you need to add your formId. It is the ID of the review template that you just created/imported in gotoHuman. Requirements gotoHuman (human supervision, memory for self-learning) OpenAI (classification, drafting) Gmail or your preferred email provider (for email trigger+replies) Linear (ticketing) How to customize Expand or refine the categories used by the classifier. Update the prompt to reflect your own taxonomy. Filter fetched training data from gotoHuman by reviewer so the writer adapts to their personalized tone and preferences. Add more context to the AI email writer (calendar events, FAQs, product docs) to improve reply quality.