Skip to main content
Glama

getNFTOwner

Retrieve the owner of an ERC721 NFT by providing the contract address and token ID using an Ethereum provider on the MCP Ethers Wallet server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNoOptional. The chain ID to use.
contractAddressYesThe address of the ERC721 contract
providerNoOptional. The provider to use. If not provided, the default provider is used.
tokenIdYesThe ID of the token to check

Implementation Reference

  • Handler function that executes the getNFTOwner tool. Calls EthersService.getERC721Owner to fetch the owner address of the specified NFT token and returns a formatted text response or error.
    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)}` }] }; } }
  • TypeScript interface defining the input parameters for the getNFTOwner tool.
    type GetNFTOwnerParams = { contractAddress: string; tokenId: string | number; provider?: string; chainId?: number; };
  • Registration of the getNFTOwner tool on the MCP server, including tool name, description, input schema (Zod), and handler function.
    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)}` }] }; } } );
  • Calls registerERC721Tools to register all ERC721 tools including getNFTOwner.
    registerERC721Tools(server, ethersService);

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/crazyrabbitLTC/mcp-ethers-server'

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