Class: ClaudeSDK::McpServerConfig::HttpServer

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

Overview

MCP HTTP server configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, headers: {}) ⇒ HttpServer

Returns a new instance of HttpServer.

Parameters:

  • url (String)

    the server URL

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

    HTTP headers



103
104
105
106
107
# File 'lib/claude_sdk/types.rb', line 103

def initialize(url:, headers: {})
  @type = :http
  @url = url
  @headers = headers
end

Instance Attribute Details

#headersObject

HTTP headers



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/claude_sdk/types.rb', line 97

class HttpServer
  attr_accessor :url, :headers
  attr_reader :type

  # @param url [String] the server URL
  # @param headers [Hash<String, String>] HTTP headers
  def initialize(url:, headers: {})
    @type = :http
    @url = url
    @headers = headers
  end

  # Convert to hash for JSON serialization
  #
  # @return [Hash]
  def to_h
    hash = { type: type.to_s, url: url }
    hash[:headers] = headers unless headers.empty?
    hash
  end
end

#typeObject

Returns the value of attribute type.



99
100
101
# File 'lib/claude_sdk/types.rb', line 99

def type
  @type
end

#urlObject

the server URL



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/claude_sdk/types.rb', line 97

class HttpServer
  attr_accessor :url, :headers
  attr_reader :type

  # @param url [String] the server URL
  # @param headers [Hash<String, String>] HTTP headers
  def initialize(url:, headers: {})
    @type = :http
    @url = url
    @headers = headers
  end

  # Convert to hash for JSON serialization
  #
  # @return [Hash]
  def to_h
    hash = { type: type.to_s, url: url }
    hash[:headers] = headers unless headers.empty?
    hash
  end
end

Instance Method Details

#to_hHash

Convert to hash for JSON serialization

Returns:

  • (Hash)


112
113
114
115
116
# File 'lib/claude_sdk/types.rb', line 112

def to_h
  hash = { type: type.to_s, url: url }
  hash[:headers] = headers unless headers.empty?
  hash
end