Class: SwarmSDK::V3::MCP::ServerDefinition
- Inherits:
-
Object
- Object
- SwarmSDK::V3::MCP::ServerDefinition
- Defined in:
- lib/swarm_sdk/v3/mcp/server_definition.rb
Overview
Immutable value object for MCP server configuration
Supports two transport types:
-
‘:stdio` — spawns a subprocess and communicates via JSON-RPC over stdin/stdout
-
‘:http` — connects to an HTTP MCP endpoint
Instance Attribute Summary collapse
-
#args ⇒ Array<String>
readonly
Subprocess arguments (stdio only).
-
#command ⇒ String?
readonly
Subprocess command (stdio only).
-
#env ⇒ Hash<String, String>
readonly
Subprocess environment variables (stdio only).
-
#headers ⇒ Hash<String, String>
readonly
HTTP headers (http only).
-
#name ⇒ Symbol
readonly
Server identifier.
-
#ssl_verify ⇒ Boolean?
readonly
Per-server SSL verification override (nil = use global config).
-
#tools ⇒ Array<Symbol>?
readonly
Tool names to expose (nil = all).
-
#type ⇒ Symbol
readonly
Transport type (:stdio or :http).
-
#url ⇒ String?
readonly
HTTP endpoint URL (http only).
Instance Method Summary collapse
-
#filter_tools? ⇒ Boolean
Whether this definition filters exposed tools.
-
#initialize(name:, type:, tools: nil, **options) ⇒ ServerDefinition
constructor
Create a new server definition.
Constructor Details
#initialize(name:, type:, tools: nil, **options) ⇒ ServerDefinition
Create a new server definition
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 75 def initialize(name:, type:, tools: nil, **) @name = name.to_sym @type = type.to_sym @command = [:command] @args = Array([:args]).freeze @env = ([:env] || {}).transform_keys(&:to_s).freeze @url = [:url] @headers = ([:headers] || {}).freeze @ssl_verify = [:ssl_verify] @tools = tools ? Array(tools).map(&:to_sym).freeze : nil validate! freeze end |
Instance Attribute Details
#args ⇒ Array<String> (readonly)
Returns Subprocess arguments (stdio only).
42 43 44 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 42 def args @args end |
#command ⇒ String? (readonly)
Returns Subprocess command (stdio only).
39 40 41 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 39 def command @command end |
#env ⇒ Hash<String, String> (readonly)
Returns Subprocess environment variables (stdio only).
45 46 47 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 45 def env @env end |
#headers ⇒ Hash<String, String> (readonly)
Returns HTTP headers (http only).
51 52 53 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 51 def headers @headers end |
#name ⇒ Symbol (readonly)
Returns Server identifier.
30 31 32 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 30 def name @name end |
#ssl_verify ⇒ Boolean? (readonly)
Returns Per-server SSL verification override (nil = use global config).
54 55 56 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 54 def ssl_verify @ssl_verify end |
#tools ⇒ Array<Symbol>? (readonly)
Returns Tool names to expose (nil = all).
36 37 38 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 36 def tools @tools end |
#type ⇒ Symbol (readonly)
Returns Transport type (:stdio or :http).
33 34 35 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 33 def type @type end |
#url ⇒ String? (readonly)
Returns HTTP endpoint URL (http only).
48 49 50 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 48 def url @url end |
Instance Method Details
#filter_tools? ⇒ Boolean
Whether this definition filters exposed tools
100 101 102 |
# File 'lib/swarm_sdk/v3/mcp/server_definition.rb', line 100 def filter_tools? !@tools.nil? end |