Overview
This guide helps you set up MentraOS Cloud on your local machine for development. You’ll learn how to configure the environment, expose your local server using ngrok, and connect the mobile app to your development cloud instance.Prerequisites
Before starting, ensure you have:- Bun installed (install.bun.sh)
- Docker and Docker Compose installed
- ngrok account and CLI (ngrok.com)
- Git for cloning the repository
- MentraOS mobile app installed on your phone
- A MentraOS account
Step 1: Clone and Setup
Clone the Repository
Install Dependencies
Step 2: Environment Configuration
Create .env File
Create a.env file in the cloud directory.
For Internal Team Members: Ask on Slack for the current
.env file with all API keys configured.For External Contributors: You’ll need to set up accounts with all third-party services listed below to run the cloud successfully.Essential vs Optional Variables
Essential for basic operation:PORT=80- Must be 80 for Docker port mapping to workNODE_ENV,CLOUD_VERSIONMONGO_URL- MongoDB connection stringSUPABASE_*- All Supabase variables for authenticationAUGMENTOS_AUTH_JWT_SECRET- JWT signing secretTPA_AUTH_JWT_PRIVATE_KEY- RSA key for app authentication
- Transcription:
AZURE_SPEECH_*orSONIOX_API_KEY - AI features: LLM configuration (Azure OpenAI, OpenAI, or Anthropic)
- Email:
RESEND_API_KEY - Video streaming:
CLOUDFLARE_* - Web search:
SERPAPI_API_KEY - TTS:
ELEVENLABS_*
Generating Secrets
For External Contributors: Setting up Services
MongoDB Setup
Option 1: Local MongoDB with Docker- Sign up at mongodb.com/atlas
- Create a free M0 cluster
- Add
0.0.0.0/0to the IP whitelist (for development only) - Create a database user with read/write access
- Get your connection string and add to
MONGO_URL
Supabase Setup (Required)
- Create a project at supabase.com
- Go to Settings → API
- Copy:
- Project URL →
SUPABASE_URL anonpublic key →SUPABASE_ANON_KEYservice_rolesecret key →SUPABASE_SERVICE_KEYandSUPABASE_SERVICE_ROLE_KEY
- Project URL →
- Go to Settings → Database → Secrets
- Copy the JWT Secret →
SUPABASE_JWT_SECRET
Azure Speech Setup (For Transcription)
- Create an Azure account with free credits
- Create a Speech Service resource
- Copy the key and region to
AZURE_SPEECH_KEYandAZURE_SPEECH_REGION
LLM Provider Setup (Choose One)
Azure OpenAI:- Request access to Azure OpenAI
- Deploy a GPT-4 model
- Copy credentials to the Azure OpenAI variables
- Create account at platform.openai.com
- Generate API key →
OPENAI_API_KEY
- Create account at console.anthropic.com
- Generate API key →
ANTHROPIC_API_KEY
Other Services (Optional)
- Resend (Email): Sign up at resend.com
- Cloudflare Stream (Video): Requires paid Cloudflare account
- SerpAPI (Search): Sign up at serpapi.com
- PostHog (Analytics): Sign up at posthog.com
- Sentry (Error tracking): Sign up at sentry.io
Step 3: Start the Cloud with Docker
The cloud runs in Docker with all dependencies:- Builds and starts the cloud service in Docker
- Maps internal port 80 (from .env) to external port 8002 (from docker-compose.dev.yml)
- Mounts your code for hot reloading
- Installs dependencies and builds the SDK
What Docker Does
Thedocker-compose.dev.yml file:
- Creates a container for the cloud service
- Mounts your local code into
/app - Shares bun dependencies in a Docker volume
- Runs:
bun install && cd packages/sdk && bun run build && cd ../cloud && bun install && bun run dev
Verify Services
Step 4: Start the Cloud Server
Verify Cloud is Running
Step 5: Expose with ngrok
To connect from the mobile app, expose your local server using ngrok:Install ngrok
Configure ngrok (First Time)
Start ngrok Tunnel
https://abc123.ngrok.app)
Step 6: Configure Mobile App
Enable Developer Mode
- Open the MentraOS mobile app
- Navigate to the Account page
- Tap on your account section 10 times quickly
- You’ll see a toast: “Developer mode activated”
- Force close and restart the mobile app
Configure Cloud URL
- After restart, go to Account section
- You’ll now see Developer Settings option
- Tap Developer Settings
- Find Cloud URL field
-
Enter your ngrok URL with
:443suffix:Note: The:443is required even though it’s the default HTTPS port. - Tap Save or Apply
- The app will reconnect to your local cloud
Verify Connection
Watch your cloud logs:Step 7: Development Workflow
Hot Reloading
The development server supports hot reloading:- Code changes in
packages/cloud/srcautomatically restart - WebSocket connections will reconnect automatically
Useful Commands
Testing with Real Glasses
- Connect glasses to mobile app as usual
- All communication now goes through your local cloud
- Monitor WebSocket messages in real-time:
Database Access
MongoDB (Local)Common Issues & Solutions
Port 8002 Already in Use
Docker Connection Refused
ngrok Session Expired
- Free ngrok sessions expire after 2 hours
- Restart ngrok and update mobile app URL
- Consider ngrok paid plan for stable domain
Mobile App Can’t Connect
- Check ngrok is running and URL is correct
- Include :443 in the URL
- Force close and restart mobile app
- Check logs for authentication errors
- Verify .env has correct JWT secrets
Step 8: Run Web Portals (Store & Developer Console)
MentraOS includes two web applications for app management:MentraOS Store
The public app store where users discover and install apps:- Browse available apps
- View app details and permissions
- Install/uninstall apps
- Search and filter apps
- User authentication
Developer Console
Portal for developers to create and manage their apps:- Create new apps
- Configure app settings and permissions
- Manage API keys
- Submit apps for review
- View analytics and usage
- Organization management
- Member invitations
Configure Portals for Local Development
Both portals need to connect to your local cloud: 1. Update API endpoints in code: For Store (cloud/store/web/src/api/index.ts):
cloud/developer-portal/src/services/api.service.ts):
.env file.
Access the Portals
-
Store: http://localhost:5173
- Sign in with your MentraOS account
- Browse and install apps to your account
-
Developer Console: http://localhost:5174
- Sign in with your developer account
- Create and manage your apps
- Get API keys for testing
Create Test Data
Step 9: Tips for Productive Development
-
Use multiple terminals:
- Terminal 1:
bun run dev(cloud server) - Terminal 2:
ngrok http 8002(tunnel) - Terminal 3:
bun run logs:cloud -- -f(logs)
- Terminal 1:
-
VSCode debugging:
-
Git workflow:
Security Reminders
- Never commit .env files
- Don’t share ngrok URLs with sensitive data
- Use strong JWT secrets in production
- Rotate secrets regularly
Next Steps
- Review Cloud Architecture
- Understand Message Types
- Learn about UserSession
- Join Discord for help