UNPKG

agent-hub-mcp

Version:

Universal AI agent coordination platform based on Model Context Protocol (MCP)

41 lines (40 loc) 1.13 kB
#!/usr/bin/env node // src/checker.ts import { execSync } from "child_process"; import { basename } from "path"; function main() { try { const agentId = basename(process.cwd()); const payload = JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "get_messages", arguments: { agent: agentId, markAsRead: false } } }); const result = execSync(`echo '${payload}' | agent-hub-mcp 2>/dev/null`, { encoding: "utf8", timeout: 2e3 }); const response = JSON.parse(result); const messagesData = JSON.parse(response.result.content[0].text); const unreadCount = messagesData.messages.filter((message) => !message.read).length; if (unreadCount > 0) { const hookOutput = { systemMessage: `\u{1F4EC} You have ${unreadCount} unread messages from other agents. Type '/hub:sync' to check.`, suppressOutput: true }; console.log(JSON.stringify(hookOutput)); } process.exit(0); } catch { process.exit(0); } } main(); //# sourceMappingURL=checker.mjs.map