@sinch/mcp
Version:
Sinch MCP server
36 lines • 1.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.startSmsVerificationHandler = exports.registerStartVerificationWithSms = void 0;
const zod_1 = require("zod");
const verification_service_helper_1 = require("./utils/verification-service-helper");
const verification_tools_helper_1 = require("./utils/verification-tools-helper");
const utils_1 = require("../../utils");
const types_1 = require("../../types");
const TOOL_KEY = 'startSmsVerification';
const TOOL_NAME = (0, verification_tools_helper_1.getToolName)(TOOL_KEY);
const registerStartVerificationWithSms = (server, tags) => {
if (!(0, verification_tools_helper_1.shouldRegisterTool)(TOOL_KEY, tags))
return;
server.tool(TOOL_NAME, 'Start new phone number verification requests. If the request is successful, you should ask the user to enter the OTP they received on the phone number we are verifying.', {
phoneNumber: zod_1.z.string().describe('Phone number in E.164 format to send the SMS to')
}, exports.startSmsVerificationHandler);
};
exports.registerStartVerificationWithSms = registerStartVerificationWithSms;
const startSmsVerificationHandler = async ({ phoneNumber }) => {
const maybeClient = (0, verification_service_helper_1.getVerificationClient)(TOOL_NAME);
if ((0, utils_1.isPromptResponse)(maybeClient)) {
return maybeClient.promptResponse;
}
const verificationService = maybeClient.verification;
const response = await verificationService.verifications.startSms({
startVerificationWithSmsRequestBody: {
identity: {
type: 'number',
endpoint: phoneNumber
}
}
});
return new types_1.PromptResponse(`Started verification for ${phoneNumber}. The verification ID is ${response.id}`).promptResponse;
};
exports.startSmsVerificationHandler = startSmsVerificationHandler;
//# sourceMappingURL=start-sms-verification.js.map