Skip to main content
Glama

azeth_accounts

List and manage Azeth smart accounts with names, addresses, and token IDs for use in blockchain operations.

Instructions

List all your Azeth smart accounts with their names, addresses, and trust registry token IDs.

Use this when: You want to see all your accounts at a glance, find an account by name, or get the "#N" index for use in other tools.

Returns: Your EOA owner address and an indexed list of smart accounts. Each account shows its #N index (usable in other tools), name, address, and tokenId.

Note: This is a read-only operation. Names come from the trust registry. The owner is determined by the AZETH_PRIVATE_KEY environment variable.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainNoTarget chain. Defaults to AZETH_CHAIN env var or "baseSepolia". Accepts "base", "baseSepolia", "ethereumSepolia", "ethereum" (and aliases like "base-sepolia", "eth-sepolia", "sepolia", "eth", "mainnet").

Implementation Reference

  • Handler function for 'azeth_accounts' tool which lists all smart accounts.
    server.registerTool(
      'azeth_accounts',
      {
        description: [
          'List all your Azeth smart accounts with their names, addresses, and trust registry token IDs.',
          '',
          'Use this when: You want to see all your accounts at a glance, find an account by name,',
          'or get the "#N" index for use in other tools.',
          '',
          'Returns: Your EOA owner address and an indexed list of smart accounts.',
          'Each account shows its #N index (usable in other tools), name, address, and tokenId.',
          '',
          'Note: This is a read-only operation. Names come from the trust registry.',
          'The owner is determined by the AZETH_PRIVATE_KEY environment variable.',
        ].join('\n'),
        inputSchema: z.object({
          chain: z.string().optional().describe('Target chain. Defaults to AZETH_CHAIN env var or "baseSepolia". Accepts "base", "baseSepolia", "ethereumSepolia", "ethereum" (and aliases like "base-sepolia", "eth-sepolia", "sepolia", "eth", "mainnet").'),
        }),
      },
      async (args) => {
        let client;
        try {
          client = await createClient(args.chain);
          const accounts = await client.getSmartAccounts();
    
          if (accounts.length === 0) {
            return success({
              owner: client.address,
              accounts: [],
              message: 'No smart accounts found. Use azeth_create_account to create one.',
            });
          }
    
          // Look up name and tokenId for each account on-chain via TrustRegistryModule + ERC-8004
          const chain = resolveChain(args.chain);
          const trustRegistryAddr = AZETH_CONTRACTS[chain].trustRegistryModule;
          const identityRegistryAddr = ERC8004_REGISTRY[chain];
    
          const serverUrl = process.env['AZETH_SERVER_URL'] ?? 'https://api.azeth.ai';
          const accountDetails: Array<{
            index: number;
            address: string;
            name: string;
            entityType: string;
            tokenId: string;
          }> = [];
    
          for (let i = 0; i < accounts.length; i++) {
            const addr = accounts[i]!;
            let name = '(unregistered)';
            let entityType = 'agent';
            let tokenIdStr = '(none)';
    
            try {
              // Step 1: Get tokenId from TrustRegistryModule (on-chain)
              const tokenId = await client.publicClient.readContract({
                address: trustRegistryAddr,
                abi: TrustRegistryModuleAbi,
                functionName: 'getTokenId',
                args: [addr],
              });
    
              if (tokenId > 0n) {
                tokenIdStr = tokenId.toString();
    
                // Step 2: Get tokenURI from ERC-8004 Identity Registry (on-chain)
                try {
                  const uri = await client.publicClient.readContract({
                    address: identityRegistryAddr,
                    abi: ERC8004_TOKEN_URI_ABI,
                    functionName: 'tokenURI',
                    args: [tokenId],
                  });
                  const meta = parseAgentMetadata(uri);
                  name = meta.name;
                  entityType = meta.entityType;
                } catch {
                  // tokenURI call failed — token exists but URI unreadable
                  name = '(registered)';
                }
              }
            } catch {
              // getTokenId call failed — account not registered on this module
            }
    
            accountDetails.push({
              index: i + 1,
              address: addr,
              name,
              entityType,
              tokenId: tokenIdStr,
              ...(tokenIdStr !== '(none)' ? {
                badge: `${serverUrl}/badge/${tokenIdStr}`,
                profile: `https://azeth.ai/agent/${addr}`,
              } : {}),
            });
          }
    
          return success({
            owner: client.address,
            accounts: accountDetails,
          });
        } catch (err) {
          return handleError(err);
        } finally {
          try { await client?.destroy(); } catch (e) { process.stderr.write(`[azeth-mcp] destroy error: ${e instanceof Error ? e.message : String(e)}\n`); }
        }
      },
    );

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/azeth-protocol/mcp-azeth'

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