Skip to main content
Glama

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
NameRequiredDescriptionDefault
ownerYesThe wallet address to get NFTs for
pageKeyNoKey for pagination
pageSizeNoNumber of NFTs to return in one page (max: 100)
contractAddressesNoList of contract addresses to filter by
withMetadataNoWhether to include NFT metadata

Implementation Reference

  • 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"],
    },
  • 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")
      );
    };
  • 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;

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/itsanishjain/alchemy-sdk-mcp'

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