What is Model Context Protocol (MCP) | Clearly Explained

There has been a lot of hype around Model Context Protocol and I’m going to make an attempt to provide an extremely simple explanation of MCP today. I will also go into technical details so that if you are building an AI application it helps you. If you think about age of building AI applications, we are seeing a clear evolution.

First we started with LLM without any tools. Then we started building these agentic frameworks, where LLM gets help from tools and knowledge.

Now, we are entering the realm of standardized ways of interacting with these tools and knowledge so that building AI applications becomes easier. Let me give you an example.

Say you are a equity research analyst working at some company. Let’s say Jeffries. You want to develop a report comparing Nvidia and Tesla stock where you have company description at the beginning, then you have some financial metrics, then you have a summary of those metrics and in the end you have recent news about those companies.

Now you are a tech savvy person. So you will talk to your AI engineer friend working at Jeffries and you will ask him to build an AI application that can automatically generate this report. Now your AI engineer friends understands the capability of LLM. See, they know that LLM can pull the description of Nvidia and Tesla because it is part of that training data set, but it cannot pull the latest stock price for example.

Once you have somehow retrieved, let’s say the latest stock price LLM can summarize that particular information. Okay, so if you think about pure LLM, it has all these capabilities.

Now you’ll ask me. Okay, if I go to chat GPT and if I type this question, it is pulling the information but look at this it is searching the web actually. So chat GPT is an agent. I am referring to GPT 4.0 model. Okay. So, now you already know the answer that you can use web search or maybe you can call Yahoo Finance API, which is called a tool to retrieve the latest information. To summarize, AI engineer will build this application where the heart is LLM and LLM is interacting with some tools which can be Yahoo Finance API or web search.

It is also interacting with some knowledge. You might have some private database in Jeffries, some PDF files. LLM might want to pull data from it and he will write all glue code.

Okay, glue code is basically the code that you are writing for these interactions. Now, this can be an agentic application in which glue code is written by the agentic framework such as crew AI, Agno, etc. or it can be a workflow application where as part of your Python code, you are writing all this glue code.

This is just one application. Imagine Jeffries is building 20 such application and think about all the companies in the world building millions of applications. That is a lot of glue code. It sounds like you have this old computer and you’re connecting with keyboard, mouse, etc. through all these different wires.

But, today things have changed. Today you can connect computer using this unified interface USB-C port. You can have your USB hub and you can connect all these devices. Well that USB-C moment has arrived for AI and that is your model context protocol.

In this your LLM will interact through model context protocol with different MCP servers. So for our Jeffries example think that Yahoo! Finance is building an MCP server or let’s say Google search is building another MCP server where they are exposing all these tools and resources and prompts, etc. and that way these interactions becomes easier.

Now you’re a smart programmer and you’ll be like, hey we are still writing glue code, right? Because you need to do all these interactions. The answer is yes, you are writing some glue code here, but the age of writing that code is increasing. Going back to our old diagram the problem here was not just writing the code but maintaining it because tomorrow if Yahoo! Finance changes their API you have to maintain this code, right? So all this glue code becomes a nightmare to maintain.

Whereas with this MCP due to the standard protocol writing and maintaining the code has become easier and also since writing this code is centralized, let’s say Yahoo! Finance folks will write their MCP server. So now all these 10,000 programmers in the world, they don’t have to write the code Okay, so they are kind of getting this ready-made thing and they are saving time on building their AI applications. Let’s go deeper into technical details now.

Say you are building a chatbot for your organization which requires interacting with Google Maps API. So let’s say you’re getting some location and you are automatically creating the to-do task using this app Todoist and the technical teams at Google Maps and Todoist have already built these MCP servers. In MCP client, which is your chatbot, you will have a configuration which will tell you what kind of servers are available to this client.

When this chatbot starts at the beginning, let’s say just think about Google Maps server. It will make a call called list tools and this call will be made for Google Maps Todoist all the servers which are listed. Google Maps MCP server will return all its capabilities in form of this type of response.

So here you are saying that I can help you search places and you are providing this detailed description. This description is very important because it will guide LLM to call an appropriate tool. LLM has language intelligence.

So just by reading this description, it can figure out that for whatever query, if I have to search places, I can use this map search places tool. Not only that, from the query, it will also extract the required parameters such as search query, latitude, longitude, etc. Let’s say you are going for a hiking in Bandarban and you will say I’m going from Bandarban to this place. You know, show me the places. So from that natural question, it will extract the parameter Bandarban is a location and it will map it to longitude and latitude and it will also determine that it needs to call this function. Now you will have all the tools.

