Skip to main content
Glama

get_nft_info

Read-onlyIdempotent

Retrieve ERC721 NFT details including metadata URI by providing contract address and token ID on EVM-compatible networks.

Instructions

Get information about an ERC721 NFT including metadata URI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contractAddressYesThe NFT contract address
tokenIdYesThe NFT token ID
networkNoNetwork name or chain ID. Defaults to Ethereum mainnet.

Implementation Reference

  • Registration of the 'get_nft_info' tool on the MCP server, including input schema and inline handler function.
    'get_nft_info',
    'Get detailed information about a specific NFT (ERC721 token), including collection name, symbol, token URI, and current owner if available.',
    {
      tokenAddress: z
        .string()
        .describe(
          "The contract address of the NFT collection (e.g., '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D' for Bored Ape Yacht Club)"
        ),
      tokenId: z
        .string()
        .describe("The ID of the specific NFT token to query (e.g., '1234')"),
      network: z
        .string()
        .optional()
        .describe(
          "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Most NFTs are on Ethereum mainnet, which is the default."
        )
    },
    async ({ tokenAddress, tokenId, network = 'ethereum' }) => {
      try {
        const nftInfo = await services.getERC721TokenMetadata(
          tokenAddress as Address,
          BigInt(tokenId),
          network
        );
    
        // Check ownership separately
        let owner = null;
        try {
          // This may fail if tokenId doesn't exist
          owner = await services.getPublicClient(network).readContract({
            address: tokenAddress as Address,
            abi: [
              {
                inputs: [{ type: 'uint256' }],
                name: 'ownerOf',
                outputs: [{ type: 'address' }],
                stateMutability: 'view',
                type: 'function'
              }
            ],
            functionName: 'ownerOf',
            args: [BigInt(tokenId)]
          });
        } catch (e) {
          // Ownership info not available
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  contract: tokenAddress,
                  tokenId,
                  network,
                  ...nftInfo,
                  owner: owner || 'Unknown'
                },
                null,
                2
              )
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error fetching NFT info: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • Handler function that executes the tool logic, calling getERC721TokenMetadata and ownerOf to fetch NFT details.
    'get_nft_info',
    'Get detailed information about a specific NFT (ERC721 token), including collection name, symbol, token URI, and current owner if available.',
    {
      tokenAddress: z
        .string()
        .describe(
          "The contract address of the NFT collection (e.g., '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D' for Bored Ape Yacht Club)"
        ),
      tokenId: z
        .string()
        .describe("The ID of the specific NFT token to query (e.g., '1234')"),
      network: z
        .string()
        .optional()
        .describe(
          "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Most NFTs are on Ethereum mainnet, which is the default."
        )
    },
    async ({ tokenAddress, tokenId, network = 'ethereum' }) => {
      try {
        const nftInfo = await services.getERC721TokenMetadata(
          tokenAddress as Address,
          BigInt(tokenId),
          network
        );
    
        // Check ownership separately
        let owner = null;
        try {
          // This may fail if tokenId doesn't exist
          owner = await services.getPublicClient(network).readContract({
            address: tokenAddress as Address,
            abi: [
              {
                inputs: [{ type: 'uint256' }],
                name: 'ownerOf',
                outputs: [{ type: 'address' }],
                stateMutability: 'view',
                type: 'function'
              }
            ],
            functionName: 'ownerOf',
            args: [BigInt(tokenId)]
          });
        } catch (e) {
          // Ownership info not available
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  contract: tokenAddress,
                  tokenId,
                  network,
                  ...nftInfo,
                  owner: owner || 'Unknown'
                },
                null,
                2
              )
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error fetching NFT info: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • Zod input schema for validating tool parameters: tokenAddress, tokenId, network.
      tokenAddress: z
        .string()
        .describe(
          "The contract address of the NFT collection (e.g., '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D' for Bored Ape Yacht Club)"
        ),
      tokenId: z
        .string()
        .describe("The ID of the specific NFT token to query (e.g., '1234')"),
      network: z
        .string()
        .optional()
        .describe(
          "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Most NFTs are on Ethereum mainnet, which is the default."
        )
    },
  • Core helper function that reads name, symbol, and tokenURI from ERC721 contract using viem's getContract.
    export async function getERC721TokenMetadata(
      tokenAddress: Address,
      tokenId: bigint,
      network: string = 'ethereum'
    ): Promise<{
      name: string;
      symbol: string;
      tokenURI: string;
    }> {
      const publicClient = getPublicClient(network);
    
      const contract = getContract({
        address: tokenAddress,
        abi: erc721Abi,
        client: publicClient,
      });
    
      const [name, symbol, tokenURI] = await Promise.all([
        contract.read.name(),
        contract.read.symbol(),
        contract.read.tokenURI([tokenId])
      ]);
    
      return {
        name,
        symbol,
        tokenURI
      };
    }
  • ERC721 ABI used for reading NFT metadata (name, symbol, tokenURI).
    const erc721Abi = [
      {
        inputs: [],
        name: 'name',
        outputs: [{ type: 'string' }],
        stateMutability: 'view',
        type: 'function'
      },
      {
        inputs: [],
        name: 'symbol',
        outputs: [{ type: 'string' }],
        stateMutability: 'view',
        type: 'function'
      },
      {
        inputs: [{ type: 'uint256', name: 'tokenId' }],
        name: 'tokenURI',
        outputs: [{ type: 'string' }],
        stateMutability: 'view',
        type: 'function'
      }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, destructiveHint=false, openWorldHint=true, and idempotentHint=true, covering safety and idempotency. The description adds value by specifying the scope ('ERC721 NFT' and 'metadata URI'), which isn't in annotations, but doesn't detail rate limits, auth needs, or response format. No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the purpose without unnecessary words. It earns its place by clearly stating what the tool does in minimal terms.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, 2 required), rich annotations covering safety and behavior, and 100% schema coverage, the description is mostly complete. However, without an output schema, it could benefit from hinting at return values like metadata structure, but the annotations and schema provide sufficient context for a read-only query.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear parameter descriptions in the schema. The description mentions 'ERC721 NFT' and 'metadata URI', which adds context about the resource but doesn't provide additional syntax or format details beyond the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'information about an ERC721 NFT including metadata URI', which is specific and distinguishes it from sibling tools like get_balance, get_contract_abi, or get_erc1155_balance that target different resources or data types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving NFT metadata but provides no explicit guidance on when to use this tool versus alternatives like read_contract for custom queries or get_erc1155_balance for other token standards. It lacks when-not scenarios or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/chulanpro5/evm-mcp-server'

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