discover-agents
Find active AI agents in the MCP Agentic Framework to coordinate tasks and verify availability before messaging them.
Instructions
See who's awake in the conversation! Returns ALL active agents with their IDs, names, and current status. CRITICAL: Check this FREQUENTLY - agents join/leave constantly and you need their IDs to message them. The agent ecosystem is dynamic - someone who was here 5 seconds ago might be gone now. Always verify an agent exists before messaging them.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.js:117-157 (handler)Main handler function for discover-agents tool. Calls agentRegistry.discoverAgents() to get all registered agents, creates resource links for agent profiles, formats the response with agent details (name, ID, status, description), and returns a structured response with metadata.
/** * Discover all registered agents */ export async function discoverAgents() { const startTime = Date.now(); try { const agents = await agentRegistry.discoverAgents(); // Create resource links for agent profiles const resourceLinks = agents.map(agent => createAgentProfileLink(agent.id, agent.name) ); const metadata = addResourceLinks( createMetadata(startTime, { tool: 'discover-agents', agentCount: agents.length }), resourceLinks ); let message; if (agents.length === 0) { message = 'No agents currently registered'; } else { // Include agent details in the message const agentList = agents.map(agent => `- ${agent.name} (ID: ${agent.id})\n Status: ${agent.status || 'No status set'}\n Description: ${agent.description}` ).join('\n'); message = `Found ${agents.length} registered agent${agents.length === 1 ? '' : 's'}:\n${agentList}`; } return structuredResponse({ agents }, message, metadata); } catch (error) { if (error instanceof MCPError) { throw error; } throw Errors.internalError(error.message); } } - src/toolDefinitions.js:88-120 (schema)Tool definition schema for discover-agents. Defines the tool name, title, description, inputSchema (empty properties object), and outputSchema with an agents array containing id, name, description, status, registeredAt, and lastActivityAt fields.
name: 'discover-agents', title: 'Discover Active Agents', description: 'See who\'s awake in the conversation! Returns ALL active agents with their IDs, names, and current status. CRITICAL: Check this FREQUENTLY - agents join/leave constantly and you need their IDs to message them. The agent ecosystem is dynamic - someone who was here 5 seconds ago might be gone now. Always verify an agent exists before messaging them.', inputSchema: { $schema: 'http://json-schema.org/draft-07/schema#', type: 'object', properties: {}, additionalProperties: false }, outputSchema: { $schema: 'http://json-schema.org/draft-07/schema#', type: 'object', properties: { agents: { type: 'array', description: 'List of currently registered agents', items: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' }, description: { type: 'string' }, status: { type: 'string' }, registeredAt: { type: 'string' }, lastActivityAt: { type: 'string' } } } } }, required: ['agents'], additionalProperties: false } }, - src/server.js:160-162 (registration)Registration of discover-agents tool in the MCP server's CallToolRequestSchema handler. Maps the 'discover-agents' tool name to the discoverAgents() handler function.
case 'discover-agents': { return await discoverAgents(); } - src/lib/agentRegistry.js:155-165 (helper)Core implementation of discoverAgents in the agent registry. Loads agents from JSON storage file and returns an array of agent objects with id, name, description, status, and lastActivityAt fields.
const discoverAgents = async () => { const agents = await loadAgents(storagePath); return Object.values(agents).map(({ id, name, description, status, lastActivityAt }) => ({ id, name, description, status, lastActivityAt })); };