// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { isJqError, maybeFilter } from '@whop/mcp/filtering'; import { Metadata, asErrorResult, asTextContentResult } from '@whop/mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; import Whop from '@whop/sdk'; export const metadata: Metadata = { resource: 'products', operation: 'read', tags: [], httpMethod: 'get', httpPath: '/products/{id}', operationId: 'retrieveProduct', }; export const tool: Tool = { name: 'retrieve_products', description: "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nRetrieves a product by ID or route\n\nRequired permissions:\n - `access_pass:basic:read`\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/product',\n $defs: {\n product: {\n type: 'object',\n description: 'Represents a product on whop. Use products to sell anything on the platform.',\n properties: {\n id: {\n type: 'string',\n description: 'The internal ID of the public product.'\n },\n business_type: {\n $ref: '#/$defs/business_types'\n },\n company: {\n type: 'object',\n description: 'A short type of the company that this product belongs to.',\n properties: {\n id: {\n type: 'string',\n description: 'The ID (tag) of the company.'\n },\n route: {\n type: 'string',\n description: 'The slug/route of the company on the Whop site.'\n },\n title: {\n type: 'string',\n description: 'The title of the company.'\n }\n },\n required: [ 'id',\n 'route',\n 'title'\n ]\n },\n created_at: {\n type: 'string',\n description: 'When the product was created.',\n format: 'date-time'\n },\n custom_cta: {\n $ref: '#/$defs/custom_cta'\n },\n custom_cta_url: {\n type: 'string',\n description: 'The custom call to action URL for the product, if any.'\n },\n custom_statement_descriptor: {\n type: 'string',\n description: 'The custom statement descriptor for the product.'\n },\n description: {\n type: 'string',\n description: 'A short description of what the company offers or does.'\n },\n external_identifier: {\n type: 'string',\n description: 'A unique identifier used to create or update products. When provided on product creation endpoints, we’ll look up an existing product by this identifier — if it exists, we’ll update it; if not, we’ll create a new one.'\n },\n global_affiliate_percentage: {\n type: 'number',\n description: 'The percentage of a transaction a user is eligible to earn from the whop marketplace global affiliate program.'\n },\n global_affiliate_status: {\n $ref: '#/$defs/global_affiliate_status'\n },\n headline: {\n type: 'string',\n description: 'The headline of the product.'\n },\n industry_type: {\n $ref: '#/$defs/industry_types'\n },\n member_affiliate_percentage: {\n type: 'number',\n description: 'The percentage of a transaction a user is eligible to earn from the whop marketplace member affiliate program.'\n },\n member_affiliate_status: {\n $ref: '#/$defs/global_affiliate_status'\n },\n member_count: {\n type: 'integer',\n description: 'The number of active users for this product.'\n },\n owner_user: {\n type: 'object',\n description: 'The user that owns the product (company owner).',\n properties: {\n id: {\n type: 'string',\n description: 'The internal ID of the user.'\n },\n name: {\n type: 'string',\n description: 'The name of the user from their Whop account.'\n },\n username: {\n type: 'string',\n description: 'The username of the user from their Whop account.'\n }\n },\n required: [ 'id',\n 'name',\n 'username'\n ]\n },\n product_tax_code: {\n type: 'object',\n description: 'The product tax code for the product, if any.',\n properties: {\n id: {\n type: 'string',\n description: 'The internal ID of the product tax code.'\n },\n name: {\n type: 'string',\n description: 'The name of the product tax code.'\n },\n product_type: {\n type: 'string',\n description: 'The type of product this tax code applies to.',\n enum: [ 'physical',\n 'digital',\n 'services'\n ]\n }\n },\n required: [ 'id',\n 'name',\n 'product_type'\n ]\n },\n published_reviews_count: {\n type: 'integer',\n description: 'The number of reviews that have been published for the product.'\n },\n route: {\n type: 'string',\n description: 'The route of the product.'\n },\n title: {\n type: 'string',\n description: 'The title of the product. Use for Whop 4.0.'\n },\n updated_at: {\n type: 'string',\n description: 'When the product was updated.',\n format: 'date-time'\n },\n verified: {\n type: 'boolean',\n description: 'Whether this product is Whop verified.'\n },\n visibility: {\n $ref: '#/$defs/visibility'\n }\n },\n required: [ 'id',\n 'business_type',\n 'company',\n 'created_at',\n 'custom_cta',\n 'custom_cta_url',\n 'custom_statement_descriptor',\n 'description',\n 'external_identifier',\n 'global_affiliate_percentage',\n 'global_affiliate_status',\n 'headline',\n 'industry_type',\n 'member_affiliate_percentage',\n 'member_affiliate_status',\n 'member_count',\n 'owner_user',\n 'product_tax_code',\n 'published_reviews_count',\n 'route',\n 'title',\n 'updated_at',\n 'verified',\n 'visibility'\n ]\n },\n business_types: {\n type: 'string',\n description: 'The different business types a company can be.',\n enum: [ 'education_program',\n 'coaching',\n 'software',\n 'paid_group',\n 'newsletter',\n 'agency',\n 'physical_products',\n 'brick_and_mortar',\n 'events',\n 'coaching_and_courses',\n 'other',\n 'saas',\n 'course',\n 'community'\n ]\n },\n custom_cta: {\n type: 'string',\n description: 'The different types of custom CTAs that can be selected.',\n enum: [ 'get_access',\n 'join',\n 'order_now',\n 'shop_now',\n 'call_now',\n 'donate_now',\n 'contact_us',\n 'sign_up',\n 'subscribe',\n 'purchase',\n 'get_offer',\n 'apply_now',\n 'complete_order'\n ]\n },\n global_affiliate_status: {\n type: 'string',\n description: 'The different statuses of the global affiliate program for a product.',\n enum: [ 'enabled',\n 'disabled'\n ]\n },\n industry_types: {\n type: 'string',\n description: 'The different industry types a company can be in.',\n enum: [ 'trading',\n 'sports_betting',\n 'reselling',\n 'fitness',\n 'amazon_fba',\n 'real_estate',\n 'kindle_book_publishing',\n 'dating',\n 'agencies',\n 'health_and_wellness',\n 'social_media',\n 'sales',\n 'business',\n 'ecommerce',\n 'video_games',\n 'home_services',\n 'ai',\n 'public_speaking',\n 'personal_finance',\n 'careers',\n 'travel',\n 'clipping',\n 'spirituality',\n 'vas',\n 'personal_development',\n 'software',\n 'other',\n 'marketing_agency',\n 'sales_agency',\n 'ai_agency',\n 'design_agency',\n 'coaching_agency',\n 'development_agency',\n 'recruiting_agency',\n 'customer_support_agency',\n 'clipping_agency',\n 'clothing',\n 'supplements',\n 'beauty_and_personal_care',\n 'fitness_gear',\n 'accessories',\n 'home_goods',\n 'electronics_and_gadgets',\n 'food_and_beverages',\n 'gym',\n 'restaurant',\n 'retail_store',\n 'coffee_shop',\n 'salon_spa',\n 'medical_dentist_office',\n 'hotel_lodging',\n 'auto_repair_shop',\n 'masterminds',\n 'webinars',\n 'bootcamps',\n 'convention',\n 'concerts',\n 'meetups',\n 'parties'\n ]\n },\n visibility: {\n type: 'string',\n description: 'Visibility of a resource',\n enum: [ 'visible',\n 'hidden',\n 'archived',\n 'quick_link'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { id: { type: 'string', }, jq_filter: { type: 'string', title: 'jq Filter', description: 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, required: ['id'], }, annotations: { readOnlyHint: true, }, }; export const handler = async (client: Whop, args: Record | undefined) => { const { id, jq_filter, ...body } = args as any; try { return asTextContentResult(await maybeFilter(jq_filter, await client.products.retrieve(id))); } catch (error) { if (error instanceof Whop.APIError || isJqError(error)) { return asErrorResult(error.message); } throw error; } }; export default { metadata, tool, handler };