Skip to main content
Glama
cswkim

Discogs MCP Server

by cswkim

get_inventory_exports

Retrieve recent exports of your Discogs inventory to track and manage your music collection data.

Instructions

Get a list of all recent exports of your inventory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Tool definition including the handler (execute function) for 'get_inventory_exports', which calls InventoryService.getExports() and returns JSON stringified response.
    export const getInventoryExportsTool: Tool<FastMCPSessionAuth, ToolParameters> = {
      name: 'get_inventory_exports',
      description: 'Get a list of all recent exports of your inventory',
      parameters: z.object({}),
      execute: async () => {
        try {
          const inventoryService = new InventoryService();
          const exports = await inventoryService.getExports();
    
          return JSON.stringify(exports);
        } catch (error) {
          throw formatDiscogsError(error);
        }
      },
    };
  • Registers the getInventoryExportsTool on the FastMCP server instance.
    export function registerInventoryExportTool(server: FastMCP): void {
      server.addTool(inventoryExportTool);
      server.addTool(getInventoryExportsTool);
      server.addTool(getInventoryExportTool);
      server.addTool(downloadInventoryExportTool);
    }
  • Core helper method in InventoryService that fetches inventory exports from Discogs API endpoint '/inventory/export' and validates with schema.
    async getExports(): Promise<InventoryExportsResponse> {
      try {
        const response = await this.request<InventoryExportsResponse>('/export');
    
        const validatedResponse = InventoryExportsResponseSchema.parse(response);
        return validatedResponse;
      } catch (error) {
        if (isDiscogsError(error)) {
          throw error;
        }
        throw new Error(`Failed to get inventory exports: ${String(error)}`);
      }
    }
  • Zod schemas for InventoryExportItem and InventoryExportsResponse used to validate the API response in the helper.
    export const InventoryExportItemSchema = z.object({
      status: z.string(),
      created_ts: z.string().nullable(),
      url: urlOrEmptySchema(),
      finished_ts: z.string().nullable(),
      download_url: urlOrEmptySchema(),
      filename: z.string(),
      id: z.number(),
    });
    
    export const InventoryExportsResponseSchema = PaginatedResponseSchema(
      InventoryExportItemSchema,
      'items',
    );
  • Top-level registration function that calls registerInventoryExportTool to add the tool to the server.
    export function registerTools(server: FastMCP): void {
      registerDatabaseTools(server);
      registerMarketplaceTools(server);
      registerInventoryExportTool(server);
      registerUserIdentityTools(server);
      registerUserCollectionTools(server);
      registerUserWantlistTools(server);
      registerUserListsTools(server);
      registerMediaTools(server);
    }

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