Cool.
So before we write our MCP clients, we want to first write our MCP servers.
So we'll be able to connect them to our clients.
And we're going to write two very simple MCP servers.
One is going to expose mathematic tools to add numbers and multiply them, which is going to communicate
via Stdio.
And the other server is going to be a very dumbed down weather server, which is simply going to output
that.
It's very hot outside.
But the interesting fact about this server is that it's going to communicate via SSH server sent events.
And this is the first time we introduce how to do that.
And I'll give you a very quick spoiler.
It's going to be very easy.
All righty.
So let's go and create a new package.
And I'm going to call it servers.
So this is now a new directory.
And let's make it a package by creating an empty underscore init.py file.
So this is now our servers package here.
And now I want to create a new file which I'm going to call math server dot Pi.
And here we're going to have the implementation of an SMTP server, which exposes two tools, one to
add numbers and the other tool to multiply those numbers.
And by the way, when making this course, I started by naming this file math.pi and eventually what
happened?
It turns out that it collided with the built in math package in Python, and it really took me some
time to figure it out.
And once I gave up, I simply dumped my error to cursor and it was able to point that out.
So the TLDR here called this file math server.py, because this is a very simple amqp server, and we've
already done how to do very similar things.
I'm simply going to copy paste it from the LinkedIn adapters repository, and we can skim this implementation
here.
And this is a very simple implementation.
But what's important to note is this transport layer which is stdio.
All right.
So let me copy that and let's go to cursor and paste it.
And let's try to run it now in our terminal.
And I'm going to do it by running UV run server math server dot pi.
We can see that it is running successfully with this blinking square over here.
All right.
So let's now create the second server which is going to be a server which outputs the weather.
But it's going to be a very damped version of the server.
And it's always going to output that it's hot as hell.
So maybe it's going to be relevant only for Dubai.
And here's a clip from me in Dubai.
But the cool thing about this server, and this is the first time I was covering it, it's going to
be a server which the transport is going to be via SSH.
So it's going to be a server sent event MCP server.
And this means that the communication between the client and the server, it's not going to happen via
Stdio.
It's going to happen via HTTP.
And the client is going to make http post request to the server.
And of course we don't really need to handle this communication over here.
We get this out of the box when we use the MCP SDK.
Just need to specify to the server that we want that the transport to be SSH.
And this is super easy.
It's just a flag that we pass when we run the server.
Alrighty.
So we're back in cursor and we want to create a new file.
And let's call this file weather underscore server dot p y.
And it's going to hold the implementation of our weather and CP.
And let's go back to the link chain MCP open source.
And let me copy this dummy server they have here.
And I'm going to copy it.
And we can see it's a very simple implementation of a server which exposes the Get weather tool.
And it's going to return always the same static string.
So just for the fun, let's go and change the string.
And let's say that it is always hot as hell.
Sorry about that.
Let me just correct it to hot as hell.
All right.
So now we are done with the server.
And the important thing to notice is that transport here the transport here is SSE.
So this is how we communicate with this MCP server.
And let me show you how it's different when we run it.
If we go now and create a new terminal instance let me split here this view and let me run our UV run
and then weather sorry servers weather server server.py.
We can see now that the server is actually running in localhost port 8000.
If we want to change the ports to run on a different port, we can totally do that.
We simply need to specify and tell via the MCP SDK.
And that's pretty much it for this video.
So we created two simple web servers, one running in SDL and the other the transport is via SSH.
So let's go and let's commit this code over here.
So let me go now and see which files changed.
Only the servers directory.
And I added it.
And let's go and use cursor to commit this code here.
So cursor is going to auto generate the commit message.
Let me commit that and let's push it to the repository.
And if we go back now to the repository then we can see right now we have the new directory here.
And we can see we have now two commits.
We have the first commit from the previous video and this commit from this video.