CREATE_WITHDRAWAL
Initiate a digital asset withdrawal by specifying currency, amount, recipient address, and network type.
Instructions
Request a digital asset withdrawal (requires private API)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| currency | Yes | ||
| amount | Yes | ||
| address | Yes | ||
| net_type | Yes | ||
| secondary_address | No | ||
| transaction_type | No |
Implementation Reference
- src/tools/create-withdrawal.ts:19-35 (handler)The execute function that performs the withdrawal request. It validates private API access is enabled, constructs the HTTP client, signs a JWT token with the request params, and POSTs to /withdraws/coin on Upbit's API.
export const createWithdrawalTool = { name: "CREATE_WITHDRAWAL", description: "Request a digital asset withdrawal (requires private API)", parameters: paramsSchema, execute: async (params: Params) => { ensurePrivateEnabled(); const baseURL = `${config.upbit.baseUrl}${config.upbit.apiBasePath}`; const client = createHttpClient(baseURL); const token = signJwtToken(params); const data = await fetchJson<unknown>(client, "/withdraws/coin", { method: "POST", data: params, headers: { Authorization: `Bearer ${token}` }, }); return JSON.stringify(data, null, 2); }, } as const; - src/tools/create-withdrawal.ts:6-15 (schema)Zod validation schema for CREATE_WITHDRAWAL parameters: currency (string), amount (string), address (string), net_type (string), optional secondary_address, and optional transaction_type (default or internal).
const paramsSchema = z .object({ currency: z.string(), amount: z.string(), address: z.string(), net_type: z.string(), secondary_address: z.string().optional(), transaction_type: z.enum(["default", "internal"]).optional(), }) .strict(); - src/index.ts:7-7 (registration)Import of the createWithdrawalTool from the tool module.
import { createWithdrawalTool } from "./tools/create-withdrawal.js"; - src/index.ts:40-40 (registration)Registration of the CREATE_WITHDRAWAL tool with the FastMCP server via server.addTool().
server.addTool(createWithdrawalTool); - src/lib/upbit-auth.ts:5-16 (helper)ensurePrivateEnabled() - helper that validates private API credentials are configured before proceeding with the withdrawal.
export function ensurePrivateEnabled(): void { if (!config.upbit.enablePrivate) { throw new Error( "Private trading tools are disabled. Set UPBIT_ENABLE_TRADING=true to enable.", ); } if (!config.upbit.accessKey || !config.upbit.secretKey) { throw new Error( "Upbit API keys are not configured. Set UPBIT_ACCESS_KEY and UPBIT_SECRET_KEY.", ); } }