Class: McpInspector::Transport::ServerConfig
- Inherits:
-
Object
- Object
- McpInspector::Transport::ServerConfig
- Defined in:
- lib/mcp_inspector/transport/server_config.rb
Defined Under Namespace
Classes: ValidationError
Constant Summary collapse
- REQUIRED_FIELDS =
%w[name transport].freeze
- STDIO_REQUIRED_FIELDS =
%w[command].freeze
- URL_REQUIRED_FIELDS =
%w[url].freeze
- VALID_TRANSPORTS =
%w[stdio sse websocket].freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#working_directory ⇒ Object
readonly
Returns the value of attribute working_directory.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config_hash) ⇒ ServerConfig
constructor
A new instance of ServerConfig.
- #sse? ⇒ Boolean
- #stdio? ⇒ Boolean
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
- #websocket? ⇒ Boolean
Constructor Details
#initialize(config_hash) ⇒ ServerConfig
Returns a new instance of ServerConfig.
17 18 19 20 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 17 def initialize(config_hash) @raw_config = config_hash validate_and_parse_config! end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
15 16 17 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 15 def args @args end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
15 16 17 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 15 def command @command end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
15 16 17 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 15 def env @env end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 15 def name @name end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
15 16 17 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 15 def transport @transport end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
15 16 17 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 15 def url @url end |
#working_directory ⇒ Object (readonly)
Returns the value of attribute working_directory.
15 16 17 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 15 def working_directory @working_directory end |
Class Method Details
.from_json(json_string) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 22 def self.from_json(json_string) config_hash = JSON.parse(json_string) new(config_hash) rescue JSON::ParserError => e raise ValidationError, "Invalid JSON: #{e.message}" end |
Instance Method Details
#sse? ⇒ Boolean
33 34 35 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 33 def sse? transport == "sse" end |
#stdio? ⇒ Boolean
29 30 31 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 29 def stdio? transport == "stdio" end |
#to_h ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 41 def to_h { name: name, transport: transport, command: command, args: args, env: env, working_directory: working_directory, url: url }.compact end |
#to_json(*args) ⇒ Object
53 54 55 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 53 def to_json(*args) to_h.to_json(*args) end |
#websocket? ⇒ Boolean
37 38 39 |
# File 'lib/mcp_inspector/transport/server_config.rb', line 37 def websocket? transport == "websocket" end |