@sinch/mcp
Version:
Sinch MCP server
56 lines • 2.21 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sha256 = exports.shouldRegisterTool = exports.getToolName = void 0;
const utils_1 = require("../../../utils");
const tools_config_1 = require("../../../tools-config");
const mailgun_service_helper_1 = require("./mailgun-service-helper");
const crypto_1 = __importDefault(require("crypto"));
const toolsConfig = {
analyticsMetrics: {
name: 'analytics-metrics',
tags: ['all', 'email', 'analytics-metrics'],
},
listEmailEvents: {
name: 'list-email-events',
tags: ['all', 'email', 'list-email-events'],
},
listEmailTemplates: {
name: 'list-email-templates',
tags: ['all', 'email', 'notification', 'list-email-templates'],
},
retrieveEmailInfo: {
name: 'retrieve-email-info',
tags: ['all', 'email', 'notification', 'retrieve-email-info'],
},
sendEmail: {
name: 'send-email',
tags: ['all', 'email', 'notification', 'send-email'],
}
};
const getToolName = (toolKey) => toolsConfig[toolKey].name;
exports.getToolName = getToolName;
const shouldRegisterTool = (toolKey, tags) => {
const filteringTags = toolsConfig[toolKey].tags;
const toolName = toolsConfig[toolKey].name;
if (!(0, utils_1.matchesAnyTag)(filteringTags, tags)) {
tools_config_1.toolsStatusMap[toolName] = `The filtering tags don't contain ${filteringTags.join(' or ')}`;
return false;
}
if (typeof (0, mailgun_service_helper_1.getMailgunApiKey)() !== 'string') {
tools_config_1.toolsStatusMap[toolName] = `Incorrect configuration. The environment variable "MAILGUN_API_KEY" is not set.`;
return false;
}
tools_config_1.toolsStatusMap[toolName] = tools_config_1.ENABLED;
return true;
};
exports.shouldRegisterTool = shouldRegisterTool;
const sha256 = (str) => {
const hash = crypto_1.default.createHash('sha256');
hash.update(str);
return hash.digest('hex');
};
exports.sha256 = sha256;
//# sourceMappingURL=mailgun-tools-helper.js.map