get_user_inventory
Retrieve a user's inventory listings from Discogs, filtered by status, sorted, and paginated for easy management of music collections.
Instructions
Returns the list of listings in a user's inventory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | ||
| per_page | No | ||
| sort | No | ||
| sort_order | No | ||
| status | No | ||
| username | Yes |
Implementation Reference
- src/tools/marketplace.ts:183-197 (handler)Defines the 'get_user_inventory' MCP tool, including name, description, parameters schema, and the execute handler that calls UserInventoryService.get(args).export const getUserInventoryTool: Tool<FastMCPSessionAuth, typeof UserInventoryGetParamsSchema> = { name: 'get_user_inventory', description: `Returns the list of listings in a user's inventory`, parameters: UserInventoryGetParamsSchema, execute: async (args) => { try { const userInventoryService = new UserInventoryService(); const inventory = await userInventoryService.get(args); return JSON.stringify(inventory); } catch (error) { throw formatDiscogsError(error); } }, };
- src/types/user/inventory.ts:5-19 (schema)Zod schema for input parameters of the get_user_inventory tool, extending UsernameInputSchema with optional status and query params.export const UserInventoryGetParamsSchema = UsernameInputSchema.extend({ status: SaleStatusSchema.optional(), }).merge( QueryParamsSchema([ 'listed', 'price', 'item', 'artist', 'label', 'catno', 'audio', 'status', 'location', ]), );
- src/tools/marketplace.ts:241-241 (registration)Registers the getUserInventoryTool with the FastMCP server.server.addTool(getUserInventoryTool);
- src/services/user/inventory.ts:20-36 (helper)The get method in UserInventoryService that performs the Discogs API request to fetch user inventory and validates the response.async get({ username, ...options }: UserInventoryGetParams): Promise<UserInventoryResponse> { try { const response = await this.request<UserInventoryResponse>(`/${username}/inventory`, { params: options, }); // Validate the response using Zod schema const validatedResponse = UserInventoryResponseSchema.parse(response); return validatedResponse; } catch (error) { if (isDiscogsError(error)) { throw error; } throw new Error(`Failed to get inventory: ${String(error)}`); } }
- src/tools/index.ts:17-17 (registration)Calls registerMarketplaceTools in the top-level tool registration function, which includes get_user_inventory.registerMarketplaceTools(server);