Transcript for:
Understanding Model Context Protocol (mCP)

hi folks in this video we're going to learn what the mCP the model context protocol is all about and we're going to do it with as little Theory as possible and keep it very pragmatic and practical Marco codes all right so I have claw desktop open why is that because mCP model context protocol is an initiative being pushed by entropic the people behind clot and you'll find that there are a couple of tools and other providers already supporting mCP not by the way open a/ chbt at the time of this recording though that might change hence we're going to start with Claude desktop for now and I want to show you the problem I have currently is that I want to ask Claude hey summarize the three latest commit in the Jeet brain's cotton repository for me and when we execute their query then uh Claude will tell me I apologize but on I don't have direct access to GitHub repositories additionally I had a knowledge cut off so there's no way for claw to actually tell me what the summary of these three latest commit is or is there well let me fast forward a tiny bit in the video now I've reconfigured claw desktop under the hood to use the mCP protocol I'm executing the same query and now suddenly when I execute that query I get a new checkbox says hey should I run list commits from GitHub I say allow and then suddenly you'll find that Claud is actually able to give me a nice little summary of the most recent commits that the cotton repository just received that is quite nice and on an abstract level that's what mCP is being us use for giving llms access to your data it might be your private database where you want claw to actually be able to somehow query your data from the database or it might be data from Google Docs or your file system or your slack messages any sort of data source and we'll Now find out how that actually works how mCP enables that data access and for that I'm going to do some drawing haven't done that in a while let's try and figure out who is involved in a mCP transaction so first first of all we have claw desktop which in mCP terms we call host or client actually host and client are two different entities uh with mCP what I've just noticed when talking with people about it is they often use them kind of interchangeably most often they use client there are slight differences that a host actually can contain multiple clients and we'll dig deeper into that theory but for now I'll just want you to use it host or client that will work in our case claw desktop is the client but it could be your server application you could be any other application whatever have you then we actually have the real llm uh CLA in this case so CLA desktop is just a frontend application and send the queries through the internet to get the responses and then we have GitHub in this example which has the repositories the list of commits uh it could be a database as I said before it could be your local file system could be anything and now we really want to give you know CLA here access to the GitHub data how does that work forgive me my ugly handwriting but at the end of the day we're going to have an mCP server a new entity and it's actually called server the server is a tiny program which at the moment runs wherever your claw desktop runs or let's say on premises or near the application and what the server can do is it can for example access github's rest API to list commits in just in case you're not aware GitHub has a pretty extensive rest API for example a commit endpoint where as soon as you know the owner name and the re repository name you can essentially gets you know the list of commits the repository has and filter them and all that sort of stuff now what specifically can an mCP server do uh to oversimplify for the time being an mCP server has an endpoint which is called SL tools and the/ tools endpoint just returns in plain text what the server itself can do for example it can list commits or it can create you know a new pull request or it could for example I don't know push new files so anything the server can do um needs to be returned by the tools endpoint and don't worry we're going to have a look at a real endpoint um soon in a second the second uh thing it needs to be able to do is actually have an implementation for all these tools so it needs to be able then to actually you know call the rest API uh and list all the commits or create a new PR let's have a look at how such a real life mCP server for GitHub is actually implemented now I went to GitHub to the model context protocol uh organization and you'll see that there are are a couple of servers here already pre-implemented for you and that is really nice it's these are a couple of reference servers and you can see on the left side you have a server an mCP server for the file system which allows you to know access your local file system when configure correctly for Google Drive for G the command line tool for GitHub for Google Maps for postgress so there's a couple of you know of these reference implementations already which exist I'm going to have a look at the GitHub uh server and when you look at the read me you can see that it says here are the tools that the server actually um understands for example you can create or update files on GitHub in a repository let me just scroll down a tiny bit and find the list commit tool and really this is just plain text where you say list commits the description is gets commit of a branch and a repository it has these inputs an owner uh as a string repository owner an actual repository the string name uh and then optional parameters to actually page also through the commits and this is by the way not just plain text here in the re me but if you look at the source code of the server you will see there is a tools endpoint right and then we um return Json uh with the name list commits we return the description and then the schema here is actually being replaced what you saw earlier uh the repository name the owner name at the page and all that so literally you just return a Jason object uh with that specific data of what can the server actually do with GitHub and then thinking back to to point number two on my superb drawing there's actually also an implementation of that list commits function because at some point someone will call us the mCP server and say hey then please execute a du list commits for me with these specific parameters and you'll see that at the end of the day you just executing here a um rest API request to a specific URL the one you sol from the documentation with the parameters and return the Json back to the caller that's literally it which brings me back to my drawing because we now need to conceptually hook this up we now have Cloud desktop host client we have a new mCP server which is running uh which you know has that tools mpoint and can also actually call GitHub we have CLA llm now how does such a full workflow actually work step number one before Claude desktop now sends you know the actual query like summarize the five latest commits uh to Claude it calls the preconfigured mCP server and ask hey please let me know all the tools you have uh to which the mCP server will respond in this case well I can do list commits I can do create update file all these different tools so for now let's just say list commits then step number two is CLA debal execute the actual query like summarize the repo for me only now it will send the query the actual query plus the tools and it's literally just you know uh the Json response and another parameter uh in inside that request so we will send the request to Claud and say hey please do the summary for me now it gets a bit ugly but as step number three is that Claud says well I don't have actually information about any repositories but you just told me there is a tool somewhere which you can call uh so please use the tool um and ask it to you know list the commits for you hence you get a response back from CLA saying please use the tool and then call me again at which point CLA desktop the client will actually use the tool it will call the mCP server and tell the mCP server hey you told me earlier you can do a list commit now do the list commit for me um and the mCP server will call the rest API it will call GitHub right and then you get the GitHub response back like the last five uh commits or whatever have you will be returned to CLA desktop then CLA desktop needs to do another request to Claud and I made it red and I'm going to get you know the worst grad for this for this uh drawing here but anyway the last and final query will be please summarize the repository for me including the tools including the data so you actually send the latest five commits to Claud and what Claud then does is at the end of the day just some let's say natural language processing on all of that context you sent and then Claud can tell you well you gave me the latest five commits so I'm just going to put them in nicer English words in that case but Claud actually has no access to the database or to GitHub in that example it all is being done through the mCP server through commands the only thing that Claud knows is hey I don't have the answer now please use a tool you have to use the tool which comes from the mCP server and from the original query that we have one query please summarize the call now we actually have five queries so all all that stuff happens in the background okay now let's see this in action I'm backing hot desktop how can I configure it to use a know of my mCP server well there's a good old config file it Lees under on Mac OS for example library application support cloud cloud desktop config Json uh you'll find a link below on where the file is located on your specific operating system what goes inside the file when going back to the model context protocol service repository you can actually see that all these reference servers they come with instructions of what you need to paste into the claw desktop config file and then it depends on how you want to run the uh the server because CLA desktop will actually run the server you don't have to run it yourself uh you'll find Docker commands you'll find MPX or uh npm commands here sometimes also python commands I had the best luck so far always going with the docker commands but for those you'll have to have obviously Docker installed you can see that the command is being run so you just call Docker run uh you need to paste in or configure your G personal access token which you need to pre-configure for it to work and then that's the uh actual Docker image uh you will uh run and execute but taking this Chason object putting it into the config file making sure that your G personal access token here is actually replaced properly will be enough for CLA desktop to actually run and talk to your mCP server now once you restart Cloud opening up again you will see that here in the chat box you now have a tiny hammer down here where it says 17 mCP tools available and that's because Cloud desktop the host client ask the mCP server so it actually spawned the mCP server and now ask the mCP server hey which tools you have the mCP server responded with well I can create issues I can create update files I can create poll requests I can list commits so and so forth so now the next time oops you paste in summarized the three latest commits in the Jeet brains cotton repository what happens is that cloud desktop asks you hey there is a tool I want to run uh locally which is run list commits from GitHub through an mCP server which I'm going to allow and then you get the response back that you expect with the help from the mCP server uh now two last points the first one being we've been focusing on tools at the time being uh for the mCP server mCP servers per definition can actually do more than just tools I'll give you some keyword sampling Roots uh template prompts and we'll cover these in later uh videos just so you know the tools are definitely where the hype is because they allow you to have real agentic workflows and point number two is in the next episode we will Implement a client we're not going to use you know claw desktop anymore but just our own server program and then you'll see the actual flow that is being used here uh in code leave me a comment down below if you want to see the client uh being implemented in nodejs or Java my python is not that good so I prefer either of these two choices and that's it I hope you learned what all the CP hype is about see you next time SAA