cerebras-code-mentraos-mcp

RhizomaticRobin/cerebras-code-mentraos-mcp

3.2

If you are the rightful owner of cerebras-code-mentraos-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

MentraOS MCP Server is designed for smart glasses development, integrating with OpenCode CLI and powered by Cerebras for high-speed AI inference.

Tools
8
Resources
0
Prompts
0

MentraOS MCP Server

MCP server for MentraOS smart glasses development with OpenCode CLI integration.

A Model Context Protocol (MCP) server that provides specialized AI agents for MentraOS development, powered by high-speed inference from Cerebras.

Features

  • 8 Specialized Managers: WebSocket, Session, Display, App, SDK, Layout, Bluetooth, BLE Protocol
  • High-Speed Inference: 2000-3000 tokens/sec via Cerebras API
  • Structured Workflow: Explore → Plan → Execute → Verify
  • Claude Integration: Works seamlessly with Claude Code

Prerequisites

  • Node.js 18+
  • OpenCode CLI (npm install -g opencode)
  • Cerebras API key

Installation

# Clone the repository
git clone <repository-url>
cd cerebras-code-mentraos-mcp

# Run the installation script
./install.sh

Configuration

Add to Claude Code

claude mcp add mentraos-mcp \
  --command node \
  --args "/path/to/dist/index.js" \
  --args "-m" \
  --args "cerebras/zai-glm-4.6" \
  --env CEREBRAS_API_KEY=your-api-key

Or add to .mcp.json

{
  "mcpServers": {
    "mentraos-mcp": {
      "command": "node",
      "args": ["/path/to/dist/index.js", "-m", "cerebras/zai-glm-4.6"],
      "env": {
        "CEREBRAS_API_KEY": "your-api-key"
      }
    }
  }
}

Project Setup

Initialize a new project with MentraOS agents:

./init-project.sh /path/to/your/project

This creates:

  • opencode.json - Configuration with auto-approved permissions
  • .opencode/agent/ - Specialized agent files for each manager

Available Managers

ManagerUse For
websocket-managerWebSocket routing, JWT auth, connection handling
session-managerUserSession state, manager orchestration, lifecycle
display-managerDisplay throttling, boot screens, content routing
app-managerApp lifecycle, webhooks, running/loading state
sdk-session-managerThird-party SDK, event subscriptions, ResourceTracker
layout-managerContent formatting, ViewTypes, display requests
bluetooth-managerBLE communication, factory pattern, MTU negotiation
ble-protocol-managerProtobuf schema, message types, versioning

Usage with Claude

// Example: Implement WebSocket authentication
mcp__mentraos-mcp__websocket-manager(
  prompt="TASK: Add LiveKit transport preference to WebSocket upgrade",
  cwd="/path/to/project"
)

// Example: Add display feature
mcp__mentraos-mcp__display-manager(
  prompt="TASK: Implement priority display system for urgent notifications",
  cwd="/path/to/project"
)

// Example: SDK session feature
mcp__mentraos-mcp__sdk-session-manager(
  prompt="TASK: Add camera streaming to SDK AppSession",
  cwd="/path/to/project"
)

Project Structure

cerebras-code-mentraos-mcp/
├── .opencode/
│   └── agent/              # Specialist agent prompts
├── mentraos-managers/      # Reference documentation
│   ├── INDEX.md
│   ├── WEBSOCKET_SERVICE.md
│   ├── SESSION_MANAGER.md
│   ├── DISPLAY_MANAGER.md
│   ├── APP_MANAGER.md
│   ├── SDK_SESSION.md
│   ├── LAYOUT_MANAGER.md
│   ├── BLUETOOTH_MANAGER.md
│   └── BLE_PROTOCOL.md
├── src/
│   ├── index.ts            # MCP server entry point
│   ├── constants.ts        # Configuration
│   ├── tools/              # Tool implementations
│   └── utils/              # Utilities
├── ORCHESTRATION.md        # Claude orchestration guide
├── WORKING_INSTRUCTIONS.md
├── package.json
└── tsconfig.json

MentraOS Architecture

Smart Glasses (Android ASG Client)
    │
    │ BLE (Protobuf: PhoneToGlasses / GlassesToPhone)
    ▼
Mobile App (React Native + Expo)
    │
    │ WebSocket (JSON Messages)
    ▼
MentraOS Cloud Backend (Node.js/TypeScript)
    │
    │ WebSocket (SDK Messages)
    ▼
Third-Party Apps (Using MentraOS SDK)

Key Gotchas

  • WebSocketService: Singleton pattern, JWT verification at upgrade time
  • UserSession: Manager init order matters (subscriptionManager FIRST)
  • DisplayManager: 300ms throttle is sacred, CommitDisplay to render
  • AppManager: Loading vs Running are distinct states
  • SDK AppSession: ResourceTracker prevents memory leaks
  • BLE Protocol: Bump schema version on ANY change

Development

# Build
npm run build

# Run in development
npm run dev

# Type check
npm run lint

The Orchestration Pattern

This MCP server follows a specific workflow:

  1. Claude receives user request
  2. Claude breaks it into focused steps
  3. Claude calls appropriate manager MCP tool
  4. OpenCode executes with specialized agent
  5. Claude verifies the result
  6. Repeat until complete

See ORCHESTRATION.md for detailed orchestration instructions.

License

MIT