Skip to main content
Glama

astra-mcp

An MCP server for Astra's Companion API v2. It lets Claude and other MCP clients see and drive a running Astra desktop music player — what's playing, search the library, start and queue music, manage favorites and playlists.

Read-only by default: Astra ships the API disabled, and each capability is a separate switch the user controls. This server adapts to whatever is granted and hides the tools that aren't.

Setup

1. Turn on Astra's Local API

In Astra: Settings → Integrations → Local API.

Switch

Grants

Tools it unlocks

Local Integration API

observe

astra_now_playing, astra_queue, astra_capabilities

External Playback Controls

playback-control

astra_control, astra_play, astra_enqueue, astra_queue_edit

Library Search

library-search

astra_search, astra_open

Favorites & Playlist Changes

library-write

astra_set_favorite, astra_playlist

Copy the Local API Key from that panel. The token only works over 127.0.0.1.

2. Build

npm install
npm run build

3. Register the server

Claude Code:

claude mcp add astra --env ASTRA_API_TOKEN=<your-token> -- node /absolute/path/to/astra-mcp/dist/index.js

Claude Desktop (claude_desktop_config.json) and other clients:

{
  "mcpServers": {
    "astra": {
      "command": "node",
      "args": ["/absolute/path/to/astra-mcp/dist/index.js"],
      "env": { "ASTRA_API_TOKEN": "your-token" }
    }
  }
}

4. Browser-based clients (llama.cpp WebUI, and similar)

Clients that run in a browser cannot spawn a subprocess, so stdio is not an option for them. Start the server in HTTP mode instead:

$env:ASTRA_API_TOKEN = 'your-token'
node dist/index.js --http          # http://127.0.0.1:38500/mcp
node dist/index.js --http=9000     # or pick a port

Then in llama.cpp: launch llama-server with --webui-mcp-proxy (spelled --ui-mcp-proxy on some builds) so the WebUI can reach it past CORS, and add http://127.0.0.1:38500/mcp as an MCP server in the WebUI settings.

GET /health reports whether the Astra link is up and which scopes are granted — the quickest way to tell a broken token from a stopped app.

The HTTP transport is stateless: it never issues an Mcp-Session-Id. That is deliberate. llama.cpp's WebUI does not echo that header back (ggml-org/llama.cpp#20471), so a stateful server would reject every call after initialize. The trade-off is that HTTP clients get no server-initiated messages: no tools/list_changed when you flip a scope switch in Astra, and no resource-update notifications. Tool calls are unaffected. Both work normally over stdio.

GET /mcp returns 405 for the same reason — there is no session to push a stream to, and an open one would leak.

Configuration

Variable

Default

Purpose

ASTRA_API_TOKEN

—

Local API Key from Astra settings. Required.

ASTRA_API_URL

http://127.0.0.1:38401

Set this if you changed the port in Astra.

ASTRA_POSITION_INTERVAL_MS

1000

How often Astra pushes position updates (250–5000).

ASTRA_DISABLE_EVENTS

unset

Set to 1 to poll instead of holding an event stream.

ASTRA_MCP_HTTP_PORT

38500

Enables HTTP mode, same as --http.

ASTRA_MCP_HTTP_HOST

127.0.0.1

Bind address for HTTP mode.

ASTRA_MCP_HTTP_ORIGINS

empty

Comma-separated browser origins allowed to call the server directly.

A missing token is a warning, not a crash — the server starts and each tool explains what to fix.

On ASTRA_MCP_HTTP_ORIGINS: this process holds a token that can control your music player, so no browser origin is allowed by default. Any page you allowlist can drive Astra. You do not need this for llama.cpp — its proxy calls from the server side, where CORS does not apply.

Related MCP server: Spotify MCP Server

Tools

Tool

What it does

astra_search

Find tracks, albums, artists, playlists. Start here — everything else takes refs from it.

astra_now_playing

Current track, position, volume, shuffle, repeat, output device.

astra_control

play, pause, stop, next, previous, seek, set-volume, set-muted, set-shuffle, set-repeat.

astra_play

Play a ref now, replacing the queue.

astra_enqueue

Add a ref to the queue, next or end.

astra_open

Focus the Astra window on a ref without playing it.

astra_queue

Read the queue with per-item ids.

astra_queue_edit

Move, remove, or clear upcoming queue items.

astra_set_favorite

Set a track's favorite state explicitly.

astra_playlist

Create, rename, and edit the contents of normal playlists.

astra_capabilities

Granted scopes, features, limits — the tool to reach for when something is 403.

