Class: Anthropic::Resources::Beta::Tunnels

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/resources/beta/tunnels.rb,
lib/anthropic/resources/beta/tunnels/certificates.rb,
sig/anthropic/resources/beta/tunnels.rbs,
sig/anthropic/resources/beta/tunnels/certificates.rbs

Defined Under Namespace

Classes: Certificates

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Tunnels

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Tunnels.

Parameters:



215
216
217
218
# File 'lib/anthropic/resources/beta/tunnels.rb', line 215

def initialize(client:)
  @client = client
  @certificates = Anthropic::Resources::Beta::Tunnels::Certificates.new(client: client)
end

Instance Attribute Details

#certificatesAnthropic::Resources::Beta::Tunnels::Certificates (readonly)



8
9
10
# File 'lib/anthropic/resources/beta/tunnels.rb', line 8

def certificates
  @certificates
end

Instance Method Details

#archive(tunnel_id, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaTunnel

The Tunnels API is in research preview. It requires the anthropic-beta: mcp-tunnels-2026-06-22 header and may change without a deprecation period. It supersedes the Admin API endpoints at /v1/organizations/tunnels, which remain available during a migration window.

Archives a tunnel. Archival is irreversible: every non-archived certificate on the tunnel is archived in the same operation, the hostname is retired and never re-allocated, and the tunnel token is invalidated. Retrying against an already-archived tunnel returns the existing record unchanged.

Parameters:

Returns:

See Also:



134
135
136
137
138
139
140
141
142
143
# File 'lib/anthropic/resources/beta/tunnels.rb', line 134

def archive(tunnel_id, params = {})
  parsed, options = Anthropic::Beta::TunnelArchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/tunnels/%1$s/archive?beta=true", tunnel_id],
    headers: parsed.transform_keys(betas: "anthropic-beta"),
    model: Anthropic::Beta::BetaTunnel,
    options: {extra_headers: {"anthropic-beta" => "mcp-tunnels-2026-06-22"}, **options}
  )
end

#create(display_name: nil, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaTunnel

The Tunnels API is in research preview. It requires the anthropic-beta: mcp-tunnels-2026-06-22 header and may change without a deprecation period. It supersedes the Admin API endpoints at /v1/organizations/tunnels, which remain available during a migration window.

Creates a tunnel. Creation allocates a fresh hostname and provisions the tunnel; it is not idempotent. The new tunnel rejects MCP traffic until at least one CA certificate is added.

Parameters:

  • display_name (String, nil)

    Body param: Optional human-readable name for the tunnel (1-255 characters).

  • betas (Array<String, Symbol, Anthropic::Models::AnthropicBeta>)

    Header param: Optional header to specify the beta version(s) you want to use.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/anthropic/resources/beta/tunnels.rb', line 30

def create(params = {})
  parsed, options = Anthropic::Beta::TunnelCreateParams.dump_request(params)
  header_params = {betas: "anthropic-beta"}
  @client.request(
    method: :post,
    path: "v1/tunnels?beta=true",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Anthropic::Beta::BetaTunnel,
    options: {extra_headers: {"anthropic-beta" => "mcp-tunnels-2026-06-22"}, **options}
  )
end

#list(include_archived: nil, limit: nil, page: nil, betas: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Beta::BetaTunnel>

Some parameter documentations has been truncated, see Models::Beta::TunnelListParams for more details.

The Tunnels API is in research preview. It requires the anthropic-beta: mcp-tunnels-2026-06-22 header and may change without a deprecation period. It supersedes the Admin API endpoints at /v1/organizations/tunnels, which remain available during a migration window.

Lists tunnels. Results are ordered by creation time, newest first; archived tunnels are excluded unless include_archived is set.

Parameters:

  • include_archived (Boolean)

    Query param: Whether to include archived tunnels in the results. Defaults to fal

  • limit (Integer)

    Query param: Maximum number of tunnels to return per page. Defaults to 20, maxim

  • page (String)

    Query param: Opaque pagination cursor from a previous list_tunnels response.

  • betas (Array<String, Symbol, Anthropic::Models::AnthropicBeta>)

    Header param: Optional header to specify the beta version(s) you want to use.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/anthropic/resources/beta/tunnels.rb', line 98

