Skip to main content
Glama

List Registered Agents

listRegisteredAgents

Retrieve registered agent details and enriched data from the AgentScore Registry, optionally filtering by owner address to access performance metrics and registration information.

Instructions

List all agents (or single agent by owner address). Returns enriched data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerNoOptional owner address

Implementation Reference

  • The handler function for the `listRegisteredAgents` tool, which fetches agent profiles from the smart contract.
    async ({ owner }: { owner?: string }) => {
      try {
        const agents: any[] = [];
    
        if (owner) {
          const addr = owner.toLowerCase() as `0x${string}`;
          const tokenId = await publicClient.readContract({
            address: CONTRACT_ADDRESS,
            abi: AGENT_SCORE_ABI,
            functionName: "agentIds",
            args: [addr],
          });
          if (tokenId === 0n)
            return {
              content: [{ type: "text", text: "[]" }],
            };
    
          const profile = (await publicClient.readContract({
            address: CONTRACT_ADDRESS,
            abi: AGENT_SCORE_ABI,
            functionName: "agentProfiles",
            args: [tokenId],
          })) as AgentProfile;
          const uri = await publicClient.readContract({
            address: CONTRACT_ADDRESS,
            abi: AGENT_SCORE_ABI,
            functionName: "tokenURI",
            args: [tokenId],
          });
          const ownerAddr = await publicClient.readContract({
            address: CONTRACT_ADDRESS,
            abi: AGENT_SCORE_ABI,
            functionName: "ownerOf",
            args: [tokenId],
          });
    
          agents.push({
            tokenId: Number(tokenId),
            owner: ownerAddr,
            score: Number(profile.score),
            metadataURI: uri,
          });
        } else {
          const tokenIds = await publicClient.readContract({
            address: CONTRACT_ADDRESS,
            abi: AGENT_SCORE_ABI,
            functionName: "getAllAgents",
          });
    
          const enriched = await Promise.all(
            tokenIds.map(async (tid) => {
              const profile = (await publicClient.readContract({
                address: CONTRACT_ADDRESS,
                abi: AGENT_SCORE_ABI,
                functionName: "agentProfiles",
                args: [tid],
              })) as AgentProfile;
              const uri = await publicClient.readContract({
                address: CONTRACT_ADDRESS,
                abi: AGENT_SCORE_ABI,
                functionName: "tokenURI",
                args: [tid],
              });
              const ownerAddr = await publicClient.readContract({
                address: CONTRACT_ADDRESS,
                abi: AGENT_SCORE_ABI,
                functionName: "ownerOf",
                args: [tid],
              });
              return {
                tokenId: Number(tid),
                owner: ownerAddr,
                score: Number(profile.score),
                metadataURI: uri,
              };
            }),
          );
          agents.push(...enriched);
        }
    
        return {
          content: [
            { type: "text", text: JSON.stringify(agents, null, 2) },
          ],
        };
      } catch (err: any) {
        return {
          isError: true,
          content: [{ type: "text", text: `Error: ${err.message}` }],
        };
      }
    },
  • Input and output schema definitions for the `listRegisteredAgents` tool.
    inputSchema: z.object({
      owner: z
        .string()
        .regex(/^0x[a-fA-F0-9]{40}$/i)
        .optional()
        .describe("Optional owner address"),
    }),
    outputSchema: z.array(
      z.object({
        tokenId: z.number(),
        owner: z.string(),
        score: z.number(),
        metadataURI: z.string(),
      }),
    ),
  • src/tools.ts:146-168 (registration)
    Registration of the `listRegisteredAgents` tool with the server.
    // Tool 3: listRegisteredAgents
    server.registerTool(
      "listRegisteredAgents",
      {
        title: "List Registered Agents",
        description:
          "List all agents (or single agent by owner address). Returns enriched data.",
        inputSchema: z.object({
          owner: z
            .string()
            .regex(/^0x[a-fA-F0-9]{40}$/i)
            .optional()
            .describe("Optional owner address"),
        }),
        outputSchema: z.array(
          z.object({
            tokenId: z.number(),
            owner: z.string(),
            score: z.number(),
            metadataURI: z.string(),
          }),
        ),
      },
Behavior2/5

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

No annotations provided, so description carries full burden. Mentions 'Returns enriched data' hinting at comprehensive output, but fails to disclose critical behavioral traits like pagination for 'all agents', rate limits, or authorization requirements.

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?

Two sentences, front-loaded with action verb. No redundant words; every clause earns its place by conveying scope or output characteristics.

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

Completeness3/5

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

Given low complexity (1 optional param) and no output schema, description minimally suffices but leaves gaps. 'Enriched data' is vague, and 'List all' raises pagination concerns that remain unaddressed.

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?

While schema has 100% coverage describing 'owner' as 'Optional owner address', the description adds crucial semantic context that this parameter filters the results to a single agent (or the agent owned by that address), clarifying the 'all vs single' behavior.

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

Purpose4/5

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

Uses specific verb 'List' with resource 'agents' and clarifies scope ('all' vs 'single agent by owner'). However, it does not explicitly differentiate from siblings getAgentHistory/getAgentScore.

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

Usage Guidelines2/5

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

Implies filtering capability via parenthetical '(or single agent by owner address)', but provides no explicit guidance on when to use this versus getAgentHistory or getAgentScore, and no exclusions or prerequisites.

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/agentscore-trustless/agentscore-mcp'

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