UNPKG

@sinch/mcp

Version:

Sinch MCP server

40 lines 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCallInformationHandler = exports.registerGetCallInformation = void 0; const zod_1 = require("zod"); const voice_tools_helper_1 = require("./utils/voice-tools-helper"); const types_1 = require("../../types"); const voice_service_helper_1 = require("./utils/voice-service-helper"); const utils_1 = require("../../utils"); const TOOL_KEY = 'getCallInformation'; const TOOL_NAME = (0, voice_tools_helper_1.getToolName)(TOOL_KEY); const registerGetCallInformation = (server, tags) => { if (!(0, utils_1.matchesAnyTag)(tags, voice_tools_helper_1.voiceToolsConfig[TOOL_KEY].tags)) return; server.tool(TOOL_NAME, 'Get information about a call using its ID', { callId: zod_1.z.string().describe('The call ID to get information about') }, exports.getCallInformationHandler); }; exports.registerGetCallInformation = registerGetCallInformation; const getCallInformationHandler = async ({ callId }) => { const maybeService = (0, voice_service_helper_1.getVoiceService)(TOOL_NAME); if ((0, utils_1.isPromptResponse)(maybeService)) { return maybeService.promptResponse; } const voiceService = maybeService; try { const response = await voiceService.calls.get({ callId }); return new types_1.PromptResponse(JSON.stringify({ success: true, call_information: response })).promptResponse; } catch (error) { return new types_1.PromptResponse(JSON.stringify({ success: false, error: error instanceof Error ? error.message : String(error) })).promptResponse; } }; exports.getCallInformationHandler = getCallInformationHandler; //# sourceMappingURL=get-call-information.js.map