Class: ModelContextProtocol::Transports::StdioTransport
- Inherits:
-
ModelContextProtocol::Transport
- Object
- ModelContextProtocol::Transport
- ModelContextProtocol::Transports::StdioTransport
- Defined in:
- lib/model_context_protocol/transports/stdio.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(server) ⇒ StdioTransport
constructor
A new instance of StdioTransport.
- #open ⇒ Object
- #send_response(message) ⇒ Object
Constructor Details
#initialize(server) ⇒ StdioTransport
Returns a new instance of StdioTransport.
9 10 11 12 13 |
# File 'lib/model_context_protocol/transports/stdio.rb', line 9 def initialize(server) @server = server @open = false super end |
Instance Method Details
#close ⇒ Object
22 23 24 |
# File 'lib/model_context_protocol/transports/stdio.rb', line 22 def close @open = false end |
#open ⇒ Object
15 16 17 18 19 20 |
# File 'lib/model_context_protocol/transports/stdio.rb', line 15 def open @open = true while @open && (line = $stdin.gets) handle_json_request(line.strip) end end |
#send_response(message) ⇒ Object
26 27 28 29 30 |
# File 'lib/model_context_protocol/transports/stdio.rb', line 26 def send_response() = .is_a?(String) ? : JSON.generate() $stdout.puts() $stdout.flush end |