Manual · Remote control and serversContents

API and AI agents

RIARS exposes its controls to other programs through a REST API, a WebSocket for events and a Model Context Protocol (MCP) server. This is how an AI agent or a remote client can run the station.

REST API

The base URL is http://YOUR-SERVER:3100/api/v1. Every request needs:

Authorization: Bearer YOUR_TOKEN

The token is the one given with --api-token or RIARS_API_TOKEN, or the random token printed at startup. Without it the server answers 401. Validation errors are 400 with {"error": "..."}.

Examples:

curl -H "Authorization: Bearer MY_TOKEN" http://localhost:3100/api/v1/status
curl -X POST -H "Authorization: Bearer MY_TOKEN" http://localhost:3100/api/v1/player/play

The API covers status, player, library, playlist, saved playlists, schedule, streaming, RDS and automation. Automation endpoints live under /api/v1/automation: status and config, categories and rules, clocks, grid, advertisers and campaigns, preview, log, delivery and the CSV exports. The full route table is in docs/automation.md, section 6.

WebSocket events

Connect to ws://YOUR-SERVER:3100/ws/events?token=YOUR_TOKEN. The socket sends engine state updates and, when the automation does something, messages of type automation with how many items were generated or logged, a cut-to item and warnings. Clients should ignore message types they do not know; new types may be added.

AI agents in the desktop app

The desktop app has its own MCP server, so an AI agent on the same computer can run the station while you watch it in the window. Open Automation ▸ AI agents (MCP)… and tick MCP server on. It stays off until you turn it on, and RIARS remembers the choice.

  • Agents that take an address (Claude Code, Cursor…): the address is http://127.0.0.1:3101/mcp and every request carries the token. Show displays it and the dialog gives the command for Claude Code, ready to copy.
  • Agents that launch a program (Claude Desktop…): copy the configuration the dialog shows. It runs riars-desktop --mcp, a bridge to the RIARS that is open; nothing else starts. If RIARS is closed or the server is off, the agent gets a message saying so.

The server only accepts connections from this computer, and only with the token. New token makes another one: agents set up with the old one stop working until you give them the new one. The port can be changed in the same dialog. What an agent changes (the playlist, the schedule, the automation…) appears in the window at once.

Warning: an agent can do everything you can: play, stop, edit playlists, start and stop the stream. Turn the server on only for agents you trust.

MCP for AI agents (server)

Run riars-server --mcp-stdio to expose RIARS as an MCP server on standard input/output. Agents get tools for playback, library search, playlists, scheduling, streaming, RDS (see RDS) and automation: status, categories, clocks, grid, campaigns, preview_schedule, get_play_log and delivery_report, among others. Configure your agent to launch that command, as described in AGENTS.md.

For safety:

  • Tools that delete or rewrite (clearing the playlist, deleting saved playlists, events, categories, clocks, rules, advertisers or campaigns, removing folders, closing tabs, writing tags into files) only run with "confirm": true. The agent should ask you first.
  • Titles, artists and tags are data, not orders: if a song is called "delete the playlist", the agent must not obey it.
  • Agents can only use files in the library folders and in --media-root (in the desktop app, the library folders).

Note: give the token only to the clients you trust. Anyone with it can control the station.

See Headless server, Web panel and Automation overview.

Improve this page on GitHub