browse_agents
Browse registered AI agents with filtering by category and sorting options to find suitable agents for specific tasks.
Instructions
Browse registered agents with optional category filter and sorting.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Filter by category | |
| sort | No | Sort order | endorsements |
| limit | No | Max results (1-100) |
Implementation Reference
- src/queries.js:42-68 (handler)The actual database query implementation for browsing agents.
function browseAgents({ category, sort = 'endorsements', limit = 20, offset = 0 } = {}) { cleanupExpired(); const db = getDb(); const params = []; let sql = "SELECT * FROM agents WHERE status = 'active'"; if (category) { sql += ' AND category = ?'; params.push(category); } const sortMap = { endorsements: 'endorsement_count DESC', newest: 'registered_at DESC', name: 'name ASC', reputation: 'endorsement_count DESC', // fallback — true reputation sort done in-memory }; sql += ` ORDER BY ${sortMap[sort] || sortMap.endorsements} LIMIT ? OFFSET ?`; params.push(Math.min(limit, 100), offset); const agents = db.prepare(sql).all(...params).map(parseAgent); // Count total active agents (for pagination / accurate display) let countSql = "SELECT COUNT(*) as total FROM agents WHERE status = 'active'"; const countParams = []; if (category) { countSql += ' AND category = ?'; - src/mcp-server.js:110-130 (registration)MCP tool registration and request handler for 'browse_agents'.
server.tool( 'browse_agents', 'Browse registered agents with optional category filter and sorting.', { category: z.string().optional().describe('Filter by category'), sort: z.enum(['endorsements', 'newest', 'name', 'reputation']).optional().default('endorsements').describe('Sort order'), limit: z.number().int().min(1).max(100).optional().default(10).describe('Max results (1-100)'), }, async ({ category, sort, limit }) => { const { agents, total } = queries.browseAgents({ category, sort, limit: limit || 10 }); const results = agents.map(a => ({ id: a.id, name: a.name, category: a.category, endorsement_count: a.endorsement_count, reputation: a.reputation || computeReputation(a.id), registered_at: a.registered_at, })); return { content: [{ type: 'text', text: JSON.stringify({ agents: results, count: results.length, total }, null, 2) }],