Metadata-Version: 2.4
Name: slskd-mcp
Version: 0.1.0
Summary: MCP server that finds Releases on Soulseek through slskd, tags them from MusicBrainz and files them into a music Library
Author: Ellexandrei Esponilla
License-Expression: MIT
License-File: LICENSE
Requires-Dist: alembic>=1.20.1
Requires-Dist: anyio>=4.16.0
Requires-Dist: beets==2.14.*
Requires-Dist: httpx>=0.29.0
Requires-Dist: mcp>=2.3.0
Requires-Dist: platformdirs>=4.14.9
Requires-Dist: pydantic>=2.14.4
Requires-Dist: questionary>=2.1.1
Requires-Dist: sqlalchemy>=2.1.9
Requires-Dist: tomlkit>=0.15.3
Requires-Python: >=3.12
Project-URL: Homepage, https://github.com/xandreiAThome/slskd-mcp
Project-URL: Repository, https://github.com/xandreiAThome/slskd-mcp
Project-URL: Issues, https://github.com/xandreiAThome/slskd-mcp/issues
Project-URL: Changelog, https://github.com/xandreiAThome/slskd-mcp/blob/main/CHANGELOG.md
Description-Content-Type: text/markdown

# slskd-mcp

An MCP server that lets an AI client find, download, and tag **Releases** and **Tracks** from Soulseek (via [slskd](https://github.com/slskd/slskd)) into a **Ready folder** for you to move into your **Library**, raising **Flags** when something needs manual MusicBrainz curation.

## How it works

1. You ask your MCP client for a **Release** or **Track**.
2. `slskd-mcp` resolves it on MusicBrainz, checks your **Library** (via OpenSubsonic), active **Downloads**, **Staging folder**, and **Ready folder** for **Duplicates**, searches Soulseek via slskd, and ranks **Candidates** by quality.
3. Once a **Download** finishes in the **Staging folder**, `slskd-mcp` tags it with MusicBrainz metadata and cover art using an ephemeral per-run beets database and moves it into the **Ready folder** (`paths.ready`, defaulting to `<slskd_downloads>/ready`) with a consistent folder and filename shape:
   - Single-disc **Release**: `Artist - Album (Year)/01 Title.ext`
   - Multi-disc **Release**: `Artist - Album (Year)/1-01 Title.ext`
4. You review the **Ready folder** and move finished **Releases** into your **Library** however you organize it. `slskd-mcp` never writes to your **Library**.

## Requirements

- **Python >= 3.12** (or [`uv`](https://docs.astral.sh/uv/) to run with `uvx`).
- **slskd** with a **ReadWrite** or **Administrator** API key.
- **An OpenSubsonic server** (such as Navidrome, gonic, or LMS) serving as a read-only index of your **Library** for **Duplicate** checks.
- **Local filesystem access** on the MCP host to both the **Staging folder** (`<slskd_downloads>/<staging_subdir>`) and the **Ready folder** (`paths.ready`, default `<slskd_downloads>/ready`). The two folders must not overlap (neither may be inside the other).
- **Optional:** a [Discogs](https://www.discogs.com) personal access token (`discogs.token` or `DISCOGS_TOKEN`) to check whether a **Release** missing from MusicBrainz exists on Discogs. Without a token, Discogs is never called.

## Install and setup

Run the interactive setup wizard directly with `uvx`:

```bash
uvx slskd-mcp setup
```

Or install it as a persistent CLI tool first:

```bash
uv tool install slskd-mcp
# or
pipx install slskd-mcp
```

Then run `slskd-mcp setup`.

### What `slskd-mcp setup` does

The interactive wizard walks you through configuration and client registration:

- **Live service checks:** verifies your slskd URL and API key role, and tests your OpenSubsonic server connection and MusicBrainz ID search capabilities.
- **Staging probe:** writes and verifies a probe file through slskd's Files API to confirm your host's `slskd_downloads` path matches slskd's downloads directory.
- **Ready folder:** configures `paths.ready` (defaulting to `<slskd_downloads>/ready`) and checks that it does not overlap the **Staging folder**.
- **Quality and behavior:** lets you pick a quality preset (Best available, CD-quality lossless first, Lossless only, or Space-saving), choose whether to enable `auto_download`, and optionally set a Discogs token or MusicBrainz contact string.
- **Safe config file:** writes the config file atomically with `0600` permissions (or leaves secrets out of the file if you prefer environment variables: `SLSKD_API_KEY`, `OPENSUBSONIC_PASSWORD` / `OPENSUBSONIC_TOKEN`, `DISCOGS_TOKEN`).
- **MCP client registration:** detects installed MCP clients and registers `slskd-mcp` into any you select, supporting **Claude Code**, **Claude Desktop**, **VS Code**, **Cursor**, **Windsurf**, **Codex**, **Antigravity (`agy`)**, and **opencode**.

`slskd-mcp setup` is re-runnable as an editor: running it again loads your existing config so you can tweak settings or register additional clients without starting over.

If you prefer to write the config file by hand, generate a commented template instead:

```bash
slskd-mcp setup --template
```

## MCP tools

`slskd-mcp` exposes **7 tools**:

| Tool | Purpose |
| --- | --- |
| `request_release` | Resolve one or more **Releases** or **Tracks** on MusicBrainz, check for **Duplicates**, search slskd, and return ranked **Candidates** (or queue automatically when `auto_download` is on). |
| `choose` | Confirm a **Candidate**, disambiguate a **Release group**, proceed past a non-blocking **Duplicate**, accept a near-miss, or pick a fallback **Candidate**. |
| `check_downloads` | Poll slskd for active **Downloads**, tag completed **Releases** with MusicBrainz metadata and cover art, and move them into the **Ready folder** (or raise a **Flag** if manual curation is needed). |
| `manage_download` | Cancel a **Download**, switch to a fallback **Candidate**, or discard / file a **Duplicate** **Download**. |
| `list_pending` | List waiting **Flags** (`missing-release`, `weak-match`, `filing-failed`, `thin-genre`, `genre-override`) and **Unavailables**, along with counts per kind. |
| `manage_pending` | Retry **Flags** or **Unavailables** (optionally supplying a MusicBrainz ID), dismiss them (optionally deleting staged files), override or remove a `thin-genre` override, or record an external URL. |
| `check_setup` | Check config, paths, slskd, and OpenSubsonic health and report the running version. Works even when the config has errors. |

### Example conversation

> **You:** Download *OK Computer* by Radiohead in FLAC.
>
> **Assistant:** *(calls `request_release`)*
> Found **OK Computer** by Radiohead (not in your **Library**). Top **Candidates** on Soulseek:
> 1. `user_a` — FLAC 16-bit/44.1kHz, 12/12 Tracks, free slot (recommended)
> 2. `user_b` — FLAC 24-bit/96kHz, 12/12 Tracks, queue length 3
>
> Want me to queue #1?
>
> **You:** Yes, go ahead.
>
> **Assistant:** *(calls `choose`)*
> Queued **Download** `dl-a1b2` from `user_a`.
>
> **You:** How's that download looking?
>
> **Assistant:** *(calls `check_downloads`)*
> `dl-a1b2` finished, tagged from MusicBrainz, and moved to your **Ready folder**:
> `/music/unsorted/ready/Radiohead - OK Computer (1997)/` (12 Tracks).
> Ready for you to move into your **Library**.

## Upgrading and downgrading

`slskd-mcp` never phones home to check for updates. Use `check_setup` to see the running version, and upgrade with whichever method you installed it:

```bash
# uvx (note: plain `uvx slskd-mcp` keeps running its cached version)
uvx slskd-mcp@latest

# uv tool
uv tool upgrade slskd-mcp

# pipx
pipx upgrade slskd-mcp
```

Before upgrading across minor versions, check **Upgrade notes** in `CHANGELOG.md` for any config or data changes.

`state.db` is backed up automatically before schema migrations. If you downgrade to an older version that does not understand a newer `state.db` schema, the server refuses to start; restore the automatic backup from your data directory to complete the downgrade.

## Local development

This project uses `uv` to manage Python dependencies and run development tools. Run all commands below from the repository root.

1. Install the runtime and development dependencies:

```bash
uv sync
```

2. Run the lint, format, type, import, and test commands:

```bash
uv run ruff check
uv run ruff format --check
uv run pyright
uv run lint-imports
uv run pytest
```

3. Run the server or setup wizard from your local checkout with the `--config` flag:

```bash
uv run slskd-mcp --config /path/to/config.toml
uv run slskd-mcp setup --config /path/to/config.toml
```

No test reaches the network. Read [docs/code-organization.md](docs/code-organization.md) for the package layout, dependency rules, and Alembic migration commands.

## Attribution

When Discogs lookup is enabled, release verification data is provided by [Discogs](https://www.discogs.com) ("Data provided by Discogs").

`slskd-mcp` uses Discogs' API, but is not affiliated with, sponsored, or endorsed by Discogs. "Discogs" is a trademark of Zink Media, LLC.
