> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sense-lab.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Inspect, diff, and manage SenseLab memory from the command line.

<Note>
  The CLI is for self-hosted SenseLab. On the managed platform, use the [Dashboard](https://amfs-login.sense-lab.ai) or [REST API](/amfs/guides/http-server) instead.
</Note>

The SenseLab CLI provides commands for inspecting, diffing, and snapshotting local memory from the terminal.

***

## Installation

```bash theme={null}
pip install amfs-cli
```

***

## Initialize a Project

```bash theme={null}
amfs init
```

Creates `amfs.yaml`, `.amfs/`, and updates `.gitignore`. Run this once per project.

***

## Inspect Memory

### List Entries

```bash theme={null}
# List all entries
amfs inspect list

# List entries for a specific entity
amfs inspect list checkout-service

# Include superseded versions
amfs inspect list checkout-service --superseded
```

### Read an Entry

```bash theme={null}
amfs inspect read checkout-service retry-pattern
```

### Diff Version History

See how an entry changed across versions:

```bash theme={null}
amfs inspect diff checkout-service retry-pattern
```

***

## Snapshots

### Export

Export all memory to a JSON file:

```bash theme={null}
amfs snapshot export backup.json
```

Export a single entity:

```bash theme={null}
amfs snapshot export backup.json --entity checkout-service
```

Include superseded versions:

```bash theme={null}
amfs snapshot export backup.json --superseded
```

### Restore

Restore memory from a snapshot:

```bash theme={null}
amfs snapshot restore backup.json
```

<Warning>
  Restore writes entries into the current adapter. Existing entries with the same keys will get new versions via CoW — nothing is overwritten destructively.
</Warning>

***

## Custom Config Path

All commands accept a `-c` / `--config` flag:

```bash theme={null}
amfs inspect list -c /path/to/amfs.yaml
```

***

## Connecting to SenseLab

CLI commands work against local storage by default. To interact with the managed platform, use the HTTP API directly or configure the MCP server with `AMFS_HTTP_URL`.

### Environment Variables

```bash theme={null}
export AMFS_HTTP_URL="https://amfs-login.sense-lab.ai"
export AMFS_API_KEY="amfs_sk_your_key_here"
```

With these set, the MCP server and HTTP server automatically route through the authenticated HTTP API. CLI inspection commands (`amfs inspect`, `amfs snapshot`) still read from the local adapter — use the Dashboard or REST API for remote inspection.

<Warning>
  Never use `AMFS_POSTGRES_DSN` for external agents in multi-tenant mode. Always use `AMFS_HTTP_URL` + `AMFS_API_KEY`.
</Warning>

See the [Connect to SenseLab](/amfs/getting-started/saas-connection) guide and [Environment Variables](/amfs/reference/environment-variables) for details.

***

## MCP Server

The MCP server has its own executable:

```bash theme={null}
# Start with stdio transport (default)
amfs-mcp-server

# Start with HTTP transport
amfs-mcp-server --transport http

# Custom host, port, and path
amfs-mcp-server --transport http --host 127.0.0.1 --port 9000 --path /amfs
```

See the [MCP Setup guide](/amfs/guides/mcp) for full details.