You will have a map place details and all the functionalities that Google Maps provides. Not only that, you will have the tool description from other servers such as Todoist as well. So once LLM knows all these details.

Now, let’s say you are asking this question that I am going for hiking in Bandarban and I need this place details. What this application, my chatbot will do is, it will use this kind of a prompt. So in this prompt, this tool description is nothing but the combined tool description of all the tools you have available.

Okay, and it will say that choose the appropriate tool based on the user question. So when you have tool description and this kind of nice prompt, LLM is smart enough to figure out which tool to call, which parameter to extract from the user question and how to make a call, get the response and how to read the response and serve to the end user. Here I have this MCP client from the Python SDK that Anthropic has provided.

When it starts, it will go through all the servers. Remember that server configuration? It will go through all the servers and each server it will ask list tools and whatever tools it is getting it will get the description of all those tools and it will put it here and look at this prompt. Okay.

So now you understand that LLM is getting question how it maps or how it figure out an appropriate tool to call. Now, let me show you the MCP server from Google Maps. Here it is listing the tools.

So when MCP client makes that request it will handle that request and it will list all the tools. So you see this call. Okay, and what are the tools? So let’s search for all those tools.

Okay So search places tool you see search places to geocode tool. Okay, so search places tool should be here. So eventually it will come to this Python function.

Oh, this is not Python. Actually, this is TypeScript So you can implement your server in either TypeScript or Python and here from the user question It will derive the query location etc And it will actually make an HTTP call to the Google Map API So it’s not like you are replacing a REST protocol here or HTTP. It’s like a wrapper and You are internally calling Google Map API and You are returning the response in a standardized format.

Okay, so there is a standard here. So if you look at The input schema. Okay, so let me search for input schema see input schema you see so for the Search places tool you see here There is a standard way you will provide the description of the tool and also The query parameter etc.

So see this input schema Description etc is part of this particular standard so you can find the this schema. I’m going to provide all the links Okay, so this is the standard. This is the schema that Anybody who is building an MCP server will have to adhere to so that way we have standard and some uniform or Predictable way of communication.

Okay, so you look at this type script schema where you say input schema is this type required? Whatever just go through this schema and you will get an idea any MCP server will expose three capabilities tool Resource and prompt their Python SDK has simple examples for each of them. So let’s look at the tool This is a simple server with one single tool. Okay, so if you look at the List tools function see list tools here It is exposing see this is an array Okay, so it is exposing a single tool called fetch and there is this standard description standard input schema and so on If you look at the implementation of fetch It looks like this.

Okay, so you are fetching a website. Okay, so here See you are fetching a website. So whenever that fetch tool is called you call this function And you are just retrieving some information by making an HTTP call.

Okay, so this is pretty straightforward the second capability is resource resources Some kind of knowledge. Okay database files, etc And similar to list tool functions, it will have list resources So when the MCP client starts it will call List tools list resources list prompts for each of the servers So it knows the full capabilities of all the servers that it has available or has access to so in the list Resources you can have a file. See this is a plain file.

Very simple example. You can have a file in your Some drive or some, you know, like Amazon s3, etc. You can also have a prompt So just imagine you are building MCP server for Yahoo Finance as a developer You know all the prompts that AI and genius Might need to interact with my API.

Okay, so you will provide all those prompts Via your server so writing prompts become very easy for the MCP client Okay, so here you are providing one single prompt So once again, you have list prompts you are providing all the prompts see this is an array and this is the simple prompt that takes context and topic and if you look at the Implementation, it’s pretty simple You have context you have topic and you are creating the prompt Using that context and topic folks. That’s it. So that is what is model context protocol I’m going to provide documentation etc.

So you can read through more details There has been a lot of hype, but I believe we are in early days This has a lot of potential but how this is going to evolve and how this is going to help AI engineers Solve the real problems is something that we will know as time goes. Okay, so some people are super excited well, I am excited too, but Just understand that we are in early days. There has been a lot of hype.

There is some reality We’ll have to see how this thing evolves. We are going to come up with few more technical tutorials On this so I’ll be building some actual servers and clients using MCP If you have any question, please post in the comment box below. Thank you for reading.

Leave a Comment

Your email address will not be published. Required fields are marked *