UNPKG

@trendmoon/mcp-server

Version:

TrendMoon MCP Server - Library and Standalone Server for Cryptocurrency and Social Data

120 lines 4.71 kB
import { z } from "zod"; // --- Schémas Zod (inchangés) --- export const GetTopAlertsTodaySchema = z.object({}); export const GetTopCategoriesTodaySchema = z.object({}); export const GetCategoryDominanceForAssetsSchema = z.object({ dateFrom: z.string().optional(), dateTo: z.string().optional(), interval: z.string().optional(), top: z.number().optional(), category: z.string().optional(), }); export const GetCategoryCoinsSchema = z.object({ category_name: z.string(), limit: z.number().optional(), offset: z.number().optional(), orderBy: z.string().optional(), orderDirection: z.string().optional(), }); export const GetAllCategoriesSchema = z.object({}); // Si les types sont exportables, remplacez 'any' par: // type McpToolCallbackExtra = RequestHandlerExtra<ServerRequest, ServerNotification>; export function registerCategoryTools(mcpServer, categoryService) { // Outil: getTopAlertsToday mcpServer.registerTool("getTopAlertsToday", { description: "Get top alerts from Trendmoon API for today", inputSchema: GetTopAlertsTodaySchema.shape, }, async (_params, _extra // Ajout du paramètre _extra ) => { try { const data = await categoryService.getTopAlertsToday(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { console.error("Error in getTopAlertsToday tool:", error); return { content: [{ type: "text", text: `Error executing getTopAlertsToday: ${error.message}` }], isError: true }; } }); // Outil: getTopCategoriesToday mcpServer.registerTool("getTopCategoriesToday", { description: "Get top categories from Trendmoon API for today", inputSchema: GetTopCategoriesTodaySchema.shape, }, async (_params, _extra) => { try { const data = await categoryService.getTopCategoriesToday(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { console.error("Error in getTopCategoriesToday tool:", error); return { content: [{ type: "text", text: `Error executing getTopCategoriesToday: ${error.message}` }], isError: true }; } }); // Outil: getCategoryDominanceForAssets mcpServer.registerTool("getCategoryDominanceForAssets", { description: "Get category dominance data for assets", inputSchema: GetCategoryDominanceForAssetsSchema.shape, }, async (params, _extra) => { try { const data = await categoryService.getCategoryDominanceForAssets(params); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { console.error("Error in getCategoryDominanceForAssets tool:", error); return { content: [{ type: "text", text: `Error executing getCategoryDominanceForAssets: ${error.message}` }], isError: true }; } }); // Outil: getCategoryCoins mcpServer.registerTool("getCategoryCoins", { description: "Get coins within a specific category", inputSchema: GetCategoryCoinsSchema.shape, }, async (params, _extra) => { try { const data = await categoryService.getCategoryCoins(params); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { console.error("Error in getCategoryCoins tool:", error); return { content: [{ type: "text", text: `Error executing getCategoryCoins: ${error.message}` }], isError: true }; } }); // Outil: getAllCategories mcpServer.registerTool("getAllCategories", { description: "Get all available categories", inputSchema: GetAllCategoriesSchema.shape, }, async (_params, _extra) => { try { const data = await categoryService.getAllCategories(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { console.error("Error in getAllCategories tool:", error); return { content: [{ type: "text", text: `Error executing getAllCategories: ${error.message}` }], isError: true }; } }); } //# sourceMappingURL=CategoryTools.js.map