UNPKG

@trendmoon/mcp-server

Version:

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

39 lines 1.56 kB
import { z } from "zod"; export const SearchUsersSchema = z.object({ query: z.string().optional(), limit: z.number().optional(), offset: z.number().optional(), }); export const GetUserByIdentifierSchema = z.object({ userId: z.string().optional(), username: z.string().optional(), }); export function registerUserTools(mcpServer, userService) { mcpServer.registerTool("searchUsers", { description: "Search for users based on various criteria", inputSchema: SearchUsersSchema.shape, }, async (params, _extra) => { try { const data = await userService.searchUsers(params); return { content: [{ type: "text", text: JSON.stringify(data) }] }; } catch (error) { console.error("Error in searchUsers tool:", error); return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] }; } }); mcpServer.registerTool("getUserByIdentifier", { description: "Get a user by their ID or username", inputSchema: GetUserByIdentifierSchema.shape, }, async (params, _extra) => { try { const data = await userService.getUserByIdentifier(params); return { content: [{ type: "text", text: JSON.stringify(data) }] }; } catch (error) { console.error("Error in getUserByIdentifier tool:", error); return { isError: true, content: [{ type: "text", text: `Error: ${error.message}` }] }; } }); } //# sourceMappingURL=UserTools.js.map