Adding to an Existing Project
You can add Mastra to an existing project using the CLI:
npm install -g mastra@latest
mastra init
Changes made to project:
- Creates
src/mastra
directory with entry point - Adds required dependencies
- Configures TypeScript compiler options
Interactive Setup
Running commands without arguments starts a CLI prompt for:
- Component selection
- LLM provider configuration
- API key setup
- Example code inclusion
Non-Interactive Setup
To initialize mastra in non-interactive mode use the following command arguments:
Arguments:
--components Specify components: agents, tools, workflows
--llm-provider LLM provider: openai, anthropic, or groq
--add-example Include example implementation
--llm-api-key Provider API key
--dir Directory for Mastra files (defaults to src/)
For more details, refer to the mastra init CLI documentation.