ruby-sdk/lib/mcp/server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Koichi ITO abc7d6c7ea Return 404 for invalid session ID in handle_delete
## Motivation and Context

The MCP specification requires that when a server receives a request containing
a session ID that is no longer valid, it MUST respond with HTTP 404 Not Found.
`handle_delete` was unconditionally calling `cleanup_session` and returning 200
even for nonexistent session IDs.

Ref: https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#session-management

> The server MAY terminate the session at any time, after which it MUST respond
> to requests containing that session ID with HTTP 404 Not Found.

## How Has This Been Tested?

Added tests for DELETE with invalid session ID, and lifecycle tests for
delete-then-POST and delete-then-DELETE scenarios.

## Breaking Change

DELETE requests with an invalid session ID now return HTTP 404 "Session not found"
instead of HTTP 200.

However, this change is considered a bug fix because it brings the behavior into
compliance with the MCP specification.
2026-03-19 14:52:13 +09:00
..
transports Return 404 for invalid session ID in handle_delete 2026-03-19 14:52:13 +09:00
capabilities.rb Extract server capabilities into dedicated Capabilities class 2025-06-04 22:52:16 +09:00
transports.rb Use autoload to defer loading of unused subsystems 2026-03-12 14:08:27 +09:00