Skip to main content
Glama

get_nft_metadata

Retrieve metadata for specific NFTs by providing contract address and token ID, supporting ERC721 and ERC1155 token standards.

Instructions

Get metadata for a specific NFT

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contractAddressYesThe contract address of the NFT
tokenIdYesThe token ID of the NFT
tokenTypeNoThe token type (ERC721 or ERC1155)
refreshCacheNoWhether to refresh the cache

Implementation Reference

  • The handler function for the get_nft_metadata tool. Validates the input parameters using isValidGetNftMetadataParams and calls the Alchemy SDK's nft.getNftMetadata method with contractAddress, tokenId, and additional params.
    private async handleGetNftMetadata(args: Record<string, unknown>) { const params = this.validateAndCastParams<GetNftMetadataParams>( args, isValidGetNftMetadataParams, "Invalid NFT metadata parameters" ); return await this.alchemy.nft.getNftMetadata( params.contractAddress, params.tokenId, params ); }
  • TypeScript type definition for GetNftMetadataParams, extending GetNftMetadataOptions with required contractAddress and tokenId.
    type GetNftMetadataParams = GetNftMetadataOptions & { contractAddress: string; tokenId: string; };
  • Validation function for get_nft_metadata parameters, ensuring required fields and types.
    const isValidGetNftMetadataParams = ( args: any ): args is GetNftMetadataParams => { return ( typeof args === "object" && args !== null && typeof args.contractAddress === "string" && typeof args.tokenId === "string" && (args.tokenType === undefined || typeof args.tokenType === "string") && (args.refreshCache === undefined || typeof args.refreshCache === "boolean") ); };
  • index.ts:444-468 (registration)
    Tool registration in ListTools handler, defining the name, description, and input schema for get_nft_metadata.
    { name: "get_nft_metadata", description: "Get metadata for a specific NFT", inputSchema: { type: "object", properties: { contractAddress: { type: "string", description: "The contract address of the NFT", }, tokenId: { type: "string", description: "The token ID of the NFT", }, tokenType: { type: "string", description: "The token type (ERC721 or ERC1155)", }, refreshCache: { type: "boolean", description: "Whether to refresh the cache", }, }, required: ["contractAddress", "tokenId"], },
  • index.ts:990-992 (registration)
    Dispatch case in CallToolRequest handler that routes to the get_nft_metadata handler.
    case "get_nft_metadata": result = await this.handleGetNftMetadata(request.params.arguments); break;

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/itsanishjain/alchemy-sdk-mcp'

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