Anthropic::BetaTunnels
MCP Tunnels API resource (beta / research preview).
Requires the mcp-tunnels-2026-06-22 beta header and may change without a
deprecation period. Supersedes Admin API endpoints at
/v1/organizations/tunnels during a migration window.
Auth: tunnel management endpoints (create/list/archive/certificates/
reveal_token/rotate_token) require a bearer token with the
workspace:manage_tunnels scope from Workload Identity Federation.
Standard ANTHROPIC_API_KEY / admin API keys are not accepted and
return 401. Using a tunnel URL from Messages (mcp_servers) still uses a
normal workspace API key + the MCP client beta — that is separate.
Creation allocates a fresh hostname; the tunnel rejects MCP traffic until at
least one CA certificate is added via certificates.
# Client must be configured with a WIF-exchanged bearer that has
# workspace:manage_tunnels (not a plain API key).
tunnel = client.beta.tunnels.create(display_name: "prod-gateway")
token = client.beta.tunnels.reveal_token(tunnel.id)
cert = client.beta.tunnels.certificates.create(
tunnel.id,
ca_certificate_pem: File.read("ca.pem"),
)
Constructors
Instance methods
Archive a tunnel irreversibly (certificates archived, hostname retired, token invalidated). Retrying an already-archived tunnel is a no-op.
Create a tunnel. Not idempotent; allocates a fresh hostname.
List tunnels (newest first). Archived tunnels excluded unless
include_archived is set.
Retrieve a tunnel by ID.
Reveal the tunnel's connector token (POST so it stays out of access logs). Repeated calls return the same value until rotated.