// 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: 'withdrawals', operation: 'read', tags: [], httpMethod: 'get', httpPath: '/withdrawals/{id}', operationId: 'retrieveWithdrawal', }; export const tool: Tool = { name: 'retrieve_withdrawals', 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 withdrawal by ID\n\nRequired permissions:\n - `payout:withdrawal:read`\n - `payout:destination:read`\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/withdrawal_retrieve_response',\n $defs: {\n withdrawal_retrieve_response: {\n type: 'object',\n description: 'A withdrawal request.',\n properties: {\n id: {\n type: 'string',\n description: 'Internal ID of the withdrawal request.'\n },\n amount: {\n type: 'number',\n description: 'How much money was attempted to be withdrawn, in a float type.'\n },\n created_at: {\n type: 'string',\n description: 'When the withdrawal request was created.',\n format: 'date-time'\n },\n currency: {\n $ref: '#/$defs/currency'\n },\n error_code: {\n type: 'string',\n description: 'The different error codes a payout can be in.',\n enum: [ 'account_closed',\n 'account_does_not_exist',\n 'account_information_invalid',\n 'account_number_invalid_region',\n 'account_frozen',\n 'account_lookup_failed',\n 'account_not_found',\n 'amount_out_of_bounds',\n 'attributes_not_validated',\n 'b2b_payments_prohibited',\n 'bank_statement_required',\n 'compliance_review',\n 'currency_not_supported',\n 'deposit_canceled',\n 'deposit_failed',\n 'deposit_rejected',\n 'destination_unavailable',\n 'exceeded_account_limit',\n 'expired_quote',\n 'generic_payout_error',\n 'technical_problem',\n 'identification_number_invalid',\n 'invalid_account_number',\n 'invalid_bank_code',\n 'invalid_beneficiary',\n 'invalid_branch_number',\n 'invalid_branch_code',\n 'invalid_phone_number',\n 'invalid_routing_number',\n 'invalid_swift_code',\n 'invalid_company_details',\n 'manual_cancelation',\n 'misc_error',\n 'missing_city_and_country',\n 'missing_phone_number',\n 'missing_remittance_info',\n 'payee_name_invalid',\n 'receiving_account_locked',\n 'rejected_by_compliance',\n 'rtp_not_supported',\n 'non_transaction_account',\n 'source_token_insufficient_funds',\n 'ssn_invalid',\n 'wallet_screenshot_required',\n 'unsupported_region'\n ]\n },\n error_message: {\n type: 'string',\n description: 'The error message for the withdrawal, if any.'\n },\n estimated_availability: {\n type: 'string',\n description: 'The estimated availability date for the withdrawal, if any.',\n format: 'date-time'\n },\n fee_amount: {\n type: 'number',\n description: 'The fee amount that was charged for the withdrawal. This is in the same currency as the withdrawal amount.'\n },\n fee_type: {\n $ref: '#/$defs/withdrawal_fee_types'\n },\n ledger_account: {\n type: 'object',\n description: 'The ledger account associated with the withdrawal.',\n properties: {\n id: {\n type: 'string',\n description: 'The ID of the LedgerAccount.'\n },\n company_id: {\n type: 'string',\n description: 'The ID of the company associated with this ledger account.'\n }\n },\n required: [ 'id',\n 'company_id'\n ]\n },\n markup_fee: {\n type: 'number',\n description: 'The markup fee that was charged for the withdrawal. This is in the same currency as the withdrawal amount. This only applies to platform accounts using Whop Rails.'\n },\n payout_token: {\n type: 'object',\n description: 'The payout token used for the withdrawal, if applicable.',\n properties: {\n id: {\n type: 'string',\n description: 'The ID of the payout token'\n },\n created_at: {\n type: 'string',\n description: 'The date and time the payout token was created',\n format: 'date-time'\n },\n destination_currency_code: {\n type: 'string',\n description: 'The currency code of the payout destination. This is the currency that payouts will be made in for this token.'\n },\n nickname: {\n type: 'string',\n description: 'An optional nickname for the payout token to help the user identify it. This is not used by the provider and is only for the user\\'s reference.'\n },\n payer_name: {\n type: 'string',\n description: 'The name of the payer associated with the payout token.'\n }\n },\n required: [ 'id',\n 'created_at',\n 'destination_currency_code',\n 'nickname',\n 'payer_name'\n ]\n },\n speed: {\n $ref: '#/$defs/withdrawal_speeds'\n },\n status: {\n $ref: '#/$defs/withdrawal_status'\n },\n trace_code: {\n type: 'string',\n description: 'The trace code for the payout, if applicable. Provided on ACH transactions when available.'\n },\n withdrawal_type: {\n $ref: '#/$defs/withdrawal_types'\n }\n },\n required: [ 'id',\n 'amount',\n 'created_at',\n 'currency',\n 'error_code',\n 'error_message',\n 'estimated_availability',\n 'fee_amount',\n 'fee_type',\n 'ledger_account',\n 'markup_fee',\n 'payout_token',\n 'speed',\n 'status',\n 'trace_code',\n 'withdrawal_type'\n ]\n },\n currency: {\n type: 'string',\n description: 'The available currencies on the platform',\n enum: [ 'usd',\n 'sgd',\n 'inr',\n 'aud',\n 'brl',\n 'cad',\n 'dkk',\n 'eur',\n 'nok',\n 'gbp',\n 'sek',\n 'chf',\n 'hkd',\n 'huf',\n 'jpy',\n 'mxn',\n 'myr',\n 'pln',\n 'czk',\n 'nzd',\n 'aed',\n 'eth',\n 'ape',\n 'cop',\n 'ron',\n 'thb',\n 'bgn',\n 'idr',\n 'dop',\n 'php',\n 'try',\n 'krw',\n 'twd',\n 'vnd',\n 'pkr',\n 'clp',\n 'uyu',\n 'ars',\n 'zar',\n 'dzd',\n 'tnd',\n 'mad',\n 'kes',\n 'kwd',\n 'jod',\n 'all',\n 'xcd',\n 'amd',\n 'bsd',\n 'bhd',\n 'bob',\n 'bam',\n 'khr',\n 'crc',\n 'xof',\n 'egp',\n 'etb',\n 'gmd',\n 'ghs',\n 'gtq',\n 'gyd',\n 'ils',\n 'jmd',\n 'mop',\n 'mga',\n 'mur',\n 'mdl',\n 'mnt',\n 'nad',\n 'ngn',\n 'mkd',\n 'omr',\n 'pyg',\n 'pen',\n 'qar',\n 'rwf',\n 'sar',\n 'rsd',\n 'lkr',\n 'tzs',\n 'ttd',\n 'uzs',\n 'rub',\n 'btc',\n 'cny'\n ]\n },\n withdrawal_fee_types: {\n type: 'string',\n description: 'The different fee types for a withdrawal.',\n enum: [ 'exclusive',\n 'inclusive'\n ]\n },\n withdrawal_speeds: {\n type: 'string',\n description: 'The different speeds of withdrawals',\n enum: [ 'standard',\n 'instant'\n ]\n },\n withdrawal_status: {\n type: 'string',\n description: 'The status of a withdrawal request',\n enum: [ 'requested',\n 'awaiting_payment',\n 'in_transit',\n 'completed',\n 'failed',\n 'canceled',\n 'denied'\n ]\n },\n withdrawal_types: {\n type: 'string',\n description: 'The types of withdrawals',\n enum: [ 'regular',\n 'clawback'\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.withdrawals.retrieve(id))); } catch (error) { if (error instanceof Whop.APIError || isJqError(error)) { return asErrorResult(error.message); } throw error; } }; export default { metadata, tool, handler };