Installation
The CLI is installed automatically when you run:Commands
create
Create a new Mastra project with interactive setup.Quick start with defaults (src, OpenAI, examples)
Comma-separated list of components to include
Default model provider (openai, anthropic, google, etc.)
API key for the model provider
Include example code
Do not include example code
Timeout for package installation in milliseconds (default: 60000)
Target directory for Mastra source code (default: src/)
Project name for package.json
MCP Server for code editor (cursor, cursor-global, windsurf, vscode, antigravity)
Install Mastra agent skills (comma-separated)
Create from template (name, GitHub URL, or blank for list)
init
Initialize Mastra in an existing project.Quick start with defaults
Directory for Mastra files (default: src/)
Comma-separated list of components
Default model provider
API key for the model provider
Include example code
MCP Server for code editor
dev
Start the Mastra development server with interactive UI.Path to your mastra folder
Path to your root folder
Comma-separated list of paths to tool files
Custom env file to include
Start in inspect mode ([host:]port, e.g., 0.0.0.0:9229)
Start in inspect mode and break at beginning
Custom arguments to pass to dev server
Enable local HTTPS
Path to request context presets JSON file
Enable debug logs
build
Build your Mastra project for production.Path to your Mastra folder
Path to your root folder
Comma-separated list of paths to tool files
Bundle the studio UI with the build
Enable debug logs
start
Start your built Mastra application.Path to your built output directory (default: .mastra/output)
Custom env file to include
Custom arguments to pass to Node.js process
studio
Start the Mastra studio UI for managing agents and workflows.Port to run the studio on (default: 3000)
Custom env file to include
Host of the Mastra API server (default: localhost)
Port of the Mastra API server (default: 4111)
Protocol of the Mastra API server (default: http)
API route prefix (default: /api)
Path to request context presets JSON file
lint
Lint your Mastra project for configuration and setup issues.Path to your Mastra folder
Path to your root folder
Comma-separated list of paths to tool files
migrate
Run database migrations to update storage schema.Path to your Mastra folder
Path to your root folder
Custom env file to include
Enable debug logs
Skip confirmation prompt (for CI/automation)
scorers
Manage scorers for evaluating AI outputs.scorers add
Add a new scorer to your project.scorers list
List available scorer templates.Environment Variables
The Mastra CLI respects these environment variables:MASTRA_ANALYTICS_ORIGIN- Analytics origin for telemetry- Model provider API keys (e.g.,
OPENAI_API_KEY,ANTHROPIC_API_KEY)
Next Steps
Installation
Set up Mastra in your project
Quickstart
Build your first agent
Development
Learn about the dev server
Deployment
Deploy to production