Tokens and credentials

Docs

Every verb needs a credential: a project token (one per project, shown and rotated in Project settings) or, after login, an account sign-in. This page is where they come from and where they go.

Resolution order

Every verb resolves its credential the same way, first match wins:

Source Notes
--token On the command line.
DS_SYNC_TOKEN In the environment, for scripts, CI and MCP configs. Set it in the shell profile or a secret store, never in a command an agent types: DS_SYNC_TOKEN=<value> npx … puts the token in the transcript.
The saved token mcp: the one saved for --project, never falling through. Others: the entry whose connected folders hold the current folder; several in a terminal open a picker, elsewhere it is an error naming them.
The account link add, create and integrate only: the account login signed in, when it trusts this folder and the folder is linked to a design system (your coding agent's use_design_system or create_design_system links it). The verb then uses that project's account routes at the server the sign-in was saved for.
The hidden prompt A terminal asks; a piped line works for create, integrate and add; never for mcp, whose stdin is the protocol. add --yes never reads stdin. Outside a terminal with nothing found, add, create and integrate stop with the no-design-system line on CLI errors.

A saved token that the server refuses is kept. connect then asks for the new one once in a terminal and saves it, and outside one stops and says to pass --token; add, create and integrate stop with the token line and save nothing, so run connect again with the new token.

A coding agent should find the token without typing it: the user runs npx designsource or npx designsource connect in a terminal in the folder once, or sets DS_SYNC_TOKEN where the agent runs. A sandboxed agent shell may be denied the keychain or the Secret Service; the CLI then says the token is in the keychain and cannot be read there, rather than that nothing is connected. Run npx designsource --store file (or connect --store file, login --store file) in a terminal in the folder once: it moves the saved tokens into the private file and keeps later ones there. See For coding agents.

mcp with no --project, no --token and no DS_SYNC_TOKEN uses the account sign-in, and only when the folder it was started in is exactly one you ran login in. With --api it uses only the account saved for that origin.

setup saves the link when you pick or make a design system; an agent's use_design_system or create_design_system saves it too. The account link follows the same folder rule: the folder's project root (the nearest folder holding .git) must be exactly one you ran login in, or a git worktree of one. A repository nested inside a trusted one gets nothing from it. A saved project token for the folder still wins over the link, so an app set up with connect behaves as before.

Where credentials are kept

System Store
macOS The login keychain, service designsource, one entry per project id and one per account.
Linux The Secret Service (secret-tool) when it answers; else the file.
Windows Encrypted for your user with DPAPI, kept in the file.
Anywhere else The file alone.

The file is $XDG_CONFIG_HOME/designsource/credentials.json, else ~/.config/designsource/credentials.json (%APPDATA%\designsource\credentials.json on Windows), created readable only by you. It always holds the index (project names, connected folders, a non-default server origin) and the token itself only when no OS store works, which connect says. A file the CLI cannot read is copied to credentials.json.bak-<time> before the next save replaces it. account.json beside it holds the account's email, trusted folders and folder links, never the token unless no OS store works. DESIGNSOURCE_STORE=file forces the file; --store file on setup, connect and login does the same for that run and moves the tokens already saved for the folder (and the sign-in for the server) into the file, removing the keychain copies. A token the keychain will not give up is removed there and asked for again (or signed in again).

Every store write is read back; one that cannot be read back falls to the file, so mcp never meets a store it cannot read. A secret reaches a store command only on its stdin, never on a command line.

Servers

--api picks another server (a local one, staging). connect saves a non-default origin with the token, so later verbs in that folder use it without the flag. A saved token goes only to the server it was saved for: --api naming another one is refused, since mcp's arguments come from a settings file in the repository. The same holds for the account link: add, create and integrate refuse an --api naming a server other than the one the sign-in was saved for, before sending anything. mcp sends a --token or DS_SYNC_TOKEN only to the default server, a server on this computer, or the one connect saved for --project. login --api outside a terminal takes only the default or a server on this computer.

What is never printed

The token is typed hidden and sent in a header. No verb prints it, no tool result carries it, the installs add runs never see it, and the settings files connect and login write hold none, so they are safe to commit. Rotating the project token in Project settings signs every computer out; each runs connect again.