Skip to main content
In this article we’ll explain how to use MCP (Model Context Protocol) inside n8n to let AI models call external tools (like Gmail) in a reusable, standardized way. You’ll get a practical, step-by-step walkthrough showing how to wire an MCP Client tool inside an AI Agent to an MCP Server Trigger that runs the actual tool in n8n. At a high level, MCP (Model Context Protocol) standardizes how models discover and call external tools. Instead of building a custom integration per model or service, MCP defines a shared contract so the same connector can be reused across models and platforms — simplifying tool reuse, governance, and security in workflows.
The image shows a workflow interface of n8n with nodes labeled "When chat message received," "AI Agent," "OpenAI Chat Model," and "Simple Memory," indicating a setup involving AI and memory tools. The interface includes a sidebar with options like "Admin Panel," "Templates," and "Variables."

Why use MCP vs a direct API integration

MCP is about reuse and standardization. A direct API integration is usually one-to-one: you build an adapter per service and per model. MCP lets you expose tools through a common protocol so multiple models or agents can call the same tool without each needing a bespoke connector.
ApproachWhen to useProsCons
MCP (Model Context Protocol)When multiple models/agents will share the same tools and you want a standard, discoverable contractReuse across models, consistent governance, fewer duplicated connectorsRequires implementing MCP server/client contract
Direct API integrationWhen a single model/service needs a bespoke integrationSimple for single-use casesDuplication, harder to manage across models and teams

Example: AI chat that sends email via an MCP tool

This walkthrough shows how a chat-based AI (OpenAI chat model) can use an MCP Client tool to request sending an email, and how an MCP Server Trigger in n8n receives that request and executes a Gmail node. High-level steps (we follow these in the same workflow for clarity):
  1. Start with a chat trigger → AI Agent → memory (Simple Memory) flow.
  2. Add an MCP Server (MCP Trigger node) to accept client calls.
  3. Add an MCP Client tool to the AI Agent configuration and point it at the MCP Server URL.
  4. Configure server transport (HTTP Streamable recommended) and authentication.
  5. Run the workflow, send a chat prompt, and observe the server executing the Gmail action.

1) Add an MCP Server Trigger

Add the MCP Trigger node to act as your server endpoint. The trigger exposes a Test URL and a Production URL — functionally similar to webhooks — which the MCP Client will call.
The image displays an interface for configuring an MCP Server Trigger, featuring a Test URL, authentication options, and paths. The interface includes buttons for executing steps and copying the MCP URL.
You can enable authentication on the MCP Server if you want production-grade security. For fast demos, you can use the Test URL without authentication — copy the Test URL to the clipboard; that is the endpoint the MCP Client will call.
Leaving your MCP Server unsecured (no authentication) is acceptable only for local demos. For any shared or production environment enable authentication and secure your endpoints.

2) Configure the MCP Client in the AI Agent

Open the AI Agent’s tool configuration and add an MCP Client. Paste the MCP Server Test URL into the client’s endpoint field so the client knows where to send tool calls.
The image shows a software interface for "MCP Client" with settings for parameters such as endpoint, server transport, authentication, and tools to include. The interface is divided into sections labeled "INPUT" and "OUTPUT."
One critical client setting is the server transport. n8n previously recommended SSE (Server-Sent Events) for persistent connections, but SSE has been deprecated in favor of HTTP Streamable.
SSE uses a persistent connection for server-to-client events. HTTP Streamable streams responses over chunked HTTP, allowing the client to start processing partial results as they arrive. For new n8n setups, choose HTTP Streamable.
  • Set Server Transport to HTTP Streamable.
  • If the MCP Server requires credentials, configure matching authentication on the MCP Client; otherwise set to None for demos.

3) Inform the model about the tool (system message)

Tell the model that a tool is available and when to use it:
You are a helpful email assistant with a tool attached. Use the tool to send emails when requested.
The image shows a user interface of an AI tool configuration panel, with settings for an AI agent, including a section for parameters and options. There are input data fields, a system message configuration, and an option to execute or view data.

4) Run the flow and trigger the model

Execute the workflow and send a chat prompt to the agent. Example prompt: “Hi, can you send an email to marconi.zammo@codecloud.com regarding my appointment on Thursday from Jason.” When the model decides to use the tool, it will call the MCP Client, which forwards the request to your MCP Server Trigger. The server executes the configured tool — in this demo, a Gmail action that composes and sends the email using the Gmail node’s account.
The image shows a workflow diagram in a software tool that includes nodes like "AI Agent," "OpenAI Chat Model," and "MCP Server Trigger," with a message waiting to trigger an event. There are also sidebar options for managing the workflow and user interactions.
Demo logs showed the sent message was: “Hello, I’m writing to confirm my appointment on Thursday. Best regards, Jason.” Because the system prompt was minimal, the email body was short. For production, expand the system prompt or add instruction-following steps so the model fills subject lines, recipient names, and message style appropriately.

Troubleshooting and tips

  • If the MCP Client can’t reach the server: verify the Test URL, confirm the server is active, and check any authentication settings.
  • If partial responses are missing or delayed: confirm Server Transport is set to HTTP Streamable and your n8n instance supports it.
  • For complex email generation: add fields in the system prompt or use a follow-up step to collect subject, salutation preferences, or signatures.
For advanced MCP usage, consult the official MCP documentation and your provider’s guidelines to find available servers, client capabilities, and best practices for authentication and governance.

Watch Video

Practice Lab