Transcript for:
Exploring Model Context Protocol (MCP)

Anthropic introduces model context protocol. So what does this mean? Here is the live demo. What is the weather in London? So now it's going to check the weather but unfortunately Claude doesn't have real-time weather information. So you need to integrate your custom application with Claude. So that's what I've done here. So this is my own application running in an endpoint. So I'm going to allow for this chat. And finally I got the answer here. Current weather, tomorrow's weather and Thursday's weather. So what's happening here? The AI is passing the city name that is London as a tool call to my application. And my application is returning the weather details based on the city name. That's all it is. This is same as GPT actions or GPT plugins which is released by OpenAI previously. They have their own way of implementation with... open API schema, but here they are implementing differently using MCP connects clients, servers and large language models. So you do not need to get confused with all these terms. Seems like they made it so complicated to understand. Technically MCP server is your own application and MCP client is cloud. Your own application will have endpoints like an API endpoint and cloud will be using that endpoint to answer your questions. By the end of this video you will learn how you can set up MCP, create node server, create weather server and finally integrate that with cloud desktop app. I'm going to take you through step by step. Even if you are an absolute beginner, you should be able to follow and I will provide all the code in the description below. But before that, I regularly create videos in regards to artificial intelligence on my YouTube channel. So do subscribe and click the bell icon to stay tuned. Make sure you click the like button so this video can be helpful for many others like you. As a pre-requisite, you need to install cloud for desktop. just download based on your operating system. So let's open up your terminal in your computer. Make sure python and uv is installed on your computer. To install uv in my mac I'm using brew install uv but you can just copy this command and paste it if you want to install in linux. Once after you install uv, uv is a package manager instead of pip. Now we are going to type uvx create mcp server. So first we are going to create notes application. To do that, type uvx create mcp server and then click enter. Then providing the project name, I'm going to give notes. Then providing a description, version number. Then it's giving me a path to create the notes. So this is my path. I'm saying yes. Now it's installing all the required packages. Now it says cloud.app detected. Would you like to install the server in cloud.app? So I'm going to say yes. This will automatically create this cloud. desktop config.json in this path. So you might need to open this code and here it is. So this is the directory where I've installed notes, run notes, that's it. This gets automatically added. If not, just paste this. By default, cloud provides a boilerplate that is notes. So now here you can see I need to navigate to notes and then install all the required packages. So cd notes and then uv sync all extras. that's it now if i see the folder structure here you can see notes inside that you got these files and the key files are inside the source folder the server so i'm going to open the server so inside this the key things to note is the function definition so in list tools you can see the list of tools added that is the function definition there's a add tool a description add a new note when provided with the name and the content it saves the data in a tool so when the launch language model call this tool this call tool function will be initiated that is a decorator and if the name is add note then it will get the note name and the content then process it accordingly as simple as that similarly you can integrate your own application own tool by adding the function definition that is a description about what the tool does the input and the output and the execution of the tool This is the default boilerplate code which automatically gets generated when you initialize MCP. So this is my cloud app. You might need to restart this app to get this working. So I'm going to close this and now I have opened it. Now I'm going to say meeting with Mervin Prezen. Add this as a note. Now you can see it's asking my permission and I'm going to say allow for this chat. Now it says I've added a basic note about meeting with Mervin Prezen. So when you see the details first it gives the name that is the required field and then the content that is also a required field and based on this information we are calling the tool that is our own custom tool notes tool and it's automatically adding the notes also just to note that if you have already added the tool you can see the tool listed here you can also go to settings and then in the developer section you can see those two MCPs you can edit the configuration directly from here if you want to see the log just at the top in the developer section click open MCP log file And that will open this MCP log where you can see that our MCP server nodes got connected, MCP server weather got connected. You can extend this nodes tool by storing the data in a database and retrieving the data when requested to do so. So here there's only one tool call that is add node. You can add multiple tool calls such as delete node, update node, read node. So this is a basic setup to start. Next we are going to see how you can create a weather application, a real-time weather data. As we have seen before, when we ask what is the weather in London, the AI chatbot will say I don't have real-time data. But when you add this function calling feature, that is nothing but calling an API, it's going to call getWeather function, get the weather and return the data. In a similar way, you are able to integrate your own application in this section, any of your application, which has an API endpoint. So here is Claude, what is the weather in London? That's what I'm asking. And it says, I apologize. I don't have access to real-time weather data. So we are going to make this work. So same like before, type uvx create mcp server and click enter. Now give a project name. I'm going to say weather, a project description, version. It'll automatically create a weather folder. And again, it's asking if I need to add the configuration to cloud.app, which I'm going to say yes. And click enter. Now navigate to the weather folder. and you can actually install all the required packages by typing uvsync. I will put all the command in the description below. Now if you see the files, same like notes, we also have server.py. That's where we are going to add our code. And here is the code. We are going to use OpenWeather API. So using that, we are going to get the weather data and then pass it to Claude. So here is the fetch weather function, which is going to use the city name and based on that, get the weather information. And then return all these results. Here is the list tools decorator where we are going to define about our function. So get forecast function requires a city name. So based on that it's going to return the relevant information about the weather. And the call tool decorator will check if the requested tool is get forecast. So based on that it's going to run the tool and return the results. There are two more decorator which you might need to know. that is list resource and read resource list resource listing the list of tools and read resource reading the tool now we have successfully completed creating the real-time weather app go to open weather and get open weather api key so here is the configuration the path to the weather application and the path to the notes application so here provide your open weather api key that's it just save it now you need to restart your cloud app again i'm closing it and now I have started the application. I'm going to say what is the weather in London. Here you can see it's able to call the function with the city name London and get the weather details and then pass that to the large language model to give us the weather of London. This is super cool and just to note that I'm able to run only this MCP locally on my computer using the desktop cloud app. Not sure when this will be available in the web cloud app. Also just to note that when I asked for other tools available, it gave me get forecast, add note, then artifacts. Artifacts is used as a tool using this MCP and it also use ripple for JavaScript analysis. So up until this time, the tool MCP is closed source. Now it's been open and we are able to add our custom tools and I'm really excited about this. Considering you already like this cloud feature, you might also like another feature which is cloud context catching, which I've already covered in detail. And I'll put the link here and I highly recommend for you to watch if you want to know more about cloud. And I will see you there.