1 00:00:00,05 --> 00:00:03,01 - [Narrator] Before our agent can really do anything useful, 2 00:00:03,01 --> 00:00:04,06 it needs tools. 3 00:00:04,06 --> 00:00:07,09 So in this lesson we'll explore what a tool really is, 4 00:00:07,09 --> 00:00:10,00 how tools work in n8n, 5 00:00:10,00 --> 00:00:12,06 and what the difference is between built-in custom 6 00:00:12,06 --> 00:00:16,07 and external tools, including things like MCP. 7 00:00:16,07 --> 00:00:17,07 But before we get there, 8 00:00:17,07 --> 00:00:21,00 let's quickly discuss what exactly is a tool. 9 00:00:21,00 --> 00:00:24,03 Well, conceptually a tool is just an API call 10 00:00:24,03 --> 00:00:26,08 wrapped with plain language documentation: 11 00:00:26,08 --> 00:00:29,02 a name, a description, and a schema 12 00:00:29,02 --> 00:00:33,03 that lists the input parameters the agent can supply. 13 00:00:33,03 --> 00:00:36,06 That schema is the bridge between the agent's reasoning 14 00:00:36,06 --> 00:00:38,07 and structure data. 15 00:00:38,07 --> 00:00:41,07 Think of a tool like a function with documentation built in. 16 00:00:41,07 --> 00:00:44,01 The LLM here doesn't read code, 17 00:00:44,01 --> 00:00:46,07 it reads the available tool descriptions 18 00:00:46,07 --> 00:00:48,01 and keeps them in context, 19 00:00:48,01 --> 00:00:51,00 typically as part of the system prompt. 20 00:00:51,00 --> 00:00:52,03 Let's make this concrete. 21 00:00:52,03 --> 00:00:55,02 Imagine we would like to give our LLM a tool 22 00:00:55,02 --> 00:00:58,03 that allows it to create GitHub issues for us. 23 00:00:58,03 --> 00:01:01,05 Here's a GitHub API call that creates an issue. 24 00:01:01,05 --> 00:01:03,03 It sends a title and body. 25 00:01:03,03 --> 00:01:06,06 It's a simple POST HTTP request. 26 00:01:06,06 --> 00:01:09,03 To give the LLM access to this tool, 27 00:01:09,03 --> 00:01:11,07 we would define the tool similar to this 28 00:01:11,07 --> 00:01:13,04 in the system prompt. 29 00:01:13,04 --> 00:01:14,05 There isn't really a standard 30 00:01:14,05 --> 00:01:16,07 for defining these tools except for MCP, 31 00:01:16,07 --> 00:01:18,04 which we'll cover in a bit. 32 00:01:18,04 --> 00:01:21,04 For now, here's what the agent sees: 33 00:01:21,04 --> 00:01:25,00 a function like definition, typically in JSON schema 34 00:01:25,00 --> 00:01:29,07 with parameter names, types, and which ones are required. 35 00:01:29,07 --> 00:01:32,04 If we now prompt this LLM with a message like, 36 00:01:32,04 --> 00:01:35,09 "Create a GitHub issue for me, 'Bug: Payment fails,'" 37 00:01:35,09 --> 00:01:39,08 and the body message, "'Errors on checkout for EU cards,'" 38 00:01:39,08 --> 00:01:42,02 then the LLM would recognize the intent 39 00:01:42,02 --> 00:01:46,02 and match the user's goal, create an issue to the tool, 40 00:01:46,02 --> 00:01:48,01 Create a GitHub issue. 41 00:01:48,01 --> 00:01:51,06 That decision is made entirely by the LLM's reasoning, 42 00:01:51,06 --> 00:01:54,00 based on the tool's description. 43 00:01:54,00 --> 00:01:57,04 And effectively the LLM generates the payload, 44 00:01:57,04 --> 00:02:00,06 structured data that matches the schema. 45 00:02:00,06 --> 00:02:02,06 This is not the API call itself, 46 00:02:02,06 --> 00:02:06,05 it's just a description of what needs to be executed. 47 00:02:06,05 --> 00:02:11,02 Now, the LLM runtime, in our case, that's n8n, takes over. 48 00:02:11,02 --> 00:02:14,07 It recognizes that the model is trying to call a tool, 49 00:02:14,07 --> 00:02:17,03 and instead of showing that payload to the user, 50 00:02:17,03 --> 00:02:20,04 it passes it to the corresponding tool node, 51 00:02:20,04 --> 00:02:22,02 which runs the real action. 52 00:02:22,02 --> 00:02:27,00 And in this case, that's an HTTP request to the GitHub API. 53 00:02:27,00 --> 00:02:29,02 n8n handles the credentials, headers, 54 00:02:29,02 --> 00:02:31,02 and network call safely. 55 00:02:31,02 --> 00:02:34,08 The LLM never touches those directly. 56 00:02:34,08 --> 00:02:39,09 GitHub now sends back a response, the issue number and URL. 57 00:02:39,09 --> 00:02:41,09 And n8n then captures that output 58 00:02:41,09 --> 00:02:44,05 and feeds it back into the agent's memory, 59 00:02:44,05 --> 00:02:47,00 or conversation context. 60 00:02:47,00 --> 00:02:50,00 And now finally, the LLM interprets the result 61 00:02:50,00 --> 00:02:52,05 and replies a natural language. 62 00:02:52,05 --> 00:02:55,03 Note, it didn't make the API call itself. 63 00:02:55,03 --> 00:02:57,02 It simply decided what to do, 64 00:02:57,02 --> 00:03:00,05 and then n8n handled how to do it. 65 00:03:00,05 --> 00:03:03,06 That's the core of agentic tool use. 66 00:03:03,06 --> 00:03:07,06 So to recap quickly, first, the LLM decides which tool 67 00:03:07,06 --> 00:03:09,07 to use and prepares the payload. 68 00:03:09,07 --> 00:03:12,07 Second, n8n then executes the real API call 69 00:03:12,07 --> 00:03:14,05 through a node or workflow. 70 00:03:14,05 --> 00:03:18,08 And then third, the result flows back into the conversation. 71 00:03:18,08 --> 00:03:21,03 That's how the agent moves from generating text 72 00:03:21,03 --> 00:03:23,09 to performing real action. 73 00:03:23,09 --> 00:03:25,09 Let's zoom in back to n8n. 74 00:03:25,09 --> 00:03:28,07 In n8n tools come in three flavors. 75 00:03:28,07 --> 00:03:32,01 Pre-built standard nodes, custom tools in n8n, 76 00:03:32,01 --> 00:03:35,04 typically your own workflows exposed as tools, 77 00:03:35,04 --> 00:03:39,06 and external APIs, you call via HTTP requests. 78 00:03:39,06 --> 00:03:41,08 Let's look at pre-built tools. 79 00:03:41,08 --> 00:03:44,07 n8n comes with a wide range of built-in connectors 80 00:03:44,07 --> 00:03:49,02 to popular services like Gmail, Airtable, or even GitHub. 81 00:03:49,02 --> 00:03:51,05 Each of these connectors already includes 82 00:03:51,05 --> 00:03:53,09 a predefined tool description, 83 00:03:53,09 --> 00:03:56,02 which you can fully customize if you want, 84 00:03:56,02 --> 00:03:58,05 along with the most relevant data fields. 85 00:03:58,05 --> 00:04:02,01 For example, the Gmail node exposes inputs like 86 00:04:02,01 --> 00:04:04,01 the To address, the Subject line, 87 00:04:04,01 --> 00:04:07,03 and the Message body, so the agent knows exactly 88 00:04:07,03 --> 00:04:10,03 how to send an email through Gmail. 89 00:04:10,03 --> 00:04:13,08 Now, let's talk about custom internal tools. 90 00:04:13,08 --> 00:04:16,05 n8n lets you take any workflow you've built 91 00:04:16,05 --> 00:04:20,01 and expose it as a tool for your AI agent. 92 00:04:20,01 --> 00:04:23,07 That means the agent can trigger any n8n workflow, 93 00:04:23,07 --> 00:04:26,06 passing in data and getting structured results back 94 00:04:26,06 --> 00:04:28,06 just like an API call. 95 00:04:28,06 --> 00:04:31,08 Make no mistake, this is super-powerful. 96 00:04:31,08 --> 00:04:34,01 You've seen this in action earlier when we connected 97 00:04:34,01 --> 00:04:35,04 our knowledge tool. 98 00:04:35,04 --> 00:04:38,00 The agent sent a question into a workflow, 99 00:04:38,00 --> 00:04:39,07 the workflow fetched the answer 100 00:04:39,07 --> 00:04:43,04 and then returned it to the agent as a result. 101 00:04:43,04 --> 00:04:45,04 But it doesn't have to be a big workflow. 102 00:04:45,04 --> 00:04:48,04 A tool could be as simple as a little code node 103 00:04:48,04 --> 00:04:51,05 that performs a small calculation, cleans text, 104 00:04:51,05 --> 00:04:53,08 or a small transformation. 105 00:04:53,08 --> 00:04:56,04 If it accepts inputs and returns outputs, 106 00:04:56,04 --> 00:04:58,02 it can act as a tool. 107 00:04:58,02 --> 00:05:00,06 By exposing your internal logic this way, 108 00:05:00,06 --> 00:05:04,00 whether it's a full workflow or just a small code snippet, 109 00:05:04,00 --> 00:05:06,04 your agent can start using the custom logic 110 00:05:06,04 --> 00:05:09,00 that already lives inside your organization, 111 00:05:09,00 --> 00:05:11,06 not just external APIs. 112 00:05:11,06 --> 00:05:14,02 Now, let's talk about external tools. 113 00:05:14,02 --> 00:05:16,07 These are typically APIs that aren't covered 114 00:05:16,07 --> 00:05:18,06 by n8n's built-in nodes. 115 00:05:18,06 --> 00:05:20,03 The most flexible way to connect them 116 00:05:20,03 --> 00:05:23,00 is through the HTTP request node. 117 00:05:23,00 --> 00:05:26,02 Here you define the endpoint, the HTTP method, 118 00:05:26,02 --> 00:05:30,09 any headers or authentication, and the expected body fields. 119 00:05:30,09 --> 00:05:32,01 Once that's configured, 120 00:05:32,01 --> 00:05:35,02 your agent can call this node just like any other tool, 121 00:05:35,02 --> 00:05:39,04 passing in parameters and getting the API response back. 122 00:05:39,04 --> 00:05:42,03 You can use this to integrate practically anything, 123 00:05:42,03 --> 00:05:45,06 from CRMs to databases, document repositories, 124 00:05:45,06 --> 00:05:48,09 or even your own internal APIs. 125 00:05:48,09 --> 00:05:51,00 And there's also a newer standard to this 126 00:05:51,00 --> 00:05:55,07 called the Model Context Protocol, or MCP. 127 00:05:55,07 --> 00:05:59,08 MCP defines a common way for tools to describe themselves, 128 00:05:59,08 --> 00:06:02,09 including their name, description, and input schema. 129 00:06:02,09 --> 00:06:05,06 So any LLM-based agent can understand 130 00:06:05,06 --> 00:06:07,08 how to use them right away. 131 00:06:07,08 --> 00:06:11,07 n8n now supports this natively through the MCP client node, 132 00:06:11,07 --> 00:06:14,07 which connects to any MCP server. 133 00:06:14,07 --> 00:06:18,00 An MCP server can expose multiple tool at once, 134 00:06:18,00 --> 00:06:21,00 so you don't have to wire them up one by one. 135 00:06:21,00 --> 00:06:23,02 For example, imagine connecting to 136 00:06:23,02 --> 00:06:25,05 a Google Workspace MCP server 137 00:06:25,05 --> 00:06:29,02 that gives you access to Gmail, Drive, Sheets, and Docs 138 00:06:29,02 --> 00:06:31,05 all through a single connection. 139 00:06:31,05 --> 00:06:34,03 In practice, though, you might not need MCP 140 00:06:34,03 --> 00:06:37,01 that often inside n8n, since there are already 141 00:06:37,01 --> 00:06:39,08 so many built-in connectors available. 142 00:06:39,08 --> 00:06:42,03 But it's a powerful option for integrating 143 00:06:42,03 --> 00:06:47,00 external ecosystems that publish MCP endpoints. 144 00:06:47,00 --> 00:06:49,05 And since you might hear MCP more and more often, 145 00:06:49,05 --> 00:06:51,02 here's how it works. 146 00:06:51,02 --> 00:06:53,07 On the left, you have the MCP client, 147 00:06:53,07 --> 00:06:55,07 like in our case, n8n. 148 00:06:55,07 --> 00:06:58,03 It connects to an external MCP server, 149 00:06:58,03 --> 00:06:59,09 shown here in the middle. 150 00:06:59,09 --> 00:07:02,09 This server can be hosted by anyone, even by you. 151 00:07:02,09 --> 00:07:05,07 Since MCP is an open standard. 152 00:07:05,07 --> 00:07:09,02 The server then hosts and manages multiple tools, 153 00:07:09,02 --> 00:07:12,07 each with its own authentication and description. 154 00:07:12,07 --> 00:07:16,03 Now, instead of wiring up every API individually, 155 00:07:16,03 --> 00:07:20,04 n8n only needs to connect to the MCP server once. 156 00:07:20,04 --> 00:07:24,00 From there, it automatically discovers all available tools, 157 00:07:24,00 --> 00:07:26,09 like email, documents, or database access 158 00:07:26,09 --> 00:07:28,06 that the server exposes. 159 00:07:28,06 --> 00:07:31,05 So, the MCP client in n8n becomes your bridge 160 00:07:31,05 --> 00:07:33,06 to entire ecosystems of tools, 161 00:07:33,06 --> 00:07:37,03 without the manual setup you'd normally need for each one. 162 00:07:37,03 --> 00:07:39,07 To summarize, the user sends a message 163 00:07:39,07 --> 00:07:43,05 and then the LLM decides whether and which tool to use. 164 00:07:43,05 --> 00:07:45,03 It creates a structured payload, 165 00:07:45,03 --> 00:07:48,01 which is then handed off to n8n. 166 00:07:48,01 --> 00:07:51,06 n8n then executes the real API call internally 167 00:07:51,06 --> 00:07:53,08 using a built-in tool or workflow, 168 00:07:53,08 --> 00:07:58,06 or externally by calling an HTTP API, or MCP server. 169 00:07:58,06 --> 00:08:02,01 It gets the results and feeds that back to the model. 170 00:08:02,01 --> 00:08:06,00 Finally, the LLM replies to the user in natural language. 171 00:08:06,00 --> 00:08:09,05 This simple cycle, decide, execute and return, 172 00:08:09,05 --> 00:08:12,06 is what turns a passive chatbot into an active agent 173 00:08:12,06 --> 00:08:16,00 that can actually interact with the world around it.