Configuration
Cortex uses a hierarchical configuration system managed by the CLI. Configuration is minimal by default but offers extensive customization when needed.
This guide covers self-hosted configuration. Cortex Cloud will offer zero-config managed deployments—coming soon.
Configuration Hierarchy
The CLI uses a hierarchical configuration system (highest priority first):
--url, --key, --deployment (highest priority)
CONVEX_URL, CONVEX_DEPLOY_KEY
./cortex.config.json (optional)
~/.cortexrc (managed by CLI, lowest priority)
Example: How Priority Works
# User config (~/.cortexrc) says: local deployment
# Environment variable says: CONVEX_URL=http://127.0.0.1:3210
# CLI flag overrides everything:
cortex db stats --url https://prod.convex.cloud
# Result: Uses production URL from flag
User Configuration (~/.cortexrc)
The CLI automatically manages ~/.cortexrc for deployment settings.
Viewing Configuration
$ cortex config show$ cortex config list$ cortex config pathConfiguration File Format
The ~/.cortexrc file is JSON:
{
"deployments": {
"local": {
"url": "http://127.0.0.1:3210",
"deployment": "anonymous:anonymous-cortex-sdk-local",
"projectPath": "/Users/you/projects/my-agent",
"enabled": true
},
"staging": {
"url": "https://staging.convex.cloud",
"key": "dev:staging|key",
"projectPath": "/Users/you/projects/my-agent",
"enabled": false
},
"production": {
"url": "https://prod.convex.cloud",
"key": "prod:prod|key",
"projectPath": "/Users/you/projects/my-agent",
"enabled": false
}
},
"apps": {
"quickstart": {
"type": "nextjs",
"projectPath": "/Users/you/projects/my-agent",
"path": "quickstart",
"port": 3000,
"startCommand": "npm run dev",
"enabled": true
}
},
"default": "local",
"format": "table",
"confirmDangerous": true
}
Configuration Fields
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
deployments | object | Yes | — | Named deployment configurations |
deployments[name].url | string | Yes | — | Convex deployment URL |
deployments[name].key | string | No | — | Deploy key (optional for local) |
deployments[name].deployment | string | No | — | Convex deployment name |
deployments[name].projectPath | string | No | — | Path to project directory |
deployments[name].enabled | boolean | No | false | Auto-start with cortex start |
apps | object | No | — | Named app configurations |
apps[name].type | string | No | — | App type (e.g., 'nextjs') |
apps[name].port | number | No | — | Port number |
apps[name].startCommand | string | No | — | Command to start app |
default | string | No | — | Default deployment name |
format | string | No | table | Default output format |
confirmDangerous | boolean | No | true | Require confirmation for dangerous operations |
Managing Deployments
Adding Deployments
Interactive mode (recommended)
$ cortex config add-deploymentWith options
$ cortex config add-deployment cloud --url https://your-app.convex.cloud --key "prod|..."Set as default
$ cortex config add-deployment production --url https://prod.convex.cloud --defaultRemoving Deployments
$ cortex config remove-deployment$ cortex config remove-deployment stagingCannot remove the default deployment. Set a different default first.
Updating Deployment Settings
$ cortex config set-url production --url https://new-prod.convex.cloud$ cortex config set-key production --key "prod|new-key"$ cortex config set-path production /path/to/projectEnabling/Disabling Deployments
Control which deployments start with cortex start:
$ cortex config enable staging$ cortex config disable production$ cortex config listSwitching Deployments
$ cortex use$ cortex use production$ cortex use --clearTesting Configuration
You can verify your configuration by checking the connection:
$ cortex config show$ cortex db statsEnvironment Variables
Convex Configuration
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
CONVEX_URL | string | Yes | — | Convex deployment URL |
CONVEX_DEPLOY_KEY | string | No | — | Convex deploy key |
CONVEX_DEPLOYMENT | string | No | — | Convex deployment name |
LOCAL_CONVEX_URL | string | No | http://127.0.0.1:3210 | Local Convex URL |
CLOUD_CONVEX_URL | string | No | — | Cloud Convex URL |
CLOUD_CONVEX_DEPLOY_KEY | string | No | — | Cloud deploy key |
Graph Database Configuration
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
NEO4J_URI | string | No | — | Neo4j connection URI |
NEO4J_USERNAME | string | No | — | Neo4j username |
NEO4J_PASSWORD | string | No | — | Neo4j password |
MEMGRAPH_URI | string | No | — | Memgraph connection URI |
MEMGRAPH_USERNAME | string | No | — | Memgraph username |
MEMGRAPH_PASSWORD | string | No | — | Memgraph password |
CORTEX_GRAPH_SYNC | string | No | — | Enable automatic graph sync for all operations ('true'/'false'). When true, all facts, entities, and relationships are automatically synced to the graph database (v0.29.0+) |
Other Configuration
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
OPENAI_API_KEY | string | No | — | OpenAI API key for embeddings |
CORTEX_SDK_DEV_PATH | string | No | — | Path to local SDK for dev mode |
DEBUG | string | No | — | Enable debug output |
Example .env.local
# Convex Configuration
CONVEX_URL=http://127.0.0.1:3210
# Optional: Graph Database
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=password
# Optional: Embeddings
OPENAI_API_KEY=sk-your-key-here
Use cortex dev for hot-reload development.
# Convex Configuration
CONVEX_URL=https://your-staging-app.convex.cloud
CONVEX_DEPLOY_KEY=dev:your-staging-app|key
# Optional: Graph Database
NEO4J_URI=bolt://staging-neo4j:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=staging-password
# Optional: Embeddings
OPENAI_API_KEY=sk-your-key-here
# Convex Configuration
CONVEX_URL=https://your-prod-app.convex.cloud
CONVEX_DEPLOY_KEY=prod:your-prod-app|key
# Optional: Graph Database
NEO4J_URI=bolt://prod-neo4j:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=secure-production-password
# Optional: Embeddings
OPENAI_API_KEY=sk-your-key-here
Never commit production credentials to version control!
Multi-Environment Setup
Example: Local + Staging + Production
Add local development
$ cortex config add-deployment local --url http://127.0.0.1:3210$ cortex config set-path local ~/projects/my-agentAdd staging
$ cortex config add-deployment staging --url https://staging.convex.cloud$ cortex config set-key stagingAdd production
$ cortex config add-deployment production --url https://prod.convex.cloud$ cortex config set-key productionEnable only local for auto-start
$ cortex config enable local$ cortex config disable staging$ cortex config disable productionNow cortex start starts only local. Use cortex start -d staging or cortex start -d production for other environments.
Switching Between Environments
$ cortex use local$ cortex use production$ cortex db stats -d stagingProject Configuration (Optional)
cortex.config.json
You can optionally create a cortex.config.json in your project root:
{
"defaultMemorySpace": "my-agent",
"defaultImportance": 50,
"memoryRetention": {
"maxVersions": 10,
"retentionDays": 365
},
"graph": {
"enabled": true,
"uri": "bolt://localhost:7687"
}
}
This is optional. Most configuration is managed via CLI in ~/.cortexrc.
SDK Configuration
When using the SDK programmatically, configuration is minimal:
import { Cortex } from "@cortexmemory/sdk";
// Minimal configuration
const cortex = new Cortex({
convexUrl: process.env.CONVEX_URL!, // Set by CLI or .env.local
});
With Graph Database
import {
CypherGraphAdapter,
initializeGraphSchema,
} from "@cortexmemory/sdk/graph";
const graphAdapter = new CypherGraphAdapter();
await graphAdapter.connect({
uri: process.env.NEO4J_URI!,
username: process.env.NEO4J_USERNAME!,
password: process.env.NEO4J_PASSWORD!,
});
await initializeGraphSchema(graphAdapter);
const cortex = new Cortex({
convexUrl: process.env.CONVEX_URL!,
graph: {
adapter: graphAdapter,
orphanCleanup: true,
},
});
See:
Security Configuration
Data Isolation
Ensure proper memory space boundaries:
$ cortex memory list --space user-alice$ cortex memory list --space user-bobSensitive Data
Be careful with personally identifiable information (PII).
$ cortex memory search "password" --space user-123$ cortex memory export --space user-123 --output review.json$ cortex memory delete [memoryId] --space user-123Advanced Configuration
Debug Mode
Enable verbose logging:
$ cortex db stats --debug$ DEBUG=1 cortex db statsCustom Output Formats
$ cortex db stats$ cortex db stats --format json$ cortex memory list --space user-123 --format csvConfiguration Reset
This removes all deployments and apps but keeps project .env.local files and deployed Convex data.
$ cortex config resetBest Practices
- Use environment variables - Never hardcode URLs or keys
- Separate environments - Use
cortex use local|staging|production - Secure credentials - Use
cortex config set-key(prompts securely), add.env.localto.gitignore - Test before production - Always verify on staging first
- Regular backups - Run
cortex db backupbefore major changes
Troubleshooting
$ cortex init$ cortex config add-deployment$ cortex use$ cortex use local$ cortex use --clear$ cortex config show$ cortex db stats$ cortex status && cortex start$ cortex config show --debugPriority: CLI flags > Environment variables > ~/.cortexrc