just redo all of it from scratch

This commit is contained in:
Joey Cardosi 2025-05-30 12:15:11 -04:00
commit d80b13736e
No known key found for this signature in database
GPG key ID: 5F93AEDDAAE66774

View file

@ -0,0 +1,35 @@
# frozen_string_literal: true
require_relative "../../shared/transport"
require "json"
module MCP
module Transports
class StdioTransport < Transport
def initialize(server)
@server = server
@open = false
$stdin.set_encoding("UTF-8")
$stdout.set_encoding("UTF-8")
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