Skip to main content
Glama
heyzgj

CoinMarketCap Universal MCP Server

by heyzgj
base.ts1.31 kB
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z } from 'zod'; import { logError } from '../utils/error-handler'; /** * Tool registry for registering MCP tools */ export class ToolRegistry { /** * Creates a new instance of ToolRegistry * @param server MCP server instance */ constructor(private server: McpServer) {} /** * Registers a tool with the MCP server * @param name Tool name * @param paramsSchema Parameter schema as Zod raw shape * @param handler Function to handle tool calls */ registerTool( name: string, paramsSchema: z.ZodRawShape, handler: (params: any) => Promise<any> ): void { this.server.tool( name, paramsSchema, async (params) => { try { const data = await handler(params); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error: any) { // Log error logError(`tool-${name}`, error); // Return error message return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } } ); } }

Latest Blog Posts

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/heyzgj/mcp-feargreedindex'

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