New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mastra

Package Overview
Dependencies
Maintainers
0
Versions
233
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mastra

cli for mastra

  • 0.2.6
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3.5K
increased by170.42%
Maintainers
0
Weekly downloads
 
Created
Source

The Mastra CLI

Mastra Cli

The Mastra CLI lets you initialize a new project, spin up a local dev server, and deploy it to serverless platforms like Vercel and Cloudflare Workers.

Installing the Mastra CLI

npm i -g mastra

Commands

Project Setup

# Initialize a new project
mastra init

Deployment

Mastra's data syncing infrastructure is designed for Next.js sites running on serverless hosting providers like Vercel or Netlify.

Logs are stored in Upstash.

Commands

Init

mastra init is used for initializing a new project.

This creates a mastra directory under src containing an index.ts entrypoint and an agent directory containing two sample agents.

project-root/
├── src/
   ├── app/
   └── mastra/
       ├── agents/
       │   └── agents.ts
       └── index.ts

Dev

mastra dev

This spins up a local development server that hosts REST endpoints for all agents and workflows. It also has a chat interface for testing them.

The server is useful for testing and developing agents, workflows, and integrations without needing to deploy your application.

The server is available at http://localhost:3000.

Build

mastra build

This command builds your Mastra project for deployment to different environments. The build process:

  1. Reads your Mastra configuration
  2. Generates optimized files for your target environment
  3. Outputs them to a build directory

Options:

--dir     Directory containing Mastra files (default: src/mastra)

Example usage:

# Build using default directory
mastra build

# Build from custom directory
mastra build --dir path/to/mastra

The build output is determined by your Mastra instance's deployer configuration:

const mastra = new Mastra({
  deployer: {
    type: 'HONO', // Target environment (HONO, EXPRESS, NEXT)
    // Environment-specific options
  },
});

Deploy

mastra deploy

This command deploys the mastra project to a serverless platform like Vercel or Cloudflare Workers.

The deploy command does the following:

  • Initializes the mastra project
  • Builds the project
  • Deploys the built project to the platform

Telemetry

This CLI collects anonymous usage data (no personal/sensitive info) to help improve Mastra. This includes:

  • Commands used
  • Command execution time
  • Error occurrences
  • System information (OS, Node version)

To opt-out:

  1. Add NO_MASTRA_TELEMETRY=1 to commands

Local development

  1. clone the repo
  2. Run pnpm i to install deps

Keywords

FAQs

Package last updated on 25 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc