Skip to content

CLI Reference

Cortex provides a comprehensive CLI for managing memory primitives, running the MCP server, and performing maintenance operations.

These flags are available on all commands:

FlagDescription
--configPath to config file (default: ~/.cortex/config.yaml)
--namespaceNamespace for operations (default: default)
--verboseEnable verbose output
--jsonOutput in JSON format

Start the MCP server.

Terminal window
cortex serve [flags]

Flags:

FlagDescriptionDefault
--transportTransport mode: stdio or ssestdio
--portPort for SSE transport9810
--namespaceRestrict to a single namespace(all)

Examples:

Terminal window
# Start with stdio (default for Claude Desktop)
cortex serve
# Start with SSE for web clients
cortex serve --transport sse --port 9810
# Restrict to a specific namespace
cortex serve --namespace my-project

Ingest a single document.

Terminal window
cortex knowledge ingest [flags]

Flags:

FlagDescriptionRequired
--collectionTarget collection nameYes
--titleDocument titleYes
--filePath to fileYes
--chunk-strategyChunking: fixed, sentence, paragraph, semanticNo
--chunk-max-tokensMaximum tokens per chunkNo
--chunk-overlapToken overlap between chunksNo
--metadataJSON metadata to attachNo

Examples:

Terminal window
# Basic ingestion
cortex knowledge ingest \
--collection docs \
--title "User Guide" \
--file user-guide.md
# With chunking options
cortex knowledge ingest \
--collection docs \
--title "API Reference" \
--file api.md \
--chunk-strategy paragraph \
--chunk-max-tokens 1024
# With metadata
cortex knowledge ingest \
--collection docs \
--title "FAQ" \
--file faq.md \
--metadata '{"category": "support", "version": "2.0"}'

Bulk ingest files from a directory.

Terminal window
cortex knowledge ingest-dir [flags]

Flags:

FlagDescriptionRequired
--collectionTarget collection nameYes
--dirDirectory pathYes
--patternGlob pattern for filesNo
--recursiveInclude subdirectoriesNo

Examples:

Terminal window
# Ingest all markdown files
cortex knowledge ingest-dir \
--collection docs \
--dir ./documentation \
--pattern "*.md"
# Recursive with multiple patterns
cortex knowledge ingest-dir \
--collection code \
--dir ./src \
--pattern "*.go" \
--recursive

Search the knowledge store.

Terminal window
cortex knowledge search <query> [flags]

Flags:

FlagDescriptionDefault
--collectionLimit to collection(all)
--modeSearch mode: vector, fts, hybridhybrid
--limitMaximum results10
--thresholdMinimum similarity score0.0

Examples:

Terminal window
# Basic search
cortex knowledge search "how to configure authentication"
# Hybrid search in specific collection
cortex knowledge search "error handling" \
--collection docs \
--mode hybrid \
--limit 5

List collections.

Terminal window
cortex knowledge collections [flags]

Create a new collection.

Terminal window
cortex knowledge create-collection [flags]

Flags:

FlagDescriptionRequired
--nameCollection nameYes
--descriptionCollection descriptionNo

Show knowledge store statistics.

Terminal window
cortex knowledge stats [flags]

Add a message to a conversation.

Terminal window
cortex conversation append [flags]

Flags:

FlagDescriptionRequired
--thread-idConversation thread IDYes
--roleMessage role: user, assistant, system, toolYes
--contentMessage contentYes
--metadataJSON metadataNo

Examples:

Terminal window
cortex conversation append \
--thread-id support-123 \
--role user \
--content "I need help with my order"

Retrieve conversation history.

Terminal window
cortex conversation history [flags]

Flags:

FlagDescriptionDefault
--thread-idConversation thread IDRequired
--limitMaximum messages50
--beforeMessages before timestamp(none)
--afterMessages after timestamp(none)

Search across conversations.

Terminal window
cortex conversation search <query> [flags]

Flags:

FlagDescriptionDefault
--thread-idLimit to thread(all)
--limitMaximum results10

