mcp-claude-duo/mcp-partner/tools/list_conversations.js
StillHammer 66e5c677ea v3.0 - Conversation-based messaging system
Features:
- Direct conversations (1-to-1) auto-created and permanent
- Group conversations with leave/archive support
- Real-time messaging via long-polling
- Offline notifications via CLAUDE.md
- Auto-registration on MCP startup

Architecture:
- Broker: Express HTTP server + SQLite
- MCP Partner: Modular tools (one file per tool)
- Full documentation and API reference
2026-01-25 02:57:24 +07:00

43 lines
1.2 KiB
JavaScript

import { brokerFetch, myId, ensureRegistered } from "../shared.js";
export const definition = {
name: "list_conversations",
description: "Liste toutes tes conversations actives.",
inputSchema: {
type: "object",
properties: {},
},
};
export async function handler() {
try {
await ensureRegistered();
const { conversations } = await brokerFetch(`/conversations/${myId}`);
if (!conversations?.length) {
return {
content: [{ type: "text", text: "Aucune conversation." }],
};
}
let text = "**Conversations:**\n\n";
for (const conv of conversations) {
const type = conv.type === "direct" ? "💬" : "👥";
const unread = conv.unread_count > 0 ? ` (${conv.unread_count} non lu${conv.unread_count > 1 ? "s" : ""})` : "";
const participants = conv.participants.map((p) => p.name).join(", ");
const name = conv.name || participants;
text += `${type} **${name}**${unread}\n ID: \`${conv.id}\`\n Participants: ${participants}\n\n`;
}
return {
content: [{ type: "text", text }],
};
} catch (error) {
return {
content: [{ type: "text", text: `Erreur: ${error.message}` }],
isError: true,
};
}
}