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

# CLI Reference

> Command-line interface for Mengram — setup, MCP server, data import, hooks, and rules generation.

## Installation

```bash theme={null}
pip install mengram-ai
```

## Commands

### mengram setup

Interactive signup and configuration — creates your account, saves the API key to your shell profile, and installs Claude Code hooks. All from the terminal.

```bash theme={null}
mengram setup
mengram setup --email you@example.com    # skip email prompt
mengram setup --no-hooks                 # skip Claude Code hook install
```

| Flag         | Description                             |
| ------------ | --------------------------------------- |
| `--email`    | Email address (skip interactive prompt) |
| `--no-hooks` | Skip Claude Code hook installation      |

If you already have a key, it will ask whether to reconfigure. If the email is already registered, it offers to reset your API key.

### mengram init

Interactive setup — creates config, vault, and Claude Desktop MCP integration.

```bash theme={null}
mengram init
mengram init --provider openai --api-key sk-...
mengram init --mcp-only   # only setup MCP integration
```

| Flag         | Description                                    |
| ------------ | ---------------------------------------------- |
| `--provider` | LLM provider: `openai`, `anthropic`, `ollama`  |
| `--api-key`  | API key for the provider                       |
| `--vault`    | Custom vault path                              |
| `--home`     | Mengram home directory (default: `~/.mengram`) |
| `--no-mcp`   | Skip Claude Desktop MCP setup                  |
| `--mcp-only` | Only setup MCP (config must exist)             |

### mengram server

Start the MCP server for Claude Desktop, Cursor, or Windsurf.

```bash theme={null}
mengram server              # local mode (your own LLM keys)
mengram server --cloud      # cloud mode (uses Mengram API)
```

| Flag       | Description                                     |
| ---------- | ----------------------------------------------- |
| `--config` | Config path (default: `~/.mengram/config.yaml`) |
| `--cloud`  | Use cloud API instead of local vault            |

### mengram status

Check setup status — config, vault, vector index, Claude Desktop integration.

```bash theme={null}
mengram status
```

### mengram stats

Show vault statistics — entity counts, fact counts, vector index info.

```bash theme={null}
mengram stats
```

### mengram rules

Generate a CLAUDE.md, .cursorrules, or .windsurfrules file from your cloud memory.

```bash theme={null}
mengram rules                          # default: CLAUDE.md format
mengram rules --format cursorrules     # Cursor format
mengram rules --format windsurf        # Windsurf format
mengram rules --force                  # regenerate (bypass cache)
```

| Flag       | Description                                           |
| ---------- | ----------------------------------------------------- |
| `--format` | Output format: `claude_md`, `cursorrules`, `windsurf` |
| `--force`  | Regenerate (bypass cache)                             |

### mengram hook

Manage Claude Code memory hooks (auto-save + auto-recall + session context). See [Claude Code Integration](/claude-code) for details.

```bash theme={null}
mengram hook install              # install all 3 hooks
mengram hook install --every 5    # save every 5th response
mengram hook status               # check hook status
mengram hook uninstall            # remove hook
```

### mengram try

Zero-account, local-only preview of what Mengram memory would know. Scans your Claude Code history **on-device** — nothing is uploaded, no API key needed:

```bash theme={null}
mengram try
```

Shows your projects, tech stack, and detected workflow patterns (commit→push→deploy, test→fix→re-test, ...) drawn from your own session history, then the two commands that make it permanent.

### mengram import

Import existing data into memory.

#### mengram import claude-code

Import your local Claude Code session transcripts (`~/.claude/projects`) into cloud memory — memory knows your projects from minute one instead of starting empty.

```bash theme={null}
mengram import claude-code                      # 20 most recent sessions
mengram import claude-code --last 50            # more history
mengram import claude-code --project myapp      # only one project
mengram import claude-code --yes                # skip the confirmation prompt
```

* **Secrets are redacted client-side** before anything is uploaded (API keys, tokens, JWTs → `[REDACTED]`)
* Each session counts as **one add operation** against your plan's monthly quota
* Re-runs skip already-imported sessions; `--reimport` forces a fresh pass

#### mengram import chatgpt

```bash theme={null}
mengram import chatgpt ~/Downloads/chatgpt-export.zip
mengram import chatgpt export.zip --cloud   # use cloud API
```

#### mengram import obsidian

```bash theme={null}
mengram import obsidian ~/Documents/MyVault
mengram import obsidian vault/ --cloud --chunk-chars 4000
```

#### mengram import files

```bash theme={null}
mengram import files notes.md journal.txt research.md
mengram import files *.md --cloud
```

### mengram api

Start a local REST API server.

```bash theme={null}
mengram api                    # default: 0.0.0.0:8420
mengram api --port 9000        # custom port
```

### mengram web

Start the Web UI with chat and knowledge graph visualization.

```bash theme={null}
mengram web                    # opens browser automatically
mengram web --port 9000        # custom port
mengram web --no-open          # don't open browser
```

## Environment Variables

| Variable          | Description                       |
| ----------------- | --------------------------------- |
| `MENGRAM_API_KEY` | Cloud API key (starts with `om-`) |
| `MENGRAM_URL`     | Custom API base URL               |
| `MENGRAM_USER_ID` | Default user\_id                  |
