python-sdk/examples/servers/simple-streamablehttp-stateless
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Marcelo Trylesinski 8adb5bdce8
refactor: move transport-specific parameters from FastMCP constructor to run() (#1898)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 15:16:20 +00:00
..
mcp_simple_streamablehttp_stateless refactor: move transport-specific parameters from FastMCP constructor to run() (#1898) 2026-01-16 15:16:20 +00:00
pyproject.toml Replace deprecated dev-dependencies with dependency-groups (#1488) 2025-10-23 17:22:16 -07:00
README.md chore: add markdownlint on pre-commit hook and lint md files (#996) 2025-07-10 09:43:49 +01:00

MCP Simple StreamableHttp Stateless Server Example

A stateless MCP server example demonstrating the StreamableHttp transport without maintaining session state. This example is ideal for understanding how to deploy MCP servers in multi-node environments where requests can be routed to any instance.

Features

  • Uses the StreamableHTTP transport in stateless mode (mcp_session_id=None)
  • Each request creates a new ephemeral connection
  • No session state maintained between requests
  • Task lifecycle scoped to individual requests
  • Suitable for deployment in multi-node environments

Usage

Start the server:

# Using default port 3000
uv run mcp-simple-streamablehttp-stateless

# Using custom port
uv run mcp-simple-streamablehttp-stateless --port 3000

# Custom logging level
uv run mcp-simple-streamablehttp-stateless --log-level DEBUG

# Enable JSON responses instead of SSE streams
uv run mcp-simple-streamablehttp-stateless --json-response

The server exposes a tool named "start-notification-stream" that accepts three arguments:

  • interval: Time between notifications in seconds (e.g., 1.0)
  • count: Number of notifications to send (e.g., 5)
  • caller: Identifier string for the caller

Client

You can connect to this server using an HTTP client. For now, only the TypeScript SDK has streamable HTTP client examples, or you can use Inspector for testing.