Class: RubyMCP::Transport::Stdio
- Inherits:
-
RubyMCP::Transport
- Object
- RubyMCP::Transport
- RubyMCP::Transport::Stdio
- Defined in:
- lib/ruby_mcp/transport/stdio.rb
Instance Method Summary collapse
Methods inherited from RubyMCP::Transport
Instance Method Details
#on_close(&block) ⇒ Object
28 29 30 |
# File 'lib/ruby_mcp/transport/stdio.rb', line 28 def on_close(&block) @on_close = block end |
#send(message) ⇒ Object
22 23 24 25 |
# File 'lib/ruby_mcp/transport/stdio.rb', line 22 def send() $stdout.puts(JSON.generate()) $stdout.flush end |
#start ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ruby_mcp/transport/stdio.rb', line 4 def start @running = true while @running begin line = $stdin.gets break if line.nil? .call(line.strip) rescue StandardError => e RubyMCP.logger.error("Exception: #{e}") end end @on_close.call end |