Skip to content
GitHub stars

CLI Reference

Global Flags

FlagDescription
--configPath to config file (default: ~/.msgvault/config.toml)
--homeHome directory for all data (overrides MSGVAULT_HOME)
-v, --verboseVerbose output
--localForce local database mode when [remote] is configured
--helpShow help

init-db

Initialize the SQLite database.

Terminal window
msgvault init-db

add-account

Add a Gmail account and authorize via OAuth.

Terminal window
msgvault add-account <email>
msgvault add-account <email> --headless
FlagDescription
--headlessShow instructions for headless server setup
--display-nameSet a display name for the account

sync-full

Download all messages from a Gmail account. When called without an email argument, syncs all configured accounts.

Terminal window
msgvault sync-full [email] [flags]
FlagDescription
--limit NMaximum messages to download
--after YYYY-MM-DDOnly messages after this date
--before YYYY-MM-DDOnly messages before this date
--queryGmail search query filter
--noresumeIgnore checkpoints, start fresh
--verboseDetailed progress output

sync

Sync new and changed messages using Gmail History API. When called without an email argument, syncs all accounts that have completed an initial full sync.

Terminal window
msgvault sync [email]

import-mbox

Import a local MBOX archive into msgvault.

Terminal window
msgvault import-mbox <identifier> <export-file>

The export file may be a plain .mbox/.mbx file or a .zip containing one or more MBOX files.

FlagDefaultDescription
--source-typemboxSource type recorded in database (e.g., hey for HEY.com)
--labelLabel to apply to all imported messages
--no-resumefalseStart fresh, ignoring interrupted progress
--checkpoint-interval200Save progress every N messages
--no-attachmentsfalseSkip writing attachments to disk

See Importing Local Email for usage examples.


import-emlx

Import Apple Mail .emlx files into msgvault.

Terminal window
msgvault import-emlx <identifier> <mail-dir>

The mail directory should be an Apple Mail mailbox tree containing .mbox or .imapmbox directories, each with a Messages/ subdirectory of .emlx files. You can also point directly at a single .mbox directory. Labels are derived from directory names.

FlagDefaultDescription
--source-typeapple-mailSource type recorded in database
--no-resumefalseStart fresh, ignoring interrupted progress
--checkpoint-interval200Save progress every N messages
--no-attachmentsfalseSkip writing attachments to disk

See Importing Local Email for usage examples.


Search the archive with Gmail-like query syntax.

Terminal window
msgvault search <query> [flags]
FlagDescription
-n, --limit NMaximum number of results (default: 50)
--offset NSkip first N results
--jsonOutput results as JSON

See Searching for the full operator reference.


tui

Launch the interactive terminal interface.

Terminal window
msgvault tui [flags]
FlagDescription
--force-sqlForce SQLite queries instead of Parquet
--no-cache-buildSkip automatic cache build/update

export-eml

Export a message as a .eml file. Accepts either a numeric database ID or a Gmail message ID.

Terminal window
msgvault export-eml <id> [flags]
FlagDescription
-o, --output <path>Output file (default: <gmail_id>.eml, use - for stdout)

export-attachment

Export an attachment by its SHA-256 content hash.

Terminal window
msgvault export-attachment <content-hash> [flags]
FlagDescription
-o, --output <path>Output file path (use - for stdout)
--base64Output raw base64 to stdout
--jsonOutput as JSON with base64-encoded data

The --json, --base64, and --output flags are mutually exclusive.

See Exporting Data for usage examples.


export-attachments

Export all attachments from a message as individual files.

Terminal window
msgvault export-attachments <message-id> [flags]
FlagDescription
-o, --output <dir>Output directory (default: current directory)

Accepts internal numeric IDs or Gmail message IDs. See Exporting Data for usage examples.


export-token

Export a browser-created OAuth refresh token to a remote msgvault instance.

Use this for headless deployments (NAS, cloud VM, any remote server) that cannot run a browser flow.

Terminal window
msgvault export-token <email> [flags]
FlagDescription
--to <url>Remote msgvault URL (or MSGVAULT_REMOTE_URL)
--api-key <key>API key (or MSGVAULT_REMOTE_API_KEY)
--allow-insecureAllow HTTP for trusted networks (for example Tailscale)

