@sinch/mcp
Version:
Sinch MCP server
38 lines • 2.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.listAllAppsHandler = exports.registerListAllApps = void 0;
const utils_1 = require("../../utils");
const format_list_all_apps_response_1 = require("./utils/format-list-all-apps-response");
const conversation_service_helper_1 = require("./utils/conversation-service-helper");
const types_1 = require("../../types");
const registerListAllApps = (server, tags) => {
if (!(0, utils_1.hasMatchingTag)(['all', 'conversation', 'notification'], tags)) {
return;
}
server.tool('list-all-apps', 'Get a list of all Conversation apps in the account. Apps are created and configured in the Sinch Dashboard or with the Conversation API. The App is the entity that holds the credentials related to the various channels', exports.listAllAppsHandler);
};
exports.registerListAllApps = registerListAllApps;
const listAllAppsHandler = async () => {
const maybeClient = (0, conversation_service_helper_1.getConversationService)();
if ((0, utils_1.isPromptResponse)(maybeClient)) {
return maybeClient.promptResponse;
}
const sinchClient = maybeClient;
const regions = ['us', 'eu', 'br'];
let reply = '';
try {
for (const region of regions) {
sinchClient.conversation.setRegion(region);
const response = await sinchClient.conversation.app.list({});
reply += `${reply ? '\n' : ''}List of conversations apps in the '${region}' region: ${JSON.stringify((0, format_list_all_apps_response_1.formatListAllAppsResponse)(response))}`;
}
}
catch (error) {
return new types_1.PromptResponse(`Error fetching apps: ${error instanceof Error ? error.message : 'Unknown error'}`).promptResponse;
}
return new types_1.PromptResponse(`${reply}.\nPlease return the data in a structured array format with each item on a separate line. Just display the Id, display name, channels and region columns. Example:
| ID | Display name | Channels | Region |
| 0123 | My app name | SMS, MESSENGER | US |`).promptResponse;
};
exports.listAllAppsHandler = listAllAppsHandler;
//# sourceMappingURL=list-all-apps.js.map