Resources

astra://playback, astra://queue, and astra://capabilities are live JSON views that support subscriptions. astra://artwork/{ref} returns album art as a blob — a resource rather than a tool so a model can't flood its own context with 2 MiB images.

How it works

Refs are opaque. Astra never exposes file paths or database ids; it hands out signed AstraRef strings. Nothing here accepts a name, so every flow is search → act. Refs can go stale and start returning 404, which means search again.

One event stream, not polling. The server holds a single SSE connection to /v2/events and keeps playback and queue snapshots warm, so astra_now_playing usually costs zero HTTP requests. Astra's budget is 120 requests/minute shared across everything using the token; a client-side limiter keeps this server under it by queuing rather than failing. If the stream drops, tools fall back to direct reads.

202 is not "done". Playback, intent, and queue commands are queued to Astra's renderer and return immediately. astra_control and astra_play wait briefly on the event stream and report the state Astra actually reached, rather than claiming success.

The tool list is live. Flipping a switch in Astra's settings force-closes the event stream; the reconnect handshake carries the new scopes, and the server enables or disables tools to match. (Over HTTP the gating still applies, but the client is not notified — it sees the change on its next tools/list.)

One Astra connection, many MCP servers. HTTP mode builds a fresh McpServer per request, as stateless mode requires, but they all share a single AstraRuntime holding one HTTP client and one event stream. Otherwise each request would open its own stream and exhaust Astra's limit of eight.

What this cannot do

Astra's v2 contract deliberately omits catalog browsing, audio streaming, metadata editing, library scans, remote-source administration, settings, DSP/EQ, lyrics, playlist deletion, and dynamic playlist rules. Those endpoints do not exist, so no tool here can reach them. Library writes are limited to favorites and locally owned normal playlists — mirrored (Jellyfin/Subsonic) and dynamic playlists reject edits.

Only the loopback transport is supported. Astra also serves the same v2 surface to paired LAN devices over HTTPS on port 38402, which needs its own pairing flow.

Development

npm run build       # tsc
npm test            # build, then unit + contract tests
npm run inspector   # MCP Inspector against the built server
npm run smoke       # end-to-end against a running Astra (read-only)

Smoke testing runs against a live Astra and is read-only unless you opt in. --play replaces the current queue; --write creates a playlist you then have to delete by hand, since Astra has no delete endpoint. Neither touches existing playlists or favorites.

# PowerShell
$env:ASTRA_API_TOKEN = 'your-token'
npm run smoke
node scripts/smoke.mjs "Miles Davis"           # + search
node scripts/smoke.mjs "Miles Davis" --play    # + play and enqueue
node scripts/smoke.mjs "Miles Davis" --write   # + playlist creation
# bash / zsh
export ASTRA_API_TOKEN='your-token'
npm run smoke

src/types.ts mirrors Astra's src/types/companionApi.ts by hand, and ASTRA_ENDPOINTS in src/client.ts lists every endpoint this server calls. test/contract.test.mjs checks both against Astra's own docs/api/openapi-v2.json, and fails if the source calls a path that isn't declared. It looks for the Astra checkout as a sibling directory; set ASTRA_REPO if yours lives elsewhere.

License

GPL-3.0

Available Tools

11 tools
astra_capabilitiesAstra: capabilities and granted scopesA
Read-only

Report which Astra Companion API scopes are granted, which features are available, and the current limits. Useful for diagnosing a permission error: if a tool returns "insufficient_scope", this shows which switch is off in Astra → Settings → Integrations → Local API.

Inputs: no named parameters.

astra_controlAstra: control playbackA

Control playback in Astra: play, pause, stop, next, previous, seek, set-volume, set-muted, set-shuffle, set-repeat. Each action needs its own argument — seek needs positionSeconds, set-volume needs volume (0-1), set-muted needs muted, set-shuffle needs enabled, set-repeat needs mode. Astra accepts commands asynchronously; this tool waits briefly and reports the state it actually landed on. To start a specific track or album instead, use astra_search then astra_play.

Inputs: action (required), mode, muted, volume, +2 more.

astra_enqueueAstra: add a target to the queueA

Add a track, album, artist, or playlist to the Astra queue without interrupting what is playing. Takes an opaque ref from astra_search. Use position "next" to play it after the current track, or "end" to append. Refs are opaque signed strings from astra_search (or from the current track / queue). Pass them through verbatim — never parse, edit, or invent one. A ref can go stale and return 404.

Inputs: targetRef (required), position.

astra_now_playingAstra: now playingA
Read-only

