AICMO_API_KEYenvironment variable (fastest, no browser needed)~/.ai-cmo/credentials.jsonfile from a previous device authorization- Browser device authorization flow (interactive, first-run only)
The legacy env var namesIf neither the env var nor an existing credential file is found, the server starts a device authorization flow.NOISEMAKER_API_KEYandNOISEMAKER_BASE_URLare still recognized as fallbacks in tier 1.
Device authorization flow
1
Server requests a device code
POST
/api/v1/device-authorizations with an empty JSON body.The server responds with a code and verificationUri:2
Browser opens for approval
The MCP server opens
verificationUri in your default browser. If it cannot open the browser (e.g., headless environment), it prints the URL to stderr.3
Approve or deny in the browser
The
/authorize/device?code=... page shows the requested scopes and lets you select a workspace. You must be signed in with a session cookie — API keys cannot approve device authorizations.The authorization creates an API key with exactly these 10 scopes:workspace:readmetrics:readrecs:readrecs:writeruns:readruns:writereports:readchat:readchat:writesettings:read
4
Poll for the token
The MCP server polls
POST /api/v1/device-authorizations/{code}/token every 2 seconds. The poll returns one of:The polling deadline is 10 minutes. After that, the server throws an error.
5
Credential is persisted
On approval, the API key and workspace are written to
~/.ai-cmo/credentials.json:- Directory
~/.ai-cmo/is created with mode0700 - Credential file is created with mode
0600 - Write is atomic: written to a temp file (
credentials.json.<pid>.tmp), then renamed
Error states
Credential resolution order
- If
AICMO_API_KEY(or legacyNOISEMAKER_API_KEY) is set in the environment, use it directly (noworkspace— the tool call may need an explicitworkspaceparameter). - If
~/.ai-cmo/credentials.jsonexists and parses correctly, use it (includes aworkspacefor default routing). - Otherwise, run the device authorization flow, persist the result, and use it.