|
| 1 | +# n8n |
| 2 | + |
| 3 | +The [n8n MCP Server](https://docs.n8n.io/advanced-ai/accessing-n8n-mcp-server/) |
| 4 | +connects your ADK agent to [n8n](https://n8n.io/), an extendable workflow |
| 5 | +automation tool. This integration allows your agent to securely connect to an |
| 6 | +n8n instance to search, inspect, and trigger workflows directly from a natural |
| 7 | +language interface. |
| 8 | + |
| 9 | +!!! note "Alternative: Workflow-level MCP Server" |
| 10 | + |
| 11 | + The configuration guide on this page covers **Instance-level MCP access**, |
| 12 | + which connects your agent to a central hub of enabled workflows. |
| 13 | + Alternatively, you can use the |
| 14 | + [MCP Server Trigger node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger/) |
| 15 | + to make a **single workflow** act as its own standalone MCP server. This |
| 16 | + method is useful if you want to craft specific server behaviors or expose |
| 17 | + tools isolated to one workflow. |
| 18 | + |
| 19 | +## Use cases |
| 20 | + |
| 21 | +- **Execute Complex Workflows**: Trigger multi-step business processes defined |
| 22 | + in n8n directly from your agent, leveraging reliable branching logic, loops, |
| 23 | + and error handling to ensure consistency. |
| 24 | + |
| 25 | +- **Connect to External Apps**: Access pre-built integrations through n8n |
| 26 | + without writing custom tools for each service, eliminating the need to manage |
| 27 | + API authentication, headers, or boilerplate code. |
| 28 | + |
| 29 | +- **Data Processing**: Offload complex data transformation tasks to n8n |
| 30 | + workflows, such as converting natural language into API calls or scraping and |
| 31 | + summarizing webpages, utilizing custom Python or JavaScript nodes for precise |
| 32 | + data shaping. |
| 33 | + |
| 34 | +## Prerequisites |
| 35 | + |
| 36 | +- An active n8n instance |
| 37 | +- MCP access enabled in settings |
| 38 | +- A valid MCP access token |
| 39 | + |
| 40 | +Refer to the |
| 41 | +[n8n MCP documentation](https://docs.n8n.io/advanced-ai/accessing-n8n-mcp-server/) |
| 42 | +for detailed setup instructions. |
| 43 | + |
| 44 | +## Use with agent |
| 45 | + |
| 46 | +=== "Local MCP Server" |
| 47 | + |
| 48 | + ```python |
| 49 | + from google.adk.agents import Agent |
| 50 | + from google.adk.tools.mcp_tool import McpToolset |
| 51 | + from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams |
| 52 | + from mcp import StdioServerParameters |
| 53 | + |
| 54 | + N8N_INSTANCE_URL = "https://localhost:5678" |
| 55 | + N8N_MCP_TOKEN = "YOUR_N8N_MCP_TOKEN" |
| 56 | + |
| 57 | + root_agent = Agent( |
| 58 | + model="gemini-2.5-pro", |
| 59 | + name="n8n_agent", |
| 60 | + instruction="Help users manage and execute workflows in n8n", |
| 61 | + tools=[ |
| 62 | + McpToolset( |
| 63 | + connection_params=StdioConnectionParams( |
| 64 | + server_params=StdioServerParameters( |
| 65 | + command="npx", |
| 66 | + args=[ |
| 67 | + "-y", |
| 68 | + "supergateway", |
| 69 | + "--streamableHttp", |
| 70 | + f"{N8N_INSTANCE_URL}/mcp-server/http", |
| 71 | + "--header", |
| 72 | + f"authorization:Bearer {N8N_MCP_TOKEN}" |
| 73 | + ] |
| 74 | + ), |
| 75 | + timeout=300, |
| 76 | + ), |
| 77 | + ) |
| 78 | + ], |
| 79 | + ) |
| 80 | + ``` |
| 81 | + |
| 82 | +=== "Remote MCP Server" |
| 83 | + |
| 84 | + ```python |
| 85 | + from google.adk.agents import Agent |
| 86 | + from google.adk.tools.mcp_tool import McpToolset |
| 87 | + from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPServerParams |
| 88 | + |
| 89 | + N8N_INSTANCE_URL = "https://localhost:5678" |
| 90 | + N8N_MCP_TOKEN = "YOUR_N8N_MCP_TOKEN" |
| 91 | + |
| 92 | + root_agent = Agent( |
| 93 | + model="gemini-2.5-pro", |
| 94 | + name="n8n_agent", |
| 95 | + instruction="Help users manage and execute workflows in n8n", |
| 96 | + tools=[ |
| 97 | + McpToolset( |
| 98 | + connection_params=StreamableHTTPServerParams( |
| 99 | + url=f"{N8N_INSTANCE_URL}/mcp-server/http", |
| 100 | + headers={ |
| 101 | + "Authorization": f"Bearer {N8N_MCP_TOKEN}", |
| 102 | + }, |
| 103 | + ), |
| 104 | + ) |
| 105 | + ], |
| 106 | + ) |
| 107 | + ``` |
| 108 | + |
| 109 | +## Available tools |
| 110 | + |
| 111 | +Tool | Description |
| 112 | +---- | ----------- |
| 113 | +`search_workflows` | Search for available workflows |
| 114 | +`execute_workflow` | Execute a specific workflow |
| 115 | +`get_workflow_details` | Retrieve metadata and schema information for a workflow |
| 116 | + |
| 117 | +## Configuration |
| 118 | + |
| 119 | +To make workflows accessible to your agent, they must meet the following |
| 120 | +criteria: |
| 121 | + |
| 122 | +- **Be Active**: The workflow must be activated in n8n. |
| 123 | + |
| 124 | +- **Supported Trigger**: Contain a Webhook, Schedule, Chat, or Form trigger |
| 125 | + node. |
| 126 | + |
| 127 | +- **Enabled for MCP**: You must toggle "Available in MCP" in the workflow |
| 128 | + settings or select "Enable MCP access" from the workflow card menu. |
| 129 | + |
| 130 | +## Additional resources |
| 131 | + |
| 132 | +- [n8n MCP Server Documentation](https://docs.n8n.io/advanced-ai/accessing-n8n-mcp-server/) |
0 commit comments