get_top_tokens_by_market_cap
Fetch top cryptocurrencies by market capitalization using Token Metrics API. Specify the number of tokens (up to 100) and control pagination to retrieve precise data for crypto analysis and decision-making.
Instructions
Fetch the the list of coins with top market cap from Token Metrics API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Enables pagination and data retrieval control by skipping a specified number of items before fetching data. Page should be a non-negative integer, with 1 indicating the beginning of the dataset. | |
| top_k | No | Specifies the number of top cryptocurrencies to retrieve, based on their market capitalization. Default is 50. Maximum is 100. Exmaple: 100 |
Implementation Reference
- src/tools/top-tokens.ts:44-54 (handler)Specific handler that performs the API request to the '/top-market-cap-tokens' endpoint using input parameters.
protected async performApiRequest( input: TopTokensInput, ): Promise<TokenMetricsResponse> { this.validateApiKey(); const params = this.buildParams(input); return (await this.makeApiRequest( "/top-market-cap-tokens", params, )) as TokenMetricsResponse; } - src/tools/top-tokens.ts:20-42 (schema)Tool definition including name, description, and input schema for parameters top_k and page.
getToolDefinition(): Tool { return { name: "get_top_tokens_by_market_cap", description: "Fetch the the list of coins with top market cap from Token Metrics API.", inputSchema: { type: "object", properties: { top_k: { type: "number", description: "Specifies the number of top cryptocurrencies to retrieve, based on their market capitalization. Default is 50. Maximum is 100. Exmaple: 100", }, page: { type: "number", description: "Enables pagination and data retrieval control by skipping a specified number of items before fetching data. Page should be a non-negative integer, with 1 indicating the beginning of the dataset.", }, }, required: [], }, } as Tool; } - src/tools/index.ts:38-40 (registration)Registration of TopTokensTool instance in the AVAILABLE_TOOLS array.
new CryptoInvestorTool(), new TopTokensTool(), new ResistanceSupportTool(), - src/tools/base-api-tool.ts:21-45 (helper)Base execute method called by MCP to run the tool, which invokes the specific performApiRequest and formats the response.
async execute(args: any): Promise<ToolResponse> { try { const result = await this.performApiRequest(args); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error fetching data: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } } - src/tools/top-tokens.ts:51-54 (helper)Validation of API key before making requests (inherited but called here).
"/top-market-cap-tokens", params, )) as TokenMetricsResponse; }