getNFTOwner
Retrieve the Ethereum address that owns a specific ERC721 NFT token by providing the contract address and token ID. This tool queries blockchain data to identify current NFT ownership.
Instructions
Get the current owner of a specific ERC721 NFT token. Returns the Ethereum address that owns the specified token ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contractAddress | Yes | The address of the ERC721 contract | |
| tokenId | Yes | The ID of the token to check | |
| provider | No | Optional. The provider to use. If not provided, the default provider is used. | |
| chainId | No | Optional. The chain ID to use. |
Implementation Reference
- src/tools/erc721.ts:143-177 (registration)Registration of the getNFTOwner MCP tool, including inline schema definition and handler function that queries the owner via ethersService and returns formatted response.server.tool( "getNFTOwner", "Get the current owner of a specific ERC721 NFT token. Returns the Ethereum address that owns the specified token ID.", { contractAddress: contractAddressSchema.describe("The address of the ERC721 contract"), tokenId: tokenIdSchema.describe("The ID of the token to check"), provider: providerSchema.describe("Optional. The provider to use. If not provided, the default provider is used."), chainId: chainIdSchema.describe("Optional. The chain ID to use.") }, async (params) => { try { const owner = await ethersService.getERC721Owner( params.contractAddress, params.tokenId, params.provider, params.chainId ); return { content: [{ type: "text", text: `Owner of token ${params.tokenId} is ${owner}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error getting NFT owner: ${error instanceof Error ? error.message : String(error)}` }] }; } } );
- src/tools/erc721.ts:47-52 (schema)TypeScript type definition for the input parameters of the getNFTOwner tool.type GetNFTOwnerParams = { contractAddress: string; tokenId: string | number; provider?: string; chainId?: number; };
- src/tools/index.ts:25-25 (registration)Call to registerERC721Tools function which includes the getNFTOwner tool registration.registerERC721Tools(server, ethersService);
- src/mcpServer.ts:51-51 (registration)Top-level call to registerAllTools, which indirectly registers getNFTOwner via the tools index.registerAllTools(server, ethersService);