Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/mastra-ai/mastra/llms.txt

Use this file to discover all available pages before exploring further.

The Mastra CLI provides commands to create, develop, build, and deploy AI applications.

Installation

The CLI is installed automatically when you run:
npm create mastra@latest
Or install it globally:
npm install -g mastra

Commands

create

Create a new Mastra project with interactive setup.
mastra create [project-name]
Options:
--default
flag
Quick start with defaults (src, OpenAI, examples)
-c, --components
string
Comma-separated list of components to include
-l, --llm
string
Default model provider (openai, anthropic, google, etc.)
-k, --llm-api-key
string
API key for the model provider
-e, --example
flag
Include example code
-n, --no-example
flag
Do not include example code
-t, --timeout
number
Timeout for package installation in milliseconds (default: 60000)
-d, --dir
string
Target directory for Mastra source code (default: src/)
-p, --project-name
string
Project name for package.json
-m, --mcp
string
MCP Server for code editor (cursor, cursor-global, windsurf, vscode, antigravity)
--skills
string
Install Mastra agent skills (comma-separated)
--template
string
Create from template (name, GitHub URL, or blank for list)
Example:
mastra create my-app --llm openai --example

init

Initialize Mastra in an existing project.
mastra init
Options:
--default
flag
Quick start with defaults
-d, --dir
string
Directory for Mastra files (default: src/)
-c, --components
string
Comma-separated list of components
-l, --llm
string
Default model provider
-k, --llm-api-key
string
API key for the model provider
-e, --example
flag
Include example code
-m, --mcp
string
MCP Server for code editor

dev

Start the Mastra development server with interactive UI.
mastra dev
Options:
-d, --dir
string
Path to your mastra folder
-r, --root
string
Path to your root folder
-t, --tools
string
Comma-separated list of paths to tool files
-e, --env
string
Custom env file to include
-i, --inspect
string
Start in inspect mode ([host:]port, e.g., 0.0.0.0:9229)
-b, --inspect-brk
string
Start in inspect mode and break at beginning
-c, --custom-args
string
Custom arguments to pass to dev server
-s, --https
flag
Enable local HTTPS
--request-context-presets
string
Path to request context presets JSON file
--debug
flag
Enable debug logs
Example:
mastra dev --https --debug

build

Build your Mastra project for production.
mastra build
Options:
-d, --dir
string
Path to your Mastra folder
-r, --root
string
Path to your root folder
-t, --tools
string
Comma-separated list of paths to tool files
-s, --studio
flag
Bundle the studio UI with the build
--debug
flag
Enable debug logs
Example:
mastra build --studio

start

Start your built Mastra application.
mastra start
Options:
-d, --dir
string
Path to your built output directory (default: .mastra/output)
-e, --env
string
Custom env file to include
-c, --custom-args
string
Custom arguments to pass to Node.js process
Example:
mastra start --env .env.production

studio

Start the Mastra studio UI for managing agents and workflows.
mastra studio
Options:
-p, --port
string
Port to run the studio on (default: 3000)
-e, --env
string
Custom env file to include
-h, --server-host
string
Host of the Mastra API server (default: localhost)
-s, --server-port
string
Port of the Mastra API server (default: 4111)
-x, --server-protocol
string
Protocol of the Mastra API server (default: http)
--server-api-prefix
string
API route prefix (default: /api)
--request-context-presets
string
Path to request context presets JSON file
Example:
mastra studio --port 3001

lint

Lint your Mastra project for configuration and setup issues.
mastra lint
Options:
-d, --dir
string
Path to your Mastra folder
-r, --root
string
Path to your root folder
-t, --tools
string
Comma-separated list of paths to tool files

migrate

Run database migrations to update storage schema.
mastra migrate
Options:
-d, --dir
string
Path to your Mastra folder
-r, --root
string
Path to your root folder
-e, --env
string
Custom env file to include
--debug
flag
Enable debug logs
-y, --yes
flag
Skip confirmation prompt (for CI/automation)
Example:
mastra migrate --yes

scorers

Manage scorers for evaluating AI outputs.

scorers add

Add a new scorer to your project.
mastra scorers add [scorer-name]

scorers list

List available scorer templates.
mastra scorers list

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

Build docs developers (and LLMs) love