Skip to main content
Glama
cswkim

Discogs MCP Server

by cswkim

get_user_collection_items

Retrieve items from a user's Discogs music collection with options to filter by folder, sort by criteria like artist or year, and paginate results for efficient browsing.

Instructions

Retrieve a list of items in a user's collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes
folder_idYes
pageNo
per_pageNo
sortNo
sort_orderNo

Implementation Reference

  • MCP tool definition and handler (execute function) for get_user_collection_items, which delegates to UserService.collection.getItems and returns JSON stringified result.
    export const getUserCollectionItemsTool: Tool<
      FastMCPSessionAuth,
      typeof UserCollectionItemsParamsSchema
    > = {
      name: 'get_user_collection_items',
      description: `Retrieve a list of items in a user's collection`,
      parameters: UserCollectionItemsParamsSchema,
      execute: async (args) => {
        try {
          const userService = new UserService();
          const items = await userService.collection.getItems(args);
    
          return JSON.stringify(items);
        } catch (error) {
          throw formatDiscogsError(error);
        }
      },
    };
  • Input parameters Zod schema (UserCollectionItemsParamsSchema) for the get_user_collection_items tool.
    export const UserCollectionItemsParamsSchema = UsernameInputSchema.merge(
      FolderIdParamSchema().merge(
        QueryParamsSchema([
          'added',
          'artist',
          'catno',
          'format',
          'label',
          'rating',
          'title',
          'year',
        ] as const),
      ),
    );
  • Direct registration of the tool in registerUserCollectionTools function.
    server.addTool(getUserCollectionItemsTool);
  • Registration of the user collection tools module (including this tool) in the main tools registry.
    registerUserCollectionTools(server);
  • Supporting UserCollectionService.getItems method that performs the HTTP request to Discogs API endpoint for fetching user collection items and validates the response.
    async getItems({
      username,
      folder_id,
      ...options
    }: UserCollectionItemsParams): Promise<UserCollectionItemsByRelease> {
      try {
        const response = await this.request<UserCollectionItemsByRelease>(
          `/${username}/collection/folders/${folder_id}/releases`,
          {
            params: options,
          },
        );
    
        const validatedResponse = UserCollectionItemsByReleaseSchema.parse(response);
        return validatedResponse;
      } catch (error) {
        if (isDiscogsError(error)) {
          throw error;
        }
    
        throw new Error(`Failed to get collection items: ${String(error)}`);
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cswkim/discogs-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server