# Overview

The superglue CLI (`sg`) lets you manage systems, build and run tools, create MCP servers, and inspect runs from a terminal or AI coding agent.

## Install

```bash
npm install -g @superglue/cli@latest
sg --version
```

Use `sg update --check` later to check whether a newer version is available.

## Authenticate

### Browser login

For local, interactive use, sign in through your superglue account:

```bash
sg login
sg whoami
```

`sg login` opens the web app and stores an OAuth session in `~/.superglue/auth.json`. Run `sg logout` to remove it.

For a self-hosted or custom deployment, provide the API and web app endpoints:

```bash
sg --endpoint "https://api.example.com" login \
  --web-endpoint "https://app.example.com" \
  --save-config
```

### API key

For CI, servers, and other non-interactive environments, configure an API key instead:

```bash
export SUPERGLUE_API_KEY="your-api-key"
export SUPERGLUE_API_ENDPOINT="https://api.superglue.cloud"

sg whoami
```

`SUPERGLUE_API_ENDPOINT` is optional for superglue Cloud and required when the CLI should target another instance. Per-command `--api-key` and `--endpoint` flags override stored configuration and environment variables.

**Note:** `sg init` remains available for scripts that use its legacy API-key setup flow. New interactive
  setups should use `sg login`; new headless setups should use environment variables or global
  flags.

## Use the CLI with an AI agent

Start with [CLI + Skills](/docs/getting-started/cli-skills/) when using `sg` through Cursor, Claude Code, Codex, or another coding agent. It covers installing the bundled superglue skill, adding project context, and the discovery workflow agents should follow before changing systems or tools.

## Output and help

Commands return JSON by default. Add `--table` for human-readable tables or `--full` to disable truncation of large fields.

Use the built-in help for the installed version:

```bash
sg --help
sg tool --help
sg tool run --help
```

See the [commands reference](/docs/cli/commands/) for every command and flag.