@trendmoon/mcp-server
Version:
TrendMoon MCP Server - Library and Standalone Server for Cryptocurrency and Social Data
84 lines • 3.6 kB
JavaScript
import { z } from "zod";
export const GetChatByUsernameSchema = z.object({
group_username: z.string(), // CHANGEMENT ICI: Renommé "groupUsername" en "group_username"
});
export const GetGroupsServiceStatusSchema = z.object({});
export const GetSpecificGroupSchema = z.object({
groupId: z.string().optional(),
groupUsername: z.string().optional(),
});
export const AddNewGroupSchema = z.object({
group_username: z.string(),
group_type: z.string(),
platform: z.string(),
});
export const GetAllGroupsSchema = z.object({});
export function registerChatTools(mcpServer, chatService) {
mcpServer.registerTool("getChatByUsername", {
description: "Get chat details by group username",
inputSchema: GetChatByUsernameSchema.shape,
}, async (params, _extra) => {
try {
// Le cast "as Types.GetChatByUsernameParams" est maintenant plus sûr
const data = await chatService.getChatByUsername(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getChatByUsername tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("getGroupsServiceStatus", {
description: "Get the status of the groups service",
inputSchema: GetGroupsServiceStatusSchema.shape,
}, async (_params, _extra) => {
try {
const data = await chatService.getGroupsServiceStatus();
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getGroupsServiceStatus tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("getSpecificGroup", {
description: "Get the status of a specific group",
inputSchema: GetSpecificGroupSchema.shape,
}, async (params, _extra) => {
try {
const data = await chatService.getSpecificGroup(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getSpecificGroup tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("addNewGroup", {
description: "Add a new group to be monitored",
inputSchema: AddNewGroupSchema.shape,
}, async (params, _extra) => {
try {
const data = await chatService.addNewGroup(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in addNewGroup tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("getAllGroups", {
description: "Get a list of all monitored groups",
inputSchema: GetAllGroupsSchema.shape,
}, async (_params, _extra) => {
try {
const data = await chatService.getAllGroups();
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getAllGroups tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
}
//# sourceMappingURL=ChatTools.js.map