get_nft_info
Retrieve comprehensive details about an NFT, including collection name, symbol, token URI, and owner, by specifying the token address, ID, and network using the EVM MCP Server.
Instructions
Get detailed information about a specific NFT (ERC721 token), including collection name, symbol, token URI, and current owner if available.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | No | Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Most NFTs are on Ethereum mainnet, which is the default. | |
| tokenAddress | Yes | The contract address of the NFT collection (e.g., '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D' for Bored Ape Yacht Club) | |
| tokenId | Yes | The ID of the specific NFT token to query (e.g., '1234') |
Implementation Reference
- src/core/tools.ts:1400-1478 (handler)The primary handler for the 'get_nft_info' tool. Registers the tool, defines input schema with Zod, fetches NFT metadata via service, queries ownerOf, and returns formatted JSON response or error.server.tool( '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 }; } }
- src/core/tools.ts:1403-1418 (schema)Zod input schema for the get_nft_info tool parameters: tokenAddress (string), tokenId (string), network (optional string).{ 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." ) },
- src/core/services/tokens.ts:118-146 (helper)Helper function that implements the core logic to read ERC721 contract for name, symbol, and tokenURI using viem getContract and read methods.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 }; }
- src/server/server.ts:18-18 (registration)Calls registerEVMTools which contains the server.tool registration for get_nft_info.registerEVMTools(server);