Standalone Server Quickstart
The create mastra CLI command is the quickest way to spin up a standalone Mastra server. It walks you through setup and creates example agents, workflows, and tools for you to run locally or adapt
If you need more control over the setup, see the manual installation guide. You can also use mastra init for existing projects.
Before you begin
- You'll need an API key from a supported model provider. If you don't have a preference, use OpenAI.
Initialize Mastra
You can run create mastra anywhere on your machine.
When prompted, choose a provider (e.g. OpenAI) and enter your key:
- npm
- pnpm
- yarn
- bun
npm create mastra@beta
pnpm create mastra@beta
yarn create mastra@beta
bun create mastra@beta
This creates a new directory for your project with a src/mastra folder containing an example weather agent and the following files:
index.ts- Mastra config, including memorytools/weather-tool.ts- a tool to fetch weather for a given locationagents/weather-agent.ts- a weather agent with a prompt that uses the tool
Test your agent
Once setup is complete, follow the instructions in your terminal to start the Mastra dev server, then open Studio at localhost:4111.
Try asking about the weather. If your API key is set up correctly, you'll get a response:
Studio lets you rapidly build and prototype agents without needing to build a UI. Once you're ready, you can integrate your Mastra agent into your app using the guides below.
Next steps
- Integrate Mastra with your frontend framework: Next.js, React, or Astro
- Read more about Mastra's features
- Build an agent from scratch following one of our guides
- Watch conceptual guides on our YouTube channel and subscribe