Skip to main content
The Narrator CLI provides database management tools for the Narrator storage system. It includes commands for initializing database tables and checking database status.

Installation

The Narrator CLI is automatically installed when you install the Narrator package:
After installation, the narrator command will be available (run with uv run narrator if using uv).

Commands

Database Commands

narrator init

Initialize database tables for thread and message storage:
This command creates the necessary database tables:
  • threads - Stores conversation threads
  • messages - Stores messages within threads

narrator status

Check database connection and display basic statistics:
The status command shows:
  • Database connection status
  • Number of recent threads
  • Basic health check information

Docker Commands

narrator docker-setup

One-command setup that starts PostgreSQL and initializes tables:
This command:
  1. Starts a PostgreSQL container with the correct configuration
  2. Waits for the database to be ready
  3. Initializes the required tables
  4. Provides the connection string to use

narrator docker-start

Start a PostgreSQL container for Narrator:

narrator docker-stop

Stop the PostgreSQL container:

Quick Start with Docker

The fastest way to get started with PostgreSQL for Narrator:
That’s it! Your database is ready to use.

Configuration

Environment Variables

The Narrator CLI respects these environment variables:

Database Connection

Docker Configuration

These variables affect the docker-* commands:

Connection Pool Settings

For PostgreSQL connections:

Database URLs

Narrator supports different database backends:

Examples

Local Development Setup

Custom Docker Configuration

Production Setup

CI/CD Pipeline

Integration with Tyler

When using Tyler agents with persistent storage:

Troubleshooting

Connection Errors

“Failed to connect to database”: Check your database URL and ensure the database server is running:
“No such command ‘init’”: Make sure you’re using the correct command:

Permission Errors

“Permission denied”: Ensure your database user has CREATE TABLE permissions:

Migration Issues

“Table already exists”: The init command is idempotent and will skip existing tables. This is not an error.

Environment Variable Issues

“No database URL provided”: Set the environment variable:

Best Practices

  1. Always initialize before use: Run narrator init before using ThreadStore with a database
  2. Use environment variables: Avoid hardcoding database URLs in your code
  3. Use connection pooling: For production, configure pool settings appropriately
  4. Regular backups: Set up automated backups for production databases
  5. Monitor connections: Keep an eye on connection pool usage in production

Advanced Usage

Custom Database Configuration

Create a .env file for your project:
Then load it in your application:

Database Migrations

For schema changes between Narrator versions:

Next Steps

ThreadStore API

Learn about the ThreadStore API

Conversation Persistence

Build agents with persistent memory

Tyler CLI

Create and chat with agents

Production Deployment

Deploy agents to production