def list(params = {})
  query_params = [:include_archived, :limit, :page]
  parsed, options = Anthropic::Beta::TunnelListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "v1/tunnels?beta=true",
    query: query,
    headers: parsed.except(*query_params).transform_keys(betas: "anthropic-beta"),
    page: Anthropic::Internal::PageCursor,
    model: Anthropic::Beta::BetaTunnel,
    options: {extra_headers: {"anthropic-beta" => "mcp-tunnels-2026-06-22"}, **options}
  )
end

#retrieve(tunnel_id, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaTunnel

The Tunnels API is in research preview. It requires the anthropic-beta: mcp-tunnels-2026-06-22 header and may change without a deprecation period. It supersedes the Admin API endpoints at /v1/organizations/tunnels, which remain available during a migration window.

Fetches a tunnel by ID.

Parameters:

Returns:

See Also:



61
62
63
64
65
66
67
68
69
70
# File 'lib/anthropic/resources/beta/tunnels.rb', line 61

def retrieve(tunnel_id, params = {})
  parsed, options = Anthropic::Beta::TunnelRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v1/tunnels/%1$s?beta=true", tunnel_id],
    headers: parsed.transform_keys(betas: "anthropic-beta"),
    model: Anthropic::Beta::BetaTunnel,
    options: {extra_headers: {"anthropic-beta" => "mcp-tunnels-2026-06-22"}, **options}
  )
end

#reveal_token(tunnel_id, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaTunnelToken

The Tunnels API is in research preview. It requires the anthropic-beta: mcp-tunnels-2026-06-22 header and may change without a deprecation period. It supersedes the Admin API endpoints at /v1/organizations/tunnels, which remain available during a migration window.

Reveals a tunnel's connector token. The value is fetched live on each call; Anthropic does not store it. Repeated calls return the same value until the token is rotated. Exposed as POST so the token does not appear in intermediary access logs.

Parameters:

Returns:

See Also:



166
167
168
169
170
171
172
173
174
175
# File 'lib/anthropic/resources/beta/tunnels.rb', line 166

def reveal_token(tunnel_id, params = {})
  parsed, options = Anthropic::Beta::TunnelRevealTokenParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/tunnels/%1$s/reveal_token?beta=true", tunnel_id],
    headers: parsed.transform_keys(betas: "anthropic-beta"),
    model: Anthropic::Beta::BetaTunnelToken,
    options: {extra_headers: {"anthropic-beta" => "mcp-tunnels-2026-06-22"}, **options}
  )
end

#rotate_token(tunnel_id, reason: nil, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaTunnelToken

The Tunnels API is in research preview. It requires the anthropic-beta: mcp-tunnels-2026-06-22 header and may change without a deprecation period. It supersedes the Admin API endpoints at /v1/organizations/tunnels, which remain available during a migration window.

Rotates a tunnel's connector token. Rotation invalidates the current token for new connections and returns a fresh value; established connections are not severed. A connector restarted after rotation must use the new value.

Parameters:

  • tunnel_id (String)

    Path param: Path parameter tunnel_id

  • reason (String, nil)

    Body param: Optional free-text reason for the rotation, recorded for audit.

  • betas (Array<String, Symbol, Anthropic::Models::AnthropicBeta>)

    Header param: Optional header to specify the beta version(s) you want to use.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/anthropic/resources/beta/tunnels.rb', line 199

def rotate_token(tunnel_id, params = {})
  parsed, options = Anthropic::Beta::TunnelRotateTokenParams.dump_request(params)
  header_params = {betas: "anthropic-beta"}
  @client.request(
    method: :post,
    path: ["v1/tunnels/%1$s/rotate_token?beta=true", tunnel_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Anthropic::Beta::BetaTunnelToken,
    options: {extra_headers: {"anthropic-beta" => "mcp-tunnels-2026-06-22"}, **options}
  )
end