MemtraceDOCS

memtrace connectEnterprise

Connect an organization member to self-hosted MemDB, or use a manual credential for bootstrap and offline setups.

Usage#

memtrace connect <organization-slug> | [<bundle.tar.gz|connect.json>] [--endpoint <url>] [--database <db>] [--org <slug>] [--token <memdb-token>] [--offline-license <license.mtl>] [--status] [--disconnect]Enterprise

The normal enterprise form is memtrace connect <organization-slug>. It uses the account from memtrace auth login, verifies current organization membership, obtains a signed enrollment assertion, and asks the self-hosted MemDB to create an expiring local bearer. It then writes secretless .memtrace/team.toml and stores the bearer in the user's config directory. The command also accepts the engineer half of a provisioning bundle — a bare connect.json or a .tar/.tar.gz bundle — or plain --endpoint/--database/--org flags, authenticates your license, writes a committable, secretless .memtrace/team.toml at the workspace root, stores any MemDB access token per-endpoint in ~/.config/memtrace/credentials.json, and probes the endpoint. Afterwards, memtrace start boots in external mode with zero environment variables required.

NOTE

External MemDB mode requires an authenticated community or enterprise edition session. Organization enrollment requires an active enterprise member and a deployment made from a current bundle. The owner file and memtrace access remain manual fallback paths. See Deploy MemDB for the operator install guide and Self-hosted MemDB (connect) for engineer onboarding.

Inputs: bundle, connect.json, or flags#

