Creating an SSE server
Okay, so we understand the concepts of SSE and how to build a server, and even how our testing tools work and are different from STDIO. Now it’s time to build our own SSE server. We’ll learn how to do the following:
- Set up a project
- Add the server code
- Test the server
Create the project
Let’s create a new project like so:
- Create a virtual environment:
python -m venv venv - Activate the virtual environment:
source venv/bin/activate - Install the dependencies:
pip install "mcp[cli]"
There, you should be all set up to start building your SSE server.
Add the server code
Now add the following code to your project:
In server.py, add the following code:
from starlette.applications import Starlette
from starlette.routing import Mount, Host
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("My App"...