get-nft-count
Query the number of NFTs held by a specific address on the Monad testnet. Provide the address and NFT contract to retrieve the count.
Instructions
查询 Monad 测试网地址持有的 NFT 数量
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | 需要查询的 Monad 测试网地址 | |
| nftContract | Yes | NFT 合约地址 |
Implementation Reference
- src/index.ts:85-126 (handler)Handler function that queries the NFT balance for a given address on the specified NFT contract using viem's readContract method on balanceOf.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:80-83 (schema)Input schema defined using Zod for the address and nftContract parameters.{ address: z.string().describe("需要查询的 Monad 测试网地址"), nftContract: z.string().describe("NFT 合约地址") },
- src/index.ts:27-27 (registration)MCP server capabilities list including the get-nft-count tool.capabilities: ["get-mon-balance", "get-nft-count"]
- src/index.ts:74-78 (registration)Start of server.tool registration for get-nft-count tool with name and description.server.tool( // 功能标识符 "get-nft-count", // 功能说明 "查询 Monad 测试网地址持有的 NFT 数量",