Class: RobotLab::MCP::Server
- Inherits:
-
Object
- Object
- RobotLab::MCP::Server
- Defined in:
- lib/robot_lab/mcp/server.rb
Overview
Configuration for an MCP server connection
Constant Summary collapse
- VALID_TRANSPORT_TYPES =
Valid transport types for MCP connections
%w[stdio sse ws websocket streamable-http http].freeze
- DEFAULT_TIMEOUT =
Default timeout for MCP requests (in seconds)
15
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ String
readonly
The server name.
-
#timeout ⇒ Numeric
readonly
Request timeout in seconds.
-
#transport ⇒ Hash
readonly
The transport configuration.
Instance Method Summary collapse
-
#initialize(name:, transport:, timeout: nil, description: nil, **_extra) ⇒ Server
constructor
Creates a new Server configuration.
-
#to_h ⇒ Hash
Converts the server configuration to a hash.
-
#transport_type ⇒ String
Returns the transport type.
Constructor Details
#initialize(name:, transport:, timeout: nil, description: nil, **_extra) ⇒ Server
Creates a new Server configuration.
48 49 50 51 52 53 54 |
# File 'lib/robot_lab/mcp/server.rb', line 48 def initialize(name:, transport:, timeout: nil, description: nil, **_extra) @name = name.to_s @description = description.to_s @transport = normalize_transport(transport) @timeout = normalize_timeout(timeout) validate! end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
38 |
# File 'lib/robot_lab/mcp/server.rb', line 38 attr_reader :name, :transport, :timeout, :description |
#name ⇒ String (readonly)
Returns the server name.
38 39 40 |
# File 'lib/robot_lab/mcp/server.rb', line 38 def name @name end |
#timeout ⇒ Numeric (readonly)
Returns request timeout in seconds.
38 |
# File 'lib/robot_lab/mcp/server.rb', line 38 attr_reader :name, :transport, :timeout, :description |
#transport ⇒ Hash (readonly)
Returns the transport configuration.
38 |
# File 'lib/robot_lab/mcp/server.rb', line 38 attr_reader :name, :transport, :timeout, :description |
Instance Method Details
#to_h ⇒ Hash
Converts the server configuration to a hash.
66 67 68 69 70 71 72 73 |
# File 'lib/robot_lab/mcp/server.rb', line 66 def to_h { name: name, description: description, transport: transport, timeout: timeout } end |
#transport_type ⇒ String
Returns the transport type.
59 60 61 |
# File 'lib/robot_lab/mcp/server.rb', line 59 def transport_type @transport[:type] end |