Skip to main content
Glama
cswkim

Discogs MCP Server

by cswkim

get_list

Retrieve a specific Discogs music collection list using its unique ID to access saved records, artists, or releases.

Instructions

Get a list by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
list_idYes

Implementation Reference

  • The MCP tool handler for 'get_list', including name, description, parameters schema, and execute function that instantiates ListService and calls getList on the provided args.
    export const getListTool: Tool<FastMCPSessionAuth, typeof ListIdParamSchema> = {
      name: 'get_list',
      description: `Get a list by ID`,
      parameters: ListIdParamSchema,
      execute: async (args) => {
        try {
          const listService = new ListService();
          const list = await listService.getList(args);
    
          return JSON.stringify(list);
        } catch (error) {
          throw formatDiscogsError(error);
        }
      },
    };
  • Zod input schema for the get_list tool parameters, requiring a numeric list_id.
    export const ListIdParamSchema = z.object({
      list_id: z.number(),
    });
  • Registration of the get_list tool (and get_user_lists) on the FastMCP server instance.
    export function registerUserListsTools(server: FastMCP): void {
      server.addTool(getUserListsTool);
      server.addTool(getListTool);
    }
  • Core helper function in ListService that performs the Discogs API request to fetch the list by ID and validates the response with ListSchema.
    async getList({ list_id }: ListIdParam): Promise<List> {
      try {
        const response = await this.request<List>(`/${list_id}`);
    
        // Validate the response using Zod schema
        const validatedResponse = ListSchema.parse(response);
        return validatedResponse;
      } catch (error) {
        // If it's already a Discogs error, just rethrow it
        if (isDiscogsError(error)) {
          throw error;
        }
    
        // For validation errors or other unexpected errors, wrap them
        throw new Error(`Failed to get list: ${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