Skip to main content
Glama
cswkim

Discogs MCP Server

by cswkim

get_marketplace_orders

Retrieve and filter marketplace orders from Discogs by status, date, and other criteria to manage sales and track transactions.

Instructions

Get a list of marketplace orders

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusNo
created_afterNo
created_beforeNo
archivedNo
pageNo
per_pageNo
sortNo
sort_orderNo

Implementation Reference

  • The MCP tool handler (execute function) for 'get_marketplace_orders'. It creates a MarketplaceService instance and calls getOrders with the input args, returning the JSON stringified result or formatted error.
    export const getMarketplaceOrdersTool: Tool<FastMCPSessionAuth, typeof OrdersParamsSchema> = {
      name: 'get_marketplace_orders',
      description: 'Get a list of marketplace orders',
      parameters: OrdersParamsSchema,
      execute: async (args) => {
        try {
          const marketplaceService = new MarketplaceService();
          const orders = await marketplaceService.getOrders(args);
    
          return JSON.stringify(orders);
        } catch (error) {
          throw formatDiscogsError(error);
        }
      },
    };
  • Zod schema defining the input parameters for the get_marketplace_orders tool, including optional status, date filters, archived flag, and query params.
    export const OrdersParamsSchema = z
      .object({
        status: OrderStatusSchema.optional(),
        created_after: z.string().optional(),
        created_before: z.string().optional(),
        archived: z.boolean().optional(),
      })
      .merge(QueryParamsSchema(['id', 'buyer', 'created', 'status', 'last_activity'] as const));
  • Function that registers all marketplace tools, including getMarketplaceOrdersTool, to the FastMCP server. This function is called from src/tools/index.ts.
    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);
    }
  • The MarketplaceService.getOrders method, which performs the actual API request to Discogs /marketplace/orders endpoint with params, validates response with OrdersResponseSchema, and handles errors.
    async getOrders(params: OrdersParams): Promise<OrdersResponse> {
      try {
        const response = await this.request<OrdersResponse>(`/orders`, {
          params,
        });
    
        const validatedResponse = OrdersResponseSchema.parse(response);
        return validatedResponse;
      } catch (error) {
        if (isDiscogsError(error)) {
          throw error;
        }
    
        throw new Error(`Failed to get orders: ${String(error)}`);
      }
    }
  • Invocation of registerMarketplaceTools in the main registerTools function, which adds the get_marketplace_orders tool to the MCP server.
    registerMarketplaceTools(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