@trendmoon/mcp-server
Version:
TrendMoon MCP Server - Library and Standalone Server for Cryptocurrency and Social Data
90 lines • 3.78 kB
JavaScript
import { z } from "zod";
export const GetMessagesForChatSchema = z.object({
groupChatId: z.string(),
start_date: z.string().optional(), // CORRECTION: Renommé "dateFrom" en "start_date"
end_date: z.string().optional(), // CORRECTION: Renommé "dateTo" en "end_date"
interval: z.string().optional(),
limit: z.number().optional(),
offset: z.number().optional(),
});
export const SearchMessagesSchema = z.object({
query: z.string(),
start_date: z.string().optional(),
end_date: z.string().optional(),
interval: z.string().optional(),
groupChatId: z.string().optional(),
userId: z.string().optional(),
limit: z.number().optional(),
offset: z.number().optional(),
});
export const GetMessagesWithinTimeframeSchema = z.object({
dateFrom: z.string(),
dateTo: z.string(),
interval: z.string().optional(),
limit: z.number().optional(),
offset: z.number().optional(),
});
export const GetMessagesForUserSchema = z.object({
userId: z.string(),
start_date: z.string().optional(),
end_date: z.string().optional(),
interval: z.string().optional(),
limit: z.number().optional(),
offset: z.number().optional(),
});
export function registerMessageTools(mcpServer, messageService) {
mcpServer.registerTool("getMessagesForChat", {
description: "Get messages for a specific chat",
inputSchema: GetMessagesForChatSchema.shape,
}, async (params, _extra) => {
try {
// Le cast "as Types.GetMessagesForChatParams" est maintenant plus sûr
const data = await messageService.getMessagesForChat(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getMessagesForChat tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("searchMessages", {
description: "Search for messages based on various criteria",
inputSchema: SearchMessagesSchema.shape,
}, async (params, _extra) => {
try {
const data = await messageService.searchMessages(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in searchMessages tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("getMessagesWithinTimeframe", {
description: "Get messages within a specific timeframe",
inputSchema: GetMessagesWithinTimeframeSchema.shape,
}, async (params, _extra) => {
try {
const data = await messageService.getMessagesWithinTimeframe(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getMessagesWithinTimeframe tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("getMessagesForUser", {
description: "Get messages sent by a specific user",
inputSchema: GetMessagesForUserSchema.shape,
}, async (params, _extra) => {
try {
const data = await messageService.getMessagesForUser(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getMessagesForUser tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
}
//# sourceMappingURL=MessageTools.js.map