Class: ClaudeAgentSDK::McpServerStatus

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

Overview

Status of a single MCP server connection

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, status:, server_info: nil, error: nil, config: nil, scope: nil, tools: nil) ⇒ McpServerStatus

Returns a new instance of McpServerStatus.



1458
1459
1460
1461
1462
1463
1464
1465
1466
# File 'lib/claude_agent_sdk/types.rb', line 1458

def initialize(name:, status:, server_info: nil, error: nil, config: nil, scope: nil, tools: nil)
  @name = name
  @status = status
  @server_info = server_info
  @error = error
  @config = config
  @scope = scope
  @tools = tools
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



1456
1457
1458
# File 'lib/claude_agent_sdk/types.rb', line 1456

def config
  @config
end

#errorObject

Returns the value of attribute error.



1456
1457
1458
# File 'lib/claude_agent_sdk/types.rb', line 1456

def error
  @error
end

#nameObject

Returns the value of attribute name.



1456
1457
1458
# File 'lib/claude_agent_sdk/types.rb', line 1456

def name
  @name
end

#scopeObject

Returns the value of attribute scope.



1456
1457
1458
# File 'lib/claude_agent_sdk/types.rb', line 1456

def scope
  @scope
end

#server_infoObject

Returns the value of attribute server_info.



1456
1457
1458
# File 'lib/claude_agent_sdk/types.rb', line 1456

def server_info
  @server_info
end

#statusObject

Returns the value of attribute status.



1456
1457
1458
# File 'lib/claude_agent_sdk/types.rb', line 1456

def status
  @status
end

#toolsObject

Returns the value of attribute tools.



1456
1457
1458
# File 'lib/claude_agent_sdk/types.rb', line 1456

def tools
  @tools
end

Class Method Details

.parse(data) ⇒ Object



1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
# File 'lib/claude_agent_sdk/types.rb', line 1468

def self.parse(data)
  server_info = (McpServerInfo.new(name: data[:serverInfo][:name], version: data[:serverInfo][:version]) if data[:serverInfo])
  tools = data[:tools]&.map { |t| McpToolInfo.parse(t) }
  config = parse_config(data[:config])

  new(
    name: data[:name],
    status: data[:status],
    server_info: server_info,
    error: data[:error],
    config: config,
    scope: data[:scope],
    tools: tools
  )
end

.parse_config(config) ⇒ Object



1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
# File 'lib/claude_agent_sdk/types.rb', line 1484

def self.parse_config(config)
  return config unless config.is_a?(Hash) && config[:type]

  case config[:type]
  when 'claudeai-proxy'
    McpClaudeAIProxyServerConfig.new(url: config[:url], id: config[:id])
  when 'sdk'
    McpSdkServerConfigStatus.new(name: config[:name])
  else
    config
  end
end