Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/mcp/server/transports/stdio_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ def parse_line(line)
# (an `initialize` after a modern lock, a modern envelope after a legacy lock, or a missing envelope after a modern lock)
# are rejected in-band by `Server#lift_request_envelope`.
def dispatch_with_era(parsed)
response = @session.handle(parsed)
# Passing `auth_info:` keeps Ruby 2.7 from taking the request Hash as keyword arguments,
# which works but warns that the conversion is deprecated.
response = @session.handle(parsed, auth_info: nil)
lock_modern_era_on_success(parsed, response)
response
end
Expand Down
19 changes: 19 additions & 0 deletions test/mcp/server/transports/stdio_transport_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,25 @@ class StdioTransportTest < ActiveSupport::TestCase
end
end

test "open passes a request to the session without a keyword argument warning" do
request = { jsonrpc: "2.0", method: "ping", id: "1" }
input = StringIO.new(JSON.generate(request) + "\n")
original_stdin = $stdin
original_deprecated = Warning[:deprecated]

begin
$stdin = input
Warning[:deprecated] = true

_out, err = capture_io { @transport.open }

assert_empty(err)
ensure
$stdin = original_stdin
Warning[:deprecated] = original_deprecated
end
end

test "open handles a malformed JSON-RPC batch element and emits an error response" do
input = StringIO.new("[[]]\n")
output = StringIO.new
Expand Down
Loading