Skip to main content

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

This installs all dependencies for the cloud packages (cloud, sdk, utils, agents, apps).

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.
Here’s a complete example with all variables:

Essential vs Optional Variables

Essential for basic operation:
  • PORT=80 - Must be 80 for Docker port mapping to work
  • NODE_ENV, CLOUD_VERSION
  • MONGO_URL - MongoDB connection string
  • SUPABASE_* - All Supabase variables for authentication
  • AUGMENTOS_AUTH_JWT_SECRET - JWT signing secret
  • TPA_AUTH_JWT_PRIVATE_KEY - RSA key for app authentication
Required for specific features:
  • Transcription: AZURE_SPEECH_* or SONIOX_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

Internal team members can skip this section and get the configured .env from Slack.

MongoDB Setup

Option 1: Local MongoDB with Docker
Option 2: MongoDB Atlas (Recommended - Free Tier)
  1. Sign up at mongodb.com/atlas
  2. Create a free M0 cluster
  3. Add 0.0.0.0/0 to the IP whitelist (for development only)
  4. Create a database user with read/write access
  5. Get your connection string and add to MONGO_URL

Supabase Setup (Required)

  1. Create a project at supabase.com
  2. Go to Settings → API
  3. Copy:
    • Project URL → SUPABASE_URL
    • anon public key → SUPABASE_ANON_KEY
    • service_role secret key → SUPABASE_SERVICE_KEY and SUPABASE_SERVICE_ROLE_KEY
  4. Go to Settings → Database → Secrets
  5. Copy the JWT Secret → SUPABASE_JWT_SECRET

Azure Speech Setup (For Transcription)

  1. Create an Azure account with free credits
  2. Create a Speech Service resource
  3. Copy the key and region to AZURE_SPEECH_KEY and AZURE_SPEECH_REGION

LLM Provider Setup (Choose One)

Azure OpenAI:
  1. Request access to Azure OpenAI
  2. Deploy a GPT-4 model
  3. Copy credentials to the Azure OpenAI variables
OpenAI:
  1. Create account at platform.openai.com
  2. Generate API key → OPENAI_API_KEY
Anthropic:
  1. Create account at console.anthropic.com
  2. 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:
This:
  • 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
The PORT=80 in your .env file is critical. Docker expects the service to run on port 80 internally, which it then maps to 8002 externally. If you set a different PORT in .env, the service won’t be accessible.

What Docker Does

The docker-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

You’ll see output like:
Important: Copy the HTTPS URL (e.g., https://abc123.ngrok.app)

Step 6: Configure Mobile App

Enable Developer Mode

  1. Open the MentraOS mobile app
  2. Navigate to the Account page
  3. Tap on your account section 10 times quickly
  4. You’ll see a toast: “Developer mode activated”
  5. Force close and restart the mobile app

Configure Cloud URL

  1. After restart, go to Account section
  2. You’ll now see Developer Settings option
  3. Tap Developer Settings
  4. Find Cloud URL field
  5. Enter your ngrok URL with :443 suffix:
    Note: The :443 is required even though it’s the default HTTPS port.
  6. Tap Save or Apply
  7. 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/src automatically restart
  • WebSocket connections will reconnect automatically

Useful Commands

Testing with Real Glasses

  1. Connect glasses to mobile app as usual
  2. All communication now goes through your local cloud
  3. Monitor WebSocket messages in real-time:

Database Access

MongoDB (Local)
MongoDB Atlas

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

  1. Check ngrok is running and URL is correct
  2. Include :443 in the URL
  3. Force close and restart mobile app
  4. Check logs for authentication errors
  5. 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:
Features:
  • 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:
Features:
  • 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):
For Developer Console (cloud/developer-portal/src/services/api.service.ts):
2. Configure Supabase for authentication: Both portals use the same Supabase project as the cloud. They’ll automatically use the environment variables from your cloud .env file.

Access the Portals

  1. Store: http://localhost:5173
    • Sign in with your MentraOS account
    • Browse and install apps to your account
  2. 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

  1. Use multiple terminals:
    • Terminal 1: bun run dev (cloud server)
    • Terminal 2: ngrok http 8002 (tunnel)
    • Terminal 3: bun run logs:cloud -- -f (logs)
  2. VSCode debugging:
  3. 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

Remember: This setup is for development only. Production deployments require proper security, scaling, and monitoring configurations.