The Mastra CLI
The Mastra CLI has the following commands:
mastra init
This initializes your project, creating a number of different files, including mastra.config.ts
, mastra.docker-compose.yaml
, and adding a .env.development
file for storing your environment variables.
This prompts you for your Postgres and Inngest connection strings, and spins up a Docker container with the resources you don’t have.
mastra migrate
This migrates your Postgres database to add Mastra’s schema to it so it can store synced records. This might be needed after updating mastra or to provision a new database.
mastra dev
This spins up the Mastra admin console, which you can use to create agents, install integrations, manage synced records, and trigger workflows.
You can pass in a -e
or --env
flag with the namve of another env file (e.g. “production” to reference “.env.production”). This makes it easy to switch between different environments within the admin console.
mastra generate
This generates (or regenerates) the Typescript types and Drizzle client. You might need to run this after updating mastra.
mastra up
This is a shortcut that runs the docker-compose up command using the mastra.docker-compose.yaml file. This will spin up any local docker containers that mastra needs.
mastra build
This builds the admin console and is useful if you would like to deploy the admin console to a hosting provider.
IMPORTANT: There are currently no authentication measures within admin so please make sure to password-protect or secure your deployed site.