deployers/cloud/README.md
A cloud-optimized deployer for Mastra applications with built-in telemetry, logging, and storage integration.
pnpm add @mastra/deployer-cloud
The cloud deployer is used as part of the Mastra build process:
import { CloudDeployer } from '@mastra/deployer-cloud';
const deployer = new CloudDeployer();
// Bundle your Mastra application
await deployer.bundle(mastraDir, outputDirectory);
// The deployer automatically:
// - Adds cloud dependencies
// - Sets up instrumentation
// - Configures logging and storage
Automatically adds cloud-specific dependencies to your package.json:
@mastra/loggers - Cloud-optimized logging@mastra/libsql - Serverless SQL storage@mastra/cloud - Cloud platform utilitiesCreates a production-ready server entry point with:
Provides OpenTelemetry instrumentation for:
The deployer configures your application to use these environment variables:
# Storage Configuration
MASTRA_STORAGE_URL=your-libsql-url
MASTRA_STORAGE_AUTH_TOKEN=your-auth-token
# Logging Configuration
BUSINESS_API_RUNNER_LOGS_ENDPOINT=your-logs-endpoint
BUSINESS_JWT_TOKEN=your-jwt-token
# Studio Configuration
PLAYGROUND_JWT_TOKEN=your-playground-jwt-token
# Runtime Configuration
RUNNER_START_TIME=deployment-start-time
CI=true|false
# Deployment Metadata
TEAM_ID=your-team-id
PROJECT_ID=your-project-id
BUILD_ID=your-build-id
The deployer generates a server entry that:
Initializes Logging:
Configures Storage:
Registers Hooks:
ON_GENERATION - Tracks agent generation metricsON_EVALUATION - Stores evaluation resultsStarts Server:
After deployment, your project will have:
output/
├── package.json # With cloud dependencies
├── index.mjs # Main server entry
├── mastra.mjs # Your Mastra configuration
└── tools/ # Exported tools
The deployer includes structured readiness logs for monitoring:
{
"message": "Server starting|Server started|Runner Initialized",
"type": "READINESS",
"startTime": 1234567890,
"durationMs": 123,
"metadata": {
"teamId": "your-team-id",
"projectId": "your-project-id",
"buildId": "your-build-id"
}
}
The cloud deployer includes comprehensive tests covering:
Run tests with:
pnpm test
For local development:
# Build the deployer
pnpm build
# Run tests
pnpm test
# Lint code
pnpm lint