Skip to content

feat(mcp): add Audius MCP server package - #14816

Open
dylanjeffers wants to merge 3 commits into
mainfrom
feat/audius-mcp-server
Open

dylanjeffers wants to merge 3 commits into
mainfrom
feat/audius-mcp-server

Conversation

@dylanjeffers

@dylanjeffers dylanjeffers commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds packages/audius-mcp (@audius/mcp), a remote MCP server that lets Claude act for an Audius user as a listener and as an artist. Streamable HTTP, TypeScript, built on @audius/sdk and @modelcontextprotocol/sdk.

Do not merge yet — see "Not verified" below.

What is in it

  • 20 tools. Listener: search_tracks, search_users, search_playlists, get_trending_tracks, get_track, get_user, get_playlist, get_my_favorites, get_my_reposts, create_playlist, add_track_to_playlist, remove_track_from_playlist, favorite_track, repost_track. Artist: get_my_tracks, get_track_play_count, get_my_followers, get_top_fans, update_track_metadata, upload_track.
  • Annotations. Every tool has a title. The 13 read tools set readOnlyHint: true. Write tools set readOnlyHint: false and an explicit destructiveHint, which is true for remove_track_from_playlist and update_track_metadata.
  • Auth. Claude cannot use Audius OAuth directly, because Audius validates redirect URIs against the developer app and has no dynamic client registration. So the server is an OAuth 2.1 authorization server for MCP clients (discovery, DCR, PKCE, rotating refresh tokens, revocation) and an OAuth client of Audius through sdk.oauth.login() / handleRedirect(). /auth starts the Audius flow and /callback completes it. MCP clients never see Audius tokens.
  • Consent page. /authorize shows which client is asking and where it will redirect before handing off to Audius. Without it, anyone could register a client and reuse a user's existing Audius approval.
  • Sessions. Each grant owns one SDK instance with that user's Audius tokens in memory. Each MCP session is bound to the grant that opened it, and a different user's token is refused for that session.
  • Uploads. upload_track takes a public https audio URL. The fetch refuses private, loopback and link-local hosts, re-checks on each redirect, and enforces a size cap.

Things reviewers should look at

  • patches/zod-to-json-schema+3.25.2.patch. The MCP SDK depends on zod-to-json-schema, which npm hoists to the root next to zod@3.21.4. It imports zod/v3, which that version does not have, so the MCP SDK fails to load. The patch points those imports at zod. The alternative is raising the zod pin in sdk, common and libs, which seemed too wide for this PR.

  • package-lock.json. Besides the new packages, root qs moves 6.16.0 → 6.17.1 and json-schema-typed 8.0.1 → 8.0.2, and tinybench / why-is-node-running are hoisted.

  • get_top_fans ranks listeners by plays. The SDK only exposes top listeners per track, and its generated TopListener type drops the user and count fields, so the tool reads the raw response. With no track_id it totals plays across the artist's 25 most-played tracks (top 100 listeners each), so it is an approximation for large catalogs.

  • add_track_to_playlist / remove_track_from_playlist read the playlist and write back the whole playlistContents through updatePlaylist, since there is no per-track endpoint. Two concurrent edits to one playlist can overwrite each other.

  • SDK change. addTokenRefreshMiddleware returned the cloned response for every non-401. Under node-fetch (what cross-fetch uses in Node) an unread clone stalls the body once it passes about 16KB, so with an API key set any larger response hung forever. It now releases the clone and lets the runtime use the original. This affects every Node consumer of the SDK that sets apiKey; a patch changeset is included.

Test plan

  • npm run verify -w @audius/mcp (lint + typecheck)
  • npm run test -w @audius/mcp — 42 tests. They drive registration, consent, callback, token exchange, refresh rotation, revocation and tool calls over real HTTP with the MCP SDK client, against a fake Audius session.
  • Compiled server started locally; discovery metadata, the 401 challenge and the redirect to api.audius.co/v1/oauth/authorize checked with curl.
  • The nine public read tools run against the live Audius API and return correctly shaped results.
  • node scripts/comment-ratchet.cjs

Not verified

  • Nothing tool-side. All 20 tools have run against a real account through a real Audius sign-in: the 13 read tools at the maximum page size, and every write tool (create_playlist, add_track_to_playlist, remove_track_from_playlist, favorite_track, repost_track, update_track_metadata, upload_track with cover art, unlisted), including their not-owner, not-found, bad-ID, non-https and wrong-file-type errors.
  • claude mcp add and sign-in through /mcp in Claude Code worked; tool calls from Claude Code then exposed the bugs fixed in the last commit and have not been re-run from Claude Code since.
  • The Dockerfile. It follows packages/sdk/Dockerfile but has not been built; Docker was not running.
  • Deployment. Nothing is deployed.

Known limits

  • State is in memory. A restart signs everyone out and only one instance can run.
  • CI: .github/workflows/mcp.yml runs lint, typecheck, tests and build for this package.

🤖 Generated with Claude Code

Adds packages/audius-mcp, a remote MCP server (streamable HTTP) built on
@audius/sdk that lets Claude act for an Audius user as a listener and as
an artist.

- 20 tools: search, trending, track/user/playlist lookups, favorites,
  reposts, playlist editing, artist stats, followers, top fans, track
  metadata updates and uploads. Every tool has a title and
  readOnlyHint/destructiveHint annotations.
- Auth: the server is an OAuth 2.1 authorization server for MCP clients
  (discovery, dynamic client registration, PKCE, rotating refresh
  tokens) and signs users in through Audius OAuth via sdk.oauth. A
  consent page at /authorize names the registering client before the
  hand-off to Audius; /auth starts the Audius flow and /callback
  completes it.
- Each grant holds its own SDK instance and Audius tokens in memory, and
  each MCP session is bound to the grant that opened it.
- upload_track fetches audio from a public https URL and refuses
  private, loopback and link-local hosts.

Patches zod-to-json-schema to import from "zod" instead of "zod/v3". It
is hoisted next to the root zod 3.21.4, which has no "/v3" subpath, so
the MCP SDK failed to load without it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 19ecd90

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@audius/sdk Patch
@audius/sdk-legacy Patch
@audius/protocol-dashboard Patch
@audius/sp-actions Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@socket-security

socket-security Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Dependency limit exceeded — report not shown.

This pull request scan exceeded the 10,000-dependency limit applied to this scan, so the results are incomplete and may be inaccurate. To avoid reporting false positives, Socket has not posted a report.

Upgrade your plan to raise the dependency limit and get complete reports, or view the partial scan in the dashboard.

Socket is always free for open source. If this is a public open source project under an OSI-approved license, contact us to request a free Business plan upgrade.

dylanjeffers and others added 2 commits November 26, 2026 13:36
get_top_fans now ranks listeners by plays (per track, or totalled across the
artist's 25 most-played tracks) instead of $AUDIO tipped. Adds an MCP CI
workflow running lint, typecheck, tests and build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…account

- sdk: token refresh middleware no longer holds an unread clone of non-401
  responses. Under node-fetch that stalled any response body over ~16KB when
  an API key was set, which hung every larger MCP tool result.
- get_my_favorites uses the library endpoint; the favorites/tracks route 404s.
- update_track_metadata checks ownership first instead of reporting success
  for a write the network then rejects.
- Tool errors now report the real Audius status and are logged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant