@sinch/mcp
Version:
Sinch MCP server
50 lines • 2.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.manageConferenceParticipantHandler = exports.registerManageConferenceParticipant = void 0;
const zod_1 = require("zod");
const voice_service_helper_1 = require("./utils/voice-service-helper");
const voice_tools_helper_1 = require("./utils/voice-tools-helper");
const utils_1 = require("../../utils");
const types_1 = require("../../types");
const TOOL_KEY = 'manageConferenceParticipant';
const TOOL_NAME = (0, voice_tools_helper_1.getToolName)(TOOL_KEY);
const registerManageConferenceParticipant = (server, tags) => {
if (!(0, utils_1.matchesAnyTag)(tags, voice_tools_helper_1.voiceToolsConfig[TOOL_KEY].tags))
return;
server.tool(TOOL_NAME, 'Manage a conference participant. The conference is identified by the conference Id used in the callout, and the participants by the callId associated to their phone number when the conference callout to their number was made', {
conferenceId: zod_1.z.string().describe('The conference ID used in the callout to create the conference'),
participantId: zod_1.z.string().describe('The participant ID, which is the call ID from the conference callout'),
action: zod_1.z.enum(['mute', 'unmute', 'onhold', 'resume']).describe('The action to perform on the participant')
}, exports.manageConferenceParticipantHandler);
};
exports.registerManageConferenceParticipant = registerManageConferenceParticipant;
const manageConferenceParticipantHandler = async ({ conferenceId, participantId, action }) => {
const maybeService = (0, voice_service_helper_1.getVoiceService)(TOOL_NAME);
if ((0, utils_1.isPromptResponse)(maybeService)) {
return maybeService.promptResponse;
}
const voiceService = maybeService;
try {
await voiceService.conferences.manageParticipant({
conferenceId,
callId: participantId,
manageParticipantRequestBody: {
command: action
}
});
return new types_1.PromptResponse(JSON.stringify({
success: true,
conference_id: conferenceId,
participant_id: participantId,
action: action
})).promptResponse;
}
catch (error) {
return new types_1.PromptResponse(JSON.stringify({
success: false,
error: error instanceof Error ? error.message : String(error)
})).promptResponse;
}
};
exports.manageConferenceParticipantHandler = manageConferenceParticipantHandler;
//# sourceMappingURL=manage-conference-participant.js.map