Connect To A Runtime
| Mode | Command | Who starts the runtime | Quitting mbm2 |
|---|---|---|---|
| Local (default) | mbm2 or mbm2 --dir <path> |
The first mbm2 starts your engine; every later mbm2 joins it |
The engine keeps running while another mbm2 uses it, and stops after the last one quits |
| Attach | mbm2 --attach <url> [--dir <path>] |
You or an operator, beforehand | Leaves the server running |
mbm2 draws the interface; the runtime owns sessions, agents, tools, providers and terminals.
Both modes speak the same HTTP + event-stream API, so every guide in these docs works the same way
in either mode (ADR 0007). The second half of this page connects model providers to that
runtime with /connect (Providers and accounts).
Local Mode
-
The installer already put the runtime beside the client: v2's Go engine alone,
~/.mbm2/runtime/mbm-runtime(%USERPROFILE%\.mbm2\runtime\mbm-runtime.exeon Windows); v1'smbmis no longer bundled on any platform. The client picks:Order Runtime started When 1 The binary MBM_SERVER_BINnames, used exactly as given (a path or a wrapper script)MBM_SERVER_BINis set (for example to compare with a v1 build)2 The Go engine: mbm-runtime serve --listen 127.0.0.1:<port> --engine-data-dir ~/.local/share/mbm/mbm2/engineOtherwise: ~/.mbm2/runtime/mbm-runtime(mbm-runtime.exeon Windows), or the fileMBM2_ENGINE_BINnamesThere is no fallback: if the engine is missing
mbm2exits withno mBm engine at <path>: …, and if it fails to start withthe Go engine did not start: <reason>.MBM2_ENGINE=offis no longer accepted;mbm2exits withMBM2_ENGINE=off is removed (ADR 0277): ….On Windows the paths are the same as v1's, under your profile: configuration in
%USERPROFILE%\.config\mbm, the engine's sessions in%USERPROFILE%\.local\share\mbm\mbm2\engine(or underXDG_CONFIG_HOME/XDG_DATA_HOMEwhen you set them), and managed configuration in%ProgramData%\mbm. Terminal tabs and!commands run in a Windows pseudo console (Windows 10 1809 or later); the default shell is the first of PowerShell 7 (pwsh), Windows PowerShell, Git Bash andcmd.exethat is installed, orSHELLwhen it names one. When the lastmbm2using the engine quits, the engine stops with every terminal and job it started. -
Start the client in your project:
cd /path/to/project mbm2 -
Wait for the startup strip. It reads
Connecting to the local server at <url>until the runtime answers.
| Setting | Default | Change it with |
|---|---|---|
| Time the child may take to print its listening line | 30 s | MBM_TUI_SERVER_START_TIMEOUT=45s (a Go duration; an unreadable value is logged and the default is used) |
| Credentials handed to the child | Same resolution as attach mode, below | --username/--password or the environment variables |
The installer bundles a compatible runtime under ~/.mbm2/runtime/
(Install). If you do not want to run a local runtime, use attach mode.
| Runtime | Stores provider keys and sign-ins in | Notes |
|---|---|---|
| Go engine (the default) | ~/.local/share/mbm/mbm2/credentials.json, mode 0600 ($XDG_DATA_HOME/mbm/mbm2/ when set; %USERPROFILE%\.local\share\mbm\mbm2\ on Windows) |
v1's auth.json is never written; mbm2 auth mbm --from-v1 copies v1's keys once (Moving from v1) |
v1's runtime (a v1 MBM_SERVER_BIN) |
v1's own auth.json |
The client points it at tui.mbm.mn for licences and the model gateway unless you export MBM_LICENSE_SERVER_URL / MBM_PROXY_URL yourself |
Several Windows, One Engine
You can open mbm2 in as many terminals as you like. They all use one engine — the one the
first mbm2 started — so every window sees the same sessions, turns and background jobs, live:
# terminal 1
cd ~/src/shop-api && mbm2
# terminal 2: the same project, the same sessions, live in both
cd ~/src/shop-api && mbm2
# terminal 3: another project on the same engine; it lists that project's sessions
cd ~/src/blog && mbm2
| Question | Answer |
|---|---|
| Which window owns the engine? | None: closing the first window does not stop it while another window (or an mbm2 run, mbm2 rag … command) is connected. It stops about 5 seconds after the last one leaves, and at once when you quit the only window |
| A window crashed or its terminal was closed | The same rule applies: the engine notices the window is gone and stops after the last client, so nothing is left running |
| Different projects | Each window works in its own directory (--dir, or where you started it): its sessions, tools, configuration, agents and commands are that directory's |
| Settings that differ between windows | The engine keeps the environment of the mbm2 that started it (MBM_* variables, --port, the password); a later window uses the engine's own sign-in. What a window reads itself — tui.json, keybinds, theme — stays per window |
| Workers in two windows of one project | Each window has its own workers, and both windows' workers are on the project's team: the agents in one window see the other's as <name>@<window number> and message them. Quitting a window takes only its workers off the team (Teamwork) |
| Sharing settings in another project | Palette Sharing settings in a window of another project writes that project's .mbm/mbm.json, as the first window does for its own |
Different mbm2 versions |
A window refuses an engine of another version: the running mbm2 engine is another version: this user's engine (pid N) is version V and this mbm2 is W; quit the mbm2 windows that use it, then start mbm2 again |
The startup strip of a window that joined reads Connecting to the local server at <url>, as the
first one's does.
Attach Mode
export MBM_SERVER_USERNAME=<user>
export MBM_SERVER_PASSWORD=<password>
mbm2 --attach https://runtime.example.com --dir /srv/projects/app
| Input | Rule |
|---|---|
| URL | Must start with http:// or https://. --attach never spawns a server |
--dir |
Sent with every project request. If the path exists locally, mbm2 also changes into it; if not, it is passed through for the remote server to resolve |
--session <id> |
Checked before the interface opens; an unknown id or unreachable server exits with connect to <url>: … instead of opening an empty session |
Authentication
The runtime uses HTTP Basic authentication. mbm2 resolves each value separately:
| Order | Username | Password |
|---|---|---|
| 1 | -u, --username |
-p, --password |
| 2 | MBM_SERVER_USERNAME |
MBM_SERVER_PASSWORD |
| 3 | mbm |
The runtime's built-in development password |
Prefer the environment variables: a password on the command line lands in shell history and in
the process list. Step 3 exists so a default local runtime works with no setup; a server reachable
from a network must not run with the development credentials. The client never asks for account
or licence credentials; those stay on tui.mbm.mn in a browser.
TLS
| Situation | What to do |
|---|---|
| Remote server | Use https:// with a certificate your system trusts |
| Self-signed certificate on a test server | --insecure skips verification and prints mbm2: warning: TLS certificate verification is disabled. Do not use it to make a failing production connection look healthy |
| HTTP proxy | Not used: the client's transport has no proxy setting, so HTTPS_PROXY is ignored (internal/api/client.go:156-166) |
| Redirect to another host | Refused, so credentials never leave the host you named |
Unverified: how a private certificate authority is added on macOS and Windows; on Linux, Go programs read the system trust store.
Reconnect
| Event | Client behaviour |
|---|---|
| Event stream drops, heartbeat missing for 20 s, or the runtime restarts | The connection is marked lost; the interface stays usable |
| Retry | Waits 1 s, 2 s, 4 s, 8 s, 16 s, then every 30 s |
| Stream back | Re-reads sessions, pending permissions and questions before trusting the screen again |
401 before the first connect |
The strip reads Not connected to <url>; check the credentials and restart |
A different --attach URL or --dir is a different set of sessions. Check both before deciding
that a session is lost. Planned: a dedicated reconnect banner and an in-client credential prompt
after a 401; today the startup strip and the log are the only signals.
Examples
Local mode with a runtime you built yourself
MBM_SERVER_BIN=$HOME/src/mbm/dist/mbm mbm2 --dir ~/src/shop-api
MBM_SERVER_BIN is used exactly as given, before the bundled runtime. A slow machine that needs
longer to start it: add MBM_TUI_SERVER_START_TIMEOUT=60s.
A shared team runtime
export MBM_SERVER_USERNAME=alice
export MBM_SERVER_PASSWORD='…' # from your operator; keep it out of shell history
mbm2 --attach https://mbm.internal.example.com --dir /srv/projects/shop-api
The strip reads Connecting to https://mbm.internal.example.com until the event stream is up. On
exit, the Continue line repeats --attach and --dir, so you can paste it to come back.
A test server with a self-signed certificate
$ mbm2 --attach https://10.0.0.12:4096 --insecure --dir /srv/demo
mbm2: warning: TLS certificate verification is disabled
Use this only on a test server you control.
Through an SSH tunnel
When the runtime is reachable only from its own host, forward its port and attach to the local end:
ssh -N -L 4096:127.0.0.1:4096 you@build-box &
mbm2 --attach http://127.0.0.1:4096 --dir /home/you/src/shop-api
--dir is a path on the server. Unverified: because the address is 127.0.0.1, mbm2 treats the
runtime as local and starts the team bus, which a runtime on another host cannot reach; expect the
team tools to be missing.
Providers And Accounts
/connect (palette Connect provider, also /config → Providers and step 1 of /setup)
opens Connect a provider. Everything you connect is stored by the runtime, not by mbm2.
A first prompt sent with no provider connected opens this dialog for you.
Connect a provider
+ Add account
Connected
✓ DeepSeek deepseek
✓ DeepSeek · work deepseek-work
Popular
mBm (Recommended)
Custom (API key + URL)
OpenAI (ChatGPT Plus/Pro or API key)
Anthropic (API key)
…
Providers
…
Other Custom provider
| Row | return does |
|---|---|
+ Add account |
Add account: pick a provider (Popular first), then Account name, then the provider's sign-in methods. Use it for a second key or a second ChatGPT sign-in of a provider you already have |
| A row under Connected | A menu titled with the account's name: Edit (Edit an account) or Remove → Remove <name>? → Remove deletes that account's credential (toast Account removed); Cancel goes back. The group shows once at least one provider is connected |
| A provider row, not connected yet | Connects that provider itself, with no label |
| A provider row already connected (✓) | Adds another account of it: Account name first, as + Add account does. The first account is never written over; change it with Edit |
Other |
Asks Other: Provider id, then Provider base URL, for a provider the runtime does not list |
| A console-managed row (its footer is your org's name) | Nothing: your organisation configures it on the console |
The Popular group is, in order: mBm, AZ Network, Custom, OpenAI, GitHub Copilot, Anthropic,
Google, DeepSeek, Qwen (alibaba), Kimi (moonshotai), GLM (zhipuai), MiniMax, xAI, Mistral and
OpenRouter — each only when the runtime lists it. The runtime always lists Custom
(OpenAI-compatible) (Popular) and Ollama (Providers), before any of their accounts exists.
The model list (<leader>m) offers the same:
ctrl+a there opens Connect a provider, and with nothing connected it ends with Popular rows.
Several accounts per provider
Each account is a provider of its own, with its own id, credential and models:
| You enter | Account id (made by mbm2) |
Listed as |
|---|---|---|
DeepSeek, label work |
deepseek-work |
DeepSeek · work |
OpenAI, label Team B |
openai-team-b |
OpenAI · Team B |
| OpenAI, no label | openai-2 (then openai-3, …) |
Named by the runtime from the id |
Custom, label gpu box |
custom-gpu-box |
Custom (OpenAI-compatible) · gpu box |
Ollama, label Lab |
ollama-lab |
Ollama · Lab |
The id is <provider>-<label> lower-cased, every run of other characters turned into one -; a
label that gives no usable id, or an id already taken, becomes the first free <provider>-N from 2.
The id never changes afterwards, also when you rename the account. A name another account of the
same provider already has is refused (An account named <label> already exists), so every group
in <leader>m is one account.
v1's openai-N, custom-N and ollama-N credentials are read as accounts of OpenAI, Custom and
Ollama. Pick an account's models with <leader>m like any provider's; every request uses that
account's own key or sign-in. Unverified: the exact display name the runtime gives an unlabelled
account.
Example: a second DeepSeek key
/connect→+ Add account→DeepSeek.- Account name (placeholder
Optional): typework,return. - API key: paste the key (a paste goes into the field, never into the prompt),
return. - Toast
Provider connected; Select model opens withDeepSeek · work's models.
Example: a custom OpenAI-compatible endpoint
/connect→+ Add account→Custom(or the Custom row once one custom endpoint is connected).- Account name is
Requiredhere:gpu box. - Provider base URL:
http://10.0.0.5:8000/v1. - API key: the endpoint's key.
- Before saving, the client asks
<base URL>/modelswith that key (15 s limit); a 2xx answer is stored, and its models are what<leader>mlists for the account. A malformed URL toastsInvalid provider URL. - An endpoint with no
/models(it answers 404, 405 or 501) asks Model ids instead: type them comma-separated (gpt-4o-mini, gpt-4o),return. Those are the account's models.
An Ollama account works the same way with Ollama: a base URL ending in /v1 is trimmed, the
client probes <base>/api/tags, and an empty key is allowed unless the server needs one
(This Ollama server requires an API key). Its models are the host's /api/tags. Three Ollama
machines are three accounts: ollama-lab, ollama-laptop, ollama-gpu.
Example: two of each
/connect → Custom (OpenAI-compatible) → http://10.0.0.5:8000/v1 → key A ⇒ custom
/connect → Custom (OpenAI-compatible) ✓ → Account name `Beta` → URL → key B ⇒ custom-beta
/connect → Ollama → http://10.0.0.7:11434 → (no key) ⇒ ollama
/connect → Ollama ✓ → Account name `Lab` → http://10.0.0.8:11434 ⇒ ollama-lab
/connect → OpenAI → Manually enter API Key → sk-… ⇒ openai
/connect → OpenAI ✓ → Account name `Work` → Manually enter API Key → sk-… ⇒ openai-work
<leader>m then shows six groups — Custom (OpenAI-compatible), Custom (OpenAI-compatible) · Beta,
Ollama, Ollama · Lab, OpenAI, OpenAI · Work — each with its own models, and a prompt to a
model goes to that account's URL with that account's key.
Edit an account
/connect → the account under Connected → Edit. The steps come back filled in with what the
account has:
| Step | Prefilled | Left as it is |
|---|---|---|
| Account name | the label | keeps the name; a custom or Ollama account needs one, except the first (custom, ollama) |
| Provider base URL (custom, Ollama) | the base URL | keeps the URL |
| API key (custom, Ollama) | empty, Leave empty to keep the current key |
an empty return keeps the stored key; a new key is probed first |
| API key or sign-in (other providers) | the provider's methods | a key or a sign-in is needed again |
The toast is Account updated. The account keeps its id, so its favourites and recent models stay.
An account whose endpoint answers no model is still listed under Connected, so it can be edited
or removed.
Ollama on this machine, no setup
A local Ollama needs no /connect at all. When the runtime starts it asks
http://localhost:11434/api/tags once (or $OLLAMA_HOST/api/tags when OLLAMA_HOST is set, or
the provider.ollama.options.baseURL of mbm.json), and lists what answers as Ollama in
<leader>m; requests go to <host>/v1 with no key.
| Ollama | What you see |
|---|---|
| Running with pulled models | Ollama and its models (llama3:8b, …) in the model picker |
| Not installed or not running | Nothing: no Ollama row and no error; a closed port answers at once, so start-up does not wait (a host that accepts but never answers is given up after 15 s) |
Started after mbm2 |
Listed once the runtime builds its provider list again: a restart, a saved or removed credential, or a change to provider in mbm.json |
"disabled_providers": ["ollama"] in mbm.json |
Never asked |
A stored ollama credential (for a remote or key-protected server) replaces this probe with its own
URL and key.
Hide Providers
Two mbm.json keys choose which providers mbm2 uses at all:
{ "enabled_providers": ["mbm", "deepseek"], "disabled_providers": ["ollama"] }
| Key | Effect |
|---|---|
enabled_providers |
Only these providers are used; every other one is left out |
disabled_providers |
These are left out, even when enabled_providers names them |
A provider left out is not in /models or /connect, its account is not asked for models, and a
message to one of its models fails as an unknown model. Its stored key is kept.
ChatGPT Plus/Pro sign-in
OpenAI offers three methods in Select auth method:
| Method | What you see | Use it when |
|---|---|---|
ChatGPT Pro/Plus (browser) |
The method's title, a URL, Waiting for authorization... and c copy. Click the URL (or copy it) and sign in; the browser comes back to http://localhost:1455/auth/callback on this machine |
mbm2 and the browser are on the same computer |
ChatGPT Pro/Plus (headless) |
The URL https://auth.openai.com/codex/device and Enter code: ABCD-12345. c copies the code (Copied to clipboard); open the URL on any device, sign in, enter the code |
Over SSH, in a container, or with no browser |
Manually enter API Key |
The API key field | You pay OpenAI per use |
Nothing opens a browser by itself: the URL opens only when you click it, and a failure to open is
ignored, so the view works over SSH. Long URLs wrap so you can select them whole. The dialog waits
for your approval — up to five minutes for the browser method, fifteen for the device code — then
toasts Provider connected and lists the signed-in account's own Codex models. esc cancels. A
second ChatGPT account is + Add account → OpenAI → a label → a sign-in method.
API keys
For a provider with no sign-in method the dialog goes straight to API key. Paste the key and
press return: the runtime stores it, the client re-reads the provider list and opens
Select model for that provider. A key saved for a provider the runtime does not list toasts
Saved credential for <id>. Configure it in mbm.json to use it.
Claude
| You have | Use |
|---|---|
| An Anthropic API key (pay per use) | /connect → Anthropic → paste the key; a second key is + Add account → Anthropic |
| A Claude Pro or Max subscription | /claude: the official claude CLI in its own tab, signed in there (Claude Code tab) |
v2 does not use a Claude subscription as a model provider and does not pool subscriptions: that
path imitates the Claude Code client, breaks Anthropic's terms and puts the account at risk
(ADR 0269 A6). Unverified: v1's runtime (a v1 MBM_SERVER_BIN) may still list a
Claude Code (Claude Pro/Max subscription) row; use /claude there too.
Remove an account
/connect, move to the account under Connected, return, choose Remove. Its credential is
deleted from the runtime and its models leave the list. A console-managed provider is not listed
there and cannot be removed from the client.
| Message | Meaning |
|---|---|
Provider connected |
Stored and listed; the model list for it is open |
Account updated |
An edited account is stored under its own id; the model list for it is open |
An account named <label> already exists |
Another account already has that name; type another |
Could not connect provider |
The runtime refused the key, or the sign-in failed or expired; try again |
Could not start provider authorization |
The runtime answered the sign-in with no usable URL |
Provider ids must start with a lowercase letter … |
The Other id is not made of a-z, 0-9, -, _ |
Provider connection is unavailable |
Not connected to a runtime yet |
Terminals And Workers In Attach Mode
Terminals and terminal workers run on the runtime's host, not on your machine. With a remote
--attach, a command such as claude must be installed and signed in on that server
(Workers, Terminal). The team bus that lets workers
message each other needs the runtime on this machine, so with a remote runtime /team says
the team bus is off: the runtime is not on this machine (Teamwork).
Published from revision f88fc66f 2026-11-30