two-factor-auth
Enable or retrieve two-factor authentication (2FA) codes for Israeli bank accounts using phone number verification. Supports major banks and card providers for secure account access.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | ||
| bankId | Yes | ||
| otpCode | No | ||
| phoneNumber | Yes |
Implementation Reference
- src/server.ts:113-156 (handler)The handler function for the 'two-factor-auth' tool. It validates the bankId, creates a scraper instance, and either triggers 2FA SMS via triggerTwoFactorAuth(phoneNumber) or retrieves a long-term 2FA token via getLongTermTwoFactorToken(otpCode), returning appropriate JSON responses or errors.async ({ bankId, phoneNumber, action, otpCode }) => { try { const validBankIds = new Set(Object.values(CompanyTypes)); if (!validBankIds.has(bankId as unknown as CompanyTypes)) { throw new Error(`Invalid bank ID: ${bankId}`); } const scraper = createScraper({ companyId: bankId as unknown as CompanyTypes, startDate: new Date() }); if (action === "trigger") { await scraper.triggerTwoFactorAuth(phoneNumber); return { content: [{ type: "text", text: JSON.stringify({ success: true, message: "2FA code sent" }) }] }; } else if (action === "get-token" && otpCode) { const result = await scraper.getLongTermTwoFactorToken(otpCode); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } else { throw new Error("Invalid action or missing OTP code"); } } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: "UNKNOWN_ERROR", message: error instanceof Error ? error.message : "Unknown error occurred" }) }], isError: true }; } }
- src/server.ts:107-112 (schema)Zod schema defining input parameters for the two-factor-auth tool: bankId (enum of banks), phoneNumber (string), action (trigger or get-token), otpCode (optional string).{ bankId: z.enum(Object.values(CompanyTypes) as [string, ...string[]]), phoneNumber: z.string(), action: z.enum(["trigger", "get-token"]), otpCode: z.string().optional() },
- src/server.ts:105-157 (registration)Registration of the 'two-factor-auth' tool on the MCP server using server.tool(name, inputSchema, handlerFunction).server.tool( "two-factor-auth", { bankId: z.enum(Object.values(CompanyTypes) as [string, ...string[]]), phoneNumber: z.string(), action: z.enum(["trigger", "get-token"]), otpCode: z.string().optional() }, async ({ bankId, phoneNumber, action, otpCode }) => { try { const validBankIds = new Set(Object.values(CompanyTypes)); if (!validBankIds.has(bankId as unknown as CompanyTypes)) { throw new Error(`Invalid bank ID: ${bankId}`); } const scraper = createScraper({ companyId: bankId as unknown as CompanyTypes, startDate: new Date() }); if (action === "trigger") { await scraper.triggerTwoFactorAuth(phoneNumber); return { content: [{ type: "text", text: JSON.stringify({ success: true, message: "2FA code sent" }) }] }; } else if (action === "get-token" && otpCode) { const result = await scraper.getLongTermTwoFactorToken(otpCode); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } else { throw new Error("Invalid action or missing OTP code"); } } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: "UNKNOWN_ERROR", message: error instanceof Error ? error.message : "Unknown error occurred" }) }], isError: true }; } } );