You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1536,6 +1540,39 @@ The streamable HTTP transport supports:
1536
1540
- JSON or SSE response formats
1537
1541
- Better scalability for multi-node deployments
1538
1542
1543
+
#### Session lifetime and limits
1544
+
1545
+
A stateful session does not live forever, and one process does not hold an unlimited number of
1546
+
them. Two settings control this. Both are keyword arguments on `FastMCP(...)`. `stateless_http=True`
1547
+
keeps no sessions, so neither applies there.
1548
+
1549
+
| Setting | Default | What it does | What the client sees | Turn it off |
1550
+
|---|---|---|---|---|
1551
+
|`session_idle_timeout`|`1800` (30 min) | Closes a session that has had nothing in flight for that long. |`404 Session not found`. It has to `initialize` again. |`None`|
1552
+
|`max_sessions`|`10_000`| Refuses to open a session beyond that many. Existing sessions are untouched and nothing is evicted. |`503 Too many open sessions` with JSON-RPC code `-32603`. |`None`|
1553
+
1554
+
What counts as "in flight":
1555
+
1556
+
- An open `GET` stream. The SDK clients keep one open, so a connected client's session never
1557
+
expires.
1558
+
- A request that is still being answered. A tool call that runs longer than the timeout is not
1559
+
interrupted, and the countdown only starts once it finishes.
1560
+
- Nothing else. Between requests the clock runs. Any request on the session restarts it,
1561
+
`ping` included. Once a session has expired, nothing revives it.
1562
+
1563
+
A client that ends its session with `DELETE` frees it immediately. So does a client whose
Both events show up in the server log. An expiry is `Session <id> idle timeout` at `INFO`. A
1571
+
refused open is `Refusing to open a new session: <n> sessions are already open` at `WARNING`.
1572
+
1573
+
The limits are per process. With four workers the ceiling is four times `max_sessions`, and each
1574
+
worker expires its own sessions.
1575
+
1539
1576
#### CORS Configuration for Browser-Based Clients
1540
1577
1541
1578
If you'd like your server to be accessible by browser-based MCP clients, you'll need to configure CORS headers. The `Mcp-Session-Id` header must be exposed for browser clients to access it:
0 commit comments