Connect to a Mockarty Server
This page explains how the Mockarty CLI chooses which server to talk to, and how to override that choice for local development, self-hosted deployments, or air-gapped installs.
TL;DR. Out of the box,
mockarty-clipoints at a local Mockarty instance (http://localhost:5770). To use a different server, either pass--server <url>on each command, exportMOCKARTY_SERVER=<url>, or save it as a context withmockarty-cli config set-context <name> --server <url>and make that context active withmockarty-cli config use-context <name>.
Server URL Resolution
Every CLI command resolves its target server by walking a four-step precedence chain. The first non-empty value wins.
| # | Source | Wins over… | Typical use case |
|---|---|---|---|
| 1 | --server <url> flag |
everything below | Ad-hoc one-off run, CI/CD jobs |
| 2 | MOCKARTY_SERVER env var |
file + default | Per-shell scripts, Docker containers |
| 3 | server_url in ~/.mockarty/config.yaml |
default only | Persistent personal default |
| 4 | Compiled-in default (http://localhost:5770) |
— | Fresh install with no setup |
The legacy MOCKARTY_SERVER_URL environment variable is still honoured as an alias for MOCKARTY_SERVER so existing CI scripts keep working; if both are set, MOCKARTY_SERVER takes precedence.
Common Scenarios
1. Default install — local instance
After installing the CLI, the very first command targets a local Mockarty instance:
mockarty-cli auth login
# Server: http://localhost:5770
# Contacting Mockarty server for authentication methods…
The CLI prints the resolved server before starting the OAuth flow so you can verify the destination at a glance. If the printed URL is wrong, abort with Ctrl-C and re-run with --server <your-server-url> (or point at your self-hosted instance — see below).
2. Local development against a running Mockarty instance
Most developers run a local admin node on http://localhost:5770. The cleanest way is a one-line env override per shell session:
export MOCKARTY_SERVER=http://localhost:5770
mockarty-cli auth login
# Server: http://localhost:5770
Or per-command, without changing the shell:
mockarty-cli --server http://localhost:5770 auth login
3. Self-hosted corporate Mockarty
A long-lived persistent default goes into ~/.mockarty/config.yaml and survives across shells, containers, and reboots. Save the context, then switch to it:
mockarty-cli config set-context corp --server https://mockarty.internal.corp
mockarty-cli config use-context corp
mockarty-cli auth login
set-context only stores the URL; use-context makes it the current one. After that, any later mockarty-cli mock list / mockarty-cli run command targets the corporate server — no flag, no env var.
4. Air-gapped / multiple servers in one shell
For users that frequently switch between two or three servers, prefer the env-var path so each new shell starts with a known target:
# ~/.bashrc / ~/.zshrc
export MOCKARTY_SERVER=https://mockarty.internal.corp
# Per-job override for one CI step only:
MOCKARTY_SERVER=http://localhost:5770 mockarty-cli mock list
Verifying the Active Server
Run mockarty-cli config view to see the saved contexts and which one is current:
mockarty-cli config view
# Current context: corp
#
# * corp
# Server: https://mockarty.internal.corp
# Namespace: sandbox
The * marks the context in use. A --server flag or a MOCKARTY_SERVER value in your shell still wins over the saved context for that one command, so check those first if a command reaches an unexpected address.
Why a Local Default
A fresh install with no flag, no env, no file still has a useful, well-known target: a local Mockarty instance on http://localhost:5770. New users can start a local server and run mockarty-cli auth login immediately without having to know any URL first. Existing users with a corporate config feel no change — their personal override (a self-hosted server URL) sits above the default in the precedence chain.
The compiled-in default can also be overridden at build time, so a custom distribution can ship with a different well-known target; the precedence chain above still applies on top of whatever default the binary was built with.
Sign-in methods are chosen by the server
The sign-in page shows only the methods actually configured on the installation.
The web login page, the CLI and the Mockarty mobile app read the same list, so:
- a provider enabled in Admin → Identity Providers appears everywhere;
- a provider that is not configured, or was disabled, never appears;
- with no providers configured, the page shows the password form only.
The mobile app signs in with an OAuth/OIDC provider through the provider’s own
login page: the person approves there and the app receives its own token. The
provider secret never reaches the phone.
Pairing a phone with a QR code
A phone pairs by scanning a code that a signed-in person shows on the desktop or in the server UI. The person must be signed in to the browser; a pairing created from an API or integration credential gives the phone test-device access only and never a longer-lived user sign-in.
- The signed-in person opens the device pairing panel. It shows a short-lived, single-use code as a QR.
- The phone scans it, or types the code if the camera is unavailable.
- The phone is signed in and ready to act as a test device in the same space. No URL and no password are typed.
The code expires after a couple of minutes and a refresh shows a new one. It signs in exactly the person who created it, in exactly the space where it was created, on one device, once. A code from another server, an expired code, a code already used, or one invalidated after several wrong attempts is refused and the app asks for a fresh QR. A pairing created by an account that has since been disabled or deleted is refused instead of signing the device in.
If access is withdrawn before the code is used, the phone is refused and no credential is created. If unbinding cannot revoke every credential, the attempt fails and the binding can be retried; retry the same binding instead of creating a new pairing.
The phone can unbind itself later: open Settings → This device’s binding → Unbind this device. That revokes both the test-device credential and the sign-in the server issued.
Related Docs
- CLI User Guide — full command reference
- Quick Start — five-minute onboarding
- CLI in a Container — Docker / Kubernetes patterns
- Tips & Useful Features — why the examples use
localhost:5770placeholders elsewhere