@sinch/mcp
Version:
Sinch MCP server
48 lines • 2.32 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, utils_1.matchesAnyTag)(tags, verification_tools_helper_1.verificationToolsConfig[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 }) => {
try {
const maybeService = (0, verification_service_helper_1.getVerificationService)(TOOL_NAME);
if ((0, utils_1.isPromptResponse)(maybeService)) {
return maybeService.promptResponse;
}
const verificationService = maybeService;
const response = await verificationService.verifications.startSms({
startVerificationWithSmsRequestBody: {
identity: {
type: 'number',
endpoint: phoneNumber
}
}
});
return new types_1.PromptResponse(JSON.stringify({
success: true,
verification_id: response.id,
phone_number: phoneNumber
})).promptResponse;
}
catch (error) {
return new types_1.PromptResponse(JSON.stringify({
success: false,
error: error instanceof Error ? error.message : String(error)
})).promptResponse;
}
};
exports.startSmsVerificationHandler = startSmsVerificationHandler;
//# sourceMappingURL=start-sms-verification.js.map