Class: Foobara::McpConnector::StdioRunner

Inherits:
Object
  • Object
show all
Defined in:
foobara-mcp-connector-0.0.4/src/stdio_runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mcp_connector) ⇒ StdioRunner

Returns a new instance of StdioRunner.



6
7
8
# File 'foobara-mcp-connector-0.0.4/src/stdio_runner.rb', line 6

def initialize(mcp_connector)
  self.mcp_connector = mcp_connector
end

Instance Attribute Details

#last_unexpected_errorObject

Returns the value of attribute last_unexpected_error.



4
5
6
# File 'foobara-mcp-connector-0.0.4/src/stdio_runner.rb', line 4

def last_unexpected_error
  @last_unexpected_error
end

#mcp_connectorObject

Returns the value of attribute mcp_connector.



4
5
6
# File 'foobara-mcp-connector-0.0.4/src/stdio_runner.rb', line 4

def mcp_connector
  @mcp_connector
end

Instance Method Details

#run(io_in: $stdin, io_out: $stdout, io_err: $stderr) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'foobara-mcp-connector-0.0.4/src/stdio_runner.rb', line 10

def run(io_in: $stdin, io_out: $stdout, io_err: $stderr)
  io_in.each_line do |request|
    response = mcp_connector.run(request)

    if response
      io_out.puts response
      io_out.flush
    end
  rescue => e
    # :nocov:
    self.last_unexpected_error = e
    io_err.puts e.message
    io_err.puts e.backtrace
    io_err.flush
    # :nocov:
  end
end