get_user_collection_custom_fields
Retrieve user-defined custom fields for a Discogs collection by specifying a username. Access and manage collection notes fields associated with every release.
Instructions
Retrieve a list of user-defined collection notes fields. These fields are available on every release in the collection.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes |
Implementation Reference
- src/tools/userCollection.ts:172-192 (handler)Definition of the MCP Tool object 'getUserCollectionCustomFieldsTool' including the execute handler that wraps UserService.collection.getCustomFields and handles errors./** * MCP tool for fetching a Discogs user's collection custom fields */ export const getUserCollectionCustomFieldsTool: Tool< FastMCPSessionAuth, typeof UsernameInputSchema > = { name: 'get_user_collection_custom_fields', description: `Retrieve a list of user-defined collection notes fields. These fields are available on every release in the collection.`, parameters: UsernameInputSchema, execute: async (args) => { try { const userService = new UserService(); const customFields = await userService.collection.getCustomFields(args); return JSON.stringify(customFields); } catch (error) { throw formatDiscogsError(error); } }, };
- src/types/common.ts:120-125 (schema)Zod input schema for the tool parameters, requiring a 'username' string./** * Schema for a username input */ export const UsernameInputSchema = z.object({ username: z.string().min(1, 'username is required'), });
- src/tools/userCollection.ts:320-335 (registration)Function to register all user collection MCP tools to the FastMCP server, including getUserCollectionCustomFieldsTool at line 332.export function registerUserCollectionTools(server: FastMCP): void { server.addTool(getUserCollectionFoldersTool); server.addTool(createUserCollectionFolderTool); server.addTool(getUserCollectionFolderTool); server.addTool(editUserCollectionFolderTool); server.addTool(deleteUserCollectionFolderTool); server.addTool(findReleaseInUserCollectionTool); server.addTool(getUserCollectionItemsTool); server.addTool(addReleaseToUserCollectionFolderTool); server.addTool(rateReleaseInUserCollectionTool); server.addTool(moveReleaseInUserCollectionTool); server.addTool(deleteReleaseFromUserCollectionFolderTool); server.addTool(getUserCollectionCustomFieldsTool); server.addTool(editUserCollectionCustomFieldValueTool); server.addTool(getUserCollectionValueTool); }
- Core implementation in UserCollectionService.getCustomFields that performs the Discogs API GET request to /{username}/collection/fields and validates the response.async getCustomFields({ username }: UsernameInput): Promise<UserCollectionCustomFields> { try { const response = await this.request<UserCollectionCustomFields>( `/${username}/collection/fields`, ); const validatedResponse = UserCollectionCustomFieldsSchema.parse(response); return validatedResponse; } catch (error) { if (isDiscogsError(error)) { throw error; } throw new Error(`Failed to get collection custom fields: ${String(error)}`); } }
- src/types/user/collection.ts:17-32 (schema)Zod schema used to validate the API response for user collection custom fields, returned by the tool./** * Schema for custom fields in a user's collection */ export const UserCollectionCustomFieldsSchema = z.object({ fields: z.array( z.object({ id: z.number().int(), lines: z.number().int().optional(), name: z.string(), options: z.array(z.string()).optional(), position: z.number().int(), public: z.boolean(), type: z.string(), }), ), });