Skip to main content
Glama

azeth_discover_services

Find services, agents, and infrastructure on the Azeth trust registry by filtering for specific capabilities, entity types, and reputation scores.

Instructions

Find services, agents, and infrastructure on the trust registry by capability, entity type, and reputation.

Use this when: You need to find a participant that offers a specific capability (e.g., "swap", "price-feed"), or you want to browse available services filtered by type and minimum reputation score.

Returns: Array of registry entries with token ID, owner, entity type, name, capabilities, endpoint, and status.

Note: This queries the Azeth server API. Set AZETH_SERVER_URL env var if the server is not at the default location. Results are ranked by reputation score. No private key is required for read-only discovery.

Example: { "capability": "price-feed" } or { "entityType": "service", "minReputation": 50, "limit": 5 }

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").
capabilityNoFilter by capability (e.g., "swap", "price-feed", "translation").
entityTypeNoFilter by participant type.
minReputationNoMinimum reputation score (0-100). Higher means more trusted.
limitNoMaximum number of results. Defaults to 10.
offsetNoNumber of results to skip for pagination. Defaults to 0.

Implementation Reference

  • The handler for `azeth_discover_services`, which queries the Azeth API with fallback to on-chain registry discovery, including metadata overlay and reputation enrichment.
    server.registerTool(
      'azeth_discover_services',
      {
        description: [
          'Find services, agents, and infrastructure on the trust registry by capability, entity type, and reputation.',
          '',
          'Use this when: You need to find a participant that offers a specific capability (e.g., "swap", "price-feed"),',
          'or you want to browse available services filtered by type and minimum reputation score.',
          '',
          'Returns: Array of registry entries with token ID, owner, entity type, name, capabilities, endpoint, and status.',
          '',
          'Note: This queries the Azeth server API. Set AZETH_SERVER_URL env var if the server is not at the default location.',
          'Results are ranked by reputation score. No private key is required for read-only discovery.',
          '',
          'Example: { "capability": "price-feed" } or { "entityType": "service", "minReputation": 50, "limit": 5 }',
        ].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").'),
          capability: z.string().max(128).optional().describe('Filter by capability (e.g., "swap", "price-feed", "translation").'),
          entityType: z.enum(['agent', 'service', 'infrastructure']).optional().describe('Filter by participant type.'),
          minReputation: z.coerce.number().min(0).max(100).optional().describe('Minimum reputation score (0-100). Higher means more trusted.'),
          limit: z.coerce.number().int().min(1).max(100).optional().describe('Maximum number of results. Defaults to 10.'),
          offset: z.coerce.number().int().min(0).optional().describe('Number of results to skip for pagination. Defaults to 0.'),
        }),
      },
      async (args) => {
        try {
          const serverUrl = process.env['AZETH_SERVER_URL'] ?? 'https://api.azeth.ai';
          const chainName = resolveChain(args.chain);
    
          // Create a public client for the on-chain fallback
          const { createPublicClient, http } = await import('viem');
          const chain = resolveViemChain(chainName);
          const rpcUrl = process.env[RPC_ENV_KEYS[chainName]] ?? SUPPORTED_CHAINS[chainName].rpcDefault;
          const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
    
          const result = await discoverServicesWithFallback(
            serverUrl,
            {
              capability: args.capability,
              entityType: args.entityType as 'agent' | 'service' | 'infrastructure' | undefined,
              minReputation: args.minReputation,
              limit: args.limit ?? 10,
              offset: args.offset,
            },
            // Cast needed: viem's chain-specific PublicClient has extra tx types
            // that are a superset of the generic Chain type the SDK expects
            publicClient as any,
            chainName,
          );
    
          // Deduplicate entries: when the same entity appears multiple times
          // (e.g., registered from both EOA and smart account), keep the entry
          // with the highest tokenId (most recent) per owner+name pair.
          const deduped = new Map<string, typeof result.entries[number]>();
          for (const entry of result.entries) {
            const key = `${entry.owner?.toLowerCase() ?? ''}:${entry.name?.toLowerCase() ?? ''}`;
            const existing = deduped.get(key);
            if (!existing || BigInt(entry.tokenId) > BigInt(existing.tokenId)) {
              deduped.set(key, entry);
            }
          }
          const uniqueEntries = [...deduped.values()];
    
          // ── Overlay per-key metadata updates for on-chain fallback results ──
          if (result.source === 'on-chain' && uniqueEntries.length <= 10) {
            const overlayRegistryAddr = ERC8004_REGISTRY[chainName] as `0x${string}`;
            await Promise.all(
              uniqueEntries.map(async (entry) => {
                try {
                  await overlayMetadataUpdates(publicClient as any, overlayRegistryAddr, BigInt(entry.tokenId), entry as unknown as Record<string, unknown>);
                } catch { /* non-fatal */ }
              }),
            );
          }
    
          // ── Optional reputation enrichment ──
          // For small result sets (≤10), fetch weighted reputation for each entry.
          // Non-fatal: if reputation is unavailable for any entry, it's set to null.
          const reputationModuleAddr = AZETH_CONTRACTS[chainName].reputationModule;
          const shouldEnrich = uniqueEntries.length <= 10
            && !!reputationModuleAddr
            && reputationModuleAddr !== ('' as `0x${string}`);
          const DEFAULT_REPUTATION = { weightedValue: '0', weightedValueFormatted: '0', totalWeight: '0', totalWeightFormatted: '0', opinionCount: '0' };
          const reputationMap = new Map<string, { weightedValue: string; weightedValueFormatted: string; totalWeight: string; totalWeightFormatted: string; opinionCount: string }>();
    
          if (shouldEnrich) {
            await Promise.all(
              uniqueEntries.map(async (entry) => {
                try {
                  const tid = BigInt(entry.tokenId);
                  if (tid === 0n) return;
                  const rep = await publicClient.readContract({
                    address: reputationModuleAddr,
                    abi: ReputationModuleAbi,
                    functionName: 'getWeightedReputationAll',
                    args: [tid],
                  }) as readonly [bigint, bigint, bigint];
                  const [weightedValue, totalWeight, opinionCount] = rep;
                  // Format weighted value using same heuristic as reputation.ts
                  const absValue = weightedValue < 0n ? -weightedValue : weightedValue;
                  const isHighPrecision = absValue > 10n ** 15n;
                  const weightedValueFormatted = isHighPrecision
                    ? formatTokenAmount(weightedValue, 18, 4)
                    : weightedValue.toString();
                  // Format totalWeight as USD with adaptive precision
                  const totalWeightFormatted = formatTokenAmount(totalWeight, 12, 2);
                  reputationMap.set(String(entry.tokenId), {
                    weightedValue: weightedValue.toString(),
                    weightedValueFormatted,
                    totalWeight: totalWeight.toString(),
                    totalWeightFormatted,
                    opinionCount: opinionCount.toString(),
                  });
                } catch { /* reputation not available for this entry */ }
              }),
            );
          }
    
          const requestedLimit = args.limit ?? 10;
          // hasMore: true if the API returned a full page (before dedup), suggesting more results exist
          const hasMore = result.entries.length >= requestedLimit;
    
          return success({
            count: uniqueEntries.length,
            hasMore,
            source: result.source,
            offset: args.offset ?? 0,
            limit: requestedLimit,
            ...(result.minReputationIgnored ? { warning: 'minReputation filter is not supported in on-chain fallback mode and was ignored.' } : {}),
            services: uniqueEntries.map((s) => ({
              tokenId: String(s.tokenId),
              owner: s.owner,
              entityType: s.entityType,
              name: s.name,
              description: s.description ?? '',
              capabilities: s.capabilities,
              endpoint: s.endpoint,
              pricing: s.pricing,
              catalog: s.catalog ?? null,
              active: s.active,
              reputation: reputationMap.get(String(s.tokenId)) ?? (s.reputation ?? DEFAULT_REPUTATION),
            })),
          });
        } catch (err) {
          return handleError(err);
        }
      },
    );
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and excels: discloses 'Results are ranked by reputation score' (ordering behavior), 'No private key is required for read-only discovery' (auth/safety), and 'Set AZETH_SERVER_URL env var' (configuration requirement). Also documents return structure ('Array of registry entries with token ID, owner...') since no output schema exists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Excellent structure with clear visual sections (purpose, Use this when, Returns, Note, Example). Every sentence conveys distinct, non-redundant information. No repetition of schema details (e.g., min/max values already in schema), focusing instead on behavioral context and usage examples.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Comprehensive for a 6-parameter discovery tool with no output schema. Covers purpose, triggers, return shape, configuration prerequisites, ranking behavior, and authentication requirements. Sufficient for an agent to invoke correctly without surprises.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% description coverage, establishing baseline 3. Description adds value through concrete JSON examples showing typical usage patterns ('capability': 'price-feed' and multi-filter object), helping agents understand how to combine optional parameters effectively. Could add guidance on pagination logic, but examples provide good semantic context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with specific verb ('Find') and clear resource scope ('services, agents, and infrastructure on the trust registry'), plus filtering dimensions ('by capability, entity type, and reputation'). Differentiates from sibling 'azeth_discover_agent_capabilities' by focusing on entity discovery rather than capability enumeration, and from 'azeth_get_registry_entry' by implying search/filter vs. direct lookup.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit 'Use this when:' section provides clear positive guidance for two scenarios: finding specific capabilities (e.g., 'swap', 'price-feed') and browsing with filters. Lacks explicit 'when not to use' or pointer to 'azeth_get_registry_entry' for direct ID lookups, but the positive scoping is strong and actionable.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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