@trendmoon/mcp-server
Version:
TrendMoon MCP Server - Library and Standalone Server for Cryptocurrency and Social Data
170 lines • 7.18 kB
JavaScript
import { z } from "zod";
export const GetSocialTrendSchema = z.object({
symbol: z.string().describe("The token symbol to get social trend data for, e.g. BTC, ETH, SOL"),
dateFrom: z.string().optional(),
dateTo: z.string().optional(),
interval: z.string().optional(),
});
export const GetProjectSummarySchema = z.object({
symbol: z.string().describe("The token symbol to get project summary for, e.g. BTC"),
daysAgo: z.number().optional(),
forceRegenerate: z.boolean().optional(),
});
export const GetKeywordTrendSchema = z.object({
keyword: z.string(),
dateFrom: z.string().optional(),
dateTo: z.string().optional(),
interval: z.string().optional(),
});
export const GetTopicPostsSchema = z.object({
topic: z.string(),
dateFrom: z.string().optional(),
dateTo: z.string().optional(),
interval: z.string().optional(),
limit: z.number().optional(),
offset: z.number().optional(),
});
export const GetTopicNewsSchema = z.object({
topic: z.string(),
dateFrom: z.string().optional(),
dateTo: z.string().optional(),
interval: z.string().optional(),
limit: z.number().optional(),
offset: z.number().optional(),
});
export const SearchSocialPostsSchema = z.object({
terms: z.string(),
dateFrom: z.string().optional(),
dateTo: z.string().optional(),
interval: z.string().optional(),
symbol: z.string().optional(),
author: z.string().optional(),
platform: z.string().optional(),
limit: z.number().optional(),
offset: z.number().optional(),
});
export const GetSocialTrendsSchema = z.object({
coin_ids: z.array(z.string()).describe("Array of token symbols to get social trends for, e.g. ['BTC', 'ETH']"), // CHANGEMENT ICI
start_date: z.string().optional(), // CHANGEMENT ICI
end_date: z.string().optional(), // CHANGEMENT ICI
interval: z.string().optional(),
});
export const GetTopicSummarySchema = z.object({
topic: z.string().describe("The topic to get a summary for, e.g. bitcoin, ethereum, hyperliquid"),
});
export function registerSocialTools(mcpServer, socialService) {
mcpServer.registerTool("getSocialTrend", {
description: "Get social trend data for a coin",
inputSchema: GetSocialTrendSchema.shape,
}, async (params, _extra) => {
try {
const data = await socialService.getSocialTrend(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getSocialTrend tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("getProjectSummary", {
description: "Get a project summary for a token",
inputSchema: GetProjectSummarySchema.shape,
}, async (params, _extra) => {
try {
const data = await socialService.getProjectSummary(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getProjectSummary tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("getKeywordTrend", {
description: "Get keyword trend data",
inputSchema: GetKeywordTrendSchema.shape,
}, async (params, _extra) => {
try {
const data = await socialService.getKeywordTrend(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getKeywordTrend tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("getTopicPosts", {
description: "Get posts related to a specific topic",
inputSchema: GetTopicPostsSchema.shape,
}, async (params, _extra) => {
try {
const data = await socialService.getTopicPosts(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getTopicPosts tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("getTopicNews", {
description: "Get news related to a specific topic",
inputSchema: GetTopicNewsSchema.shape,
}, async (params, _extra) => {
try {
const data = await socialService.getTopicNews(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getTopicNews tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("searchSocialPosts", {
description: "Search social posts",
inputSchema: SearchSocialPostsSchema.shape,
}, async (params, _extra) => {
try {
const data = await socialService.searchSocialPosts(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in searchSocialPosts tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("getSocialTrends", {
description: "Get social trends for multiple coins",
inputSchema: GetSocialTrendsSchema.shape,
}, async (params, _extra) => {
try {
const data = await socialService.getSocialTrends(params);
return { content: [{ type: "text", text: JSON.stringify(data) }] };
}
catch (error) {
console.error("Error in getSocialTrends tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
mcpServer.registerTool("topic_summary", {
description: "Get a concise summary of what's going on with a specific topic (e.g. bitcoin, ethereum, hyperliquid)",
inputSchema: GetTopicSummarySchema.shape,
}, async (params, _extra) => {
try {
const response = await fetch(`https://api.qa.trendmoon.ai/social/topic_summary?topic=${encodeURIComponent(params.topic)}`, {
method: 'GET',
headers: {
'accept': 'application/json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
}
catch (error) {
console.error("Error in topic_summary tool:", error);
return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] };
}
});
}
//# sourceMappingURL=SocialTools.js.map