// 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: 'app_builds', operation: 'write', tags: [], httpMethod: 'post', httpPath: '/app_builds', operationId: 'createAppBuild', }; export const tool: Tool = { name: 'create_app_builds', 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\nCreates a new app build\n\nRequired permissions:\n - `developer:manage_builds`\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/app_build',\n $defs: {\n app_build: {\n type: 'object',\n description: 'An App Build object representing a build of an application',\n properties: {\n id: {\n type: 'string',\n description: 'The ID of the app build. It will look like apbu_xxxxx.'\n },\n checksum: {\n type: 'string',\n description: 'This is generated by the client and used to verify the integrity of the file that is submitted. It is a SHA256 hash of the app build file.'\n },\n created_at: {\n type: 'string',\n description: 'When this app build was created.',\n format: 'date-time'\n },\n file_url: {\n type: 'string',\n description: 'The URL to download the app build .zip file.'\n },\n is_production: {\n type: 'boolean',\n description: 'Whether this app build is currently being used in production.'\n },\n platform: {\n $ref: '#/$defs/app_build_platforms'\n },\n review_message: {\n type: 'string',\n description: 'The review message for the app build, if any. This is populated when the build is rejected and there is a reason specified by the reviewer.'\n },\n status: {\n $ref: '#/$defs/app_build_statuses'\n },\n supported_app_view_types: {\n type: 'array',\n description: 'The supported app view types for the app build. These are the views that the developer has specified that this build supports.',\n items: {\n $ref: '#/$defs/app_view_type'\n }\n }\n },\n required: [ 'id',\n 'checksum',\n 'created_at',\n 'file_url',\n 'is_production',\n 'platform',\n 'review_message',\n 'status',\n 'supported_app_view_types'\n ]\n },\n app_build_platforms: {\n type: 'string',\n description: 'The different platforms an app build can target.',\n enum: [ 'ios',\n 'android',\n 'web'\n ]\n },\n app_build_statuses: {\n type: 'string',\n description: 'The different statuses an AppBuild can be in.',\n enum: [ 'draft',\n 'pending',\n 'approved',\n 'rejected'\n ]\n },\n app_view_type: {\n type: 'string',\n description: 'The different types of an app view',\n enum: [ 'hub',\n 'discover',\n 'dash',\n 'dashboard',\n 'analytics'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { attachment: { anyOf: [ { type: 'object', title: 'AttachmentInputWithDirectUploadId', description: 'Input for an attachment', properties: { direct_upload_id: { type: 'string', description: 'This ID should be used the first time you upload an attachment. It is the ID of the direct upload that was created when uploading the file to S3 via the mediaDirectUpload mutation.', }, }, required: ['direct_upload_id'], }, { type: 'object', title: 'AttachmentInputWithId', description: 'Input for an attachment', properties: { id: { type: 'string', description: "The ID of an existing attachment object. Use this when updating a resource and keeping a subset of the attachments. Don't use this unless you know what you're doing.", }, }, required: ['id'], }, ], description: 'Attachment input for the app build file. This should be an upload in .zip format. The zip should contain at least one main_js_bundle.hbc file and optionally an assets folder next to it.', }, checksum: { type: 'string', description: 'Checksum of the app build file. This is generated by the client and used to verify the integrity of the file that is submitted when un-packaged later on a device.', }, platform: { $ref: '#/$defs/app_build_platforms', }, ai_prompt_id: { type: 'string', description: 'The id of the ai prompt that created this build', }, app_id: { type: 'string', description: 'The ID of the app to create a build for. By default the current app from the api key is used.', }, supported_app_view_types: { type: 'array', description: 'Supported app view types for the app build. A build can specify multiple view types, but should only specify ones that its code supports.', items: { $ref: '#/$defs/app_view_type', }, }, 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: ['attachment', 'checksum', 'platform'], $defs: { app_build_platforms: { type: 'string', description: 'The different platforms an app build can target.', enum: ['ios', 'android', 'web'], }, app_view_type: { type: 'string', description: 'The different types of an app view', enum: ['hub', 'discover', 'dash', 'dashboard', 'analytics'], }, }, }, annotations: {}, }; export const handler = async (client: Whop, args: Record | undefined) => { const { jq_filter, ...body } = args as any; try { return asTextContentResult(await maybeFilter(jq_filter, await client.appBuilds.create(body))); } catch (error) { if (error instanceof Whop.APIError || isJqError(error)) { return asErrorResult(error.message); } throw error; } }; export default { metadata, tool, handler };