Skip to main content
Glama

Rootstock MCP Server

by cuongpo

get_nft_info

Retrieve detailed information about an ERC721 NFT contract or specific token using the Rootstock MCP Server. Input the contract address and optional token ID to access metadata or ownership details.

Instructions

Get information about an ERC721 NFT contract or specific token

Input Schema

NameRequiredDescriptionDefault
tokenAddressYesContract address of the NFT
tokenIdNoOptional token ID to get specific token info

Input Schema (JSON Schema)

{ "properties": { "tokenAddress": { "description": "Contract address of the NFT", "type": "string" }, "tokenId": { "description": "Optional token ID to get specific token info", "type": "string" } }, "required": [ "tokenAddress" ], "type": "object" }

Implementation Reference

  • Primary MCP tool handler for 'get_nft_info'. Receives parameters, calls RootstockClient.getNFTInfo, formats and returns the response content.
    private async handleGetNFTInfo(params: GetNFTInfoParams) { try { const result = await this.rootstockClient.getNFTInfo(params.tokenAddress, params.tokenId); return { content: [ { type: 'text', text: `NFT Information:\n\nAddress: ${result.address}\nName: ${result.name}\nSymbol: ${result.symbol}\nTotal Supply: ${result.totalSupply}${result.tokenId ? `\nToken ID: ${result.tokenId}` : ''}${result.tokenURI ? `\nToken URI: ${result.tokenURI}` : ''}${result.owner ? `\nOwner: ${result.owner}` : ''}`, }, ], }; } catch (error) { throw new Error(`Failed to get NFT info: ${error}`); } }
  • src/index.ts:518-535 (registration)
    Tool registration in getAvailableTools() method, defining name, description, and input schema for the MCP server.
    { name: 'get_nft_info', description: 'Get information about an ERC721 NFT contract or specific token', inputSchema: { type: 'object', properties: { tokenAddress: { type: 'string', description: 'Contract address of the NFT', }, tokenId: { type: 'string', description: 'Optional token ID to get specific token info', }, }, required: ['tokenAddress'], }, },
  • TypeScript interface defining the input parameters for the get_nft_info tool.
    export interface GetNFTInfoParams { tokenAddress: string; tokenId?: string; }
  • Core blockchain interaction logic in RootstockClient. Queries ERC721 contract for name, symbol, totalSupply, and optionally tokenURI and ownerOf for specific tokenId.
    async getNFTInfo(tokenAddress: string, tokenId?: string): Promise<{ address: string; name: string; symbol: string; totalSupply: string; tokenId?: string; tokenURI?: string; owner?: string; }> { try { const nftContract = new ethers.Contract( tokenAddress, this.getStandardERC721ABI(), this.getProvider() ); const [name, symbol, totalSupply] = await Promise.all([ nftContract.name(), nftContract.symbol(), nftContract.totalSupply(), ]); const result = { address: tokenAddress, name, symbol, totalSupply: totalSupply.toString(), tokenId, }; // If tokenId is provided, get additional token-specific information if (tokenId) { try { const [tokenURI, owner] = await Promise.all([ nftContract.tokenURI(tokenId), nftContract.ownerOf(tokenId), ]); return { ...result, tokenURI, owner, }; } catch (error) { // Token might not exist or contract might not support these functions console.warn(`Could not get token-specific info for token ${tokenId}:`, error); return result; } } return result; } catch (error) { throw new Error(`Failed to get NFT info: ${error}`); } }
  • Alternative handler/registration for get_nft_info in the Smithery stateless server variant, using Zod schema inline.
    server.tool( "get_nft_info", "Get comprehensive ERC721 NFT information including collection details and specific token info", { tokenAddress: z.string().describe("ERC721 NFT contract address"), tokenId: z.string().optional().describe("Optional token ID to get specific token info"), }, async ({ tokenAddress, tokenId }) => { try { const result = await rootstockClient.getNFTInfo(tokenAddress, tokenId); const explorerUrl = rootstockClient.getExplorerUrl(); return { content: [ { type: "text", text: `ERC721 NFT Information:\n\n` + `Contract Address: ${result.address}\n` + `Collection Name: ${result.name}\n` + `Collection Symbol: ${result.symbol}\n` + `Total Supply: ${result.totalSupply}\n` + `${result.tokenId ? `Token ID: ${result.tokenId}\n` : ''}` + `${result.tokenURI ? `Token URI: ${result.tokenURI}\n` : ''}` + `${result.owner ? `Token Owner: ${result.owner}\n` : ''}\n` + `Contract Explorer: ${explorerUrl}/address/${result.address}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error getting NFT 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