List conversation threads.

Terminal window
cortex conversation list [flags]

Summarize and compress conversation history.

Terminal window
cortex conversation summarize [flags]

Flags:

FlagDescriptionRequired
--thread-idThread to summarizeYes
--keep-recentMessages to keep uncompressedNo

Delete conversation history.

Terminal window
cortex conversation clear [flags]

Flags:

FlagDescriptionRequired
--thread-idThread to clearYes

Retrieve a value.

Terminal window
cortex context get <key> [flags]

Flags:

FlagDescription
--run-idScope to specific run

Store a value.

Terminal window
cortex context set <key> <value> [flags]

Flags:

FlagDescription
--ttlTime-to-live (e.g., 24h, 7d)
--run-idScope to specific run

Examples:

Terminal window
# Simple set
cortex context set "config/debug" "true"
# JSON value with TTL
cortex context set "cache/user-123" '{"name": "Alice"}' --ttl 1h

Merge values with strategy.

Terminal window
cortex context merge <key> <value> [flags]

Flags:

FlagDescriptionDefault
--strategyMerge strategy: replace, merge_shallow, merge_deep, appendreplace

List keys.

Terminal window
cortex context list [flags]

Flags:

FlagDescription
--prefixFilter by key prefix
--run-idScope to specific run

View version history.

Terminal window
cortex context history <key> [flags]

Delete a key.

Terminal window
cortex context delete <key> [flags]

Clean up expired or old context data.

Terminal window
cortex context cleanup [flags]

Flags:

FlagDescription
--expired-ttlRemove expired TTL values
--old-runsRemove old run-scoped values
--dry-runShow what would be deleted

List entities.

Terminal window
cortex entity list [flags]

Flags:

FlagDescription
--typeFilter by type: person, organization, location, concept, product, event
--sortSort by: name, mention_count, created_at
--limitMaximum results

Get entity details.

Terminal window
cortex entity get <id>

Semantic search for entities.

Terminal window
cortex entity search <query> [flags]

Create a new entity.

Terminal window
cortex entity create [flags]

Flags:

FlagDescriptionRequired
--nameEntity nameYes
--typeEntity typeYes
--descriptionDescriptionNo
--metadataJSON metadataNo

Add an alias to an entity.

Terminal window
cortex entity add-alias <id> [flags]

Flags:

FlagDescriptionRequired
--aliasAlias to addYes

Create a relationship between entities.

Terminal window
cortex entity add-relationship <source-id> <target-id> [flags]

Flags:

FlagDescriptionRequired
--typeRelationship type (e.g., works_at, knows, part_of)Yes
--metadataJSON metadataNo

Get entity relationships.

Terminal window
cortex entity relationships <id> [flags]

Flags:

FlagDescriptionDefault
--directionincoming, outgoing, or bothboth
--typeFilter by relationship type(all)

Merge duplicate entities.

Terminal window
cortex entity merge <keep-id> <remove-id>

Show entity extraction queue statistics.

Terminal window
cortex entity queue-stats

Run garbage collection.

Terminal window
cortex gc [flags]

Flags:

FlagDescription
--allRun all cleanup tasks
--dry-runShow what would be deleted

Create a database backup.

Terminal window
cortex backup [flags]

Flags:

FlagDescriptionRequired
--outputOutput file pathYes

Export namespace data to JSON.

Terminal window
cortex export [flags]

Flags:

FlagDescriptionRequired
--namespaceNamespace to exportYes
--outputOutput file pathYes

Show namespace statistics.

Terminal window
cortex namespace stats [flags]

Delete a namespace and all its data.

Terminal window
cortex namespace delete <namespace> [flags]

Flags:

FlagDescription
--forceSkip confirmation prompt

Launch the interactive terminal UI.

Terminal window
cortex tui [flags]

Flags:

FlagDescription
--namespaceDefault namespace to browse

Navigation:

KeyAction
1-5Switch sections
j/kMove up/down
EnterSelect item
/Search
qQuit