# Set up kcli (instructions for an AI agent)

You are helping someone set up kcli, the command-line tool and MCP server for
Kasm Workspaces. Follow these steps in order. Never ask for an API key secret
or a password in the chat, and never write one to a file or pass one as a
command argument. The person enters secrets in their own terminal.

## 1. Install kcli

Check for it with `kcli --version`. If it is missing, then:

- **Linux or macOS:**
  `curl -fsSL https://kcli.sandbox.kasm.com/install.sh | bash`
- **Windows:** read `version` from
  `https://kcli.sandbox.kasm.com/releases/latest.json`,
  then download `kcli-windows-amd64.exe` (or `-arm64`) from
  `https://kcli.sandbox.kasm.com/releases/<version>/`,
  save it as `kcli.exe` in a folder on `PATH`.

If `kcli` is still not found after the installer, it printed the line to add
to the shell profile so its folder is on `PATH`. If kcli is already installed, `kcli update` brings it up to date.

## 2. Configure it

Ask the person for their Kasm deployment URL. Then ask them to run this
**in their own terminal**, because it prompts for secrets:

```
kcli config init
```

In Claude Code they can type `! kcli config init` at the prompt. It asks how
to sign in: an API key, a username and password, or creating an API key from
an administrator's sign-in. Secrets go to the system keychain.

Don't suggest `--no-verify-tls` unless the person says their deployment uses a
self-signed certificate.

## 3. Check it works

```
kcli config show                # the profile, secrets redacted
kcli platform version get       # succeeds only if the URL and credentials work
```

If the second command fails, show the person the error and go back to step 2.

## 4. Connect your agent (MCP)

Ask what the person wants to do:

- **Administer the deployment:** scope `admin`.
- **Work with their own user and catalog:** scope `user`.
- **Launch and drive workspace sessions:** skip to step 5. Sessions need the
  Kasm toolkit, which registers the `session` scope.

For `admin` or `user`, register kcli with your own agent, using kcli's full
path (`command -v kcli`):

| Agent | Command |
| --- | --- |
| Claude Code | `claude mcp add --scope user kasm -- <kcli> mcp serve --scope <scope>` |
| Codex | `codex mcp add kasm -- <kcli> mcp serve --scope <scope>` |
| OpenCode | `opencode mcp add kasm --global -- <kcli> mcp serve --scope <scope>` |
| Hermes | `hermes mcp add kasm --command <kcli> --args mcp serve --scope <scope>` (answer Y to enable its tools) |
| Anything else | `kcli mcp config --scope <scope>` prints an `mcpServers` entry to add to its settings |

Tell the person to restart the agent, or start a new session, to load it.

## 5. Sessions: the Kasm toolkit

The toolkit gives you the skills and examples for launching and driving Kasm
sessions, and registers kcli's `session` scope. Run `kcli toolkit --help`. If
kcli says the command is unknown, this kcli can't set up sessions yet: tell
the person, and stop. Otherwise:

```
kcli toolkit install
kcli toolkit link --agent claude|codex|opencode|hermes
```

`link` prints the MCP command for that agent: an entry named `kasm-session`
with `--scope session`, so it sits beside any `kasm` entry from step 4. Run
it, then tell the person to restart the agent or start a new session.
