Creating and testing a server with Streamable HTTP
Let’s create a server, and in doing so, we’ll also integrate notifications. After the server is built, in the next section, we’ll try testing it out with the different tools we have at our disposal, such as writing our own client, using the Inspector tool, and testing with cURL.
To create the server code, there are a few things we need to do:
- Set up the transport as Streamable HTTP.
- Add features.
- Add code that sends notifications when a tool is called.
Great, now that we have our plan in place, let’s implement it. Here’s an attempt to implement the first two points of our plan:
# server.py
from mcp.server.fastmcp import FastMCP, Context
from typing import Optional, Dict, Any, List, AsyncGenerator
from mcp.types import (
    LoggingMessageNotificationParams,
    TextContent
)
# Create an MCP server
mcp = FastMCP("Streamable DEMO")
# 2. Adding features... 
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                