search_agents
Find AI agents by name, description, or category with reputation scores to identify trustworthy agents for your specific tasks.
Instructions
Search the AgentStamp agent directory by query and/or category. Returns agents with reputation scores.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Search term to match against agent names, descriptions, and capabilities | |
| category | No | Filter by category: data, trading, research, creative, infrastructure, other | |
| limit | No | Max results (1-100) |
Implementation Reference
- src/mcp-server.js:20-47 (handler)MCP tool registration and handler implementation for 'search_agents'. It calls the underlying query function and computes reputation scores for the results.
server.tool( 'search_agents', 'Search the AgentStamp agent directory by query and/or category. Returns agents with reputation scores.', { query: z.string().optional().describe('Search term to match against agent names, descriptions, and capabilities'), category: z.string().optional().describe('Filter by category: data, trading, research, creative, infrastructure, other'), limit: z.number().int().min(1).max(100).optional().default(10).describe('Max results (1-100)'), }, async ({ query, category, limit }) => { const agents = queries.searchAgents({ q: query, category, limit: limit || 10 }); const withRep = agents.map(a => ({ id: a.id, name: a.name, description: a.description, category: a.category, capabilities: a.capabilities, endorsement_count: a.endorsement_count, reputation: computeReputation(a.id), profile_url: `https://agentstamp.org/registry/${a.id}`, })); return { content: [{ type: 'text', text: JSON.stringify({ agents: withRep, count: withRep.length }, null, 2), }], }; } - src/queries.js:20-40 (helper)Core logic for searching agents in the database, used by the MCP tool handler.
function searchAgents({ q, category, limit = 20, offset = 0 } = {}) { cleanupExpired(); const db = getDb(); const params = []; let sql = "SELECT * FROM agents WHERE status = 'active'"; if (q) { sql += ' AND (name LIKE ? OR description LIKE ? OR capabilities LIKE ?)'; const like = `%${q}%`; params.push(like, like, like); } if (category) { sql += ' AND category = ?'; params.push(category); } sql += ' ORDER BY endorsement_count DESC LIMIT ? OFFSET ?'; params.push(Math.min(limit, 100), offset); return db.prepare(sql).all(...params).map(parseAgent); }