tessl install tessl/npm-mastra@1.0.5Command-line tool for creating, developing, and deploying AI-powered applications with the Mastra framework
Mastra CLI is a command-line tool for creating, developing, and deploying AI-powered applications built with the Mastra framework.
npm install -g mastra or use with npx mastramastra# Install globally
npm install -g mastra
# Create new project
mastra create my-app
# Start development
cd my-app
mastra dev| Command | Purpose | Key Options |
|---|---|---|
create [name] | Create new project | --default, --components, --llm |
init | Initialize in existing project | --components, --llm |
dev | Start development server | --https, --inspect, --debug |
build | Build for production | --studio, --debug |
start | Run production server | --env |
studio | Launch Mastra Studio UI | --port, --server-host |
lint | Validate configuration | --dir |
migrate | Run database migrations | --yes, --env |
scorers add | Add evaluation scorer | [scorer-name] |
scorers list | List available scorers | - |
→ Complete CLI Commands Reference
type Component = 'agents' | 'workflows' | 'tools' | 'scorers';
type LLMProvider = 'openai' | 'anthropic' | 'groq' | 'google' | 'cerebras' | 'mistral';⚠️ Important: Main entry point triggers CLI. Use alternate entry points:
// Safe imports - don't trigger CLI
import { PosthogAnalytics, getAnalytics, setAnalytics } from "mastra/analytics";
import { create } from "mastra/dist/commands/create/create";
// Create project programmatically
await create({
projectName: "my-app",
components: ["agents", "workflows"],
llmProvider: "openai",
addExample: true
});# Disable telemetry
MASTRA_TELEMETRY_DISABLED=1
# Server configuration
PORT=4111 # Default server port
HOST=localhost # Default server host
# Database
DATABASE_URL=postgresql://user:pass@host:port/db
# Debug logging
DEBUG=1 # Enable CLI debug logs
MASTRA_DEBUG=1 # Enable Mastra debug logs→ Complete Configuration Reference
# Interactive (recommended)
mastra create
# With options
mastra create my-app --default
mastra create my-app --components agents,workflows --llm openaicd my-app
npm install
mastra dev # Start dev server
mastra studio # Open Studio UI (different terminal)
mastra lint # Check configurationmastra build --studio # Build with UI
mastra start # Run production servermastra scorers list # See available scorers
mastra scorers add answer-relevancy0 // Success
1 // Error (validation failure, runtime error)
130 // Interrupted (Ctrl+C)| Error | Solution |
|---|---|
| "Port already in use" | PORT=8080 mastra dev or kill process |
| "Node.js version required" | Upgrade to Node.js >=22.13.0 |
| "Directory already exists" | Choose different name or remove directory |
| "Invalid component" | Use plural: agents, workflows, tools, scorers |
| "No mastra configuration" | Run mastra init or use --dir flag |
| "DATABASE_URL not set" | Set in .env or environment |
→ Complete Error Reference & Troubleshooting
mastra createmy-app/
├── package.json # With mastra dependency
├── .env # LLM API keys (if provided)
├── .gitignore # Standard Node.js ignores
└── src/ # Source directory (configurable)
└── mastra/ # Mastra configuration
├── index.ts # Main entry point
├── agents/ # AI agents (if selected)
├── workflows/ # Workflows (if selected)
├── tools/ # Tools (if selected)
└── scorers/ # Scorers (if selected)mastra build.mastra/
└── output/ # Production build
├── index.js # Bundled server
├── package.json # Runtime dependencies
└── studio/ # Studio UI (if --studio flag)// Valid
"my-app"
"my_app"
"@scope/my-app"
// Invalid
"my app" // No spaces
".hidden" // Can't start with .
"node_modules" // Reserved name// Valid
"agents,workflows,tools"
"scorers"
// Invalid
"agent" // Must be plural
"workflow" // Must be pluralexport MASTRA_TELEMETRY_DISABLED=1
export CI=1
npm install
mastra lint
mastra migrate --yes
mastra build --studioFROM node:22.13.0-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
ENV MASTRA_TELEMETRY_DISABLED=1
RUN npx mastra build --studio
ENV PORT=4111
ENV HOST=0.0.0.0
CMD ["npx", "mastra", "start"]→ Complete Integration Examples
// Detection priority
package-lock.json → npm
pnpm-lock.yaml → pnpm
yarn.lock → yarn
bun.lockb → bun// Search order
src/mastra/ → src/ → lib/mastra/ → mastra/ → .--timeout)Current Version: 1.0.1
Node.js Compatibility: >=22.13.0
Package Manager Compatibility:
MASTRA_TELEMETRY_DISABLED=1)Quick Links: