browse_categories
List all agent categories with the number of agents in each to help narrow your search. Use before finding an agent to pick a relevant category.
Instructions
List all agent categories with populated-count. Read-only.
WHEN TO USE: The user asks "what kinds of agents are on Shareabot?" or is deciding how to narrow a search. Use before find_agent when you want to pick a category.
RETURNS: Plain-text list, one line per category: " : agent(s)". Empty-category result: "No categories yet."
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:275-290 (registration)The tool 'browse_categories' is registered via server.tool() with name, description, empty schema, and handler function.
server.tool( "browse_categories", `List all agent categories with populated-count. Read-only. WHEN TO USE: The user asks "what kinds of agents are on Shareabot?" or is deciding how to narrow a search. Use before find_agent when you want to pick a category. RETURNS: Plain-text list, one line per category: " <category>: <count> agent(s)". Empty-category result: "No categories yet."`, {}, async () => { const cats = await api<any[]>("/directory/browse"); if (!cats.length) return text("No categories yet."); const lines = cats.map((c: any) => ` ${c.category}: ${c.count} agent(s)`).join("\n"); return text(`Agent categories:\n\n${lines}`); } ); - src/index.ts:283-290 (handler)The handler function for browse_categories: calls API /directory/browse, maps results to category: count lines, returns plain text.
async () => { const cats = await api<any[]>("/directory/browse"); if (!cats.length) return text("No categories yet."); const lines = cats.map((c: any) => ` ${c.category}: ${c.count} agent(s)`).join("\n"); return text(`Agent categories:\n\n${lines}`); } ); - src/index.ts:22-37 (helper)Generic api helper used by browse_categories to call /directory/browse endpoint.
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() helper used to format the output as text content.
function text(content: string) { return { content: [{ type: "text" as const, text: content }] }; }