Skip to main content
Glama

getNFTTokenURI

Retrieve the token URI for a specific ERC721 NFT by providing the contract address and token ID using the MCP Ethers Wallet server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNoOptional. The chain ID to use.
contractAddressYesThe address of the ERC721 contract
providerNoOptional. The provider to use. If not provided, the default provider is used.
tokenIdYesThe ID of the token to get the URI for

Implementation Reference

  • Complete MCP tool registration including name, input schema (Zod), and handler function. This is the primary implementation of the getNFTTokenURI tool. The handler retrieves ERC721 token metadata via EthersService and extracts/returns the token URI.
    server.tool( "getNFTTokenURI", { contractAddress: contractAddressSchema.describe("The address of the ERC721 contract"), tokenId: tokenIdSchema.describe("The ID of the token to get the URI for"), provider: providerSchema.describe("Optional. The provider to use. If not provided, the default provider is used."), chainId: chainIdSchema.describe("Optional. The chain ID to use.") }, async (params) => { try { // Get the metadata which includes the token URI const metadata = await ethersService.getERC721Metadata( params.contractAddress, params.tokenId, params.provider, params.chainId ); const uri = metadata.uri || ""; return { content: [{ type: "text", text: `Token URI for token ${params.tokenId} is ${uri}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error getting NFT token URI: ${error instanceof Error ? error.message : String(error)}` }] }; } } );
  • TypeScript type definition for the parameters accepted by the getNFTTokenURI tool, matching the Zod schema used in registration.
    type GetNFTTokenURIParams = { contractAddress: string; tokenId: string | number; provider?: string; chainId?: number; };
  • Call within registerAllTools that invokes the ERC721 tools registration, which includes getNFTTokenURI.
    registerERC721Tools(server, ethersService);
  • src/mcpServer.ts:51-51 (registration)
    Top-level registration call in the main MCP server setup that triggers all tool registrations including getNFTTokenURI.
    registerAllTools(server, ethersService);

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/crazyrabbitLTC/mcp-ethers-server'

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