A bare positional value that is not a file path is treated as an organization slug. File inputs accept these shapes, sniffed by content rather than only by extension:

  • A bare connect.json file (detected by a leading {).
  • An uncompressed .tar bundle, or a gzipped .tar.gz (detected by gzip magic bytes; decompression is capped at 64 MiB). Either way, the tarball must contain engineer/connect.json. To connect the owner, pass the extracted bare cluster/owner-connect.json file instead; full-bundle extraction deliberately selects the non-admin engineer file.
  • No positional at all — supply --endpoint, --database, and --org directly.

Flags always override values from the file. An endpoint is mandatory from one source or the other, and must start with http:// or https://. If a bundle was built before its cluster URL was pinned, its endpoint is still the literal placeholder {{MEMDB_ENDPOINT}} — connect rejects that and asks you to pass --endpoint explicitly. Database defaults to memtrace if neither the flag nor the file supplies one.

A full MTC- license key in a connection file is authoritative and replaces an older community session. Without one, connect reuses valid stored credentials or MEMTRACE_LICENSE_KEY, then falls back to the interactive browser device flow — the same waiting-room machinery as memtrace auth login.

What it writes#

.memtrace/team.toml, anchored at the workspace root (a workspace-root override, else the git root, else the current directory — not necessarily your cwd), is secretless by construction: only endpoint, database, tls_ca, and org_slug are ever rendered. The connection file's license_key_ref and optional memdb_token are treated as secrets and are never written to team.toml or printed. Because it carries no secrets, team.toml is meant to be committed to your repo so every teammate who clones it gets the same external MemDB pointed at automatically.

The MemDB access token itself is stored separately, in ~/.config/memtrace/credentials.json, under a per-endpoint memdb_tokens map — never in team.toml. Organization-enrolled tokens also carry a local expiry and renew during startup within their final hour. Manual-token precedence is --token, MEMTRACE_MEMDB_AUTH_TOKEN, a bearer embedded in the connection file, then a previously stored token. When MemDB rejects a bearer, connect exits nonzero and keeps the written configuration so the user can sign in and retry.

PRESENCE OF TEAM.TOML IMPLIES EXTERNAL MODE

Once .memtrace/team.toml exists with an endpoint, later memtrace start runs in that workspace imply MEMTRACE_MEMDB_MODE=external automatically — no environment variables needed.

Flags#

FlagDescription
--endpoint <url>MemDB gRPC endpoint, e.g. https://memdb.corp.example:50051. Must start with http:// or https://. Overrides the file value; required when the bundle carries the {{MEMDB_ENDPOINT}} placeholder.
--database <db> (alias --db)Target MemDB database name. Overrides the file value; defaults to memtrace.
--org <slug> (alias --org-slug)Organization slug written into team.toml. Overrides the file's org_slug.
--token <memdb-token>MemDB bearer token to store, per-endpoint, in credentials.json. Highest precedence: --token > MEMTRACE_MEMDB_AUTH_TOKEN > connection-file memdb_token > previously stored credentials. Overrides an auto-installed compatibility seat token.
--offline-license <license.mtl>Install a signed offline license for air-gapped setups: signature-verified, copied to ~/.config/memtrace/license.mtl, org identity persisted to credentials.json. Fail-closed — an invalid file installs nothing. Composable with a bundle/--endpoint (license installs first, then the normal connect flow runs); alone, the command exits after installing.
--statusReport-only mode — prints effective config and a live connectivity probe, changes nothing.
--disconnectRemoves .memtrace/team.toml and scrubs the stored MemDB token for that endpoint. License credentials are left intact.
--help, -hPrints connect-specific usage and exits 0.

Environment variables#

VariableDefaultDescription
MEMTRACE_MEMDB_AUTH_TOKENMemDB bearer token; second in precedence after --token. When set during connect it's treated as freshly provided and persisted to credentials.json; --status reports it as the token source.
MEMTRACE_MEMDB_TLS_CAPath to a private CA bundle. When set it wins over the bundle/team.toml tls_ca for the connectivity probe, dialed through the same transport seam the daemon supervisor uses.
MEMTRACE_LICENSE_KEYLicense key that makes authentication fully non-interactive — checked alongside stored credentials before falling back to the bundle's license_key_ref or the interactive device flow.
MEMTRACE_OFFLINEForces offline operation after a --offline-license install; otherwise an installed license is the automatic fallback when memtrace.io is unreachable. Telemetry/heartbeat are disabled in offline mode.
ENV VARS CAN SHADOW WHAT CONNECT JUST WROTE

MEMTRACE_MEMDB_MODE/_ENDPOINT/_DB/_TLS_CA and MEMTRACE_ORG_SLUG all override team.toml at runtime. A stale exported endpoint in your shell can silently shadow what connect just wrote — run memtrace connect --status to see which source actually won.

--status and --disconnect#

memtrace connect --status never mutates anything. It prints: whether team.toml is present; the effective mode and its provenance (explicit env var, implied by team.toml, inferred from an endpoint env var, or default); endpoint, database, org, and TLS CA; whether a token is present (never the value itself); the per-machine daemon owner-lock state; and a live connectivity probe. It always exits 0, even when the endpoint is unreachable.

memtrace connect --disconnect removes .memtrace/team.toml (reading its endpoint first if --endpoint wasn't given) and scrubs the stored MemDB token for that endpoint from credentials.json. It explicitly leaves your license credentials untouched — for that, use memtrace auth logout. It's idempotent: a missing team.toml just prints "already disconnected".

After connecting#

Exit behavior on a normal (non --status/--disconnect) run: a reachable server prints a success summary — endpoint, database, org, edition, token status, team file path, and a Next: memtrace start hint — and exits 0. A reachable server that rejects the bearer exits nonzero: configuration was saved, but memtrace start cannot work until the member signs in and reconnects, or an administrator uses the manual fallback. An unreachable endpoint also exits nonzero. In both cases team.toml is deliberately kept so a later connect or --status can retry.

Once connected, run memtrace start in the same workspace: it reads .memtrace/team.toml, boots in external mode with zero environment variables, and connects straight to your self-hosted MemDB instead of spawning a local sidecar.

Connect to a self-hosted MemDBFLOW
reachable
Organization slug
Verify membermemtrace.io
Enroll bearerself-hosted MemDB
Write team.tomlsecretless
Store tokencredentials.json
Probe endpoint
memtrace startexternal mode
TRIGGERSUPPORTINGINFRASTRUCTURESERVICEEXTERNALDECISIONSUCCESS

Gotchas#

AUTHENTICATION FAILURE IS A REAL CONNECT FAILURE

Do not copy a hash = "..." value from tokens.store into --token. It is a BLAKE3 hash, not a bearer. Run memtrace auth login, then memtrace connect <organization-slug>.

TEAM.TOML LANDS AT THE WORKSPACE ROOT, NOT NECESSARILY CWD

Anchoring walks up to a workspace-root override or the git root first, so .memtrace/team.toml can end up above the directory you ran connect from.

ALL OUTPUT GOES TO STDERR

Progress checkmarks, summaries, and usage text are printed on stderr. Piping memtrace connect --status to a file without redirecting stderr captures nothing.

A FLAT LEGACY TOKEN NEVER CROSSES ENDPOINTS

An older single-token fallback field is only consulted for non-loopback endpoints, so a remote/corp token can never silently attach to a local sidecar connection — but it also means that token won't auto-apply if you connect to a second remote endpoint without its own stored entry.

Examples#

terminal
$ memtrace auth login
$ memtrace connect acme
# Verifies membership and enrolls a local expiring MemDB credential.

$ memtrace connect cluster/owner-connect.json
# Owner-only bootstrap/recovery: stores the admin bearer locally.

$ memtrace access add alice@example.com --role writer --out alice.connect.json
# Manual/offline fallback: admin creates a user-specific connection file.

$ memtrace connect alice.connect.json
# Manual/offline user stores the embedded bearer,
# writes secretless .memtrace/team.toml, and pings the server.

$ memtrace connect --endpoint https://memdb.corp.example:50051 --database corp --org acme
# Flags-only connect, no bundle; database defaults to `memtrace` if omitted.

$ memtrace connect bundle.tar.gz --endpoint https://memdb.corp.example:50051
# Needed when the bundle predates the cluster URL being pinned
# and still carries the {{MEMDB_ENDPOINT}} placeholder.

$ memtrace connect --endpoint https://memdb.corp.example:50051 --token mdb-abc123
# Compatibility/manual path. Prefer an administrator-generated connection file.

$ memtrace connect --offline-license license.mtl
# Air-gapped install: verify and install a signed offline license, then exit
# (add --endpoint/bundle args to continue into the connect flow).

$ memtrace connect --status
# Show effective config, mode provenance, token presence, and a live
# connectivity probe. Changes nothing.

$ memtrace connect --disconnect
# Remove .memtrace/team.toml and scrub the stored token for that endpoint.
# License credentials stay — use `memtrace auth logout` for those.

See also Enterprise: connect, memtrace access, memtrace auth, memtrace status, and memtrace start.