Internal Release 0.5.2

Added
- Added stdio transport functionality.
Changed
- Added stdio details to the README.
This commit is contained in:
Topher Bullock 2025-04-11 18:01:45 -04:00
commit 6da8bfab1a

View file

@ -0,0 +1,33 @@
# frozen_string_literal: true
require_relative "../transport"
require "json"
module ModelContextProtocol
module Transports
class StdioTransport < Transport
def initialize(server)
@server = server
@open = false
super
end
def open
@open = true
while @open && (line = $stdin.gets)
handle_json_request(line.strip)
end
end
def close
@open = false
end
def send_response(message)
json_message = message.is_a?(String) ? message : JSON.generate(message)
$stdout.puts(json_message)
$stdout.flush
end
end
end
end