# cli_login

Source: https://botpassword.com/docs/intents/cli_login

Built. cli_login checks that git, docker, aws or kubectl may log in with a granted credential at a host, and returns the setup lines that point the tool at…

**Status: Built.** Built for git, Docker, the AWS CLI and kubectl. Not built yet: OAuth device logins, short-lived AWS credentials, and asking for a `cli_login` grant through `request_access` (the person adds it with `bpw grant add`).

## At a glance

| Property | Value |
|---|---|
| MCP tool | `cli_login` ("Log a CLI in") |
| CLI | `bpw agent cli_login` |
| Default friction | None inside a grant that names this tool and host and allows disclosure. |
| Delivery | Always disclosing: the tool, and code the agent runs, can read the value the helper hands over. |
| MCP hints | `readOnlyHint`: true, `destructiveHint`: false, `idempotentHint`: true, `openWorldHint`: false |

## Parameters

Required: `tool`. Unknown arguments are refused. The descriptions are the tool's own, as `bpw mcp` serves them.

| Name | Type | Required? | Description |
|---|---|---|---|
| `tool` | string | required | The command-line tool to log in: git, docker, aws or kubectl. One of `git`, `docker`, `aws`, `kubectl`. |
| `site` | string | optional | A site origin or host, for example https://dash.example.com. 1 to 2048 bytes. |
| `credential` | string | optional | A credential reference (item ID), as list_credentials returns it. Not a secret value. Not empty. |

## Example

A `tools/call` request, with placeholder references (use the `id` that `list_credentials` returns):

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "cli_login",
    "arguments": {
      "tool": "git",
      "site": "https://git.example.com"
    }
  }
}
```

The result. The same JSON is also sent as text in `content[0].text`; `isError` is false for `success`.

```json
{
  "structuredContent": {
    "outcome": "success",
    "tool": "git",
    "credential": "ITEM-EXAMPLE-01",
    "site": "https://git.example.com",
    "setup": [
      "git -c credential.helper= -c 'credential.helper=!bpw git-credential --credential ITEM-EXAMPLE-01' <command>  (the empty helper first stops other helpers from answering)",
      "or in this repository: bpw login git --host git.example.com --credential ITEM-EXAMPLE-01 --apply"
    ]
  },
  "isError": false
}
```

The setup lines depend on the tool (`login_setup` in crates/cli/src/agent_call.rs); follow the ones you get back.

## From the command line

```sh
bpw agent cli_login --tool git --site https://git.example.com
```

`bpw agent <intent>` sends the same request as the MCP tool, through the same policy. Every intent except `status` needs a live agent session, or the answer is `session_required`. Run the harness with `bpw agent run -- <harness>`. On macOS and Linux, an enrolled harness started normally can also be approved in the desktop app or with `bpw session approve`.

## Result fields

Every result is one JSON object. Only `outcome` is always present.

| Field | Type | Meaning |
|---|---|---|
| `outcome` | string | The [typed outcome](/docs/outcomes) code. Always present. |
| `detail` | string | The request ID, rotation step, revision or reason, for the outcomes that carry one. |
| `intent` | string | With `not_implemented`: the intent this build cannot carry out. |
| `reason` | string | With `rejected`: why the call was refused. |
| `message` | string | With `rejected` or `daemon_unavailable`: what was wrong. Never quotes an argument value. |
| `next_step` | string | On a result that is not a plain success: one sentence on what to do now. Fixed text chosen by the outcome code; it never asks for a password or secret and never says to get around a refusal. |
| `tool` | string | The command-line tool the login is for. |
| `credential` | string | The credential the result is about. For a request made with `looking_for`, absent until the request is approved. |
| `site` | string | The canonical origin the result is about. |
| `setup` | array | Lines saying how to point the tool at its credential helper. No value. |

## Outcomes it can return

- [`success`](/docs/outcomes/success): The request ran.
- [`scope_denied`](/docs/outcomes/scope_denied): The most common refusal.
- [`disclosure_not_granted`](/docs/outcomes/disclosure_not_granted): The request would let code the agent controls read the value (`run_with` with `env` or `files`, `cli_login`, `sign_in`, `fill_totp`), and the grant does not allow disclosure.
- [`grant_expired`](/docs/outcomes/grant_expired): A grant names this credential for this client, but its lifetime is over.
- [`needs_human`](/docs/outcomes/needs_human): Something only a person can do stands in the way.
- [`session_required`](/docs/outcomes/session_required): The call did not come from inside a live agent session: none was presented, it expired, or it is malformed.
- [`vault_locked`](/docs/outcomes/vault_locked): BotPassword on this device is locked, so no credential can be used.
- [`rejected`](/docs/outcomes/rejected): The request was malformed before policy saw it.
- [`daemon_unavailable`](/docs/outcomes/daemon_unavailable): `bpw mcp` or `bpw agent` could not reach `botpasswordd`, the desktop daemon that holds the keys.

See the [outcome reference](/docs/outcomes) for what each one means and what to do next.

## Limits

- For gh, wrangler and npm use `run_with` with `GH_TOKEN`, `CLOUDFLARE_API_TOKEN` or `NPM_TOKEN`.
- `aws` takes no `site`: the AWS CLI does not tell its credential process where it will send the key.
- Without `credential`, the one granted credential for the tool and host is used; two matches answer `needs_human`.
- `grant_expired` comes back only when the call names a credential. With none named, an expired grant serves nothing and the answer is `scope_denied`.

## Tool description

What the MCP tool tells the agent, verbatim from `bpw mcp`:

> Checks that a command-line tool (git, docker, aws or kubectl) may log in with a granted credential at a host (site: the git or registry host, or the cluster's https server; aws takes none and names its credential), and returns how to point the tool at BotPassword's credential helper for it. The helper, run by the tool inside this session, hands the value to that tool, where you can read it, so only a grant that allows disclosure and names this tool and host permits it. This tool itself returns no value. Without credential, the one granted credential for the tool and host is used. For gh, wrangler and npm use run_with with GH_TOKEN, CLOUDFLARE_API_TOKEN or NPM_TOKEN. This tool never accepts or returns secret values. The result is a typed outcome such as success, vault_locked or scope_denied.

## Related

- [`run_with`](/docs/intents/run_with): runs a command with granted credentials injected by BotPassword and returns the exit status and output.
- [`list_credentials`](/docs/intents/list_credentials): lists the credentials this agent client holds grants for, with each one's reference, kind, title, site and the intents its grant allows.
- [Intent catalog](/docs/intents), [MCP server](/docs/mcp-server), [Grants and approvals](/docs/grants-and-approvals)
