browse_agents
Browse registered AI agents with category filtering and sorting options to find suitable agents based on endorsements, reputation, or registration date.
Instructions
Browse registered agents with optional category filter and sorting.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Filter by category | |
| sort | No | Sort order | endorsements |
| limit | No | Max results |
Implementation Reference
- src/queries.js:41-71 (handler)The actual implementation of the browseAgents function, which queries the database and applies sorting/filtering logic.
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); // If sort by reputation, compute and re-sort if (sort === 'reputation') { return agents .map(a => ({ ...a, reputation: computeReputation(a.id) })) .sort((a, b) => (b.reputation?.score || 0) - (a.reputation?.score || 0)); } return agents; } - src/mcp-server.js:110-118 (registration)MCP tool registration for 'browse_agents', including schema definition and invocation of the queries.browseAgents helper.
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().optional().default(10).describe('Max results'), }, async ({ category, sort, limit }) => {