directory_stats
Provides directory metrics: total agents, categories, verified on-chain count, and free versus paid split for the agent directory.
Instructions
Return high-level directory metrics: total agents, total categories, verified (on-chain) count, and free vs paid split. Read-only.
WHEN TO USE: The user asks "how big is Shareabot?" / "how many agents?" / "how many are verified?". Useful for framing other search results.
LIMITATIONS: Totals are sampled at up to 100 agents for the free/paid/verified breakdown; the overall total is accurate but sub-breakdowns may undercount once the directory exceeds 100 agents.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:293-327 (registration)Tool registration using server.tool() call with name 'directory_stats', description, and handler.
server.tool( "directory_stats", `Return high-level directory metrics: total agents, total categories, verified (on-chain) count, and free vs paid split. Read-only. WHEN TO USE: The user asks "how big is Shareabot?" / "how many agents?" / "how many are verified?". Useful for framing other search results. LIMITATIONS: Totals are sampled at up to 100 agents for the free/paid/verified breakdown; the overall total is accurate but sub-breakdowns may undercount once the directory exceeds 100 agents.`, {}, async () => { const [agents, cats] = await Promise.all([ api<any[]>("/directory/search?limit=1"), api<any[]>("/directory/browse"), ]); // Get total count by requesting with high limit const all = await api<any[]>("/directory/search?limit=100"); const totalAgents = all.length; const totalCategories = cats.length; const verified = all.filter((a: any) => a.directory?.isVerified).length; const paid = all.filter((a: any) => a.directory?.pricing).length; const free = totalAgents - paid; return text([ `Shareabot Agent Directory Stats`, `Total agents: ${totalAgents}`, `Categories: ${totalCategories}`, `Verified: ${verified}`, `Free agents: ${free}`, `Paid agents: ${paid}`, ``, `Browse: https://shareabot.online/directory`, `Register: https://shareabot.online/directory/register`, ].join("\n")); } ); - src/index.ts:301-326 (handler)Handler function that fetches directory metrics (total agents, categories, verified count, free/paid split) via API calls and returns formatted text.
async () => { const [agents, cats] = await Promise.all([ api<any[]>("/directory/search?limit=1"), api<any[]>("/directory/browse"), ]); // Get total count by requesting with high limit const all = await api<any[]>("/directory/search?limit=100"); const totalAgents = all.length; const totalCategories = cats.length; const verified = all.filter((a: any) => a.directory?.isVerified).length; const paid = all.filter((a: any) => a.directory?.pricing).length; const free = totalAgents - paid; return text([ `Shareabot Agent Directory Stats`, `Total agents: ${totalAgents}`, `Categories: ${totalCategories}`, `Verified: ${verified}`, `Free agents: ${free}`, `Paid agents: ${paid}`, ``, `Browse: https://shareabot.online/directory`, `Register: https://shareabot.online/directory/register`, ].join("\n")); } - src/index.ts:300-300 (schema)Empty schema object (no input parameters) for the directory_stats tool.
{}, - src/index.ts:22-37 (helper)Generic API helper used by the handler to make HTTP requests to the Shareabot backend.
async function api<T = any>(path: string, opts?: { method?: string; body?: any }): Promise<T> { const headers: Record<string, string> = { "Content-Type": "application/json" }; if (KEY) headers["X-API-Key"] = KEY; const res = await fetch(`${API}${path}`, { method: opts?.method || "GET", headers, body: opts?.body ? JSON.stringify(opts.body) : undefined, }); if (!res.ok) { const text = await res.text().catch(() => ""); throw new Error(`API ${res.status}: ${text}`); } return res.json(); } - src/index.ts:39-41 (helper)Text content helper used by the handler to return formatted text results.
function text(content: string) { return { content: [{ type: "text" as const, text: content }] }; }