Class: RosettAi::Mcp::Settings::ServerInstaller
- Inherits:
-
Object
- Object
- RosettAi::Mcp::Settings::ServerInstaller
- Defined in:
- lib/rosett_ai/mcp/settings/server_installer.rb
Overview
Installs MCP servers with trust-first validation.
All server installations must originate from a trusted source. Untrusted sources are rejected with actionable error messages.
Instance Method Summary collapse
-
#initialize(trust_manager:, registry:, schema_validator:) ⇒ ServerInstaller
constructor
A new instance of ServerInstaller.
-
#install(name:, uri:, transport: 'stdio') ⇒ Hash
Installs an MCP server from a URI with trust validation.
-
#remove(name:, force: false) ⇒ Hash
Removes an MCP server by name.
Constructor Details
#initialize(trust_manager:, registry:, schema_validator:) ⇒ ServerInstaller
Returns a new instance of ServerInstaller.
20 21 22 23 24 |
# File 'lib/rosett_ai/mcp/settings/server_installer.rb', line 20 def initialize(trust_manager:, registry:, schema_validator:) @trust_manager = trust_manager @registry = registry @schema_validator = schema_validator end |
Instance Method Details
#install(name:, uri:, transport: 'stdio') ⇒ Hash
Installs an MCP server from a URI with trust validation.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rosett_ai/mcp/settings/server_installer.rb', line 32 def install(name:, uri:, transport: 'stdio') trust_result = validate_trust(uri, transport) return trust_result unless trust_result[:trusted] config = build_config(name, uri, transport) validation = @schema_validator.validate(config) return validation_failure(validation) unless validation[:valid] path = @registry.add(config) { success: true, message: "Server '#{name}' installed from #{trust_result[:source_type]} source", server: config, path: path.to_s } end |
#remove(name:, force: false) ⇒ Hash
Removes an MCP server by name.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rosett_ai/mcp/settings/server_installer.rb', line 54 def remove(name:, force: false) server = @registry.find(name) return { success: false, message: "Server '#{name}' not found" } unless server if managed_server?(server) && !force return { success: false, message: "Server '#{name}' is enterprise-managed. Use --force to override." } end @registry.remove(name) { success: true, message: "Server '#{name}' removed" } end |