edit_user_collection_folder
Edit metadata for a user's Discogs collection folder, excluding folders 0 and 1. Manage folder details like name changes efficiently.
Instructions
Edit a folder's metadata. Folders 0 and 1 cannot be renamed.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder_id | Yes | ||
| name | No | ||
| username | Yes |
Implementation Reference
- src/tools/userCollection.ts:131-148 (handler)MCP tool handler for 'edit_user_collection_folder'. Creates UserService and calls collection.editFolder(args). Returns JSON string of the edited folder.export const editUserCollectionFolderTool: Tool< FastMCPSessionAuth, typeof UserCollectionFolderEditParamsSchema > = { name: 'edit_user_collection_folder', description: `Edit a folder's metadata. Folders 0 and 1 cannot be renamed.`, parameters: UserCollectionFolderEditParamsSchema, execute: async (args) => { try { const userService = new UserService(); const folder = await userService.collection.editFolder(args); return JSON.stringify(folder); } catch (error) { throw formatDiscogsError(error); } }, };
- src/types/user/collection.ts:66-76 (schema)Zod schemas for user collection folder parameters, including UserCollectionFolderEditParamsSchema used by the tool.export const UserCollectionFolderCreateParamsSchema = UsernameInputSchema.extend({ name: z.string().optional(), }); export const UserCollectionFolderEditParamsSchema = UserCollectionFolderCreateParamsSchema.merge(FolderIdParamSchema()); /** * Schema for a Discogs user collection folder get/delete parameters */ export const UserCollectionFolderParamsSchema = UsernameInputSchema.merge(FolderIdParamSchema());
- Implementation of editFolder in UserCollectionService that makes POST request to Discogs API endpoint /${username}/collection/folders/${folder_id} with body containing name.async editFolder({ username, folder_id, ...body }: UserCollectionFolderEditParams): Promise<UserCollectionFolder> { try { const response = await this.request<UserCollectionFolder>( `/${username}/collection/folders/${folder_id}`, { method: 'POST', body, }, ); // Validate the response using Zod schema const validatedResponse = UserCollectionFolderSchema.parse(response); return validatedResponse; } catch (error) { if (isDiscogsError(error)) { throw error; } // For unexpected errors, wrap them throw new Error(`Failed to edit folder: ${String(error)}`); } }
- src/tools/userCollection.ts:324-324 (registration)Tool registration call within registerUserCollectionTools function.server.addTool(editUserCollectionFolderTool);
- src/tools/index.ts:20-20 (registration)Top-level registration of user collection tools module containing the edit_user_collection_folder tool.registerUserCollectionTools(server);