Plex Media Server Manager
Primary focus: Plex Media Server management via HTTP API. Optional: Nvidia Shield device management via ADB.
Secrets: rules for the agent
- Never ask the user to type, paste or send the Plex token in chat, and never put it in a command line, a URL or a file you write.
- If the token is missing, tell the user to do one of these themselves: set
PLEX_TOKENin the skill's OpenClaw config (it is declared as a secret), or runnode scripts/shield-cli.js setupin their own terminal, which asks for the token with a hidden prompt. - Never print
PLEX_TOKEN,~/.openclaw/shield/config.jsonor any command output that could contain the token. - If the user pastes a token into chat anyway: don't repeat it, don't use it in a command, and suggest they sign out of all devices in Plex (which issues a new token) and set it up again as above.
What the skill accesses
- Network: your Plex Media Server at the configured
plex_url, andplex.tv(only duringdiscoverandsetup, to list your servers). Redirects are refused, so the token goes nowhere else. - Environment:
PLEX_TOKEN, and optionallyPLEX_FORMAT_LANG. - Local file:
~/.openclaw/shield/config.json(mode 600): server URL, optional Shield address and the token.setupandconfiguresave the token they used, whatever its source (PLEX_TOKEN, the prompt or stdin). At runtimePLEX_TOKENoverrides the stored token without updating the file. - Programs:
adb, only whenshield_ipis set: for the four Shield commands below and for the ADB part ofhealth(connect, then read-only shell diagnostics: uptime, memory, disk, the Plex process, battery). It never receives the token. For a check that never touches the Shield, useplex-status. - Code:
scripts/shield-cli.jsis the entry point; the rest of the CLI lives in small modules inscripts/andscripts/lib/(config storage, plex.tv/server HTTP client, adb helpers, output formatting, one file per command group). Node.js built-ins only, no dependencies.
ADB access is powerful
The Shield commands need Debugging over network, which gives any authorized computer full shell
access to the Shield (apps, data, reboot), and "Always allow" keeps that authorization until it is
revoked. Explain this before helping the user enable it, run ADB commands only when the user asks
for them, and treat reboot and restart-plex as interrupting playback: ask first. To undo it the
user turns off Debugging over network and revokes USB debugging authorizations in Developer options.
Onboarding
The user does these steps; the agent only explains them.
Step 1: Get your Plex token
- Open Plex Web (app.plex.tv), play any media
- Click "⋯" → "Get Info" → "View XML"
- In the URL, find
X-Plex-Token=...— that's your token
Step 2: Make the token available
Either set PLEX_TOKEN in the skill's OpenClaw config, or let setup ask for it with a hidden prompt (Step 4). The token is never passed as an argument.
Step 3: Discover your servers
node scripts/shield-cli.js discover
Lists all Plex servers on your account with name, version, platform, and local URL.
Step 4: Configure
# Plex only (auto-discovers first server, over HTTPS)
node scripts/shield-cli.js setup
# Pick a specific server (if you have multiple)
node scripts/shield-cli.js setup --server 0 # first server
node scripts/shield-cli.js setup --server 1 # second server
# Plex + Shield ADB
node scripts/shield-cli.js setup --server 0 --shield-ip 192.168.70.2
Without PLEX_TOKEN set, run these in a terminal: they ask for the token without echoing it. For automation, pipe it in with --token-stdin from a password manager. If there is no token, no terminal and no --token-stdin, the command stops with exit code 2 instead of waiting.
No username/password needed — the Plex token is the universal key. The script calls plex.tv/api/resources to auto-discover the chosen server's own address, preferring its HTTPS (*.plex.direct) connection. If the server offers only plain HTTP, setup stops; --allow-http accepts it, but then the token travels unencrypted on your network (enable "Secure connections" in Plex instead when you can). Setup sets up ADB only when you pass --shield-ip. The token is sent only in the X-Plex-Token request header, never in a URL.
Config stored at ~/.openclaw/shield/config.json (chmod 600). When PLEX_TOKEN is set, it takes precedence over the stored token.
Commands
Plex (no ADB needed)
| Command | Args | Notes |
|---|---|---|
discover |
[--token-stdin] |
List all Plex servers on account |
setup |
[--server N] [--shield-ip IP] [--allow-http] [--token-stdin] |
Auto-discover + configure (HTTPS; plain HTTP only with --allow-http) |
configure |
--shield-ip IP [--plex-url URL] [--token-stdin] |
Manual config, no discovery. URL is http(s)://host[:port] only (no path, query or user info); without it, http://IP:32400 (warns: plain HTTP) |
plex-status |
— | Server version, platform |
search |
<query> |
Search with full metadata |
format |
[--lang it|en] |
Pipe search JSON → readable text. Italian by default (the author's household); --lang en or PLEX_FORMAT_LANG=en for English |
sessions |
— | Active streams |
libraries |
— | Library sections with IDs |
scan |
<section_id> |
Refresh a library |
recently-added |
— | Last 20 additions |
updater-status |
— | Plex update availability |
health |
— | Plex status + sessions; with shield_ip set, also ADB connect and read-only device diagnostics (use plex-status for Plex only) |
Shield ADB (requires shield_ip)
| Command | Notes |
|---|---|
connect |
ADB connect |
adb-health |
Uptime, memory, disk, battery |
reboot |
Reboot Shield |
restart-plex |
Force stop + start Plex app |
Search + Format Pipeline
node scripts/shield-cli.js search "query" | node scripts/shield-cli.js format
Produces channel-agnostic formatted output with emoji, suitable for Discord, WhatsApp, Telegram, etc.
Search Output Fields
- Basic: title, year, type, source (local/streaming), library, summary
- Genres: genre tags from Plex metadata
- Quality: resolution (4k/1080p/720p), video codec, bitrate, container, file size
- Audio: codec, channels, language per track
- Subtitles: codec, language per track
- Meta: duration, studio, content rating, view count
Gotchas
- Plex token = full server admin access. Config file is chmod 600.
- No login/password needed — the token is the universal key for all Plex API calls.
- Multiple servers? Use
discoverto list them, thensetup --server <index>to pick. - Requires Node.js 18 or later (built-in
fetch).curlis no longer used. - Shield on Wi-Fi may change IP. Use DHCP reservation for ADB.
- Always pipe search through
formatfor user-facing output. - ADB features are optional — Plex-only setup works without Shield/ADB.
