Class: ClaudeSDK::McpServerConfig::StdioServer

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_sdk/types.rb

Overview

MCP stdio server configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command:, args: [], env: {}) ⇒ StdioServer

Returns a new instance of StdioServer.

Parameters:

  • command (String)

    the command to execute

  • args (Array<String>) (defaults to: [])

    command arguments

  • env (Hash<String, String>) (defaults to: {})

    environment variables



46
47
48
49
50
51
# File 'lib/claude_sdk/types.rb', line 46

def initialize(command:, args: [], env: {})
  @type = :stdio
  @command = command
  @args = args
  @env = env
end

Instance Attribute Details

#argsObject

command arguments



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/claude_sdk/types.rb', line 39

class StdioServer
  attr_accessor :command, :args, :env
  attr_reader :type

  # @param command [String] the command to execute
  # @param args [Array<String>] command arguments
  # @param env [Hash<String, String>] environment variables
  def initialize(command:, args: [], env: {})
    @type = :stdio
    @command = command
    @args = args
    @env = env
  end

  # Convert to hash for JSON serialization
  #
  # @return [Hash]
  def to_h
    hash = { command: command }
    hash[:type] = type.to_s unless type == :stdio # Optional for backwards compatibility
    hash[:args] = args unless args.empty?
    hash[:env] = env unless env.empty?
    hash
  end
end

#commandObject

the command to execute



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/claude_sdk/types.rb', line 39

class StdioServer
  attr_accessor :command, :args, :env
  attr_reader :type

  # @param command [String] the command to execute
  # @param args [Array<String>] command arguments
  # @param env [Hash<String, String>] environment variables
  def initialize(command:, args: [], env: {})
    @type = :stdio
    @command = command
    @args = args
    @env = env
  end

  # Convert to hash for JSON serialization
  #
  # @return [Hash]
  def to_h
    hash = { command: command }
    hash[:type] = type.to_s unless type == :stdio # Optional for backwards compatibility
    hash[:args] = args unless args.empty?
    hash[:env] = env unless env.empty?
    hash
  end
end

#envObject

environment variables



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/claude_sdk/types.rb', line 39

class StdioServer
  attr_accessor :command, :args, :env
  attr_reader :type

  # @param command [String] the command to execute
  # @param args [Array<String>] command arguments
  # @param env [Hash<String, String>] environment variables
  def initialize(command:, args: [], env: {})
    @type = :stdio
    @command = command
    @args = args
    @env = env
  end

  # Convert to hash for JSON serialization
  #
  # @return [Hash]
  def to_h
    hash = { command: command }
    hash[:type] = type.to_s unless type == :stdio # Optional for backwards compatibility
    hash[:args] = args unless args.empty?
    hash[:env] = env unless env.empty?
    hash
  end
end

#typeObject

Returns the value of attribute type.



41
42
43
# File 'lib/claude_sdk/types.rb', line 41

def type
  @type
end

Instance Method Details

#to_hHash

Convert to hash for JSON serialization

Returns:

  • (Hash)


56
57
58
59
60
61
62
# File 'lib/claude_sdk/types.rb', line 56

def to_h
  hash = { command: command }
  hash[:type] = type.to_s unless type == :stdio # Optional for backwards compatibility
  hash[:args] = args unless args.empty?
  hash[:env] = env unless env.empty?
  hash
end