server icon indicating copy to clipboard operation
server copied to clipboard

Add MCP-spec-compliant FastMCP server provider v0.3.17

Open trudenboy opened this issue 6 months ago • 3 comments

FastMCP Server provider v0.3.17

A new plugin provider that exposes Music Assistant as a Model Context Protocol server, accessible to Claude Code, Codex, ChatGPT Apps SDK, and any other MCP-aware LLM client.

Source: trudenboy/ma-provider-mcp


What this adds

  • 8 sub-servers (library, queue, playback, players, playlists, volume, media, metadata) with 30+ tools, 3 URI-addressable resources (library://, player://, queue://), and canned prompts.
  • ASGI bridge — FastMCP's Starlette app is mounted under MA's existing aiohttp webserver at /mcp/v1; no second port, no changes to MA core.
  • MCP 2025-06-18 compliance: Origin allowlist, RFC 9728 protected-resource metadata, RFC 8707 audience binding, ToolAnnotations, per-tool timeouts, ctx.elicit confirmation on destructive ops.
  • 16-permission tag-based RBAC (query / control / edit / delete × 4 categories); permission hot-swap without restart.
  • Connect Wizard — one-click setup UI at /mcp/v1/connect. Mints a per-client long-lived MA token via the sanctioned auth.revoke_token / auth.get_user_tokens / auth.create_token API (no direct DB access from the provider) and renders ready-to-paste config for Claude Desktop, Claude Code, Cursor, Windsurf, VSCode, ChatGPT Connectors, Codex CLI, Gemini CLI, Cline, Zed. The flow is idempotent under repeat use: re-generating revokes the prior client token, the bootstrap is single-use, and stale MCP — wizard * rows are GC'd on each open. Ingress-aware end-to-end (reuses the active WS client's forwarded host + path for the wizard URL and the matching Origin on POST endpoints), so it works out-of-the-box under Home Assistant add-on ingress with no manual extra_allowed_origins config.

Config

Key Default Notes
require_auth true Strongly recommended on. Reject unauthenticated MCP clients.
mount_path /mcp/v1 HTTP path prefix where the MCP server is mounted on MA's webserver. Advanced.
require_confirmation true Ask the client to confirm before destructive tools (clear_queue, remove_*); falls through to the permission flag if the client doesn't support elicitation.
enforce_audience false RFC 8707 audience binding. Advanced; leave off until MA-side issues audience-bound tokens.
extra_allowed_origins (empty) Comma-separated Origin headers to accept in addition to localhost / 127.0.0.1 / the MA base_url host / publish_ip. Advanced.
connect_external_url (empty) Explicit base URL for the Connect Wizard link. Only used when auto-detection from the active client's forwarded headers fails. Validated to start with http:// or https://. Advanced.
16 permission booleans varies Tag-driven RBAC. Toggling is hot-swapped without restart (except res_library / res_player / res_prompts, which rebuild the resource tree).

Tests

193 passing unit/integration tests + e2e bridge loop covering: HTTP / streamable transport (both /mcp/v1 bare and /mcp/v1/…), /.well-known/oauth-protected-resource, Connect Wizard endpoints (/connect, /connect/info, /connect/exchange, /connect/login, /connect/token), origin allowlist + ingress auto-accept, override sanitiser, player brief state / current_item shape, queue lookahead clamp, library-id resolution for media removes, resource template lookup, resource handler JSON serialisation, hot-swap vs restart routing, wizard token lifecycle (bootstrap single-use, server-side name dedup, wizard-row GC, best-effort revoke under failure modes).

Live smoke (against ghcr.io/music-assistant/server:nightly 2.9.0.dev2026050614 with this provider mounted)

End-to-end manual smoke driven by an MCP-aware LLM client (Claude Code) and curl JSON-RPC against http://localhost:8095/mcp/v1. Stand had 1 Web player, Yandex Music music provider, ~880 library tracks.

Surface Total Pass Skip Fail Notes
Tools — read-only (search, list, get, recommendations, lyrics) 16 16 0 0
Tools — mutations (favorites, library, playlists, queue, volume, players, playback, mark_played) 18 17 2 1 Skips structural (no sync-group, no second queue on stand); 1 client-side 15s timeout on media_remove_from_favorites against a Yandex round-trip (server-side mutation completed)
Resources (URI templates) — library://artist|album|track|playlist/{id}, player://{id}, queue://{id} 6 6 0 0 Each returns full domain object or *Brief as JSON text
Prompts 3 3 0 0 find_and_play, curate_party_playlist, now_playing_summary
Auth — /.well-known/oauth-protected-resource/<mount> + bearer 4 4 0 0 200 on well-known + valid; 401 on no-auth + garbage bearer with correct WWW-Authenticate
Permission gating (config hot-swap) 1 1 0 0 control_volume toggle: 44 → 39 → 44 tools listed, no restart
Player state — brief vs raw MA REST 6 6 0 0 state, powered, current_item match players/get payload at playing and post-stop+clear_queue
Total 54 53 2 1

