Intro to MCP Servers – Model Context Protocol with Python Course
Skills:
LLM Engineering90%Prompt Craft80%LLM Foundations80%Agent Foundations70%Tool Use & Function Calling70%
Key Takeaways
This video course teaches how to build Model-Context Protocol (MCP) servers using the FastMCP Python library, allowing AI agents to securely interact with databases, functions, and applications. It covers topics such as building MCP servers from scratch, converting APIs to MCP, and deploying MCP servers on the cloud.
Full Transcript
Learn about creating mono context protocol or MCP servers using fast MCP. MCP is the standard rule set that allows AI agents like GitHub Copilot and Gemini to securely and intelligently interact with your databases, functions, and applications. Carlos Leon created this course. He'll first define what MCP is and its significance before getting into practical hands-on learning across three distinct coding scenarios. You will build real world examples including different calculator types using both standard input output and HTTP stream transfers. Carlos then explores advanced techniques by showing you how to use APIs to fetch dynamic content for an agent. To ensure reliability, you'll learn essential testing practices by leveraging GitHub C-Pilot to inspect and test your new MCPs. As a final bonus, Carlos demonstrates the critical step of deploying your MCP effortlessly on the fast MCP cloud providing you with a full end to end development cycle. >> Hey, hello people from Prico Camp. I hope you're going to enjoy this course. It's going to be about MCP servers. So, we're going to go what is MCP first and then learn by doing it. And we have two examples for that. We have uh two examples of calculators in two types of transport. So, SDIO and the other one is going to be HTTP. And the last one is going to be how to use a Fits parser in order to get data about the new content of PROC camp on YouTube channel and their website. So, I hope you like it and if you have more questions, I'll leave the repository below. You can go and see the code and also if you have any comments, please leave them below. I hope you like it and keep coding. All right. All right, welcome to the course introduction to MCPS. It's not as sweet as expect. So let's start. MCP is a model context protocol. So by protocol means standard rules when you let some AI agents to interact with databases functions or in other words, it's like teaching an agent to interact with things in your own way. The types of MCPs you got to find nowadays are two mainly. The first one is standard input output. So this is when you deploy things locally. So it's like you are running another process in your computer. So you just let the agent to connect to that process. So HTTP stream is when you try to do external apps do that. So it's for remote connections and this for production things. So some examples you can find like GitHub MCP. So you can manage branches and WhatsApp you can read some messages and also send. So also there are more examples built by the community. So you can just check out some unofficial websites like this one that is here and you can see the list of things that people are doing nowadays because this is now trendy. Okay. So the question here is how to build MCP server. I can tell two ways is go to the official SDK that you have multiple language to use or the two main ones that we're going to use for this course. The fast MCP and the fast API MCP. The fast MCP is like you build an MCP from zero. You know it's quite easy to do it and you can do SDIO CBP. And the second one is when you come from the API and then you convert it to a MCP. So we're going to use a calculator example for that. How to test an MCP server. We have SCP inspector. So when you try you want to try things, you just need to use this command that you see here. MPX at model context protocol/ inspector. And the command it's going to depend if it is a SDIO or if it is a HTTP type of MCP. And yes, we're going to use it throughout this course. So don't worry too much about it. But just keep in mind that we have inspector test feeds. So not only code and then you see what happens, right? Yeah. All right. Now this is the important part. I hope you understand what happens here. So when we build a SCP server, we need a client. So this client is going to be a agent and this agent if it's local, it going to be like a g compil ji or the cloud for desktop. So this when you connect to the other server that it looks looks like an app uh sorry like a process okay also you can do uh through IDE like Visual Studio Code or Poor they have some agents inside or if you only use HTTP you can use some external tools like chat GPD or Mistra they have leat where you can just use the the connectors there to connect to the MCP server that is now deployed on certain address. So for this I will give you an example at the end of the course how to deploy this using a pass MCP cloud and we can going to use the shut so going to be more easy to understand. So first of all let's start with the calculator examples as I mentioned first we're going to start with the library fast MCP and we just going to build it with the type SDIO standard input and output. So are you ready for this? Let's go to Visual Studio Code. Right now that we are here, we try to install the libraries. So we're going to go p install pass mcp. That is all we need for now. So take some time. All right. After we do that, remember if you want to use a virtual environment in Python is recommendable. If not, then just go just b. So here in a folder we're going to create the file fastp calculator.py. Don't worry it's going to be on the GitHub as well. So you can take a look that later because we're going to go a little bit fast here. So let's import the library that we need. So the only mater right no. So the first we're going to do is from say from fast MCP import what the fast MCP. Let me see if everything's right. See fast MCP. Yes. All right. Now all we have to do is to create the MCP object. So how we do that? Say that it's going to be equal to pass MCP. We going to give it a name. So what is going to be the name of this MCP? Let's say calculator. Yeah, makes sense, right? on how we are building some mathematical operations here. All right. So we give a name to our MCP server here. Now it's time to use the decorator MCP. That this means that we're going to use a function. So we're declaring this tool. We're going to use the keyword def. That's for function in Python. Let me give it a name. So the name of this tool will be let's start with multi. Yeah, multiply. Thank you for the suggestions. Compile it. And then we're going to say that the argument is going to be type float. Are you going to return a float? Is it important? Yes. As you can you can skip that part, but you can just keep it depend if you want certain schema. And don't worry, we're not going to go much into detail at the same time with if this function is synchronous or synchronous. For now, it's going to be synchronous. So don't worry too much. And this is the dock stream. You see like some comments there, right? This is important to let the agent that this tool do certain things like this is the description of the tool this is really important and maybe you might not think like ah this is not important this is only for developers no but now we are talking to agent so agent need to read what this function does that's why we use the dock string this is very important in by using this library fastmcp and of course you can use it uh something like you can say the tool specifically you can give it a name that doesn't correspond the name of the function and you can give it a description that doesn't correspond to the doc stream as well. So for that you can you can see here like we also do like tool and then we open here and we can give it a name that we want. So for this operation this is going to be let's see we have multiplication. What else? Huh? Let's maybe do addition. Let's do it shortly. Okay. Add we add a description about this. So you see it's not visible like just add some numbers. I can just do it like before like add some arguments you know like put more context of it. This is important but for now we just leave it like that just to give an idea that we can also do that way or just do it inside the function. And then for tax this is like a way of letting the agent to access this tool like maybe this tool is related to math maybe this tool is arithmetics you know just keep some at the end keywords that recognize this tool. So now below this we're going to build our function as you know now we can just put another name this doesn't really matter because the decorator itself we put a name and a description that this is going to be for the agent and you can see here this dock stream here is not going to be uh taking account it's going to be the description on top so you can do both ways but what is the best for you uh I can tell you choose. So let's build the the rest of the tools. So we are here. Let's see. MCP tool. Let's build another function. Let's say subtract. Yes. Now we don't need to specify too much. We already have the doc name the function. So I think this is enough for the agent to know that is for subtracting. Right. You see let's compare to the others. Okay. Subtract multiplication and then grab division. Okay. Let's divide two numbers. There are float and the return also we have the assert if it is equal to zero then okay okay that seems to be that we are almost there so now we need to call this method the main when we need to call a file this is going to go to C first this is like the main function let's say so everything that is inside is going to run when we call this file so we're going to run our MCP server by just calling the MCPrun so everything goes here and it's going to run MCP. Let's see. And this is going to be SDIO by default because we didn't specify. So you can do do HTTP as well, but for now it's SDIO because it's by default. So we just run it Python. We call the name of the file and then this is running. But how do we test it? Well, it's not that simple as it seems like. There is no way to do it. You see there, but as we talking from the beginning, we need to use something like an inspector. For this we need to go to the to the folder that we are currently using. So you see we are here in a scenario one. So everything is correct. Yes. All right. So now we need to type the command on inspector that is mpx at model context protocol. Well that's pretty long. Let me see. SL inspector. And now the argument is going to be python and the name of the file fast sp.py. So you see now is the IO. This is the argument that we need to send. Um of course this is how it is running. Okay. So now we have here the interface on inspector. This is nice. You click here connect and there you have it. So this is how it looks like the UI. So not much to say here. Resources or template is for uh things that you might see in another course but resources you got to get like some data um information where to access to to the agent. The tools is the thing that we're going to see the most. So the tools that you see we just define them like some functions and you see here the description of the ad is different than the others. Why? Because it's taking into account the one not the dog string but that one. So not like the other ones, right? And yeah, that's the difference between those tools. You see, multiply, add, subtract, divide. Yeah, I hope this is like I understandable here. So let's test that and see if they work. Let's try to add some numbers here just for plain 10. Okay, let's run the tool and see the result. All right, that seems correct to me. What do you think? Okay. So, that seems the multiply works. What else? Ah, that's the obus schema by the way. And yeah. Um, let's see what else. Um, let's add some numbers. Okay. And seems that this is correct. All right. Okay. So, I think for the rest you might look like, yeah, this is going to work. Uh, notification because this is um STIO, we don't need it that much. But if you want to HP, this is really important. It's going to be like advanced topic for prompts. This is to tell the assistant or the agent let's say to interact certain way. Resources I tell is to let it to know where to access what kind of information to access. Um yeah, we're not going to go more into detail into pro resources. And here on the left we have transport type, you have STIO, we have the Sce that is deprecated, but we're going to use it for the next example. Maybe sometimes you see it but we don't need to use it anymore. HP is the recommended one. Environment environment variables. Yeah, sometime need aification as I told you. Maybe my token or or out and yep now let's try another things. Let's see the tools all the functions and yep we have it over there. So are you ready to see an example that we're going to use another library and it's going to be into HTVP where we start from an API and then we go over to the MCPS. Okay, let's close this first and then let's look into the second example. All right, let me close this. Okay. Okay. So now as I told you the second is going to be a calculator API. So now start from the API and we convert it into MCP. For this we're going to use pass API_MCP. It's another library. It's not the same. Remember that. And this is going to be HTTP. And at the end of it, I going to teach you how to do that with our previous library. So first of all, let's go here to All right. Now let's go and install things. Install fast API. This a library just do the APIs. Now the fast API NCP that converts the API into an MCP and lastly our UI that's going to help to deploy a server. All right. So let's see and let's wait for a few seconds. It takes minutes but you get the point. So let's wait. All right. After everything installed then we're just going to create our file. So let's see scenario two. Let's create the file and you're going to name it as API. Yeah, CPIC, right? That's quite easy. Okay, there's going to be also I file just forget that. Okay, we go that M. Okay, let's put like calculator as well. This is going to be long but specific, right? MCP calculator guy. Okay. So now as I told you we're going to do first the API and after that we're going to build build it into MCP. So and yeah it's protocol is going to be HTTP. So I also did something here by default is S S but we should take into account HTTP because it's the standard nowadays but let's let's see. Okay. Now let's create import the pass API. Let's try to create our API app. So, okay, let's come here just to get a reference. Uh how let's do it. Um are we going to do your yeah calculator, right? Okay. But anyway, let's let's build a pass API app and it's going to help us uh Yep. Just give it here. I don't want to come in there. Okay. The app or the fast API just do it this way. I will give it a name. this case is going to be a title of the API. So how we going to call that? As before remember we use a calculator but now just put API to just distinguish this. All right. Now that we have our app then we need to keep the endpoints of it and you know we have some some standards like we get post put and but for this we're gonna be just post because we're gonna send things and and get it back right. So, so for the endpoint of let's see the we're going to have the employee multiplication it's going to be multiply when we address this we're going to have we're going to have like a parishion so for this we create a function let's see uh for this function is going to be multiply numbers this float float yeah makes sense right we're going to return this one field that's going to be the result okay not bad I will say this kind of compel this I I kind of like it now. Okay. And here remember we cannot use that like float. Not no we are using API first. All right. This is enough MCP as well. Um okay. Now let's continue with our endpoints. It's going to add the input of addition. So the same process. Now it's going to go for subtraction. And here we go. And lastly for division. So you see here. Okay. So this is only an API. Remember we don't have much here to tell is the MCP. No, no, no. We haven't even called the library yet. Okay. So now let's try to run it. What are we going to do first? Okay. Remember just call the main function. So when we call this, we're going to deploy as server. And you see here it's going to run here at the host. Yeah, it's going to run our app at the host. Let's see. Zero. and the port so that is available by default is 8080 but yeah let's leave it at 808 80 is fine okay everything seems fine and let's run it ah by the way there's something that inel we try to run it yeah let me go to the folder but when we try to run it into 0000 you know this is going to be on our API address so that means people can access to our API address and that port and voila, you have the API. But we don't want that. As you as you see here, 00 doesn't exist, right? You need to put the API address, but I'm not going to show you my IP address. Instead, we can change it to local host for now. Just talking that we can just use the computer for this example. It doesn't have to be an IP address. So, okay, let's try to run the API. So, going to go here to local host, try to access. And you see there's nothing but ha here's the magic. Let's go to slash and then we put the input tax and then you see like u swagger here where you can see all the inputs that we have available for the API and of course you can test them. So here we have the all of them are type post multiplication. Uhhuh. Addition subtraction and the division. Voila. That's pretty much what we have here. Do you want to check the schemas? Yeah, that's another topic for another day. So don't worry. And MCPS also have schemas, but we're not going to go much into detail. All right. So this is the return time. is a JSON that they give you some details. If you are more into APIs, you already know this, but let's test it out. So, you have here on the right a button to try it out and we'll put some values here 8. Try to run this and we got the return. Yeah, that seems right, right? Okay. Now, let's go for another one. So, it says here 10 two. So, it should be 12. Let's check. Yeah, the result is 12. And we can keep going with the other functions. Sorry, end points now. And uh it says okay, it seems that everything works as expecting division. Yeah, it sure it should work, right? Yeah, let's hope so. And yep, let's see. As you remember, if you go without input, we don't see anything. Okay. So now let's try to convert this into MCP. What we're going to do first, remember we have a library specifically for this. Now we just try to see here. Yeah, here's where I go with the SMCP part. We just leave a comment and then we're going to import the library just you know for reference in case you're going to go to GitHub repo and you're going to check the file. Ah yeah, you're going to remember this part. Okay. So first of all we're going to call this library. So we're going to import it from let's see fast API. Yeah. Fast API MCP. And this is the tricky part. Remember to import the name of this is tricky. As you know capital A MCP like this I yeah just remember that because I made some mistakes in the past. So just remember to keep it like that and we should you should be fine. Now we try to convert this API app. Remember that the name was app at the beginning when we Yep. We get the fast API app and then voila that's how we build the MCP. Now we converted but of course in order to work you need to kind of say the protocol and everything but for now we just give it a name. Don't worry. So for the name of the MCP is going to be a calculator MCP something simple. Now in order to run we need to mount it somehow. So we need to say that this MCP is ready to start. So we just do it by MCP mount. And yeah that seems to be there. But this is still not finished because we didn't specify the the format. Remember I told you by default it's like sce and no http. Why is that important? Because one is duplicated no longer used. So yeah but okay let's go with example first. Let's try to run this and see if that works. So we're going to go to the folder. We're going to run this. We're going to call Uber. So you see it's going to deploy in certain location. It's going to be in on at our local host the port. But yeah, you see the comments here, you need to use something specific like HTTP or something to specify what kind of protocol are we using. We are using here. So if you're http let's go like that. Okay. So okay now this seems that the server is running. We are ready to go to that address right and we need to find the now that is MCP. We need to find the input MCP. You will see that briefly this. So don't worry too much about it. Just remember that this is should be clear enough but okay let's try to access and we access again dox we still see the endpoints over there. All right but now the MCP part it's going to be the endpoint of MCD. All right then seems like yeah we cannot do much here right like how can we access this? Okay maybe we can just come prompt here. Um yeah, maybe we can just like uh request something from this address. Let's see. Uhhuh. Should return something and I will tell you no, that doesn't happen. So uh how can we test something like this? And of course this is where the inspector comes. So let's try to run it. And one of the mistakes that we can make is that we can call it as a SDIO and this is not like this. So you see here this could be a common mistake that we can call it like python and then we call the name of this but no we are no longer using stdio. So for this we just put the address that's going to be local hostah slashmcp where this is deployed right. So that's how we can test inspector and yeah let's give it some time to just initialize and there we have it the UI again. So here on the left you see everything we're trying to connect but ah that won't be possible because we need to change something. Can you see that? Yeah. Yeah. Yeah. Can you see it? It's on the left top left. No. So yeah, we can spend like a lot of time, but you have to do this manually. So you can check here the transport type. We have STIO. So we need to change it into what for now. We're going to use the server and events as E by default. But remember that we no longer use that nowadays. It's created. But here we go. It works that way for this example. So you see the tools that we created now are into MCP because yeah they're API but now I compared to MCP tool you see nice oh well um what else can we do here so you can test them as well and also if you want you can just go to the API so that's the advantage of having this so for multiply let's see okay let's try to multiply two numbers again just to see everything works run it and voila You see and let's see that addition part. Okay. Something that needs some improving if you see is the description of the tools. It's not like that customizable as the other one. But of course there's there should be some parameters that we did change there. But at the end this is what we have two different leveries. And okay we got more things to change for now. No. Okay. So, what if we want to use the HTTP? Well, uh we just need to change something. Remember that SS is duplicated. So, we need to change the M. So, for this, okay, let me close the server first. So, make sure that it's not running anymore. Mhm. Okay. Close it. And so, for this, I ask you, we have the MCP mount, right? That's what they call the gimbus server side events. We don't want that anymore. So, we just need to use HTTP. Here we go. Just change that and we run it again. So, let's see if the protocol is running here. Yeah. Okay. Let me just try to close this everywhere and try to call the protocol again. Try to run the server. Let's run the server now in HTTP mode. And finally the inspector. But actually inspector we cannot close it just refresh it. But well as a rule of thumb we just try to you know restart the things like the way we do things in a computer sometimes when doesn't work. You just restart it right. Okay. So see that's should be the the address. Correct. Okay. Just let's wait a few minutes here and yeah. Voila. We are here. So now just go to the transport type. We change it to streamable http one. We connect and we are there. Okay. So now we just go list of tools and yep you have it. Wy the working. Yep. Okay. We don't need to test too much, right? already tested with the SSC and we don't have any errors. So yeah, this shouldn't be the case as well. Yep, that's is a second example. And if you're thinking what are the other things like resources, tools for this needs to be non display but oh yeah there are some limitations still and we need to go to implementation but we're not going to use too much this library but I just wanted to show you that this is possible coming from the API and converting into MCP. So what if you want to do this into HTTP but the fast using the fast MCP library the one that we use for the first scenario. Well, that's kind of simple. So, let's go to our previous sample, the first scenario. So, we're just going to close this. This is using fast API because this is a API. But, uh I will change it to SVP. But, you know, this really needs a API for work, right? So, okay, let's don't talk too much about it and let's go to our previous scenario. So we just going to go here. We're just going to copy all that. And then we're going to create a new file. So for this, okay, let's create a new file. Ah, I'm going to call this calculator now version two because now it's going to be HTTP. What's going to be the difference here? So here in the main function by default is STIO. So when we want to http we just need to specify that the transport now it's going to be yeah you name it http all right so also we're going to run a local host at the port why do we need that because we can tell the unicorn to deploy this at that that address okay so without more to do here let's try to run Let's go here. Um, okay. Let's we need to change the folder. So, let's go here. So, for this we need the command SD to points. We go to SD and scenario one. Okay, we are here in the folder. So, now we just call Python and the name of our file. Okay, since there are no errors. Okay. So now we just need to do something similar. Okay. You see local host is running and check our inspector. So same address we should do. We can go to the MCP endp point the same as before. So we just need to do it through inspector. So let's go to inspector and check out inspector. We closed before. So we just need to run it. And do we have to go to the folder? Not necessarily because this is HTTP. So you can run it anywhere and just give it the local host. But again, if you want to try the STIO and anything, just go to the folder. Okay. So for this, let's check it out. Since [Music] Okay, so the port was wrong. We did a different port. Now it's 83. You see resources we don't have. We don't have templates prompts. No, but at least it's activated. That's the difference with this and the previous version. So, okay. You have here everything looks in order. Um, yeah, this should work. But now it's different protocol. But just checking again. [Music] Okay, that works. Hey, 10 times. I'm sorry. I'm looking at other numbers here. Okay. Uh um and yeah, that seems to be the tool working. Okay. So, that's the another way to do it with only fast MCP. Um yeah. Now, let's go to our next part. The third scenario that is a little bit more complex is going to be a feed search. This has some applications in real life. So, we're going to use something called RS. That stands for reality sequence indicator that is useful for notifications. So it tell you about the new content and pretty much just by extracting the file. So we're going to do this for the YouTube channel and also for the website. So don't worry, we're going to explain a bit how it works. So you know when you go to the website of free cap you can search for maybe some courses, blogs or anything related. So let's say search for Python and you're going to see okay new courses. But if you go to the RS, you know, if you do that method, we're going to see what are the new updates. So let me show you now. We go to free cap and it should be yes RS and you see this XML file that has some new content of the website, right? So it doesn't tell the whole thing but at least this is where we're going to extract some of the data and we're going to do like our MCP server to let a agent to search on this file. So yeah, you see here there's a title, description, the content to tell you a little bit about one of the entries, but what we're looking for might be the titles of of it. So it tells you about like oh maybe a course or something. Okay, so that's pretty much the RS that helps you for notification, you know. So we don't get too much. So you see that's for we search about Python and now we search about Python. You see some keywords going on there. So yeah, there might be some information about Python that's coming to the website. So first of all, we're going to install a fit parser. So we're going to update this XML file and then we're going to search for the title or certain tags in this file. So okay, let's go to our terminal here. You need to install it's called pf install feed. Uh what is the name of this? Feed parser. Let let me double check the spelling of it. I'm you know not nice speaker as you have noticed but okay check okay let me do it again install fearser all right so yeah yep that's the library that we need for go onto the XML file and then just get the content that we want so yeah we need to go onto that file so for inance same h those are the text what are the texts that we we're going to look for all right might be this one I the beginning the title right so this is something that might interest my might interest interested us and later on we're going to do this for the YouTube channel as it as I mentioned it but for YouTube channels not a process actually for this we need to go to the to get the ID of the channel so for that you go here channel copy the ID channel and we're just going to keep it somewhere uh let's keep it here all right that's the idea of the channel later on we're going to see how to to get some data from there. But for for now, let's focus on the website. So, we're going to create a new file here. Let's go to the folders in our tree and then okay, how how do we name this? You know, this is also a dilemma every time that we create files. So, let's put it um what else to see. Okay, makes sense, right? All right. So, what we're going to do first is try to import things. So, as you know, rule of thumb, we already have working with fastmcp. So let's simpize MP now our new library of fit parser to take information about the XML file. So let's create our MCP server just give some name of it. Okay we're going to say preode camp. Um yeah kind of news but let's see. Yeah actually it's a feat search. Yeah makes sense right? This is what we do trying to get to the feet and then get some data from there. It's not the ideal solution. you know we can get an API instead but we haven't found any API yet. All right. So, MCP tool here. So, we're gonna create our function. Let me see what are the suggestions here. So, yeah, goes close to that. But let's do it manually. Okay. Search. Give it a name. So, the queries. Yeah, we might need maybe to search for a certain keyword. So, this will be our query. What type will be our query? Yeah, maybe text, right? So, let's put as a string. And then okay maybe we have a lot of results. So let's say maximum results going to be an integer. So yeah we not might get like a lot of results but just in case. Okay let's put a string by default. And then we we just add like some do string just to let the agent know what this function does right as we can just add the return type on top. But yeah it's up to you. As I told is very much about the schema how you want the output but we don't go too much deep in the course for this but all right so let's go here let's say it's a bit about description something simple enough but you can get you can get more deep into that right so don't worry too much so okay search code and yeah we're going to get again title and there should be another tag that we are looking for here let me see description might work. What do you think? Description can tell you a little bit about it. Okay, the title and description. Okay, that sounds perfect. What do you think? So, we go to the website, get into the feed and search for the for the tags of title and description. All right. So, and here the suggestions tell us that go to certain website. Yeah, I like it. Let's go here. So, the fit uh it's going to be fit. Uhhuh. You're going to select the parser here and then we're going to tell it to go to certain website and the website looks Yeah. All right. That's the one here as no feet. All right. Yep. Now we going to say we're going to parse on this address and then we're going to have a list of results empty by the way. So we're going to add there our results. So for this we need to add a selector, right? Let me see here. for the query we just need to put it lower you know sometimes we don't we put something in menu so as this is something like standard that we do sometimes so for every entry we say like okay we need to get um information about the title so we go to entry dot the title and for description we're going to do similar thing so you see if you So, okay, let me search or something. Um, yeah, only description. Okay, so they go again description here. It's going to be similar method. So, you only get the the text of description. We not get anything else. So, let's see. Let's see if our query uh is in title, we're going to put it into the list at the same time. If it is description part of the you know um the keyword then we just going to put it in the results. So yeah that's pretty much if the query let's say a keyword python is eaten title or description we're going to add it to our list. So this is what we're going to do here and for now we're going to just add it to the results by call it append. So we're going to append this to the list and what is going to be that. Okay, here we go. 10. Yep, I think it could work. We can add content and the URL could be important as well. But okay, let me Okay, let's put something like a title like this. Yeah, that correct. Let's see what are the other things. URL is it's important, right? Because we need to refate somehow. So, let's get it. We haven't got this. So you could do entry you know the parser somehow I get the text link the content of that and the description we already extracted so not much of a deal here check everything working l okay let's delete description just let's get the link okay if the length of results is larger than the max of results we just um break some down get out of the loop here but This is not going to happen as I told this is a a feat. So it's like you don't have like a lot of results here but anyway and then return all the results on let's take something by default like there was no results. What do you think? Let's see here the suggestions and they say yeah just just put something like okay they say yeah message like oh the results were not found. Okay so sounds good. Are you ready to test this? Okay, now that we got our function about feet search [Music] looks okay. Please let me know if you can also improve this function on the comments and you will be happy. Don't worry, this is going to be also on GitHub so you can check out this later. So for now, let's go to our method of main and let's start our MCP server. So for this it's going to be MCP run and by default it's going to be SDIO standard input and output. So it's going to run locally as a program. So okay, let's try to see if there are any errors or something going on. Let's run it first. Yeah, it seems that there were no messages going on. Okay, so now let's go and see the inspector. So for the arguments, we're going to add the command Python and the name of the file. So here we go. We're going to start our CP inspector to see if this is really working. All right. So looks here arguments. Okay, let's connect. All right, now we are here. We got the tools. That's all the things that we have activated here. And see the function here. Okay, we query and where are the results? Okay, so we found one how to run Python and we have the URL. What do you think? We can also add the description if you want, but we only got those things. So, if you go to the news and you see, yes, the title looks there and the content makes sense somehow. Okay, we did get description, but can we see the link? Yes, it seems correct. So we found it somehow we we got to extract the URL and we got to extract the title. So this is the content. So now there is a tutorial by our friends in fre on fre campam. So perfect. Let's prompt engineering. Yeah, makes sense. So it is there. Okay. So at least got this prompt. All right. Perfect. So there's another entry here. Okay. So that's how the new search work. Now let's go to copy the ID of YouTube channel. As I we mentioned at the beginning, we need to create the ne next function or the next tool. Now that we're talking about MCP. Okay. So let's get back here. So yeah, let's create the MCP tool. You know this add the decorator mcp. tool. And now you create the function. This this is synchronous for now but you can make it as synchronous if you want I would recommend as synchronous because you know you can run this you know like not nonblocking so it doesn't wait for other process to finish. So yeah any case just let you as a homework so don't worry. So okay sorry I'm talking too much and I already did a lot of stuff here. So we do the query again. Max results the same logic that we did for the P um function. So you see max results. I don't think this is going to be a lot of videos. So let's do it by default here. So for this we're going to give a description and again what we're going to say we're going to search has the name of Frs Vel. Yeah, kind of makes sense now, right? We are just using title here. I don't know much about the YouTube uh file, but we're going to do simply by at least by my by title URL. All right. If this is and then we give the address of it there's a specific address for YouTube. So if I Google it, I know that is the YouTube channel. So for this we go to YouTube channel. Uhhuh. Pretty much the feed section. Now the video is XML and then you need to give the ID of that channel. So for the ID we already extracted and we're going to just go here copy and paste it. All right. So that seems to get us that file and yep. So here we're going to go a little bit blindly blindly. So this just pay attention to this. I hope this works. If not I just going to fix it. But don't worry this is the course. So okay just going to do the results here. the query the same process that we did before for an entry and all the entries that we have let's say we're going to iterate here and okay you're going to search for yeah we're going to have a title and somehow the URL kind of the same thing that we did before so yes kind of copy paste let's say so yeah it should give us an XML that looks similar to our previous one and we're just going to categorize everything by title and if the title is the the query is in the title. Okay, just go to the list, append the results and the link. So we not look for description here, just title. Okay, so now we return the results or we send a message that the results were not found again. And voila, that's pretty much just kind of co copy paste of the previous function. And with this, we can just start running it. But let's check if we have any errors. And no, it's running. So, okay, MCB Spectre, we run it again. Ah, we close it. Okay. Anyway, we we restart it and here we go again. So, connect drive in. And now tools. We have two tools here. Tools. Yeah. Let's go to YouTube search then. So, I don't know something about title. Found something. Yay. Yes, we found it. So, there should be a a new video coming. Yeah, I got a aent with Python. All right, that's perfect. So, it's quite recent. So, you see that's why we use the fit because it tells about the recent updates. All right, let's see another query. What do you think? Um, hey, what what can we do? AI. Okay, we have Okay, two videos to a GTKI uh using AI as a accelerator. Good. That's good. That's good. So it seems working. So what do you think? Uh now we are ready to get like a real life example as you can use it for other purposes. Maybe some websites that you have in mind or maybe you have an API instead of just using this method of the RS. Right? So yep. And also we're going to create another tool. This is for giving you um secret message. So for example, you have your own way to you know to tell certain things like I have a secret message. So so the agent will try to find this secret message that we have. So over there are we going to do this as a function? Let's say okay let's return secret message. Okay. Uh what do you think about sub secret? I think there's no recipe to code. So everything that we have to do is to keep exploring and of course um keep coding. So you're exploring and happy coding sounds perfect what you think and don't forget to leave your any thoughts here on comment section. So get creative I will say just if you have more messages it would be great. All right so yep that sounds cool. Um description return message of free cut camp [Music] have been cutting. Okay, that's perfect. Um yeah, we're not going to test that. You already know that that should work. It's just a message. So all right, now we can go to the next part. We can go to connecting our MCPS. So for this, it's going to be directly into VS Code. So for let's go here. We're going to create a file that it's mainly work for VS code configuration. So we're going to go to the folder VS code MCP JSON. So you see here MCP JSON it going to give us the information about how to set up MCP and this only for V code. Remember we need to go to the VS code. So for that we're going to open brackets. We're going to get the keyword servers and here we're going to put the information about the NCP server. So for this we need a uh the title of the HTP server. You see you're going to put a calculator. The command will be how you going to open or start the server and the arguments. Yeah, they're going to depend if it's SDIO or HTTP. So yeah, and the address where is uh the path sorry and the password is your your file. So for this let's say we're going to go for the scenario first scenario. So the name of the file is going to be SDIO for now. So py the first one that here and the command python and here we don't need environ environments will going to be like a token or notification to you might have here okay so command will be python by default but since I'm using a virtual environment in python I need to put the full path where is my python file so I need to go here to the okay to the virtual environment where where I have the folder virtual environment so if you didn't install a virtual environment you put Python I should work for my case I need to find the PythonX and there you have it so I need to cop the full path and Mhm. need to change here the slider. That looks better. Okay. So now you can avoid that command or just put Python if you don't have a virtual environment. Okay. So that should do the job for this. You tell the V code to to add this MCP server. And also you can do this manually but I haven't really tried that way. I I've seen that they have a functions a visual code to do it but it's not that clear to me yet but I hope this one works and it's quite clear for you. So if you have another method please let me know. Okay. So what we're going to do here as I told you can this automatically here like kind of go and add a command to run this is going to be Python blah blah blah but it just gonna give you an ID and this ID I don't know where it is. So yeah, it was looking quite confusing. Let's open the agent mode here. And now you're going to have an icon of the servers. You have the agent. Yeah. Go to the method of agent. You can choose the the model that you you want or at least you have access to. And then you have the icon of kind of servers here that tell you how to runa. So to run the MCP server and it's kind of running somehow, but you need to be quite careful. So let's go here to this area and just make sure that it's running or not. So here you see somehow it's running but we don't see it. So let's go to the output problems the console or something. No. Okay. So let's stop it. Restart it. See? Okay. So now we see it somehow. So let's see if it's running. Yes, it's running with transport SDIO. Okay, so it seems that the configuration was correct. Now we can make use of our SCP server. So it's going to go to the agent mode. And here we're going to try to maybe ask for a something that we already have in our MCP server, right? So let's see. Okay, let's multiply three times two. And it's going to wait for the result. Uhhuh. So now you're going to ask us to run our uh a function in our NCP server tool sorry a tool. Okay. Okay. And voila you have it. So the protocol is going to be six. So that means it works. Also if you had a different configuration of multiplication it going to run on that point. For example you can set a multiplication to power off in your SCP server. You're going to get the result of power even though you have the function assembification. But okay. So here is just the summary what you can do at least you can see the configuration file here as well what we have just done and yeah voila that's the first one so there are two more to go okay so let's go and create the second scenario so for this one was uh HTTP do you remember that yeah so we do something similar but okay I going to do this again and then we're going to copy inside the keyword of server So this one gets a little bit more clear again, right? So for this we can just copy paste what we just done. But this is going to be a duplicate. So later on we're going to put inside one keyword server. All right. So okay, don't worry. We're just going to do that in a moment. So let's focus on this. First of all, we're not going to use the executable Python. But here we need to change the name to HTTP first. Okay. For the executable, we don't use Python. It's going to be HTTP. Is it? So we need to connect to a server. So for that we're going to use mpx command and here we're going to have something really important here. You need to put the keyword mcp remote so that you tell it that this server we are using something remotely right. So you need to connect a server somehow. So you got to connect at this address. So if it is deployed somewhere you have to put it slashmcp. Okay. Okay, so this is running local host at this port and the MCP is running at this endpoint. All right, so that seems correct. But is it enough? H there is something wrong. I told you at the beginning we can we need to put it somewhere inside a keyboard. Aha. So this is not enough. You see this code start to give us some hints there that something is wrong. So well yes. So we need to put everything inside one keyboard servers otherwise it's going to be messy. So here we go again. So this copy mark here the name and then the commas and everything. Okay let me just go here command. Okay sorry if this was not that um you know clear but yeah now it does. Let's go to agent mode and see the icon of servers here. Trust our own server. Yes. Okay. So this is will try to connect to the MCP server somehow to connect to that address but not really running it. you will see what I'm what I'm saying here like okay so how it says like okay there is a server running here right so let's restart it so it tell us about like connection error da da da da okay so that's what it tell us is that there is nothing going on that address so what we have to do is to go to our terminal at the server now in http mode all right so we can deactivate the stio so we only focus on the MCP of HTTP to see how it works. So let's go this far. We see that it's not running. It's only HTTP connection. So let's say multiply two times by and okay. So this is by default by the agent. It's not something you know using the RMCP. What can we do? The configuration is correct. At least it's accessing it. But something is going on. Okay, we're going to try to implement the tier one and then I going to show you the the solution for this. So let's do this simply. Okay, for now we have the the feet as well and we're going to add Python because we are using a virtual environment. We just need to tell the scenario tree is going to be the name of the file. The name of the file is feet score mcp. Okay. So after doing this configuration on the third NCP server then we can fix that part. So let's double check if on extension we find the new one. Yes. Yeahp. Correct. Okay. Let's try that here. MCP model is where you can choose what kind of model can access to your SAP server. So this is what what happened with previously. So we didn't say specifically to the let's say like the UI over visual studio code to let compiler to access to certain MCP servers. So here you need to tell it exactly what kind of agents have access to what kind of MCPs. So yeah, we see here configure mode access and you can tell okay only three mini only cloud can access to this or yeah so that's was the thing that we miss but now should work without a doubt. Okay so that one now let's just yeah looks good. Mhm. And yeah let's try here. So I just tried that before. Okay. Now we can say we like to find if there are any courses in let's say precook but related to Python. Check. Now it should run the MCP. Uhhuh. Yes. We're going to query for a Well, it's quite long. Probably is not going to get any results. We need to find by insert by keyword. Uhhuh. As it goes to YouTube channel. Yeah. Probably is going to not going to find anything. You
Original Description
Learn to build Model-Context Protocol (MCP) servers with the open source FastMCP Python library.
MCP is the standard that lets AI agents, like GitHub Copilot and Gemini, securely interact with your databases, functions, and apps.
You'll learn what MCP is and why it matters. Then you'll dive into three hands-on coding projects.
You'll build calculator apps using Standard I/O (STIO) and HTTP Stream, integrate APIs for dynamic content, and apply testing with GitHub Copilot.
You’ll finish by deploying your MCP on FastMCP Cloud for a complete end-to-end workflow.
💻 Code: https://github.com/BarrileteChapin/FCC-MCP-Course
✏️ Course created by Carlos Leon.
Connect with Carlos on LinkedIn: https://www.linkedin.com/in/leoncarlo/
❤️ Support for this channel comes from our friends at Scrimba – the coding platform that's reinvented interactive learning: https://scrimba.com/freecodecamp
⭐️ Contents ⭐️
- 0:00:00 Greetings
- 0:01:54 About MCP
- 0:04:46 Coding Scenario 1
- 0:13:58 Coding Scenario 2
- 0:32:41 Coding Scenario 3
- 0:49:58 Testing MCPs with Github Copilot
- 1:02:23 Bonus: Deploying a MCP on FastMCP Cloud
🎉 Thanks to our Champion and Sponsor supporters:
👾 Drake Milly
👾 Ulises Moralez
👾 Goddard Tan
👾 David MG
👾 Matthew Springman
👾 Claudio
👾 Oscar R.
👾 jedi-or-sith
👾 Nattira Maneerat
👾 Justin Hual
--
Learn to code for free and get a developer job: https://www.freecodecamp.org
Read hundreds of articles on programming: https://freecodecamp.org/news
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from freeCodeCamp.org · freeCodeCamp.org · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
React: Production Server Setup Part 2 - Live Coding with Jesse
freeCodeCamp.org
cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
freeCodeCamp.org
Browser history tutorial - Beau teaches JavaScript
freeCodeCamp.org
Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
freeCodeCamp.org
React: Parameterized Routing with Next.js - Live Coding with Jesse
freeCodeCamp.org
React: Dealing with jQuery Issues - Live Coding with Jesse
freeCodeCamp.org
setInterval and setTimeout: timing events - Beau teaches JavaScript
freeCodeCamp.org
Browser and Device Testing - Live Coding with Jesse
freeCodeCamp.org
Last Minute Updates - Live Coding with Jesse
freeCodeCamp.org
Post Launch Updates - Live Coding with Jesse
freeCodeCamp.org
React: Setting Up Google Analytics - Live Coding with Jesse
freeCodeCamp.org
React: Masonry Layout - Live Coding with Jesse
freeCodeCamp.org
Load Balancing Digital Ocean Droplets - Live Coding with Jesse
freeCodeCamp.org
try, catch, finally, throw - error handling in JavaScript
freeCodeCamp.org
Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
freeCodeCamp.org
Graphs: breadth-first search - Beau teaches JavaScript
freeCodeCamp.org
React: Masonry Layout Part 2 - Live Coding with Jesse
freeCodeCamp.org
React: WordPress API Live Search - Live Coding with Jesse
freeCodeCamp.org
Creating WordPress Custom Post Types - Live Coding With Jesse
freeCodeCamp.org
Dates - Beau teaches JavaScript
freeCodeCamp.org
Miscellaneous Front End Updates - Live Coding with Jesse
freeCodeCamp.org
Merging a Pull Request from GitHub - Live Coding with Jesse
freeCodeCamp.org
React + Prettier + Standard JS - Live Coding with Jesse
freeCodeCamp.org
React: Sortable Responsive Table - Live Coding with Jesse
freeCodeCamp.org
Geolocation Sorting by Distance - Live Coding with Jesse
freeCodeCamp.org
Tradeoff Matrix - Agile Software Development
freeCodeCamp.org
The Definition of Ready - Agile Software Development
freeCodeCamp.org
Getting first React job without experience - Ask Preethi
freeCodeCamp.org
React: Google Analytics Click Tracking - Live Coding with Jesse
freeCodeCamp.org
Submitting a PR to an Open Source Project - Live Coding with Jesse
freeCodeCamp.org
Should I go back to school to get CS degree? - Ask Preethi
freeCodeCamp.org
Hero Section CSS Changes - Live Coding with Jesse
freeCodeCamp.org
Working Agreement - Agile Software Development
freeCodeCamp.org
A day at Pennybox with Co-Founder Reji Eapen
freeCodeCamp.org
React: Sorting and Filtering Data - Live Coding with Jesse
freeCodeCamp.org
React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
freeCodeCamp.org
React: Building a New UI - Live Coding with Jesse
freeCodeCamp.org
Definition of Done - Agile Software Development
freeCodeCamp.org
Getting started with jQuery (tutorial) - Beau teaches JavaScript
freeCodeCamp.org
Making a React Blog with WordPress Content - Live Coding with Jesse
freeCodeCamp.org
React, NextJS, CSS - Live Coding with Jesse
freeCodeCamp.org
jQuery events - Beau teaches JavaScript
freeCodeCamp.org
React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
freeCodeCamp.org
React: Working with API Data - Live Coding with Jesse
freeCodeCamp.org
React: Refactoring Components - Live Streaming with Jesse
freeCodeCamp.org
jQuery effects - Beau teaches JavaScript
freeCodeCamp.org
More React Refactoring - Live Coding with Jesse
freeCodeCamp.org
animate in jQuery - Beau teaches JavaScript
freeCodeCamp.org
"Finishing" My React Site - Live Coding with Jesse
freeCodeCamp.org
Starting a New React Project (P2D1) - Live Coding with Jesse
freeCodeCamp.org
React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
freeCodeCamp.org
The Agile Manifesto - Agile Software Development
freeCodeCamp.org
jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
freeCodeCamp.org
React Project 2 Day 3 - Live Coding with Jesse
freeCodeCamp.org
The INVEST approach to product backlog items
freeCodeCamp.org
React Project 2 Day 4 - Live Coding with Jesse
freeCodeCamp.org
Chickens and Pigs - Agile Software Development
freeCodeCamp.org
React Project 2 Day 5 - Live Coding with Jesse
freeCodeCamp.org
jQuery: add and remove DOM elements - Beau teaches JavaScript
freeCodeCamp.org
React Project 2 Day 6 - Live Coding with Jesse
freeCodeCamp.org
More on: LLM Engineering
View skill →Related Reads
📰
📰
📰
📰
We Built AI Using Wikipedia, But Wikipedia Is 40% Wrong
Medium · Machine Learning
LLM vs RAG Explained (EP2): How AI Actually Finds the Right Answers
Medium · Data Science
LLM vs RAG Explained (EP2): How AI Actually Finds the Right Answers
Medium · LLM
LLM vs RAG Explained (EP2): How AI Actually Finds the Right Answers
Medium · RAG
🎓
Tutor Explanation
DeepCamp AI