Skip to content

Commit b0ee1a4

Browse files
committed
fix: add warning log when rejecting unknown/expired session ID
Fixes #2204
1 parent b33c811 commit b0ee1a4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/mcp/server/streamable_http_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ async def run_server(*, task_status: TaskStatus[None] = anyio.TASK_STATUS_IGNORE
225225
read_stream, write_stream = streams
226226
task_status.started()
227227
try:
228-
# Use a cancel scope for idle timeout when the
228+
# Use a cancel scope for idle timeout \u2014 when the
229229
# deadline passes the scope cancels app.run() and
230230
# execution continues after the ``with`` block.
231231
# Incoming requests push the deadline forward.
@@ -272,6 +272,7 @@ async def run_server(*, task_status: TaskStatus[None] = anyio.TASK_STATUS_IGNORE
272272
# Unknown or expired session ID - return 404 per MCP spec
273273
# TODO: Align error code once spec clarifies
274274
# See: https://github.com/modelcontextprotocol/python-sdk/issues/1821
275+
logger.warning("Rejected request with unknown or expired session ID: %s", request_mcp_session_id)
275276
error_response = JSONRPCError(
276277
jsonrpc="2.0",
277278
id=None,

0 commit comments

Comments
 (0)