---
title: "CLI: signing in, connecting and the local server"
description: "The commands of the doorman command line that are not an operation of the API: login, logout, whoami, connect and mcp, the flags every command takes, and what is kept on the machine."
url: https://doorman.fyi/docs/cli/commands/session
markdown: https://doorman.fyi/docs/cli/commands/session.md
area: "SDKs and tools"
section: "Command line"
---

# CLI: signing in, connecting and the local server

The commands of the doorman command line that are not an operation of the API: login, logout, whoami, connect and mcp, the flags every command takes, and what is kept on the machine.

Source: https://doorman.fyi/docs/cli/commands/session

## Flags every command takes

| Flag | What it does |
| --- | --- |
| `--api-key <key>` | Use this credential for the run. It comes before `DOORMAN_API_KEY`, a browser sign-in and a saved key. |
| `--base-url <url>` | The API to call. It comes before `DOORMAN_API_URL` and the saved address. |
| `--json` | Print the API's JSON instead of a table. With a JSON object after it, the object is the request body. |
| `--help`, `-h` | Print the command's usage and flags. |

A boolean input is a flag by itself, `--is-read`, or a flag with a value, `--is-read false`; `--no-is-read` says false. An input that takes an object or a list takes it as JSON in one quoted word. A flag the command does not know is refused before anything is sent.

The credential a command runs on is the first of these that is present: `--api-key`, `DOORMAN_API_KEY`, the browser sign-in kept for the API's address, a key saved by `doorman login --api-key`.

## doorman login

Command:
```sh
doorman login [--base-url <url>] [--scope "<permissions>"] [--no-browser]
doorman login --api-key <credential> [--base-url <url>] [--no-verify]
```

Signs in through the browser: the approval page opens, you allow access there, and the sign-in is kept on this machine in a file only you can read. No API key is created, copied or stored.

| Flag | What it does |
| --- | --- |
| `--base-url <url>` | The API to sign in to. It is remembered after the first sign-in. |
| `--scope "<list>"` | Ask for exactly these permissions, separated by spaces. Without it the sign-in asks for the default agent permissions: `account:read`, `inboxes:read`, `mail:read`, `mail:write`, `mail:send`. |
| `--no-browser` | Print the address to open instead of opening it. The browser has to run on this machine. |
| `--api-key <key>` | Save a key instead of signing in. The key is checked first with one request. |
| `--no-verify` | Skip that check, for an app token that was not given `account:read`. |

**Permissions a sign-in can ask for**

| Permission | What it allows |
| --- | --- |
| `account:read` | Read account identity, plan, usage and aggregate activity. |
| `inboxes:read` | Read inbox addresses, metadata and activity summaries. |
| `inboxes:write` | Create, update and delete inboxes. |
| `mail:read` | Read messages, threads, attachments and mail-bearing events, and the services and verification codes found in mail. |
| `mail:write` | Change thread read state, metadata and labels, trash threads, record the services an address signs up for, and start a sign-in the owner allows. |
| `mail:send` | Send mail and replies from the account's inboxes. |
| `mail:draft` | Write drafts for the owner to send. It sends nothing. |
| `events:read` | Read and stream the event log, including message content. |
| `webhooks:manage` | Manage this installation's webhook endpoints and deliveries. |
| `rules:manage` | Manage this installation's durable inbound rules. |

Shell:
```sh
# Sign in, with the default agent permissions
doorman login --base-url "https://api.doorman.fyi"

# Sign in again to add the permission that watching events needs
doorman login --scope "account:read inboxes:read mail:read mail:write mail:send events:read"
```

## doorman logout and doorman whoami

Command:
```sh
doorman logout
doorman whoami [--json]
```

`doorman logout` removes the saved sign-ins, the saved key and the saved address from this machine. The connection stays listed under [Agents](https://doorman.fyi/console/connect) in the console until you end it there or it goes unused.

`doorman whoami` shows the caller the API sees and which credential the command line used to ask: a flag, the environment, a browser sign-in or a saved key.

## doorman connect

Command:
```sh
doorman connect [host] [--name <name>] [--yes] [--print] [--plugin <directory>] [--base-url <url>]
```

Connects the agent you use to this inbox. The agent signs in through the browser and you approve there: no API key is involved. With no host, the command lists the agents it knows and marks the ones found on this machine. With a host, it shows the steps to connect it and, after asking, carries out the ones that can be done from here.

- A command is run exactly as it is shown.
- A settings file gets one entry added. Everything else in it is kept as it is, and the file as it was is saved beside it.
- Steps that happen in the agent's own screens are left to you.

| Flag | What it does |
| --- | --- |
| `--name <name>` | What the agent calls the connection: lowercase letters, digits and hyphens. Defaults to `doorman`. |
| `--yes` | Carry out the steps without asking first. |
| `--print` | Only show the steps. |
| `--base-url <url>` | The API to connect to. Defaults to the one you signed in to. |
| `--plugin <directory>` | For an agent that installs plugins, write the agent's plugin package into this directory instead. The directory must be new or empty. The package carries this connection and the skills that say how to use the inbox, is made for this API's address and holds no key. |
| `--plugin-version <version>` | The version the package states, such as `1.2.0`. |

[Connect your agent](https://doorman.fyi/docs/connect.md#command-line) has the steps for each agent.

## doorman mcp

Command:
```sh
doorman mcp [--base-url <url>] [--api-key <key>]
```

Runs this inbox's Model Context Protocol server on standard input and output, for an agent that starts a program on this machine. An agent that connects to an address needs no program.

- After `doorman login`: The server runs on that sign-in. It offers the tools the sign-in was allowed, answers in text sized for a model, and keeps the sign-in renewed for as long as it runs.
- With a key: `--api-key` or `DOORMAN_API_KEY`. The server offers every tool this API has switched on, with structured answers, for a program. A key given for the run comes first.

Either way, a tool that belongs to a capability the API has not switched on is left out. The server asks the API once when it starts and waits five seconds at most: without an answer it starts without those tools. See [Connect over local stdio](https://doorman.fyi/docs/mcp.md#connect-stdio).

## What is kept on this machine

Both files are in `~/.config/doorman/`, or `$XDG_CONFIG_HOME/doorman/` where that is set, with `0600` permissions.

- `credentials.json`: A browser sign-in for each API address: its tokens and the permissions it was allowed. The command line renews it while it is used.
- `config.json`: A key saved with `doorman login --api-key`, and the API address.

> Note: CI needs neither file: set `DOORMAN_API_KEY` and `DOORMAN_API_URL`.

## Output and failure

- On a terminal a command prints a table or a short summary. Piped, or with `--json`, it prints the API's JSON and nothing else.
- A secret that is shown once, such as a new key's token, is printed in full when the command that creates it runs.
- A refused call prints the error's code, status and message on standard error, with `Retry-After` when the API sent one, and the command exits with a status other than zero.
- A call refused for a missing permission names the permission and prints the `doorman login --scope` line that adds it.
