
To try everything Brilliant has to offer—free—for a full 30 days, visit https://brilliant.org/DevelopersDigest/ . You’ll also get 20% off an annual premium subscription. Build and Deploy Your Own Model Context Protocol Server with Cloudflare Workers In this video, I show you how to build and deploy your own Model Context Protocol (MCP) server using CloudFlare workers. MCP, introduced by Anthropic last year, has gained traction with integrations in Claude Desktop App, Cursor, and Windsurf. I'll guide you through setting up the server, initializing a project, and deploying it, complete with a TypeScript implementation. Also, learn how to handle function invocations and update your MCP servers. Don't forget to try out Brilliant.org for enhancing your analytical skills! Repo: https://github.com/cloudflare/workers-mcp 00:00 Introduction to MCP Servers 00:44 Understanding MCP and Its Applications 02:28 Setting Up Your MCP Server 03:56 Deploying and Testing Your MCP Server 04:48 Exploring MCP Server Functions 05:33 Integrating MCP with Claude and Cursor 07:15 Sponsor Message: Brilliant.org 08:18 Scaling and Additional Configurations 11:51 Conclusion and Next Steps Shoutout to my sponsor, Brilliant.org, for their amazing interactive lessons. This video was sponsored by Brilliant
--- type: transcript date: 2025-03-07 youtube_id: 3Jsh4brTjE0 --- # Transcript: How to Build and Deploy a Custom MCP Server in 10 Minutes in this video I'm going to be showing you how you can build and deploy your own mCP server in just a number of minutes if you're not familiar with model context protocol this is something that came out late last year from anthropic and ever since its release it's really started to capture quite a bit of momentum so where we started to see this originally take off was within the anthropic desktop app but ever since then we've seen Integrations come to both cursor as well as wind serves what I'm going to be showing you in this video is how to deploy your mCP server to a cloud flare work Cloud flare put out this really great repository that frankly I don't think has enough attention because this is probably the most clear example on how you can set up and deploy an mCP server so before I dive in I just want to quickly touch on mCP and how it works let's say you're a user and you're using the claw desktop app what the claw desktop app will do is it it's going to go and make a request to the mCP servers that you have connected to the application and the first thing that it's going to do is it's going to ask that server to list out the different tools that are available we're also going to have this Json payload that gets sent to the large language model to inform the model okay these are the tools that are available if you detect an intention to use one of these tools go ahead and send the signal to invoke that tool now within clad let's say the large language model that you're using whether it's Sonet or Hau or Opus determines that there is a function invocation that is required what will happen is it's going to send that that request over to our mCP server that request could include a payload of the different parameters that you specified of what is required or potentially optional within your tools from there your function is going to be invoked on the mCP server and then once your function has done whatever it needs to do it could be retrieving information it could also be taking actions and potentially updating information for you once we have that done we're going to send that tool response back to the CLA desktop app how this works is once we run through the setup you'll see how simple this is it might look like a lot but it's actually very straightforward once we go and initialize the project we're going to have our functions available within this index TS file and this could be really anything it could be you wrapping an existing API it could be you creating a new API really you can put anything within this the first thing that I'm going to do is I'm going to run npx create cloudflare at latest and I'm just going to call this mCP demo if it's the first time that you've installed this and if you haven't used cloudflare before you will just have to make an account go through the authentication steps you also have a generous free tier on cloudflare as well so you will be able to try all of this out for free so so in this example I'm going to get started with the hello world template here and in this example I'm going to be showing you the typescript implementation but you can also do this within JavaScript or there is a python version that's currently in beta it will just take a moment to install everything for you now you do have the option to set up git if you like in this cas case I'm just going to say no and then you also have the option to deploy your application which I'm not going to be doing just quite yet now that we have that I'm just going to go ahead and CD into our mCP demo directory here and then once we have that I'm going to MPX workers mCP and run setup so next once we have that we'll have this on our screen that it says it found the npm script of the key deploy that contains Wrangler deploy it's going to go ahead and update that for us we just want to make sure and go and proceed all that we're doing instead of just the standard Wrangler deploy is we're also going to be generating this string which you'll see in just a moment I'll go ahead and click proceed here we're going to go ahead and replace the contents of the index TS here and then finally we see that it's deploying our code here we see that it's uploading it uploaded the mCP demo and now we have our worker successfully deployed to our mCP server here once you have that you can name your mCP server whatever you'd like I'm just going to name it mCP demo in this case once you name it what it's going to do is it's going to write to the Claud desktop configuration file as soon as you name your worker what you'll see is it will write that configuration to where the Claude desktop configuration object is and this is going to be where all of the different mCP servers are so I already have another demo within here which is another cloudflare worker of an example that I was working on just before recording this video and then this is going to be what we had just set up within here we have the instructions on how to run this and also largely this is the example of what we're going to be using with in Wind serve once we configure that within their interface now if we take a look at our project it's very straightforward so we have our source test as well as our disc folder first if we take a look at our index TS here this is the simplest implementation of an mCP server within here we have our cloudflare worker and we have this class structure and the nice thing with this is what we can do is we can Define with a dock string on what our function does and this is very important because this is going to be what informs the llm of what that function actually does the portion here is going to be what gets exposed to the large language model the thing that's important when you're writing your doc string is you have to just inform what the function is doing what parameters are required if any and then finally what the function or service is going to be returning as well as in what format within here we have the simple say hello and the one thing that you will have to make sure to do is just make sure that you restart your server here what I'm going to do is I'm just going to go ahead and open up our CLA desktop application here now once we go within the claw desktop app we'll see that we have one mCP tool available right now we just have say hello which is a warm friendly greeting from your new workers mCP server and it's from the server of mCP demo now if I take a look at the dock string within our worker we see a warm friendly greeting from our new workers mCP server now what I can say is say hello to developers digest and what it will do here is it will detect the intent of we're saying hello it will look to see that list of tools that we've sent in with our request and it will say okay I've determined of those tools say hello is the one to use what we can do within here is I can allow it for chat and within here we see that we're sending in the payload of developers digest for the name and then for the payload that we get back from our server we see hello from an mCP worker developers digest and then what it will do with that response is it will generate this from our language model that's effectively M CP in a nutshell so in this case I'll just ask cursor I'll say a random image generator and here we'll see it will generate the dock string for us as well as the get random image if I go and save that out and if I take a look at our package.json we see that we have this deployment script like we saw earlier now what I can do is if I just mpm run deploy what it will do is it's going to go and update our mCP server to now also have this get random image generator and the cool thing with this now mind you you will have to restart the cloud desktop app but once you've reset the app what you'll see within here is now we have say hello and get a random image generator so now it is deployed to a cloudfl worker before I move on I want to thank today's sponsor brilliant.org brilliant takes a Fresh Approach to learning that perfectly complements these AI developments imagine a fitness center for your mind where every lesson makes you mentally stronger instead of sitting back you're diving in tackling challenging problems with Crystal Clear explanations research shows this approach is six times more effective than conventional learning methods their latest course on large language models especially caught my attention offering a comprehensive yet digestible exploration of AI technology you don't need to be a coding Wizard or an academic scholar to benefit from brilliant it's designed for anyone eager to enhance their analytical thinking and Brun their understanding of modern Concepts whether you're on a daily commute lunch break or evening downtime brilliant transforms spare moments into valuable learning opportunities head over to brilliant .org SD developers digest for a 30-day free trial plus if you join you'll receive 20% off your annual subscription the great thing with it being on a worker is this can EB and flow to the demand whether you have 10 users or you have a 100,000 users in the course of a number of hours it will be able to scale to that demand that's one of the really nice things with workers is if you're not really using it you're not going to be built for it whereas if you all of a sudden have a project that takes off which mind you in AI is definitely a thing cloudflare workers is a really great option for setting up endpoints as well as things like mCP servers now just to touch on a couple things that are within the project you will have your test file so you can write out all of your different tests within here and then for the doc generation command that we saw at the beginning of the video This Is What It generates for us we have our worker and then within here we also have all of that documentation that was generated we have that say hello a warm friendly greeting like all of those different pieces that we saw within the clock UI and also what was behind the scenes that was ultimately getting sent to that large language model next on how to set these up within Cloud cursor as well as wind serve here is an example of the cloud desktop configuration within here we'll have our mCP servers and for each server that we have will have a uniquely named key in this case we're going to have our mCP demo and this is going to be the command on how we can run this as well as where we can access it if I command shift p on Mac and I open up our Command pallet here and I go to the cursor settings here and I go down to mCP what we'll see here is add a new mCP server I'm just going to put this side by side with the configuration that we have once we click add a new server we can name this whatever we want I'll call this mCP demo within the command what we're going to do is we're just going to copy these different values here so the first one I'm going to grab the command once I have that I can put run mCP demo and then from there I'll grab our workers URL and then finally our path here that's one thing I don't love personally about the cursor implementation I personally like this mCP configuration that they have within the claw desktop app as well as wind surf which you'll see in just a moment here I'll go ahead and add this in here and then as soon as we add it it will test the connection and then once you have it available we'll see that we have this Green Dot here if I open up the chat view or the composer view within cursor what I can do within here is I can say what tools are available when I send in that request what we'll see here is we have some core functionality what's funny with cursor here is it actually says message context protocol there is actually a bit of a hallucination between these two words but nevertheless we have our tools available here we have that say hello function as well as that get random image function that we just set up within our Cloud flare worker so when to set this up within wind surf it's super straightforward if I go over to the panel on the right hand side for Cascade I can click configure mCP and within here we'll have our mCP servers and here I have a pre-existing one for neon now all that I need to do to access this mCP server that we just made is just copy that configuration I'm going to add a comma here below neon and then I'm going to add in our new server make sure to save it out and the one thing that you'll have to make sure to do is just make sure you go and you refresh your servers here it will go check for that file and here we now see that we have access to this mCP demo now if I say hello to developers digust and gener at a random photo I'll send that in here we go the greeting message was hello from an mCP server developers digest and here is a random image that was generated and the cool thing with the wind surf is it will even show you the image right within the editor there otherwise that's pretty much it for this video I'll put the links to everything that I showed you within the description of the video if you're interested in trying this out let me know what you have found most useful for different mCP servers that you're using or what you're going to be building with mCP servers I'd be really interested interested in hearing in the comments below but otherwise if you found this video useful please comment share and subscribe otherwise until the next one
Weekly deep dives on AI agents, coding tools, and building with LLMs - delivered to your inbox.
Free forever. No spam.
Subscribe FreeNew tutorials, open-source projects, and deep dives on coding agents - delivered weekly.
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.