get_nfts_for_owner
Retrieve NFT collections owned by a specific wallet address using the Alchemy MCP Plugin. Filter results by contract addresses and include metadata as needed.
Instructions
Get NFTs owned by a specific wallet address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | The wallet address to get NFTs for | |
| pageKey | No | Key for pagination | |
| pageSize | No | Number of NFTs to return in one page (max: 100) | |
| contractAddresses | No | List of contract addresses to filter by | |
| withMetadata | No | Whether to include NFT metadata |
Implementation Reference
- index.ts:1157-1164 (handler)The handler function for the 'get_nfts_for_owner' tool. It validates the input arguments using a type guard and calls the Alchemy SDK's nft.getNftsForOwner method with the validated parameters.private async handleGetNftsForOwner(args: Record<string, unknown>) { const params = this.validateAndCastParams<GetNftsForOwnerParams>( args, isValidGetNftsForOwnerParams, "Invalid NFTs for owner parameters" ); return await this.alchemy.nft.getNftsForOwner(params.owner, params); }
- index.ts:412-442 (registration)The registration of the 'get_nfts_for_owner' tool in the MCP server's tool list, including its name, description, and input schema definition.name: "get_nfts_for_owner", description: "Get NFTs owned by a specific wallet address", inputSchema: { type: "object", properties: { owner: { type: "string", description: "The wallet address to get NFTs for", }, pageKey: { type: "string", description: "Key for pagination", }, pageSize: { type: "number", description: "Number of NFTs to return in one page (max: 100)", }, contractAddresses: { type: "array", items: { type: "string", }, description: "List of contract addresses to filter by", }, withMetadata: { type: "boolean", description: "Whether to include NFT metadata", }, }, required: ["owner"], },
- index.ts:103-116 (schema)Type guard validation function for 'get_nfts_for_owner' parameters, ensuring they conform to GetNftsForOwnerParams type.const isValidGetNftsForOwnerParams = ( args: any ): args is GetNftsForOwnerParams => { return ( typeof args === "object" && args !== null && typeof args.owner === "string" && (args.pageKey === undefined || typeof args.pageKey === "string") && (args.pageSize === undefined || typeof args.pageSize === "number") && (args.contractAddresses === undefined || Array.isArray(args.contractAddresses)) && (args.withMetadata === undefined || typeof args.withMetadata === "boolean") ); };
- index.ts:54-54 (schema)TypeScript type definition for the parameters of 'get_nfts_for_owner', extending Alchemy SDK's GetNftsForOwnerOptions with required owner field.type GetNftsForOwnerParams = GetNftsForOwnerOptions & { owner: string };
- index.ts:987-989 (registration)Dispatcher switch case that routes calls to the 'get_nfts_for_owner' handler in the MCP tool request handler.case "get_nfts_for_owner": result = await this.handleGetNftsForOwner(request.params.arguments); break;