Skip to Content
ReferenceCLImastra init

mastra init

The mastra init command initializes Mastra in an existing project. Use this command to scaffold the necessary folders and configuration without generating a new project.

Usage

mastra init [options]

Options

--default?:

boolean
Quick start with defaults (src, OpenAI, no examples)

--dir:

string
Directory for Mastra files (defaults to src/)

--components:

string
Comma-separated list of components (agents, tools, workflows)

--llm:

string
Default model provider (openai, anthropic, groq, google or cerebras)

--llm-api-key:

string
API key for the model provider

--example?:

boolean
Include example code

--no-example?:

boolean
Do not include example code

--mcp:

string
MCP Server for code editor (cursor, cursor-global, windsurf, vscode)

--help?:

boolean
Display help for command

Advanced usage

Disable analytics

If you prefer not to send anonymous usage data then set the MASTRA_TELEMETRY_DISABLED=1 environment variable when running the command:

MASTRA_TELEMETRY_DISABLED=1 mastra init

Custom provider endpoints

Initialized projects respect the OPENAI_BASE_URL and ANTHROPIC_BASE_URL variables if present. This lets you route provider traffic through proxies or private gateways when starting the dev server later on.