- Tubelator AI
- >
- Videos
- >
- Science & Technology
- >
- Step-by-Step Guide to Setting Up MCP Servers and Tools for Agents
Step-by-Step Guide to Setting Up MCP Servers and Tools for Agents
Learn how to create and run MCP servers with tools in Cloud Desktop, using a simple example of a tool that counts R's in a word. Follow a step-by-step process from opening your IDE, creating a new folder, setting up the environment, and activating it.
Video Summary & Chapters
No chapters for this video generated yet.
Video Transcript
Let me show you how to set up a simple MCP server with a tool and get it running in
Cloud Desktop. If you're not familiar with what an MCP server is, you can think of it like
exposing a tool or set of tools to your AI assistant or agent.
So I created a tool that counts the number of R's in a given word.
And so here in Cloud Desktop, I say use the count R tool to count the R's in
strawberry. Here it says, I'll use the count R tool to count the number of R letters in
the word strawberry. There it is. The word strawberry contains three letter R's. Very simple,
but it should give you the basis to build any tool that you want. Let me show you how I did it now.
So the first thing you're going to do is open up your IDE of preference. Today I'm going to be
using Windsurf. Then you're going to open up the terminal. So the first thing you're going to do
is create a new folder. So you can create it anywhere and you just type MKDIR and then the
folder name. So count our
server. From there, hit enter. I already have that folder created, so then I'm just going
to cd into it. So count our server. Then the next thing you're going to do is spin up a
new environment. So to do that, you type python-m venv.vnv and then hit enter. Then you activate
the environment. And if you're on Windows, this is how you do it. .vnv backslash scripts
backslash activate hit enter. And you can see it is activated right there. Now, if you're
on a Mac, this is how you do it.
Source.vmv.bin.activate.
But now you can see there is our environment and there we are in the right folder.
The next thing you're going to do is install the MCP library.
So pip install MCP and then hit enter.
And then it should install everything you need.
And now you're ready to write your actual server.
Create a new file, server.py.
And it's going to be a Python file, obviously.
Now, this is a.
slightly more complex version of an MCP server than what is absolutely necessary.
I just put some error handling around it and just a little bit more robustness.
So let me walk you through what it is.
First thing you're going to do is import.
So from MCP.server.fastmcp import fastmcp.
I also decided to make it a little bit more robust.
Import time, import signal, import sys.
The number of lines you really need to get an MCP server up and running is pretty minimal,
probably about less than a dozen.
But again, I decided to make it a little bit more robust.
Here we have the signal handler just giving us some nice output
and handling the control C gracefully.
This is where the MCP server starts.
So you want to declare a new variable and it equals fast MCP.
And here are the parameters you need.
First, you need a name.
We're going to count it the count R.
This is what you're going to reference when you're calling the tool.
So you can in a prompt explicitly say use the count R.
tool to do this. Then you're going to give it the host URL.
So if you're hosting this on a server somewhere, this would be different.
But since I'm running everything locally,
I'm giving it our local host address, 127.0.0.1.