@sinch/mcp
Version:
Sinch MCP server
37 lines • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getVoiceService = void 0;
const types_1 = require("../../../types");
const sdk_client_1 = require("@sinch/sdk-client");
const voice_1 = require("@sinch/voice");
const utils_1 = require("../../../utils");
const getVoiceService = (toolName) => {
const applicationKey = process.env.APPLICATION_KEY;
const applicationSecret = process.env.APPLICATION_SECRET;
if (!applicationKey && !applicationSecret) {
return new types_1.PromptResponse('Missing environment variables: "APPLICATION_KEY" and "APPLICATION_SECRET".');
}
if (!applicationKey) {
return new types_1.PromptResponse('Missing environment variable: "APPLICATION_KEY".');
}
if (!applicationSecret) {
return new types_1.PromptResponse('Missing environment variable: "APPLICATION_SECRET".');
}
const voiceService = new voice_1.VoiceService({});
const fetcher = new sdk_client_1.ApiFetchClient({
requestPlugins: [
new sdk_client_1.XTimestampRequest(),
new sdk_client_1.SigningRequest(applicationKey, applicationSecret),
new sdk_client_1.AdditionalHeadersRequest({
headers: (0, sdk_client_1.buildHeader)('User-Agent', (0, utils_1.formatUserAgent)(toolName, applicationKey)),
}),
],
});
// Remove the VersionRequest plugin, as we override the user-agent header
fetcher.apiClientOptions.requestPlugins?.shift();
fetcher.apiClientOptions.hostname = sdk_client_1.VOICE_HOSTNAME.replace(sdk_client_1.REGION_PATTERN, sdk_client_1.VoiceRegion.DEFAULT);
voiceService.lazyVoiceClient.apiFetchClient = fetcher;
return voiceService;
};
exports.getVoiceService = getVoiceService;
//# sourceMappingURL=voice-service-helper.js.map