Skip to main content
Glama

Nobitex Market Data MCP Server

by xmannii
market.tools.ts1.59 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; import { NobitexService, MarketStatsParamsSchema } from "../services/nobitex.service.js"; /** * Registers Nobitex market data tools with the MCP server. * @param server The McpServer instance. * @param nobitexService An instance of the NobitexService. */ export function registerMarketTools(server: McpServer, nobitexService: NobitexService) { async function handleToolCall<TParams>(toolName: string, serviceMethod: (params: TParams) => Promise<any>, params: TParams) { try { const data = await serviceMethod(params); const contentText = typeof data === 'string' ? data : JSON.stringify(data, null, 2); return { content: [{ type: "text" as const, text: contentText }], }; } catch (error: any) { console.error(`Error executing tool '${toolName}':`, error); // Log errors to stderr return { content: [{ type: "text" as const, text: `Error fetching data for ${toolName}: ${error.message}` }], isError: true }; } } const getShape = <T extends z.ZodRawShape>(schema: z.ZodObject<T>) => schema.shape; // the tools we have are here server.tool( "getMarketStats", getShape(MarketStatsParamsSchema), (params) => handleToolCall('getMarketStats', nobitexService.getMarketStats.bind(nobitexService), params) ); server.tool( "getGlobalStats", {}, (params) => handleToolCall('getGlobalStats', nobitexService.getGlobalStats.bind(nobitexService), params as Record<string, never>) ); }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xmannii/nobitex-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server