Skip to main content
Glama

get-nft-count

Retrieve the number of NFTs held by a specific address on the Monad testnet by providing the address and NFT contract details using this tool.

Instructions

查询 Monad 测试网地址持有的 NFT 数量

Input Schema

NameRequiredDescriptionDefault
addressYes需要查询的 Monad 测试网地址
nftContractYesNFT 合约地址

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "address": { "description": "需要查询的 Monad 测试网地址", "type": "string" }, "nftContract": { "description": "NFT 合约地址", "type": "string" } }, "required": [ "address", "nftContract" ], "type": "object" }

Implementation Reference

  • Handler function that queries the NFT balance for a given address on a specific contract using viem's readContract with the ERC721 balanceOf ABI.
    async ({ address, nftContract }) => { try { // 调用合约的 balanceOf 方法查询 NFT 数量 const balance = await publicClient.readContract({ address: nftContract as `0x${string}`, abi: [ { inputs: [{ name: "owner", type: "address" }], name: "balanceOf", outputs: [{ name: "", type: "uint256" }], stateMutability: "view", type: "function" } ], functionName: "balanceOf", args: [address as `0x${string}`] }); // 返回格式化的查询结果 return { content: [ { type: "text", text: `地址 ${address} 在合约 ${nftContract} 中持有的 NFT 数量为:${balance.toString()} 个`, }, ], }; } catch (error) { // 错误处理 return { content: [ { type: "text", text: `查询地址 ${address} 的 NFT 数量失败:${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
  • Zod schema defining the input parameters: address (wallet address) and nftContract (NFT contract address).
    { address: z.string().describe("需要查询的 Monad 测试网地址"), nftContract: z.string().describe("NFT 合约地址") },
  • src/index.ts:74-126 (registration)
    Registers the 'get-nft-count' tool on the MCP server with name, description, input schema, and handler function.
    server.tool( // 功能标识符 "get-nft-count", // 功能说明 "查询 Monad 测试网地址持有的 NFT 数量", // 参数定义 { address: z.string().describe("需要查询的 Monad 测试网地址"), nftContract: z.string().describe("NFT 合约地址") }, // 功能实现 async ({ address, nftContract }) => { try { // 调用合约的 balanceOf 方法查询 NFT 数量 const balance = await publicClient.readContract({ address: nftContract as `0x${string}`, abi: [ { inputs: [{ name: "owner", type: "address" }], name: "balanceOf", outputs: [{ name: "", type: "uint256" }], stateMutability: "view", type: "function" } ], functionName: "balanceOf", args: [address as `0x${string}`] }); // 返回格式化的查询结果 return { content: [ { type: "text", text: `地址 ${address} 在合约 ${nftContract} 中持有的 NFT 数量为:${balance.toString()} 个`, }, ], }; } catch (error) { // 错误处理 return { content: [ { type: "text", text: `查询地址 ${address} 的 NFT 数量失败:${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
  • src/index.ts:27-28 (registration)
    Lists 'get-nft-count' as one of the server capabilities.
    capabilities: ["get-mon-balance", "get-nft-count"] });

Other Tools

Related 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/bble/monad-mcp'

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