get_user_inventory
Retrieve a user's Discogs inventory listings with filtering options for status, sorting, and pagination to manage music collections.
Instructions
Returns the list of listings in a user's inventory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | ||
| status | No | ||
| page | No | ||
| per_page | No | ||
| sort | No | ||
| sort_order | No |
Implementation Reference
- src/tools/marketplace.ts:183-197 (handler)MCP tool object defining the 'get_user_inventory' tool, including its name, description, input parameters schema, and the execute handler function that uses UserInventoryService to fetch the inventory.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 to the get_user_inventory tool, extending UsernameInputSchema with optional status and query parameters.export const UserInventoryGetParamsSchema = UsernameInputSchema.extend({ status: SaleStatusSchema.optional(), }).merge( QueryParamsSchema([ 'listed', 'price', 'item', 'artist', 'label', 'catno', 'audio', 'status', 'location', ]), );
- src/tools/marketplace.ts:240-252 (registration)Registration function that adds the get_user_inventory tool (and other marketplace tools) to the FastMCP server.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); }
- src/tools/index.ts:15-24 (registration)Top-level tool registration function that calls registerMarketplaceTools, thereby registering the get_user_inventory tool.export function registerTools(server: FastMCP): void { registerDatabaseTools(server); registerMarketplaceTools(server); registerInventoryExportTool(server); registerUserIdentityTools(server); registerUserCollectionTools(server); registerUserWantlistTools(server); registerUserListsTools(server); registerMediaTools(server); }
- src/services/user/inventory.ts:20-36 (helper)The get method of UserInventoryService, which performs the actual API request to fetch user inventory and validates the response. Called by the tool handler.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)}`); } }