ruby-sdk/lib/mcp
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Koichi ITO 66428ace04 Close streams outside mutex in session cleanup
## Motivation and Context

`cleanup_session_unsafe` was closing streams inside the mutex, which could block all session
operations if `stream.close` is slow or blocks (e.g., waiting for network I/O).
The original `reap_expired_sessions` avoided this by closing streams outside the mutex,
but the other 6 call sites of `cleanup_session_unsafe` did not, creating an inconsistency.

This change separates stream closing from session deletion. `cleanup_session_unsafe`
now only removes the session from `@sessions` and returns it.
All callers close streams outside the mutex via `close_stream_safely`,
ensuring consistent behavior and preventing mutex contention from blocking I/O.

## How Has This Been Tested?

Added tests that verify streams are closed outside the mutex by using `Mutex#try_lock`
inside mock stream close callbacks:

- `reap_expired_sessions closes stream outside mutex`
- `send_notification closes stream outside mutex on write error`

## Breaking Changes

None. This is an internal improvement with no change to public API behavior.
2026-04-04 03:46:00 +09:00
..
client Add MCP::Client::Stdio transport 2026-03-19 12:41:27 +09:00
prompt Support Ruby 2.7 - Ruby 3.1 2026-01-06 10:38:56 +09:00
resource Fix Resource::Contents#to_h to use correct property names per MCP spec 2026-02-19 13:50:10 +09:00
server Close streams outside mutex in session cleanup 2026-04-04 03:46:00 +09:00
tool Use symbolize_names: true in JSON.parse calls 2026-03-31 04:15:42 +09:00
transports Add a migration path for Server::Transports::StdioTransport 2025-06-10 16:27:22 +09:00
annotations.rb Extract MCP::Annotations into a dedicated file 2026-02-03 15:38:04 +09:00
client.rb Support completion/complete per MCP specification 2026-04-03 01:35:07 +09:00
configuration.rb Support Ruby 2.7 - Ruby 3.1 2026-01-06 10:38:56 +09:00
content.rb Add Content::EmbeddedResource class for embedded resource content type 2026-03-02 01:33:05 +09:00
icon.rb Support icons parameter 2025-12-30 05:35:22 +09:00
instrumentation.rb Support Ruby 2.7 - Ruby 3.1 2026-01-06 10:38:56 +09:00
logging_message_notification.rb logging_message_notification: Remove unused require 2026-02-05 16:05:08 -05:00
methods.rb Add Elicitation skeleton 2025-11-21 02:42:20 +09:00
progress.rb Remove Server#notify_progress broadcast API 2026-03-29 15:11:28 +09:00
prompt.rb Use autoload to defer loading of unused subsystems 2026-03-12 14:08:27 +09:00
resource.rb Use autoload to defer loading of unused subsystems 2026-03-12 14:08:27 +09:00
resource_template.rb Omit icons from responses when empty or nil 2026-01-12 09:46:45 +09:00
server.rb Support completion/complete per MCP specification 2026-04-03 01:35:07 +09:00
server_context.rb Remove Server#notify_progress broadcast API 2026-03-29 15:11:28 +09:00
server_session.rb Introduce ServerSession for per-connection state 2026-03-29 08:04:56 +09:00
string_utils.rb Fix ReDoS vulnerability in StringUtils#underscore 2026-01-09 01:14:52 +09:00
tool.rb Use autoload to defer loading of unused subsystems 2026-03-12 14:08:27 +09:00
transport.rb Introduce ServerSession for per-connection state 2026-03-29 08:04:56 +09:00
version.rb Release 0.10.0 2026-03-30 06:13:16 +09:00