Skip to main content
Glama

list_contacts

Retrieve saved providers from your contacts list, ordered by most recent activity. Combine with search filters for refined results.

Instructions

List providers saved in the active agent's .contacts.json, newest activity first. Use search_agents with contacts_only=true to combine this with online/capability filters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Implementation Reference

  • Handler for the 'list_contacts' tool. Reads the .contacts.json file for the active agent, sorts contacts by lastJobAt (or addedAt), applies the limit from the schema, sanitizes fields via sanitizeField/sanitizeUntrusted, and returns a text result with the contact list.
    defineTool({
      name: 'list_contacts',
      description:
        "List providers saved in the active agent's .contacts.json, newest activity " +
        'first. Use search_agents with contacts_only=true to combine this with online/' +
        'capability filters.',
      schema: ListContactsSchema,
      async handler(ctx, input) {
        ctx.toolRateLimiter.check();
    
        const agent = ctx.active();
        if (!agent.agentDir) {
          return textResult(
            'Active agent is ephemeral; no on-disk contacts. Create a persistent agent first.',
          );
        }
    
        const data = await readContacts(agent.agentDir);
        const sorted = [...data.contacts].sort((left, right) => {
          const leftKey = left.lastJobAt ?? left.addedAt;
          const rightKey = right.lastJobAt ?? right.addedAt;
          return rightKey - leftKey;
        });
        const limited = sorted.slice(0, input.limit).map((contact) => ({
          npub: contact.npub,
          name: contact.name !== undefined ? sanitizeField(contact.name, 200) : undefined,
          note: contact.note !== undefined ? sanitizeField(contact.note, 500) : undefined,
          added_at: contact.addedAt,
          last_job_at: contact.lastJobAt,
          last_capability:
            contact.lastCapability !== undefined
              ? sanitizeField(contact.lastCapability, 200)
              : undefined,
        }));
    
        const { text: wrapped } = sanitizeUntrusted(JSON.stringify(limited, null, 2), 'structured');
        return textResult(`${limited.length} contact(s):\n${wrapped}`);
      },
    }),
  • Zod schema for list_contacts: accepts an optional 'limit' (1-200, default 50).
    const ListContactsSchema = z.object({
      limit: z.number().int().min(1).max(200).default(50),
    });
  • All tools are aggregated in the allTools array. feedbackContactsTools (which contains list_contacts) is spread into the registry at line 38.
    const allTools: ToolDefinition[] = [
      ...discoveryTools,
      ...customerTools,
      ...walletTools,
      ...dashboardTools,
      ...agentTools,
      ...feedbackContactsTools,
      ...policiesTools,
    ];
  • readContacts reads the .contacts.json file from the agent's directory. Returns an empty list if missing or corrupt.
    /** Read .contacts.json. Returns an empty list if missing or corrupt. */
    export async function readContacts(agentDir: string): Promise<Contacts> {
      return readRaw(pathFor(agentDir));
    }
  • sanitizeField strips dangerous Unicode and truncates to maxLen. Used by the list_contacts handler to sanitize contact name, note, and lastCapability before returning.
    export function sanitizeField(input: string, maxLen: number): string {
      let text = stripDangerousUnicode(input);
      if (text.length > maxLen) {
        text = text.slice(0, maxLen) + '...';
      }
      return text;
    }
Behavior3/5

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

No annotations are provided, so the description must carry the burden. It discloses the data source (.contacts.json) and ordering (newest activity first), suggesting a read operation. But it omits details like permissions, side effects, or behavior when the file is missing.

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 concise sentences: one for core purpose and ordering, another for usage tip. No redundant information.

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

Completeness4/5

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

For a simple list tool with one optional parameter, the description covers purpose, ordering, and an alternative. It lacks output expectations but is adequate given no output schema.

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

Parameters2/5

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

Schema description coverage is 0%. The description adds context to the overall operation but does not explain the 'limit' parameter beyond its schema constraints. The parameter is self-explanatory but not explicitly described.

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?

The description clearly states it lists providers saved in .contacts.json with newest activity first, distinguishing it from sibling search_agents by providing an alternative for filtering.

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?

It explicitly advises using search_agents with contacts_only=true for online/capability filters, giving clear guidance on when to use an alternative. However, it does not address other siblings like list_agents.

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/elisymlabs/elisym'

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