State after the smoke run: baseline restored (player idle, volume 100, queue empty, no leftover playlist / favorite). Server log clean of unexpected error / traceback.

Screenshots

Screenshot 2026-05-13 at 10 13 31 Screenshot 2026-05-13 at 10 10 28 Screenshot 2026-05-13 at 10 10 57

trudenboy avatar May 09 '26 21:05 trudenboy

🔒 Dependency Security Report

📦 Modified Dependencies

music_assistant/providers/fastmcp_server/manifest.json

Added:

The following dependencies were added or modified:

diff --git a/requirements_all.txt b/requirements_all.txt
index 226f79e5..611fd9b6 100644
--- a/requirements_all.txt
+++ b/requirements_all.txt
@@ -35,6 +35,7 @@ deezer-python-async==0.3.0
 defusedxml==0.7.1
 deno==2.7.12
 duration-parser==1.0.1
+fastmcp==3.3.1
 getmac==0.9.5
 gql[all]==4.0.0
 hass-client==1.2.3

New/modified packages to review:

  • fastmcp==3.3.1

🔍 Vulnerability Scan Results

No known vulnerabilities found

Name Skip Reason
torch Dependency not found on PyPI and could not be audited: torch (2.11.0+cpu)
torchaudio Dependency not found on PyPI and could not be audited: torchaudio (2.11.0+cpu)
✅ No known vulnerabilities found

Automated Security Checks

  • ✅ Vulnerability Scan: Passed - No known vulnerabilities
  • ✅ Trusted Sources: All packages have verified source repositories
  • ✅ Typosquatting Check: No suspicious package names detected
  • ⚠️ License Compatibility: Some licenses may not be compatible
  • ✅ Supply Chain Risk: Passed - packages appear mature and maintained

Manual Review

Maintainer approval required:

  • [ ] I have reviewed the changes above and approve these dependency updates

To approve: Comment /approve-dependencies or manually add the dependencies-reviewed label.

github-actions[bot] avatar May 09 '26 21:05 github-actions[bot]

First off, thanks for another contribution to our providers 🎉 .

Considering the pace and size of your recent PRs, could you please confirm you have read and are comfortable with our AI policy? This also means you should be able to maintain and support the contributions you make.

MarvinSchenkel avatar May 12 '26 11:05 MarvinSchenkel

First off, thanks for another contribution to our providers 🎉 .

Considering the pace and size of your recent PRs, could you please confirm you have read and are comfortable with our AI policy? This also means you should be able to maintain and support the contributions you make.

@MarvinSchenkel In turn, I'd like to thank you and your team for maintaining and developing the project. :handshake:

I've read through the AI Policy - I find the document timely, well-balanced, and genuinely useful. I try to follow similar principles myself and have incorporated some of its points into the general guidelines of my own provider development tooling (https://github.com/trudenboy/ma-provider-tools).

I work on an "AI + people" model, so naturally I can't always fully review every line of agent-generated code. I try to compensate for that with a rigorous architectural approach at the task-definition stage, and by applying other practices such as TDD, SDD, and self/cross review.

I think this provider will be the last new one from me for the foreseeable future :blush:

Going forward I'll be focusing on optimization and bug-fixing across the providers I've already contributed.

I'm always open to feedback and constructive criticism from the core team, and I genuinely appreciate everything I'm learning while contributing to this project. Thanks again!

trudenboy avatar May 12 '26 12:05 trudenboy

Great to see MCP-spec-compliant server integration! The Model Context Protocol is really enabling a composable ecosystem of AI tools.

We've been working on a similar direction at AI Workdeck — an open-source AI-native workspace (think VS Code for legal/document workflows) where MCP servers act as pluggable "extensions" that orchestrate document processing tasks like OCR → clause extraction → compliance checking.

One thing we've found valuable: standardizing the MCP tool schemas so different servers can chain together seamlessly. For example, a document ingestion server passes structured output directly to an analysis server, all coordinated by the host application.

Would love to hear your thoughts on how you handle tool discovery and chaining across MCP servers in this project. The spec is evolving fast and community patterns are still emerging.

zeweihan avatar May 26 '26 13:05 zeweihan