Skip to main content
Glama

Rootstock MCP Server

by cuongpo

get_token_info

Query detailed information about an ERC20 token on the Rootstock blockchain using its contract address.

Instructions

Get information about an ERC20 token

Input Schema

NameRequiredDescriptionDefault
tokenAddressYesERC20 token contract address

Input Schema (JSON Schema)

{ "properties": { "tokenAddress": { "description": "ERC20 token contract address", "type": "string" } }, "required": [ "tokenAddress" ], "type": "object" }

Implementation Reference

  • Primary MCP tool handler for 'get_token_info'. Calls rootstockClient.getTokenInfo and formats the response as text content.
    private async handleGetTokenInfo(params: GetTokenInfoParams) { try { const result = await this.rootstockClient.getTokenInfo(params.tokenAddress); return { content: [ { type: 'text', text: `Token Information:\n\nAddress: ${result.address}\nName: ${result.name}\nSymbol: ${result.symbol}\nDecimals: ${result.decimals}\nTotal Supply: ${result.totalSupply}${result.owner ? `\nOwner: ${result.owner}` : ''}`, }, ], }; } catch (error) { throw new Error(`Failed to get token info: ${error}`); } }
  • src/index.ts:445-457 (registration)
    Tool registration in getAvailableTools() including name, description, and input schema for list tools request.
    name: 'get_token_info', description: 'Get information about an ERC20 token', inputSchema: { type: 'object', properties: { tokenAddress: { type: 'string', description: 'ERC20 token contract address', }, }, required: ['tokenAddress'], }, },
  • TypeScript interface defining input parameters for the get_token_info tool.
    export interface GetTokenInfoParams { tokenAddress: string; }
  • Core helper method in RootstockClient that queries the ERC20 smart contract for token details using ethers.js: name, symbol, decimals, totalSupply, and owner if available.
    async getTokenInfo(tokenAddress: string): Promise<{ address: string; name: string; symbol: string; decimals: number; totalSupply: string; owner?: string; }> { try { const tokenContract = new ethers.Contract( tokenAddress, this.getStandardERC20ABI(), this.getProvider() ); const [name, symbol, decimals, totalSupply] = await Promise.all([ tokenContract.name(), tokenContract.symbol(), tokenContract.decimals(), tokenContract.totalSupply(), ]); let owner: string | undefined; try { // Try to get owner if it's a mintable token const mintableContract = new ethers.Contract( tokenAddress, this.getMintableERC20ABI(), this.getProvider() ); owner = await mintableContract.owner(); } catch { // Owner function doesn't exist, it's a standard token } return { address: tokenAddress, name, symbol, decimals: Number(decimals), totalSupply: ethers.formatUnits(totalSupply, decimals), owner, }; } catch (error) { throw new Error(`Failed to get token info: ${error}`); } }
  • Alternative tool registration and inline handler in Smithery-compatible server using Zod schema.
    server.tool( "get_token_info", "Get comprehensive ERC20 token information including name, symbol, decimals, supply, and owner", { tokenAddress: z.string().describe("ERC20 token contract address"), }, async ({ tokenAddress }) => { try { const result = await rootstockClient.getTokenInfo(tokenAddress); const explorerUrl = rootstockClient.getExplorerUrl(); return { content: [ { type: "text", text: `ERC20 Token Information:\n\n` + `Contract Address: ${result.address}\n` + `Name: ${result.name}\n` + `Symbol: ${result.symbol}\n` + `Decimals: ${result.decimals}\n` + `Total Supply: ${result.totalSupply}\n` + `Owner: ${result.owner || 'N/A'}\n\n` + `Contract Explorer: ${explorerUrl}/address/${result.address}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error getting token info: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );

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/cuongpo/rootstock-mcp'

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