Set Up Our MCP Project
Table of Contents + −
Enough theory. Let’s start building! 🚀
In the previous part, we learned what MCP is, why it is useful, and how MCP clients and servers communicate.
Now it’s time to build our first MCP server.
By the end of this chapter, we will have a running MCP server.
We won’t add any tools yet. We will connect Jan in the next chapter, and then build tools after that.
Our goal here is simple:
Let’s get started.
🧱 3.1 What Are We Building?
Before writing any code, let’s understand what we are going to build.
We are going to create a small Python application that acts as an MCP server.
For now, the server won’t do anything useful. It won’t have a calculator, database, file reader, or any other tool.
That’s intentional.
We first want to make sure that we can:
- Create an MCP project.
- Install the MCP SDK.
- Create an MCP server.
- Start the server successfully.
Later, we will add tools to this server.
Our project will eventually look like this:
But for this chapter, we’ll start with just:
Once this works, we can build on top of it.
🐍 3.2 Why Python?
For this tutorial, we will use Python to build our MCP server.
MCP is not tied to a particular programming language. You can build MCP servers using different languages and SDKs.
We are choosing Python because it is:
- Easy to learn
- Widely used in AI and automation
- Well suited for building small services
- Easy to set up
- A good fit for our MCP examples
So our stack will be:
If you’re completely new to Python, don’t worry. You only need a basic understanding of Python to follow this tutorial.
📥 3.3 Install Python
Before creating our MCP project, we need Python installed on our machine.
We recommend using a recent supported Python 3 version for this tutorial.
You can check whether Python is already installed by opening a terminal.
On Windows:
python --versionOn macOS or Linux:
python3 --versionYou should see something similar to:
Python 3.x.xFor example:
Python 3.12.8If Python is not installed, install it from the official Python website.
After installation, run the version command again:
python --versionor:
python3 --versionOnce you can see the Python version, we are ready.
📁 3.4 Create the Project
Let’s create a directory for our MCP project.
Open your terminal and run:
mkdir calculator-mcpcd calculator-mcpWe now have an empty project directory:
calculator-mcp/We will gradually add our MCP server code to this directory.
For now, keep it simple.
📦 3.5 Create a Virtual Environment
Before installing any Python packages, let’s create a virtual environment.
A virtual environment gives our project its own isolated Python environment.
Why do we need this?
Imagine you have two Python projects:
Project A MCP SDK version A
Project B MCP SDK version BIf both projects use the same global Python environment, their dependencies can interfere with each other.
A virtual environment avoids this problem.
Our project will have its own environment:
calculator-mcp/│├── .venv/│└── ...⚙️ Create the virtual environment
On Windows:
python -m venv .venvOn macOS/Linux:
python3 -m venv .venvThis creates a directory called .venv.
▶️ Activate the Virtual Environment
On Windows PowerShell:
.venv\Scripts\Activate.ps1On Windows Command Prompt:
.venv\Scripts\activateOn macOS/Linux:
source .venv/bin/activateAfter activation, your terminal will usually show something like:
(.venv)For example:
(.venv) C:\projects\calculator-mcp>That tells us that our virtual environment is active.
📚 3.6 Install the MCP SDK
Now we need the Python SDK that allows us to build an MCP server.
We’ll install it using pip.
Run:
pip install mcpOn some systems, you may need:
python -m pip install mcpAfter installation, the MCP SDK is available to our Python project.
We can verify the installation with:
pip show mcpYou should see information about the installed MCP package.
Our project now has:
We’re ready to write some code. 🚀
🖥️ 3.7 Create Our First MCP Server
Now let’s create our first MCP server.
Create a file called:
server.pyOur project now looks like:
calculator-mcp/│├── .venv/│└── server.pyOpen server.py.
We’ll start with a very small MCP server.
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Calculator Server")That’s it.
Our MCP server has been created.
Let’s understand these two lines.
📦 Import FastMCP
from mcp.server.fastmcp import FastMCPFastMCP is provided by the MCP Python SDK.
It gives us a convenient way to create an MCP server without having to deal with all the lower-level protocol details ourselves.
🏗️ Create the server
mcp = FastMCP("Calculator Server")Here we create an MCP server instance.
We give our server a name:
Calculator ServerLater, we’ll add calculator tools to this server.
For now, the server doesn’t have any tools.
That’s okay.
We are building it step by step.
▶️ 3.8 Run the MCP Server
Our server needs an entry point so that Python can start it.
Update server.py:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Calculator Server")
if __name__ == "__main__": mcp.run()Now we have a complete minimal MCP server.
The complete file is:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Calculator Server")
if __name__ == "__main__": mcp.run()Let’s run it.
From the project directory:
python server.pyOn systems where Python is invoked using python3:
python3 server.pyOur server should start.
At this point, you may not see a big message saying:
MCP Server Started!And that’s okay.
Depending on the MCP SDK version and transport being used, the terminal output may be minimal.
The important thing is that the process stays running instead of immediately exiting with an error.
✅ 3.9 Verify That the Server Starts
How do we know our server actually started?
The simplest first check is the terminal.
Run:
python server.pyIf the command remains running without an exception, our server has started.
You should not see errors such as:
ModuleNotFoundErroror:
ImportErroror another startup exception.
If the process is still running, congratulations! 🎉
We have created our first MCP server.
Our current architecture is:
There is one important thing to understand.
Starting the server is not the same as using the server.
Right now, we have only created and started the server.
We haven’t connected an MCP client yet.
We also haven’t created any tools.
That’s exactly what we want at this stage.
🧾 3.10 What We Have Built
Let’s quickly review what we accomplished.
We:
- Installed Python
- Created our project
- Created a virtual environment
- Installed the MCP Python SDK
- Created an MCP server
- Started the server
- Verified that it runs
Our project is currently:
calculator-mcp/│├── .venv/│└── server.pyAnd our server code is:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Calculator Server")
if __name__ == "__main__": mcp.run()We now have the foundation for our MCP application.
But our server is still pretty boring. 😄
It doesn’t have anything for an MCP client to actually use.
That’s about to change.
In the next chapter, we’ll set up Jan as our MCP host/client, connect it to this server, and verify that the two can communicate.
Then we’ll build our first real MCP tool:
add(10, 20)And that’s where things start getting interesting. 🚀