CLI guide

Typesense CLI setup and command guide

Install the Typesense CLI, create secure profiles, discover commands, and automate Typesense operations with stable JSON output.

Install the CLI

Looking for the product overview? Start with TypesenseKit's Typesense CLI, then use this guide for complete setup and command details.

TypesenseKit requires Node.js 22.11 or newer. Install the public package globally with your preferred package manager.

pnpm
pnpm add -g @typesensekit/cli

Confirm the command is available by listing the operation registry.

shell
tsk operations

Create a secure profile

A profile stores a Typesense URL and credential reference so you do not have to repeat connection details. The interactive form prompts for the API key without putting it in shell history.

shell
tsk profile add local --url http://localhost:8108
tsk profile use local
tsk profile test local

On macOS, ask TypesenseKit to keep the key in Keychain rather than the profile configuration file.

shell
tsk profile add production --url https://search.example.com --keychain
Use the narrowest key that works. Search-only workflows should use a scoped search key instead of an admin key.

Run without a saved profile

For CI and short-lived environments, provide the connection through environment variables.

shell
TYPESENSE_URL=http://localhost:8108 \
TYPESENSE_API_KEY=xyz \
tsk health --input '{}'

For a scripted profile setup, pipe the key over stdin so it does not appear in process arguments or shell history.

shell
printf '%s' "$TYPESENSE_API_KEY" | \
tsk profile add ci --url https://search.example.com --api-key-stdin

Discover operation inputs

Operation names stay the same across the CLI and MCP server. Inspect the validation schema or generated examples before sending a request.

shell
tsk documents.search --schema
tsk documents.search --examples

Search parameters belong in the top-level params object.

search
tsk documents.search --input '{"collection":"products","params":{"q":"oak chair","query_by":"title"}}' --json

See the generated API coverage for the complete operation inventory.

Choose output for humans or scripts

Common operation results render as readable tables in a terminal. Add --json for stable, redacted JSON that can be piped into another command.

shell
tsk collections.list --input '{}'
tsk collections.list --input '{}' --json | jq '.[].name'

Input can also come from a JSON file for large imports or reusable operation payloads.

shell
tsk documents.import --input import.json --json

For complete import objects, JSONL exports, failure filtering, and layered diagnostics, follow the Typesense CLI import, export, and debugging guide.

Enable shell completion

Generate completion definitions from the current command and operation registry.

shell
# zsh
source <(tsk completion zsh)

# bash
source <(tsk completion bash)

# fish
tsk completion fish | source

Treat destructive operations deliberately

The CLI asks for confirmation before destructive requests. This makes interactive administration harder to trigger accidentally.

shell
tsk collections.delete --input '{"collection":"old_products"}'

Use --yes only in automation where the target and failure behavior are already controlled.

shell
tsk collections.delete --input '{"collection":"old_products"}' --yes --json
Next: connect the same registry to an AI client through the read-only MCP server.