Skip to main content
Glama
cswkim

Discogs MCP Server

by cswkim

create_marketplace_listing

Create a new marketplace listing on Discogs by specifying release details, condition, price, and status to sell music items.

Instructions

Create a new marketplace listing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
release_idYes
conditionYes
sleeve_conditionNo
priceYes
commentsNo
allow_offersNo
statusYes
external_idNo
locationNo
weightNo
format_quantityNo

Implementation Reference

  • The FastMCP Tool definition and handler (execute function) for the 'create_marketplace_listing' tool. It instantiates MarketplaceService and calls createListing with the input args.
    export const createMarketplaceListingTool: Tool<FastMCPSessionAuth, typeof ListingNewParamsSchema> =
      {
        name: 'create_marketplace_listing',
        description: 'Create a new marketplace listing',
        parameters: ListingNewParamsSchema,
        execute: async (args) => {
          try {
            const marketplaceService = new MarketplaceService();
            const listing = await marketplaceService.createListing(args);
    
            return JSON.stringify(listing);
          } catch (error) {
            throw formatDiscogsError(error);
          }
        },
      };
  • Zod schema defining the input parameters for the create_marketplace_listing tool (ListingNewParamsSchema).
    export const ListingNewParamsSchema = z.object({
      release_id: z.number().int(),
      condition: ConditionSchema,
      sleeve_condition: SleeveConditionSchema.optional(),
      price: z.number(),
      comments: z.string().optional(),
      allow_offers: z.boolean().optional(),
      status: SaleStatusSchema,
      external_id: z.string().optional(),
      location: z.string().optional(),
      weight: z.number().optional(),
      format_quantity: z.number().optional(),
    });
  • Registration of the createMarketplaceListingTool via server.addTool in the registerMarketplaceTools function.
    server.addTool(createMarketplaceListingTool);
  • The MarketplaceService.createListing method, which performs the HTTP POST request to the Discogs API endpoint '/marketplace/listings' with the provided parameters, handling errors and validation.
    async createListing(params: ListingNewParams): Promise<ListingNewResponse> {
      try {
        const response = await this.request<ListingNewResponse>(`/listings`, {
          method: 'POST',
          body: params,
        });
    
        const validatedResponse = ListingNewResponseSchema.parse(response);
        return validatedResponse;
      } catch (error) {
        if (isDiscogsError(error)) {
          throw error;
        }
    
        throw new Error(`Failed to create listing: ${String(error)}`);
      }
    }
  • The registerMarketplaceTools function that registers all marketplace-related tools, including create_marketplace_listing.
    export function registerMarketplaceTools(server: FastMCP): void {
      server.addTool(getUserInventoryTool);
      server.addTool(getMarketplaceListingTool);
      server.addTool(createMarketplaceListingTool);
      server.addTool(updateMarketplaceListingTool);
      server.addTool(deleteMarketplaceListingTool);
      server.addTool(getMarketplaceOrderTool);
      server.addTool(editMarketplaceOrderTool);
      server.addTool(getMarketplaceOrdersTool);
      server.addTool(getMarketplaceOrderMessagesTool);
      server.addTool(createMarketplaceOrderMessageTool);
      server.addTool(getMarketplaceReleaseStatsTool);
    }

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