export-token uploads ~/.msgvault/tokens/<email>.json to /api/v1/auth/token/<email>, saves it in the remote token store, and posts account metadata to /api/v1/accounts.


verify

Verify local archive integrity against Gmail.

Terminal window
msgvault verify <email> [flags]
FlagDescription
--sample NMessages to sample (default: 100)

stats

Show archive statistics.

Terminal window
msgvault stats

list-senders

List top senders by message count.

Terminal window
msgvault list-senders [flags]
FlagDescription
-n, --limit NNumber of results (default: 50)
--after YYYY-MM-DDOnly messages after this date
--before YYYY-MM-DDOnly messages before this date
--jsonOutput as JSON

list-domains

List top sender domains by message count.

Terminal window
msgvault list-domains [flags]
FlagDescription
-n, --limit NNumber of results (default: 50)
--after YYYY-MM-DDOnly messages after this date
--before YYYY-MM-DDOnly messages before this date
--jsonOutput as JSON

list-labels

List all labels with message counts.

Terminal window
msgvault list-labels [flags]
FlagDescription
-n, --limit NNumber of results (default: 50)
--after YYYY-MM-DDOnly messages after this date
--before YYYY-MM-DDOnly messages before this date
--jsonOutput as JSON

build-cache

Build or update the Parquet analytics cache.

Terminal window
msgvault build-cache [flags]
FlagDescription
--full-rebuildDiscard existing cache and rebuild

cache-stats

Show statistics about the analytics cache.

Terminal window
msgvault cache-stats

mcp

Start the Model Context Protocol server for AI assistant integration.

Terminal window
msgvault mcp [flags]
FlagDefaultDescription
--force-sqlfalseAlways use SQL retrieval instead of FTS5

See MCP Server for configuration and tool reference.


serve

Start the web server with optional background sync scheduling.

Terminal window
msgvault serve

The serve command has no CLI flags. All configuration (port, bind address, API key, CORS, account schedules) is read from your config.toml. See Web Server for endpoint documentation and Configuration for config options.


setup

Run the first-run setup wizard for OAuth and optional remote deployment.

Terminal window
msgvault setup

If configured for a remote server, this command generates <MSGVAULT_HOME>/nas-bundle with:

  • config.toml ready for container deployment
  • client_secret.json
  • docker-compose.yml

The wizard also stores remote URL/API key in remote config block so export-token can use it without extra flags.


show-message

Show full message details.

Terminal window
msgvault show-message <id> [flags]
FlagDescription
--jsonOutput as JSON

list-accounts

List synced email accounts.

Terminal window
msgvault list-accounts [flags]
FlagDescription
--jsonOutput as JSON

update-account

Update account settings.

Terminal window
msgvault update-account <email> [flags]
FlagDescription
--display-nameSet a display name for the account

list-deletions

List pending and recent deletion batches.

Terminal window
msgvault list-deletions

show-deletion

Show details of a deletion batch.

Terminal window
msgvault show-deletion <batch-id>

cancel-deletion

Cancel pending or in-progress deletion batches. When called without a batch ID, lists available batches.

Terminal window
msgvault cancel-deletion [batch-id]
msgvault cancel-deletion --all
FlagDescription
--allCancel all pending and in-progress batches

delete-staged

Execute staged deletions. This permanently deletes messages from Gmail.

Terminal window
msgvault delete-staged [batch-id] [flags]
FlagDescription
-y, --yesSkip confirmation prompt
--trashMove to trash instead of permanent delete
--dry-runShow what would be deleted without deleting
-l, --listList staged deletion batches
--accountFilter to a specific account

repair-encoding

Fix UTF-8 encoding issues in existing messages.

Terminal window
msgvault repair-encoding

update

Update msgvault to the latest version.

Terminal window
msgvault update [flags]
FlagDescription
--checkCheck for updates without installing
-y, --yesSkip confirmation prompt
-f, --forceForce update even if already on the latest version

version

Print version, commit, build date, and platform information.

Terminal window
msgvault version

quickstart

Print a quickstart guide for AI agents.

Terminal window
msgvault quickstart