ionosclient

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ionosclient builds and maintains the User-Agent string the MCP server attaches to outbound IONOS CLOUD API calls.

The User-Agent carries diagnostic metadata: server version, SDK bundle version, OS/arch, transport, eager-load mode, and — once the MCP initialize handshake completes — the calling host's name, version, and negotiated protocol version.

Composition is split into a static prefix built once at startup and a dynamic full string updated after handshake. UserAgent stores the composed string in an atomic.Pointer so updates are race-free.

UA injection happens at the HTTP boundary via the Transport method, which wraps the cfg.HTTPClient.Transport with a RoundTripper that sets the User-Agent header on every outbound request. Because the SDK shares the underlying *http.Client across every shallow cfg copy (compute, DNS, billing, cert, object storage base + regional clients), a single RoundTripper covers all clients without chasing cfg snapshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Product          string // e.g. "ionoscloud-mcp"
	Version          string // server version
	SDKBundleVersion string // detected from build info
	Transport        string // "stdio", "streamable-http"
	Mode             string // "eager", "lazy"
	GOOS             string
	GOARCH           string
}

Options configures the static portion of the User-Agent that is fixed at startup. All fields are best-effort: empty values cause the matching segment to be omitted.

type UserAgent

type UserAgent struct {
	// contains filtered or unexported fields
}

UserAgent owns the composed User-Agent string and updates it atomically.

func New

func New(opts Options) *UserAgent

New constructs a UserAgent with the provided static metadata. Before SetClient is called (i.e. before the MCP initialize handshake), String returns the static portion only.

func (*UserAgent) SetClient

func (u *UserAgent) SetClient(name, version, protocol string)

SetClient updates the dynamic segments with information from the MCP initialize handshake. Inputs are sanitised; empty fields are omitted. Safe to call concurrently with String and outbound requests.

func (*UserAgent) String

func (u *UserAgent) String() string

String returns the current User-Agent.

func (*UserAgent) Transport

func (u *UserAgent) Transport(base http.RoundTripper) http.RoundTripper

Transport wraps base so that every outbound request carries the current User-Agent. If base is nil, http.DefaultTransport is used.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL