// 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: 'apps', operation: 'read', tags: [], httpMethod: 'get', httpPath: '/apps/{id}', operationId: 'retrieveApp', }; export const tool: Tool = { name: 'retrieve_apps', 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 an app by ID\n\nRequired permissions:\n - `developer:manage_api_key`\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/app',\n $defs: {\n app: {\n type: 'object',\n description: 'An object representing an app',\n properties: {\n id: {\n type: 'string',\n description: 'The ID of the app'\n },\n api_key: {\n type: 'object',\n description: 'The API key for the app',\n properties: {\n id: {\n type: 'string',\n description: 'The ID of this API key'\n },\n token: {\n type: 'string',\n description: 'This is the API key used to authenticate requests'\n },\n created_at: {\n type: 'string',\n description: 'When this API key was created at',\n format: 'date-time'\n }\n },\n required: [ 'id',\n 'token',\n 'created_at'\n ]\n },\n app_type: {\n $ref: '#/$defs/app_type'\n },\n base_url: {\n type: 'string',\n description: 'The base url of the app'\n },\n company: {\n type: 'object',\n description: 'The company that owns the app',\n properties: {\n id: {\n type: 'string',\n description: 'The ID (tag) of the company.'\n },\n title: {\n type: 'string',\n description: 'The title of the company.'\n }\n },\n required: [ 'id',\n 'title'\n ]\n },\n creator: {\n type: 'object',\n description: 'The creator of the app',\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 dashboard_path: {\n type: 'string',\n description: 'The path part for a specific view of the app. This is the template part of the url after the base domain. Eg: /experiences/[experienceId]'\n },\n description: {\n type: 'string',\n description: 'The description of the app'\n },\n discover_path: {\n type: 'string',\n description: 'The path part for a specific view of the app. This is the template part of the url after the base domain. Eg: /experiences/[experienceId]'\n },\n domain_id: {\n type: 'string',\n description: 'The unique part of the proxied domain for this app. Used to generate the base url used to display the app inside the whop platform. Refers to the id part in the final url: https://{domain_id}.apps.whop.com'\n },\n experience_path: {\n type: 'string',\n description: 'The path part for a specific view of the app. This is the template part of the url after the base domain. Eg: /experiences/[experienceId]'\n },\n icon: {\n type: 'object',\n description: 'The icon for the app. This icon is shown on discovery, on the product page, on checkout, and as a default icon for the experiences.',\n properties: {\n url: {\n type: 'string',\n description: 'This is the URL you use to render optimized attachments on the client. This should be used for apps.'\n }\n },\n required: [ 'url'\n ]\n },\n name: {\n type: 'string',\n description: 'The name of the app'\n },\n requested_permissions: {\n type: 'array',\n description: 'The set of permissions that an app requests to be granted when a user installs the app.',\n items: {\n type: 'object',\n description: 'A permission that the app requests from the admin of a company during the oauth flow.',\n properties: {\n is_required: {\n type: 'boolean',\n description: 'Whether the action is required for the app to function.'\n },\n justification: {\n type: 'string',\n description: 'The reason for requesting the action.'\n },\n permission_action: {\n type: 'object',\n description: 'The action that the app will request off of users when a user installs the app.',\n properties: {\n action: {\n type: 'string',\n description: 'The identifier of the action.'\n },\n name: {\n type: 'string',\n description: 'The human readable name of the action.'\n }\n },\n required: [ 'action',\n 'name'\n ]\n }\n },\n required: [ 'is_required',\n 'justification',\n 'permission_action'\n ]\n }\n },\n stats: {\n type: 'object',\n description: 'A collection of stats for the app.',\n properties: {\n dau: {\n type: 'integer',\n description: 'This is the number of users that have spent time in this app in the last 24 hours.'\n },\n mau: {\n type: 'integer',\n description: 'This is the number of users that have spent time in this app in the last 28 days.'\n },\n time_spent_last24_hours: {\n type: 'integer',\n description: 'This how much time, in seconds, users have spent in this app in the last 24 hours.'\n },\n wau: {\n type: 'integer',\n description: 'This is the number of users that have spent time in this app in the last 7 days.'\n }\n },\n required: [ 'dau',\n 'mau',\n 'time_spent_last24_hours',\n 'wau'\n ]\n },\n status: {\n $ref: '#/$defs/app_statuses'\n },\n verified: {\n type: 'boolean',\n description: 'Whether this app has been verified by Whop. Verified apps are endorsed by whop and are shown in the \\'featured apps\\' section of the app store.'\n }\n },\n required: [ 'id',\n 'api_key',\n 'app_type',\n 'base_url',\n 'company',\n 'creator',\n 'dashboard_path',\n 'description',\n 'discover_path',\n 'domain_id',\n 'experience_path',\n 'icon',\n 'name',\n 'requested_permissions',\n 'stats',\n 'status',\n 'verified'\n ]\n },\n app_type: {\n type: 'string',\n description: 'The type of end-user an app is built for',\n enum: [ 'b2b_app',\n 'b2c_app',\n 'company_app',\n 'component'\n ]\n },\n app_statuses: {\n type: 'string',\n description: 'The status of an experience interface',\n enum: [ 'live',\n 'unlisted',\n 'hidden'\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.apps.retrieve(id))); } catch (error) { if (error instanceof Whop.APIError || isJqError(error)) { return asErrorResult(error.message); } throw error; } }; export default { metadata, tool, handler };