← Back to Docs

Host Mode

Host mode runs on your main development machine where your AI coding CLI is installed. It manages CLI sessions and shares them with connected client devices.

What is Host Mode?

In host mode, MobileCLI:

  • Launches and manages AI coding CLI processes (Claude Code, Gemini CLI, Codex, OpenCode)
  • Runs a WebSocket server for client connections
  • Stores conversation history in a local SQLite database
  • Syncs session state to all connected clients in real-time
  • Works seamlessly with Tailscale for secure remote access

Setting Up Host Mode

1. Select Host Mode

Run mobilecli setup to configure host mode. If you've already completed setup, run mobilecli setup again or use mobilecli --host.

2. Configure CLI Paths

MobileCLI auto-detects installed CLIs. Verify the paths are correct:

# Default locations
Claude Code: ~/.claude/local/claude
Gemini CLI: ~/.local/bin/gemini
Codex: ~/.local/bin/codex
OpenCode: ~/.local/bin/opencode

3. Start the WebSocket Server

The WebSocket server starts when you run mobilecli or mobilecli setup. By default, it listens on port 9847.

Local Network: ws://[your-local-ip]:9847

Connecting Clients

There are two ways to connect client devices to your host:

QR Code Pairing

The fastest method. Run mobilecli pair to display a QR code, then scan it with your mobile device.

Recommended

Manual Connection

Enter the WebSocket URL and authentication token manually in the client app settings.

Security

Host mode uses several security measures:

  • Token Authentication: Clients must present a valid token to connect
  • Transport: Session data stays on your local network or Tailnet
  • Session Isolation: Each pairing creates a unique session key

Managing Sessions

From the host, you can:

  • Create new sessions with different CLIs and working directories
  • View all active and archived sessions
  • Send input to any session (even from connected clients)
  • Monitor real-time output from CLI processes
  • Terminate sessions when done