Deploy a powerful n8n workflow acting as an AI Agent Tool Server for Gmail. Enable large language models to search, reply, label, manage drafts, and manipulate threads using this robust n8n node setup.
Download this n8n workflow template and start using it instantly.
Users utilizing AI Agents (LLMs) to perform complex, multi-step email management tasks.
n8n automation specialists building sophisticated conversational agents that require real-time Gmail access.
Developers needing a single, robust n8n API endpoint for 19 distinct Gmail functionalities.
Teams looking for advanced, AI-driven alternatives to standard n8n templates for inbox management.
This configuration is not a standard scheduled n8n workflow; it's designed specifically to function as a powerful tool server for an external AI Agent. It uses a specialized n8n trigger (mcpTrigger) to expose 19 critical Gmail operations as callable tools. This allows the AI Agent to perform advanced tasks—such as searching for specific emails, marking them as read, applying/removing labels, managing drafts, and replying to entire threads—all through a single, secure n8n endpoint.
By leveraging this n8n node setup, you create a seamless bridge between your Large Language Model and your email account, providing precise, context-aware execution capabilities that go far beyond what simple webhook n8n templates can achieve. This robust n8n workflow simplifies the LLM's interaction with complex email functionality.
The entire process is initiated by the custom n8n trigger node, named Gmail MCP Server (mcpTrigger). This specialized n8n node listens on a dedicated path (/gmail). When an external AI Agent decides it needs to perform a Gmail operation (e.g., searching for a message or creating a draft), it calls this server endpoint, providing the required input parameters (like MessageID, SearchQuery, or Message content).
This core n8n trigger then routes the request to the appropriate downstream gmailTool n8n node—such as search, reply, or createDraft—based on the command sent by the AI Agent. Each of the subsequent gmailTool nodes uses expressions like {{ $fromAI('ParameterName') }} to dynamically extract the necessary variables supplied by the Agent. The chosen gmailTool executes the specific Gmail action using the pre-configured OAuth2 credentials and returns the outcome (e.g., the message content, a list of threads, or a confirmation of the action) back through the n8n workflow to the initiating AI Agent. This design ensures that the AI Agent can execute complex, multi-step Gmail tasks with accuracy using the full power of the n8n automation platform.
gmailTool n8n node instances rely on a single, shared Gmail OAuth2 credential named 'Your Gmail Account'. You must set up or select an existing Gmail credential with appropriate read, write, and manage permissions.Gmail MCP Server n8n trigger node (the mcpTrigger) is active and obtain its specific Server-Sent Events (SSE) URL. This is the URL your AI Agent will use to send requests.gmail tool and the specific functions it exposes. Ensure the agent is aware of the required input parameters for each function (e.g., Message_ID for 'get' or 'reply', or a Search string for 'search').This n8n workflow exposes 19 functions using the gmailTool n8n node, all managed by a single mcpTrigger.
Gmail MCP Server (@n8n/n8n-nodes-langchain.mcpTrigger):
Function: The central entry point (n8n trigger) that listens for calls from the AI Agent.
Key Configuration: Path is set to gmail.
Message Operations (n8n node: gmailTool):
search: Executes complex Gmail search queries (q, sender, receivedAfter, receivedBefore) and returns matching messages.
get: Retrieves the full content of a single email using the dynamically supplied MessageID.
reply: Sends a response to a message, accepting inputs for Message, CC, BCC, and optional attachments.
delete: Permanently deletes the message specified by MessageID.
addLabels / removeLabels: Modifies the labels on a message using LabelNamesorIDs.
markAsRead / markAsUnread: Toggles the read status of a message, configured via the MessageID input.
Label Management Operations (n8n node: gmailTool, Resource: Label):
getLabels: Retrieves a list of all available labels in the account.
createLabel: Creates a new custom label.
deleteLabel: Removes an existing label by ID.
Draft Operations (n8n node: gmailTool, Resource: Draft):
createDraft: Composes a new draft email, accepting inputs for Subject and Message.
getDraft / getManyDrafts: Retrieves single or multiple drafts, supporting filters like IncludeSpamandTrash.
deleteDraft: Deletes a specific draft using its DraftID.
Thread Operations (n8n node: gmailTool, Resource: Thread):
getManyThreads / getThread: Allows the AI Agent to search for or retrieve entire conversational threads.
replyThread: Sends a reply that automatically threads correctly using the Thread_ID.
addLabelThread / removeLabelThread: Applies or removes labels to the entire thread conversation, ensuring all related messages are categorized consistently. This complete n8n workflow provides powerful AI control.
Automate Gmail customer support responses using this powerful n8n workflow. It leverages local Ollama models and Pinecone RAG for accurate, context-aware replies. Easily set up these n8n templates.

Use this powerful n8n workflow to track expenses instantly. Capture receipts via Telegram, extract text using Tesseract OCR, and categorize expenses using AI parsing via OpenRouter/LangChain.

Use this n8n workflow to securely expose a NetSuite SuiteQL endpoint. Execute dynamic database queries via an n8n webhook trigger, ideal for complex reporting and data extraction.

Use this powerful n8n workflow to automatically triage, classify, and respond to incoming Gmail messages using Google Gemini AI, and schedule meetings instantly using Google Calendar.

Experienced Linux administrator, entrepreneur, and automation enthusiast, I specialize in crafting robust, scalable workflows with n8n. I have a passion for business automation, integrating complex systems seamlessly, and sharing practical templates that empower others to automate effectively.







































