# Controlling Vivi from AI agents (MCP) `vivi-mcp` is a small separate binary that speaks the [Model Context Protocol](https://modelcontextprotocol.io) over **stdio** and forwards tool calls to a running Vivi through a local control socket. The player itself only gains a tiny socket listener (`src/ipc/`); the MCP server links nothing but `std` and `serde_json`. ``` AI client (Claude Desktop, Cursor, …) ──stdio/JSON-RPC──▶ vivi-mcp ──Unix socket/JSON lines──▶ vivi ``` ## 1. Enable remote control in Vivi The socket is **off by default**. Turn on *Settings → Controls → Remotes → Allow AI agents and scripts* (Settings → General → Remote control before 0.15) and restart Vivi, or start it once with `VIVI_IPC=1 vivi`. The socket is `$XDG_RUNTIME_DIR/vivi.sock` (fallback `~/.cache/vivi/vivi.sock`, override with `VIVI_SOCKET`), created with mode `0600`: only your user can connect. There is no network listener. ## 2. Get `vivi-mcp` It is built together with Vivi: `cargo build --release` produces `target/release/vivi-mcp` next to `target/release/vivi`. The Arch package installs it to `/usr/bin/vivi-mcp`, the Flatpak to `/app/bin/vivi-mcp`. `vivi-mcp --help` prints the socket path it will use. ## 3. Configure your client The fastest ways, if you already have `vivi-mcp` on your `PATH` (or next to `vivi`): - On [viviplayer.app/ai-agents.html](https://viviplayer.app/ai-agents.html), use **Add to Cursor** or **Add to VS Code** (official install deeplinks). - In Vivi, *Settings → Controls → Remotes → Connect to…* lists Claude Desktop, Cursor and VS Code when their config or install is found. Connect writes a `vivi` stdio entry (a `.bak` backup is kept first); it is idempotent and leaves other servers alone. **Claude Desktop** (`~/.config/Claude/claude_desktop_config.json`, macOS `~/Library/Application Support/Claude/claude_desktop_config.json`): ```json { "mcpServers": { "vivi": { "command": "/usr/bin/vivi-mcp" } } } ``` **Cursor** (`~/.cursor/mcp.json`, or `.cursor/mcp.json` in a project): ```json { "mcpServers": { "vivi": { "command": "vivi-mcp", "args": [] } } } ``` **Claude Code**: `claude mcp add vivi -- vivi-mcp` **VS Code / GitHub Copilot** (`.vscode/mcp.json`): ```json { "servers": { "vivi": { "type": "stdio", "command": "vivi-mcp" } } } ``` **Windsurf, Zed, Continue, Cline, …**: any client that launches stdio servers works with `command: vivi-mcp`. If the client does not inherit `XDG_RUNTIME_DIR`, pass the socket explicitly: `"env": { "VIVI_SOCKET": "/run/user/1000/vivi.sock" }`. **Flatpak**: use `"command": "flatpak", "args": ["run", "--command=vivi-mcp", "io.github.loafer19.vivi"]`. ## Protocol `vivi-mcp` is **dual-era**: - Clients that open with `initialize` (the handshake revisions **2025-11-25**, 2025-06-18, 2025-03-26, 2024-11-05) get the version they asked for (unknown versions get 2025-11-25). Capabilities: `tools` (`listChanged`), `resources` (`subscribe`), `prompts`. - Requests that carry `io.modelcontextprotocol/protocolVersion` in `_meta` are served statelessly as **2026-07-28**: no handshake, `server/discover`, `resultType`, `ttlMs`/`cacheScope` on lists, `io.modelcontextprotocol/serverInfo` in result `_meta`, `UnsupportedProtocolVersionError` (-32022, with the supported list) for unknown versions, and `subscriptions/listen` for change notifications. Every tool has a `title` and annotations (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`); clients that honor them ask before destructive calls (replacing or clearing the queue, removing entries, overwriting a playlist, running plugin commands). Arguments are checked against the input schema before anything reaches Vivi (types, required, enums, ranges, unknown keys); a bad call returns a tool error (`isError: true`) that says what to fix. Results always carry `structuredContent`; list tools take `offset` / `limit` and return `{total, offset, items, next_offset}` (declared as `outputSchema`, as is `get_status`). ## Tools **Now playing and transport** | Tool | Arguments | What it does | |---|---|---| | `get_status` | – | Title, artist, album, path, position, duration, volume, mute, speed, playing, subtitles and offset, audio/subtitle track, queue position, chapter, repeat, shuffle, EQ preset, `lyrics_available`, `is_stream`, `has_video` | | `play`, `pause`, `toggle_pause`, `stop` | – | Transport (`stop` pauses and rewinds) | | `seek` | `position` *or* `offset` (s) | Absolute or relative seek | | `set_volume` | `level`, `muted` | Volume in % and/or mute | | `set_speed` | `speed` (0.1–4) | Playback speed | | `set_repeat` | `mode` (`off`/`one`/`all`) | Repeat the item or the whole queue | | `set_shuffle` | `enabled` | Shuffle the queue or restore its order | **Finding and opening media** | Tool | Arguments | What it does | |---|---|---| | `open` | `target` | Play a file path or URL now, replacing the queue (yt-dlp sites work when yt-dlp is installed) | | `search_library` | `query`, `kind`, `offset`, `limit` | Words matched in title/artist/album/genre/path of the scanned library | | `list_recent` | `query`, `kind`, `offset`, `limit` | The Recent list from Home: files, folders, playlists, streams, radio, web video, Free Music, newest first | | `open_network_stream` | `target`, `name`, `queue` | Play (or queue) a stream URL: Internet radio, IPTV `.m3u8`/HLS, DASH, RTMP/RTSP/UDP, Icecast. `name` is shown while it loads | | `search_streams` | `query`, `kind` (`radio`/`tv`), `limit` | Search radio-browser.info, SomaFM, iptv-org TV, your Network Streams favorites and playlists; each item has `kind` (`radio` / `tv`) and a `url` for `open_network_stream` (network; may take a few seconds). `kind: radio` asks only the radio directories, `tv` only iptv-org; favorites and your playlists are split per entry. Fails while the Network Streams plugin is off | **Queue and playlists** | Tool | Arguments | What it does | |---|---|---| | `playlist_list` | `offset`, `limit` | Queue entries: `index`, `path`, `title`, `current` | | `playlist_add` | `target` | Append to the queue | | `playlist_play` | `index` | Jump to a queue entry | | `playlist_move` | `from`, `to` | Move an entry (0-based final position) | | `playlist_remove` | `index` | Remove one entry (destructive) | | `playlist_clear` | `keep_current` (default true) | Empty the queue, keeping the playing item unless `false` (destructive) | | `next`, `previous` | – | Queue navigation | | `list_saved_playlists` | `offset`, `limit` | Library → Playlists: `name`, `path`, `entries` | | `open_saved_playlist` | `name`, `queue` | Play a saved playlist, or append it | | `save_queue_as_playlist` | `name`, `overwrite` | Save the queue as a playlist; an existing name needs `overwrite: true` | **Tracks, subtitles, chapters** | Tool | Arguments | What it does | |---|---|---| | `list_audio_tracks` / `set_audio_track` | `id` (integer, `auto` or `no`) | Audio tracks (`id`, `title` with language, `selected`) and switching | | `list_subtitle_tracks` / `set_subtitle_track` | `id` (integer, `auto` or `no`) | Subtitle tracks (embedded and external); `no` turns them off | | `set_subtitles` | `enabled` | Show/hide subtitles | | `set_subtitle_offset` | `seconds` *or* `delta` *or* `reset` | Subtitle timing (positive = later), saved per file | | `search_subtitles` | `query` (title, episode or IMDb id `tt…`), `languages` (`en,uk`), `limit` | OpenSubtitles results for the playing file: hash matches first (`hash_match`), then by name/IMDb (`Show S01E05` and `Movie (2020)` are searched by season / episode or year); `file_id`, `language`, `downloads`, `rating`, `hearing_impaired`, `fps`, `trusted`, `machine_translated`. Needs the API key in the Subtitle Search plugin | | `load_subtitle` | `file_id`, `language` | Download (one from the daily quota; cached copies are free) and show it | | `sync_subtitles` | – | Align the external subtitle to the audio (Subtitle Auto-Sync plugin, background) | | `get_chapters` | – | `current` index and `chapters` (`index`, `title`, `start` s) | | `seek_chapter` | `index` *or* `offset` (+1/-1) | Jump to a chapter | **Bookmarks, A-B loop, sleep timer** | Tool | Arguments | What it does | |---|---|---| | `list_bookmarks` | – | Bookmarks of the playing file (`time` s, `label`, `note`, `thumb`, `created`), sorted; the 0-based index is used below | | `add_bookmark` | `label`, `note` (optional) | Bookmark the playing position; `added: false` when one is already within half a second; returns `index` and the list | | `remove_bookmark` | `index` | Delete a bookmark and its saved frame (destructive) | | `jump_to_bookmark` | `index` | Seek to a bookmark | | `export_bookmarks_as_chapters` | `to` (`player`/`file`), `path` | `player`: add the bookmarks to the chapter list until the file closes (`added`, `chapters`); `file`: write an FFmpeg metadata chapters file (the file's chapters plus bookmarks; default `