Get the current playback state of the Astra music player: track, position, duration, volume, mute, shuffle, repeat, output device, and queue length. Served from a live event stream when connected, so it is cheap to call. Returns the current track's ref, which can be passed to astra_set_favorite or astra_playlist.

Inputs: no named parameters. Returns: muted, state, repeat, source, +8 more

astra_openAstra: show a target in the appA
Idempotent

Bring the Astra window to the front and navigate to a track, album, artist, or playlist. This only changes what the user is looking at — it does not start playback. Takes an opaque ref from astra_search. Refs are opaque signed strings from astra_search (or from the current track / queue). Pass them through verbatim — never parse, edit, or invent one. A ref can go stale and return 404.

Inputs: targetRef (required).

astra_playAstra: play a target nowA
Destructive

Start playing a track, album, artist, or playlist in Astra, replacing the current queue. Takes an opaque ref from astra_search — call that first to turn a name into a ref. Refs are opaque signed strings from astra_search (or from the current track / queue). Pass them through verbatim — never parse, edit, or invent one. A ref can go stale and return 404. To resume something already loaded, use astra_control with action "play" instead.

Inputs: targetRef (required).

astra_playlistAstra: create and edit playlistsA

Create a playlist in Astra, rename one, or add / remove / reorder its tracks. "create" needs name. "rename" needs ref and name. "add-tracks" needs ref and trackRefs. "remove-track" needs ref and trackRef. "move-track" needs ref, trackRef, and position. Get playlist refs from astra_search with types ["playlist"], and track refs from astra_search with types ["track"]. Refs are opaque signed strings from astra_search (or from the current track / queue). Pass them through verbatim — never parse, edit, or invent one. A ref can go stale and return 404.

Limits: only locally owned normal playlists are editable — mirrored (Jellyfin or Subsonic) and dynamic playlists reject edits with playlist_not_writable. Astra has no playlist deletion endpoint, so playlists cannot be deleted through this server.

Inputs: action (required), ref, name, position, +2 more.

astra_queueAstra: read the play queueA
Read-only

List the tracks in the Astra play queue, in order, with the currently playing one marked. Each entry has a queue item id — pass that to astra_queue_edit to move or remove it. Served from the live event stream when connected. Astra only publishes the first 200 queue entries to the API, so a longer queue is reported as truncated and the later entries are not reachable.

Inputs: limit.

astra_queue_editAstra: edit the play queueA
Destructive

Reorder or trim the Astra play queue. "move" needs queueItemId and a 0-based position, "remove" needs queueItemId, and "clear" empties the upcoming queue without stopping the current track. Get queue item ids from astra_queue. The currently playing item cannot be moved or removed — attempting it returns queue_item_not_found. To add tracks instead, use astra_enqueue.

Inputs: action (required), position, queueItemId.

astra_set_favoriteAstra: set a track favoriteA
Idempotent

Mark or unmark a track as a favorite in the Astra library. This sets an explicit state rather than toggling, so it is safe to repeat. Takes a track ref from astra_search or from the current track reported by astra_now_playing. Refs are opaque signed strings from astra_search (or from the current track / queue). Pass them through verbatim — never parse, edit, or invent one. A ref can go stale and return 404.

Inputs: favorite (required), trackRef (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 11 tools

    Disambiguation5/5

    Each tool targets a distinct resource or action: search returns refs, play/enqueue/queue_edit manage the queue, control handles transport, set_favorite toggles favorites, playlist manages playlists, open navigates the UI, and now_playing/capabilities are informational. There is minor potential overlap between astra_play and astra_control 'play', but descriptions clearly separate starting a specific item from resuming playback.

    Naming Consistency4/5

    All tools share the astro_ prefix, but the pattern is not uniform: most are verb_noun (set_favorite, queue_edit) or bare verbs (open, play, search), while some are nouns (queue, capabilities, playlist) implying a 'get' action. Occasional phrases like now_playing deviate from a strict verb_noun convention, but the prefix and readable structure keep it mostly consistent.

    Tool Count5/5

    With 11 tools, the server is well-scoped for a music player control surface. Each tool covers a distinct operation without redundancy, and the count is within the ideal range for a focused MCP server.

    Completeness4/5

    The core workflows are covered: search, play, control, queue management, favorite toggling, and playlist CRUD (minus deletion, which is documented as unavailable). Minor gaps exist: there is no tool to list favorites or fetch the contents of a playlist, and search is bounded without pagination, but agents can work around these via now_playing/queue for current state and by using playlist refs directly.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers