feat: add collection write tools (folders, ratings, custom fields)#9
Merged
jhuggart merged 5 commits intorianvdm:mainfrom Mar 24, 2026
Merged
Conversation
Add 11 new MCP tools for modifying Discogs collections: Folder management: - list_folders, create_folder, edit_folder, delete_folder Collection items: - add_to_collection, remove_from_collection, move_release Ratings: - rate_release Custom fields: - list_custom_fields, edit_custom_field All write operations invalidate the user's collection cache to ensure subsequent reads reflect the changes. Custom field edits skip cache invalidation since they don't affect collection structure. Client layer (discogs.ts): 9 new API methods wrapping Discogs v2 endpoints with OAuth 1.0a auth, throttling, and retry. Cached layer (cachedDiscogs.ts): Pass-through wrappers that call invalidateUserCache() after mutations. Tools layer (authenticated.ts): 11 new server.tool() registrations following existing patterns (auth guard, Zod validation, consistent response format).
Add unit tests for new DiscogsClient write methods (folders, ratings, custom fields) and CachedDiscogsClient cache invalidation behavior. Fix hardcoded tool count in integration test (8 → 18).
Adds createCustomField() to DiscogsClient and CachedDiscogsClient (with cache invalidation), registers the create_custom_field MCP tool, and adds full test coverage — success, body shape, cache invalidation, and 429 rate limit tests. Bumps wrangler to ^4.76.0.
This reverts commit c893031.
|
🚀 Deploy succeeded! Your changes have been deployed to production. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 11 new MCP tools for modifying Discogs collections, complementing the existing read-only tools. This enables LLM-powered collection management workflows like bulk classification, folder organization, and rating.
New Tools
Folder management:
list_folders— List all collection folders with IDs and countscreate_folder— Create a new folderedit_folder— Rename an existing folderdelete_folder— Delete an empty folderCollection items:
add_to_collection— Add a release to a folderremove_from_collection— Remove a release instancemove_release— Move a release between foldersRatings:
rate_release— Rate a release 0-5 starsCustom fields:
list_custom_fields— List defined custom fieldsedit_custom_field— Set a custom field value on a release instanceImplementation
src/clients/discogs.ts): 9 new methods wrapping Discogs API v2 endpoints with OAuth 1.0a, throttling, and retry — following existing patterns exactlysrc/clients/cachedDiscogs.ts): Pass-through wrappers that callinvalidateUserCache()after mutations to ensure cache consistencysrc/mcp/tools/authenticated.ts): 11 newserver.tool()registrations with auth guards, Zod validation, and consistent response formattingDiscogsFolderandDiscogsCustomFieldinterfacesDiscogs API endpoints used
GET/users/{u}/collection/folderslist_foldersPOST/users/{u}/collection/folderscreate_folderPOST/users/{u}/collection/folders/{id}edit_folderDELETE/users/{u}/collection/folders/{id}delete_folderPOST/users/{u}/collection/folders/{f}/releases/{r}add_to_collectionDELETE.../instances/{i}remove_from_collectionPOST.../instances/{i}move_release,rate_releaseGET/users/{u}/collection/fieldslist_custom_fieldsPOST.../fields/{f}edit_custom_fieldCache invalidation
All write operations invalidate the user's collection cache (
collections,searches,stats) to ensure subsequent reads reflect changes.edit_custom_fieldskips invalidation since custom fields don't affect cached collection structure.Test plan
wrangler deploy --dry-runsucceeds (confirmed locally)list_folders→create_folder→list_folders(folder appears)add_to_collection→move_release→ verify folder changerate_release→search_collection(rating reflected)list_custom_fields→edit_custom_field→ verify value setdelete_folderon non-empty folder returns error