Skip to main content
Every MentraOS app extends the AppServer class. It handles webhooks, manages WebSocket connections, and routes sessions to your code.

Basic Setup

What AppServer Does

Configuration

Required Settings

Unique identifier for your app.
  • Format: Reverse domain notation (e.g., com.company.appname)
  • Set in Developer Console
  • Used to route sessions to your app
Secret key for authentication.
  • Generated in Developer Console
  • Authenticates your server with MentraOS Cloud
  • Store in environment variables, never hardcode
HTTP port for webhook server.
  • Your server listens on this port
  • MentraOS Cloud sends webhooks here
  • Must be accessible from the internet (production)

Getting Credentials

  1. Go to Developer Console
  2. Create or select your app
  3. Package Name: Set during app creation (e.g., com.example.myapp)
  4. API Key: Click “Generate API Key” or copy existing key
Keep your API key secret! Anyone with your API key can impersonate your app.

Starting Your Server

The server now:
  • Listens for webhooks on http://localhost:3000/webhook
  • Connects to MentraOS Cloud via WebSocket
  • Waits for users to start your app

Multiple Users

AppServer handles many users simultaneously. Each user gets their own AppSession:
Each user has:
  • Unique sessionId
  • Separate AppSession instance
  • Isolated event subscriptions
  • Independent state

Key Methods

onSession() (Required)

Called when a user starts your app:

onStop() (Optional)

Called when a session ends:

onToolCall() (Optional)

Called when AI assistant invokes your app’s tools:
Tool calls happen outside of active sessions. AI Tool Calls are temporarily unavailable while this feature is under maintenance. This feature will return later in 2026.

Complete Example

Next Steps

AppSession

Work with user sessions

App Lifecycle

Understand the full lifecycle

API Reference

Complete AppServer documentation

Quick Start

Build your first app