# CLI and MCP server

> The salesdogg command line, how it finds credentials, and how agents load every operation as MCP tools.

The CLI has one command per API operation, generated at runtime from the OpenAPI document. Output is always JSON on stdout. Errors are JSON on stderr with a non-zero exit code, and `error.hint` says what to do next.

```sh
npx -y @salesdogg/cli --help              # or install it: npm install -g @salesdogg/cli
salesdogg <group> --help                   # actions in a group
salesdogg <group> <action> --help          # one command's parameters
salesdogg commands                         # every command and parameter, as JSON
```

## Getting started commands

| Command | What it does |
| --- | --- |
| `salesdogg login` | Sign in through the browser (device code), or `--email` / `--password` for non-interactive use |
| `salesdogg signup` | Create an account: `--email --password [--name]` |
| `salesdogg init` | Create a project and append its keys to `./.env` (signs you in first if needed) |
| `salesdogg status` | Show which credentials and project are in use |
| `salesdogg use <project_id>` | Choose the project for session-authenticated commands |
| `salesdogg api <METHOD> <path>` | Call any endpoint directly; `--data '{...}'` for a JSON body |
| `salesdogg import revenuecat` | Move from RevenueCat (see [Moving from RevenueCat](/docs/revenuecat)) |
| `salesdogg mcp` | Run the MCP server over stdio |
| `salesdogg billing get` | Your plan, and on Free a link to choose a plan and pay |

Every API operation is `salesdogg <group> <action>`; the [API reference](/docs/api) lists the command beside each endpoint. Flags are the parameter names with `-` for `_`; nested objects take `--credentials.secret_key value` or JSON.

## Credentials

In order of precedence:

1. `SALESDOGG_API_KEY` (or `SALESDOGG_SECRET_KEY`) in the environment or `./.env`.
2. The session saved by `salesdogg login`, plus the project chosen with `salesdogg init` or `salesdogg use`.

`SALESDOGG_API_URL` selects the server (default `https://api.salesdogg.com`).

## MCP server

`salesdogg mcp` serves every API operation as a tool over stdio. Tool names are `<group>_<action>`, for example `customers_entitlements`. Read operations are marked read-only and deletes destructive, so clients can ask before running them.

```json
{
  "mcpServers": {
    "salesdogg": { "command": "npx", "args": ["-y", "@salesdogg/cli", "mcp"] }
  }
}
```

It takes credentials the same way as the CLI. To pin a project, add `"env": { "SALESDOGG_API_KEY": "sd_sk_..." }`. Setup for each agent is on [Set up with your agent](/agents).
