Skip to main content
Glama

Discogs MCP Server

by cswkim
inventory.ts3.2 kB
import { isDiscogsError } from '../errors.js'; import { type InventoryExportItem, InventoryExportItemSchema, type InventoryExportsResponse, InventoryExportsResponseSchema, type InventoryIdParam, } from '../types/inventory.js'; import { DiscogsService } from './index.js'; export class InventoryService extends DiscogsService { constructor() { super('/inventory'); } /** * Download an inventory export as a CSV * * @param {InventoryIdParam} params - The parameters for the request * @returns {string} The inventory export as a CSV * @throws {DiscogsAuthenticationError} If the request is not authenticated * @throws {DiscogsResourceNotFoundError} If the inventory export does not exist * @throws {Error} If there's an unexpected error */ async downloadExport({ id }: InventoryIdParam): Promise<string> { try { const response = await this.request<string>(`/export/${id}/download`); return response; } catch (error) { if (isDiscogsError(error)) { throw error; } throw new Error(`Failed to download inventory export: ${String(error)}`); } } /** * Request an export of your inventory as a CSV * * @returns {void} * @throws {DiscogsAuthenticationError} If the request is not authenticated * @throws {Error} If there's an unexpected error */ async export(): Promise<void> { try { await this.request<void>('/export', { method: 'POST', }); } catch (error) { if (isDiscogsError(error)) { throw error; } throw new Error(`Failed to export inventory: ${String(error)}`); } } /** * Get details about an inventory export * * @param {InventoryIdParam} params - The parameters for the request * @returns {InventoryExportItem} The inventory export item * @throws {DiscogsAuthenticationError} If the request is not authenticated * @throws {DiscogsResourceNotFoundError} If the inventory export does not exist * @throws {Error} If there's an unexpected error */ async getExport({ id }: InventoryIdParam): Promise<InventoryExportItem> { try { const response = await this.request<InventoryExportItem>(`/export/${id}`); const validatedResponse = InventoryExportItemSchema.parse(response); return validatedResponse; } catch (error) { if (isDiscogsError(error)) { throw error; } throw new Error(`Failed to get inventory export: ${String(error)}`); } } /** * Get a list of all recent exports of your inventory * * @returns {InventoryExportsResponse} The inventory exports * @throws {DiscogsAuthenticationError} If the request is not authenticated * @throws {Error} If there's an unexpected error */ 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)}`); } } }

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