Let's say you are a backend engineer and your team just got a new task to build an AI powered customer support chatbot for your e-commerce platform. Sounds straightforward, right? But then you look at what this chatbot actually needs to do. A customer asks, "Where's my order?" Your chatbot needs to query your Postgrql database with 2 million orders in it. The customer then asks, "Do you have this in blue?" Now it needs to search your elastic search product catalog with 500,000 products. The customer then asks, "I want a refund. Now it needs to call your Stripe API to process the refund and also hit your Slack API to notify the finance team." So you start building. You write custom integration code to connect your AI model. Let's say you're using Claude to Possql. Then you write another integration for Elastic Search. Then you build an authentication and data formatting layer for Stripe, then for SLE. And then your manager says, "Hey, for the simple quick response questions, let's actually use GPT4. It's faster." So now you need to do the same integrations again, but for GPT4. So you're looking at two AI models and four data sources. So eight custom integrations. And each one has different authentication, different error formats, different ways of handling rate limits. Your codebase is already a mess. And two months later, your company decides to try Gemini. So now you're rewriting everything again. And that's exactly the problem that MCP solves. So very simply put, MCP is a common communication language between LLM powered applications and all the tools that you want to use. So it's used to connect LLMs with various tools and data sources. But wait a minute, we have APIs. It's been industry standard, which is a way machines and programs have been communicating for years. They use APIs to communicate and speak common language using HTTP protocol. So why do we have MCPs suddenly instead of APIs? Can't LM just use APIs like other programs have for years? So let's dive into that question to understand why MCP concept was even created and why we need it. But first quick thing, we noticed that 80% of people who watch our videos every month are still not subscribed yet. Me and our entire video editor team are putting insane time and effort into each and every video to make it as valuable and high quality as possible for you. So, if any of these videos have helped you at all, giving it a like and subscribing to the channel and becoming officially part of our community is the simplest way to support us and it would mean the world to us. Seriously, thank you and let's get into it. So the problem with HTTP APIs is that they were designed for humans writing code not AI agents. So for example here we have an HTTP call to get pod status via Kubernetes REST API. And this is a raw Kubernetes API response when you ask for pod status. So it's hundreds of fields of nested JSON and most of it is irrelevant for the LLM. So for a human this is fine because you just parse what you need. But for an LLM this is a nightmare. An LLM has to figure out which fields actually matter and which not and it will hallucinate or get confused because most fields here are actually irrelevant to answer the question is the pod running. So LLM first has to figure out which fields are relevant for the question it is trying to answer. So what MCP does in this case is your MCP server for Kubernetes prep-processes that response from an API and returns something like pod my app is running three out of three containers ready no restarts uptime 2 hours clean relevant only the information that LLM needs no extra fields so basically MCP sits before an API and translates the API responses from API I speak to AI speak and this is how a simplified LLM friendly response of MCP server looks like in comparison. So you can actually think of it like a smart adapter between LLMs and APIs to translate the human friendly response to AI friendly response. So now as you just saw clearly and this is a very important point to understand MCP is not a replacement for APIs because your posgusql database still has its API. Stripe has its rest API kubernetes has its API. So what MCP replaces is just the glue code that you write to connect your AI model to those APIs. So it's not a replacement. It just sits between LLM and APIs. So essentially you can think of MCP as a wrapper around APIs which also means and that is another important point to understand that having MCP doesn't magically expose more features than what API actually allows. And this is a perception of a lot of people that using MCP somehow makes the tools behind it magically powerful and flexible. But essentially you are still limited to what APIs allow because APIs are like contracts. The API creator for example developers of Stripe decide what Stripe API will expose. So you're still limited to what the tool itself provides. So if poscsql API only lets you read tables, MCP cannot write to them. It will also be limited to just reading tables. So that's just something to keep in mind to be realistic about expectations of MCP. Now, another very important advantage of MCP is what's called a dynamic discovery. So, with traditional APIs, you read the documentation, you hardcode the endpoints and write custom parsers. If the API adds or changes an endpoint that you want to use, you will have to go back to your codebase, update it to call that new or changed API and parse the responses. With MCP, your AI application that is using LMS can run a tool lookup at startup and basically ask the MCP server, hey, tell me what actions or tools I have available to use. So, we can run this tools/list at startup and discover everything dynamically. And that means if you add another API or connect it to another API with bunch of new functionalities, then the AI application will simply ask the MCP server, hey, do you have new tools for me? Something some new stuff that I can use. And it will know it immediately without any changes in the code. And the term tool in MCP is actually a technical term that refers to a specific function that is exposed by an MCP server that the model can invoke or ask the MCP server to invoke on its behalf. So for example, you can have a tool called query orders for possql or you can have a tool called search products for elastic search or a tool called create refund for stripe notify slack for slack and so on. So those are MCP tools which is a function that model can choose to call which is described in machine readable form so that LLM can sit in the tools list understand what parameters it takes so every tool has a well- definfined JSON input and output shape so you know what parameters it takes and what it returns as a response and LLM can also decide when and how to invoke that MCP tool and that can be huge advantage when writing code because instead of [snorts] hard- coding every endpoint and then updating them when the endpoint changes with MCP you don't even need to know before what endpoints exist with MCP approach the LLM can essentially autodiscocover capabilities at runtime so when you start the application it will send a request hey give me all the tools available and then use them on demand so to give you an easy analogy as a comparison think about APIs like a restaurant with a printed menu. You're going to read it to know exactly what they serve. And if they add a dish or remove a dish, they must reprint or change the menu. Whereas MCP is like a waiter who basically tells you, "Today we have XY Z." And if the chef adds a new special, the waiter immediately knows about it and can just update you on the go. Another very important part is the stateful context. Let me explain. Traditional HTTP APIs are stateless, which means every request is isolated. It doesn't connect and share context with previous or following requests. So if you want to chain three API calls together, you are writing the orchestration logic yourself, which means you make the first call, you get a response, you store the result of call one in a variable, you pass it into call two, and you do the same for the third call, and so on. With MCP, the protocol session is stateful. So basically, the application that talks to the MCP server can keep prior tool results in context for the LLM because LLM will propose the orchestration steps. So you can do multi-step requests and then host will execute those steps. Which means you don't have to repeat or give the entire context in every single request. You can actually do follow-up requests instead. Now, why is this amazing for LLMs and LLM based applications? Because you have natural conversation flow for a chatbot, for example, like talking to a human. You don't need to respppecify context every time. LM can chain multiple tool calls, which is also important. So, you can carry context between requests to different tools and so on. So for example here the first request will be check my app pod status in a Kubernetes cluster. You get a response that pod is running but one of three containers is not ready. So LM decides should I restart the pod and instead of saying restart the pod my app in this name space in a Kubernetes cluster you literally just say yes restart it and it knows what it refers to. It knows what this follow-up request actually needs to do exactly from the previous call. Now there is another big advantage with MCPS around security and access control. What do I mean by that? With HTTP APIs, you actually have a big problem. If you're using 10 different APIs of 10 different tools, you're going to need to manage 10 different API keys in your code because you need to give your application access to the API keys in order to authenticate to those endpoints, right? And if you were connecting your LLMs to the APIs directly, you would actually need to give LLMs API keys to call those API endpoints which would be a security nightmare. Imagine giving your LLMs who sometimes are unpredictable API keys to all the tools that you want to connect to. And especially for enterprises and companies with lot of security requirements, a lot of compliance requirements, this is a huge one. So with MCPS the big advantage is that the secrets like API keys, connection strings, tokens and so on they live inside the MCP server itself. So LLM never sees them. The LM proposes call this tool or invokes a function and then MCP server then uses its own credentials to call the underlying APIs which means LLM never sees your secrets. So secrets stay in MCP server. LMS connect to the MCP server try to invoke different functions. So for example, LM says restart the pot in a Kubernetes cluster in this name space. MCP server will validate the request, check permissions, add authentication header and then after the LLM request is validated, it will connect to Kubernetes API and restart the pod. So LLM never sees API keys, tokens, connection, strings, internal URLs. And as I said, this is huge, especially for enterprises because you can safely give LLMs and AI agents really powerful capabilities without exposing your credentials. But note that this is just one layer of security. Your MCP servers and AI agents are still running somewhere on the network, right? And if they're reachable from the public internet, they are exposed. And this is exactly what Tailscale, the sponsor of this video, helps with. Tailscale is a modern zerorust connectivity platform. It builds an encrypted private network between your devices and services. So your MCP servers only talk to the machines you've authorized. There are no open ports, no firewall rules to manage. It handles the connection automatically even through nets and firewalls. And for AI specifically, they built Aperture, which is a gateway that sits in front of your AI setup, and you can easily swap which agents you're using without a new configuration introducing risk. You get full logs of every tool call your agent makes. You can block calls before they execute. And your API keys stay in one central place instead of being spread across containers and developer machines. Tail scale handles network level access. Aperture adds the governance layer on top of it. Two problems you'd otherwise have to solve yourself. If you're running AI agents in production, security is definitely not something that you want to skip. So, be sure to check them out. Their personal plan is always free. And if you want to bring Tailscale to work, then you can use code nana for three free months on any paid plan. Link and all the information is going to be in the description. And now back to the video. And finally, another big advantage I want to highlight is that you can swap AI models much faster when using MCP. So without MCP, Claude would need custom integration code. GPT4 would need different custom integration code. Gemini would need another one because as I said at the beginning, you were connecting each LLM directly to each tool without any middleman. But with MCPA, you basically introduce a middleman between your LLMs, all the different models of all the different LLM providers and all the tools on the other side and you change your LLM by changing one line in your host application and your integrations stay exactly the same. Now obviously you still need to write the logic or syntax for MCP client to call the MCP server, but that's it. You just write that once invoking functions of different tools like possql and stripe and slack and so on happen all through MCP server. So you don't need to write custom integration code for those. And again to think about it as an analogy think about traditional power outlets. So different countries, for example, have different plugs, right? Your laptop from Germany needs an adapter for the US, a different one for Japan or UK, different one for Australia, and so on. And HTB APIs are like power outlets. Every device needs a specific plug. You manually plug or unplug your device, and there is no intelligence or context behind. But then you have USBC, which is one port that works with everything. You just plug it in and the devices negotiate capabilities automatically. And you can even use a USBC hub to connect multiple devices through one connection. And MCP is basically like a USBC port where you have one port. You can use a hub even to connect multiple devices with different ports through the same connection. Which means your tools do not change. You still have your POSSQL database, Slack, Stripe API, Slack web hook and so on. But instead of building a custom adapter for each combination of AI model and the tool, you have one standard port that everything connects through. So now that you understand why MCP is needed, let's talk about the name MCP. So why that name and what does it actually stand for? Let's start with P which stands for protocol. Well, you already know what HTTP is. It's a standardized protocol, right? basically a common communication language that every web client like a browser and every web server agrees to speak and that's why Chrome can talk to any website in the world and the website doesn't need to write custom code for Chrome specifically. You have one standard and everything just works. MCP is the same idea but for AI models and tools. It's a standardized communication language between any AI application and any tool to talk to each other. So instead of writing eight custom integrations, you write zero integration directly between LLM and the tools because you have MCP in the middle. So you basically just write integration to the MCP server and all the tools like possql, elastic search, stripe, CRM system, kubernetes cluster, whatever tools you're using, they each expose themselves through MCP and your AI application connects to all of them through just one protocol. So that's the protocol part. Now the model MCP is specifically designed for AI models, not for web applications, not for mobile applications, for LLMs. And that distinction is important because the way an LLM needs to interact with tools is fundamentally different from how a human written application does. A normal app calls a specific API endpoint because a developer hard-coded it. And LM needs to first discover what tools even exist, understand what they do, and then decide. It's important decide because LM are more intelligent than hard-coded code. So LM will then decide based on this information which one of those tools it needs to call in which order and MCP is built around exactly that workflow. So that's why a model protocol. And then finally, we have context. And this is the one that APIs actually cannot do at all because HTTP is stateless. Every request you make starts from zero. The server has no memory of what happened before and it was supposed to be that way. But with LMS, a conversation has a state when a customer says, "I want to refund it." The word it refers to the order they asked about 30 seconds ago. And an AI assistant needs to carry that context forward. And MCP supports stateful sessions at the protocol level and your host. So basically application that has the MCP client to call the MCP server and the LLM they keep the conversation and prior tool results in context across multiple steps. So you can keep the conversation flowing with follow-up requests. So put it together, MCP or model context protocol is a protocol designed specifically for AI models that maintains context across multi-step interactions with tools. That's the name and that's exactly what it does. Okay, so now you understand what MCP is conceptually, most importantly why we need it and even the breakdown of the name. But let's get into how it actually works because the architecture is actually a very interesting part. So there are three components of an MCP. You have the host, the MCP client and the MCP server. So let's start from the tools side and work backwards. We have a posgrsql database, right? So we install an MCP server for it. That MCP server is essentially a translator between PostgresQL database responses and something that AI can understand. That MCP server is essentially a translator. On one side, it speaks MCP protocol which is the standardized language so that any AI application can talk to it and on the other side it speaks SQL to your actual database. It's a wrapper that takes MCB requests and converts them into native database operations. That MCP server exposes tools. As I mentioned before, tools are basically functions that your AI model can call. For Possql, those may be things like query orders, get customer info, check inventory, and so on. And every tool will have its set of functions like elastic search will have its own functions or tools that will be exposed as tools. Stripe, slick will have their own list of functions and so on. Now on the other side you have your host. This is your application that your customers are interacting with. For example, this could be your chatbot backend. So this is your custom code or custom application written in Node.js JS or Python, Go, whatever you prefer. And inside that host application lives an MCP client, which is a library that handles all the MCP protocol communication. So the client communicates or sends requests to the MCP server. And here is an important architectural detail. In most architectures, the host owns the MCP client and orchestrates both LLM calls and MCP calls. The LLM does not open connections to MCP servers by itself. That's handled and orchestrated by the host. So, let me walk you through exactly what happens when a user sends a message with our example chatbot. Step one is discovery. When your chatbot starts up, the MCP client asks each MCP server. So, you may have separate MCP servers for different tools. The MCP client will ask the MCP server, what tools do you have? MCP server will reply. I have query orders, get customer info and check inventory for PostgreSQL and this and this tools for elastic search and so on. And here's the input schema for each one. Your host will store that list. So LM now knows what tools exist without you hard- coding anything in the code. Step one, the user asks a question like where is order 1 2 3 4 5. Your host sends this question to LLM along with the tool definitions it just discovered. The LLM now makes a decision. It will look at the question, look at the available tools and decide in order to reply to this question, I'm going to call query orders with order ID 1 2 3 4 5 to get the result. Important, it doesn't execute anything. It just states the intent. The host executes. So your host receives that intent from the LM. It sends a tools/call request to the MCP server for Postgrql which then runs the actual SQL query and returns the result. So back to the LLM, your host will receive that result first and it will forward it back to the LLM. The LLM now has the data it needs or input data to generate the final answer in human friendly way like your order shipped yesterday via DHL and it will arrive on Thursday. And step six also very important follow-up because now user may have a follow-up question like can you actually refund it? I don't want this anymore. And because your host and LLM keep the conversation and tool results in context, your application already has the order details from the previous step. So LLM can now decide to call the Stripe tool with that amount without needing another database query again and also trigger notify SLE function or tool to alert the finance team all in one conversation flow. So that's one specific flow of MCP in practice. Now one question you might have here is do I need to build an MCP server for every single tool? And also who actually builds those MCP servers? Do I need to do it myself? Are there ready MCP servers? Where do you get one? So let's answer those questions as well. First of all, who builds those MCP servers or where do you get one? Do you have to build it yourself or how does it work? And in terms of who builds MCP servers, there are actually three types of MCP servers in the ecosystem right now. So first you have communitydriven or open-source MCP servers and this could be official reference servers like the one built by entropic which is now maintained as open-source project and this cover common tools like file systems databases basic web operations and so on and there are a lot of open-source community maintained MCP servers and they're actually good starting points for simple use cases but in production it can have limited features plus you need to make sure that they're up to date and properly maintained by whoever is maintaining them. The second option is enterprise servers and these are actually MCP servers built by the tool companies themselves and this is a gold standard because Stripe building their own MCP server is essentially the same as Stripe building their own official SDK because they know their API the best and they maintain it. So you can trust that it's production ready and up to date. And third, you also have community servers built by developers when the official one does not exist yet. The quality here is different, but this is a really good choice when there is no enterprise server available. There's nothing which is official open- source project and basically just developers and engineers or group of engineers build them because there is no other alternative. Now, another question that we asked is, do you actually need an MCP server for every single tool or can you have just one with all the tools that you want to connect to? Zapier, for example, which is an automation tool, has one MCP server that exposes 5,000 plus tools. And obviously, it's way more efficient than having 5,000 MCP servers because that would make the whole thing completely inefficient. instead you have one that aggregates many APIs but you can build your own aggregator MCP server for your own internal tools because there's still a chance that an MCP server does not actually connect to the APIs that you need. So for example let's say internally use Postrql Kubernetes uh Prometheus AWS Slack workspace and so on. So instead of installing five, six separate MCP servers, one per tool, you can build one custom MCP server that reps all five or six tools. And if you're building internal tooling, rather than installing separate MCP servers for each tool, you can actually build you will have just one deployment, one authentication layer, one endpoint to secure, and one server to manage. So it's usually better choice for companies and enterprises because you can properly manage and secure one server instead of splitting your attention and resources on multiple. And also very useful, you can actually add custom business logic in your MCP server. For example, only allow pod restarts in nonproduction after 6 p.m. And that kind of policy will live in your MCP server instead of in your prompts. And you can control rate limiting, audit logs, access control, and so on. So to wrap up, when you develop applications that use LLMs, you need those LLMs or AI agents to work with multiple tools. Without MCP, you would have to write custom integrations for every combination of AI model and the tool, which is hard to build, hard to maintain, breaks every time you swap a model or a tool, and so on. So MCP was created to give this standardized protocol that sits between your AI application and your tools. And we are already seeing MCP used in production style setups in many different use cases including DevOps for example Kubernetes operations via Cubectl style MCB servers, database queries, observability with data dog or Prometheus integrated servers, code review flows that integrate GitHosting for example or error tracking tools and in many cases these are community or internal servers rather than official vendor products. So there's a lot of activity in that space. Now I hope I was able to cover all the questions that you had around MCP and you really understood the concept of MCP, why it's useful and how it's used. Hope this is going to help you in your projects. If you found this useful, share it with one friend or colleague who you think will benefit from this knowledge as well. And with that, as always, thanks for watching and I'll see you in the next
Generated algorithmically for Search Engine
Indexing.