Agent Builder
A minimal Mastra Agent Builder template with safe defaults. It includes only the Mastra and Agent Builder setup, with no starter agents, tools, or workflows.
Features
- Agent Builder enabled by default
- WorkOS AuthKit authentication and WorkOS-backed RBAC permissions
- Local filesystem workspace at
.mastra/workspace - No starter agents, tools, or workflows
- Observational memory enabled for builder-created agents
- Optional providers only register when their environment variables are configured
Prerequisites
- Node.js 22.13 or newer
- An OpenAI API key
- A valid
MASTRA_EE_LICENSEfor Agent Builder - WorkOS AuthKit credentials for authentication/RBAC
Quickstart
-
Create the project
npx create-mastra@latest --template agent-builder -
Configure environment variables Copy
.env.exampleto.env, then set:MASTRA_EE_LICENSE— required; the template fails fast if it is missing or shorter than 32 characters.OPENAI_API_KEY— required for builder-created agents that use the default OpenAI model.WORKOS_API_KEY,WORKOS_CLIENT_ID, andWORKOS_COOKIE_PASSWORD— required for AuthKit login and RBAC. The cookie password must be at least 32 characters.WORKOS_REDIRECT_URI— defaults tohttp://localhost:4111/api/auth/callback.
-
Start Mastra
npm run dev -
Open Studio Visit localhost:4111 and open Agent Builder.
Optional integrations
The template does not register optional integrations with empty credentials. They appear only after you set their required environment variables:
- Composio: set
COMPOSIO_API_KEY. - Slack: set
SLACK_APP_CONFIG_TOKENandSLACK_APP_CONFIG_REFRESH_TOKEN.SLACK_BASE_URLis optional. - Browserbase + Stagehand: set both
BROWSERBASE_API_KEYandBROWSERBASE_PROJECT_ID.
Git credentials are not needed for the default template. The workspace uses the local filesystem, so there are no GIT_* or GITHUB_TOKEN requirements.
Making it yours
Edit the files under src/mastra to add your own resources and adjust the setup:
index.tsconfigures Mastra, Agent Builder, auth/RBAC, and optional providers.auth.tsconfigures WorkOS AuthKit and role-to-permission mappings.workspace.tsconfigures the local filesystem workspace.env.tscontains the environment variable helpers and license guard.
About Mastra templates
Mastra templates are ready-to-use projects that show what you can build with Mastra. They live in the Mastra monorepo and are synced to standalone repositories for easier cloning.