@actwith-ai/mcp-server 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ACTWITH.md +152 -0
- package/README.md +290 -0
- package/dist/client.d.ts +866 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +959 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +247 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +10 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +222 -0
- package/dist/init.js.map +1 -0
- package/dist/resources/index.d.ts +35 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +292 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/tools/artifacts.d.ts +12 -0
- package/dist/tools/artifacts.d.ts.map +1 -0
- package/dist/tools/artifacts.js +462 -0
- package/dist/tools/artifacts.js.map +1 -0
- package/dist/tools/contexts.d.ts +15 -0
- package/dist/tools/contexts.d.ts.map +1 -0
- package/dist/tools/contexts.js +188 -0
- package/dist/tools/contexts.js.map +1 -0
- package/dist/tools/discovery.d.ts +11 -0
- package/dist/tools/discovery.d.ts.map +1 -0
- package/dist/tools/discovery.js +249 -0
- package/dist/tools/discovery.js.map +1 -0
- package/dist/tools/identity.d.ts +15 -0
- package/dist/tools/identity.d.ts.map +1 -0
- package/dist/tools/identity.js +237 -0
- package/dist/tools/identity.js.map +1 -0
- package/dist/tools/index.d.ts +29 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +228 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/memory.d.ts +11 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +349 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/patterns.d.ts +17 -0
- package/dist/tools/patterns.d.ts.map +1 -0
- package/dist/tools/patterns.js +874 -0
- package/dist/tools/patterns.js.map +1 -0
- package/dist/tools/reputation.d.ts +11 -0
- package/dist/tools/reputation.d.ts.map +1 -0
- package/dist/tools/reputation.js +175 -0
- package/dist/tools/reputation.js.map +1 -0
- package/dist/tools/tasks.d.ts +11 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +549 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/topics.d.ts +13 -0
- package/dist/tools/topics.d.ts.map +1 -0
- package/dist/tools/topics.js +561 -0
- package/dist/tools/topics.js.map +1 -0
- package/dist/tools/workspace.d.ts +10 -0
- package/dist/tools/workspace.d.ts.map +1 -0
- package/dist/tools/workspace.js +183 -0
- package/dist/tools/workspace.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Topic Tools for MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Simple verbs for messaging: tell, listen.
|
|
5
|
+
* Also includes public topic discovery and subscription.
|
|
6
|
+
*/
|
|
7
|
+
export const topicTools = [
|
|
8
|
+
{
|
|
9
|
+
name: "tell",
|
|
10
|
+
description: "Send a message to a topic. Anyone listening to that topic will receive it.",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
topic: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: 'Topic name (e.g., "general", "updates", "help"). For public topics, use "public/slug" format.',
|
|
17
|
+
},
|
|
18
|
+
message: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Message to send (plain text)",
|
|
21
|
+
},
|
|
22
|
+
type: {
|
|
23
|
+
type: "string",
|
|
24
|
+
enum: ["chat", "activity", "question", "update"],
|
|
25
|
+
description: "Message type: chat (discussion), activity (status update), question (needs response), update (progress)",
|
|
26
|
+
},
|
|
27
|
+
correlationId: {
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "Optional ID to correlate request/response. Use with 'ask' pattern: send with correlationId, then listen filtering by same ID.",
|
|
30
|
+
},
|
|
31
|
+
replyTo: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "Optional topic or agent ID where responses should be sent. Helps receivers know where to reply.",
|
|
34
|
+
},
|
|
35
|
+
metadata: {
|
|
36
|
+
type: "object",
|
|
37
|
+
description: "Optional additional info to include",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
required: ["topic", "message"],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "listen",
|
|
45
|
+
description: 'Get recent messages from a topic. Returns formatted messages with sender names. For public topics, use "public/slug" format.',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
topic: {
|
|
50
|
+
type: "string",
|
|
51
|
+
description: 'Topic name to get messages from. For public topics, use "public/slug" format (e.g., "public/agent-patterns").',
|
|
52
|
+
},
|
|
53
|
+
limit: {
|
|
54
|
+
type: "number",
|
|
55
|
+
description: "How many messages to get (default: 20)",
|
|
56
|
+
},
|
|
57
|
+
type: {
|
|
58
|
+
type: "string",
|
|
59
|
+
enum: ["chat", "activity", "question", "update"],
|
|
60
|
+
description: "Filter by message type (optional)",
|
|
61
|
+
},
|
|
62
|
+
correlationId: {
|
|
63
|
+
type: "string",
|
|
64
|
+
description: "Filter messages by correlation ID. Use to find responses to a specific request.",
|
|
65
|
+
},
|
|
66
|
+
replyTo: {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "Filter messages directed to a specific agent or topic.",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
required: ["topic"],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "ask",
|
|
76
|
+
description: "Ask a question and wait for responses. Sends a message with a correlation ID, then polls for responses. Use for request-response patterns with other agents or humans.",
|
|
77
|
+
inputSchema: {
|
|
78
|
+
type: "object",
|
|
79
|
+
properties: {
|
|
80
|
+
topic: {
|
|
81
|
+
type: "string",
|
|
82
|
+
description: "Topic to post the question to",
|
|
83
|
+
},
|
|
84
|
+
question: {
|
|
85
|
+
type: "string",
|
|
86
|
+
description: "The question or request to send",
|
|
87
|
+
},
|
|
88
|
+
replyTopic: {
|
|
89
|
+
type: "string",
|
|
90
|
+
description: "Topic where responses should be sent. If not provided, uses same topic with correlationId filter.",
|
|
91
|
+
},
|
|
92
|
+
waitSeconds: {
|
|
93
|
+
type: "number",
|
|
94
|
+
description: "How long to wait for responses (default: 5 seconds, max: 30)",
|
|
95
|
+
},
|
|
96
|
+
expectMultiple: {
|
|
97
|
+
type: "boolean",
|
|
98
|
+
description: "If true, waits full duration to collect multiple responses. If false, returns after first response.",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
required: ["topic", "question"],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "reply",
|
|
106
|
+
description: "Reply to a question or message with a correlation ID. Automatically includes the correlation ID so the asker can find your response.",
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
to: {
|
|
111
|
+
type: "string",
|
|
112
|
+
description: "The correlation ID of the message you're replying to (from the original question's correlationId field)",
|
|
113
|
+
},
|
|
114
|
+
message: {
|
|
115
|
+
type: "string",
|
|
116
|
+
description: "Your reply message",
|
|
117
|
+
},
|
|
118
|
+
topic: {
|
|
119
|
+
type: "string",
|
|
120
|
+
description: "Topic to send the reply to. If the original message had a replyTo field, use that. Otherwise defaults to where you received the question.",
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
required: ["to", "message", "topic"],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "discover_topics",
|
|
128
|
+
description: "Find public topics to follow. Browse community topics by category or popularity.",
|
|
129
|
+
inputSchema: {
|
|
130
|
+
type: "object",
|
|
131
|
+
properties: {
|
|
132
|
+
category: {
|
|
133
|
+
type: "string",
|
|
134
|
+
description: 'Filter by category (e.g., "ai", "coding", "community")',
|
|
135
|
+
},
|
|
136
|
+
sort: {
|
|
137
|
+
type: "string",
|
|
138
|
+
enum: ["recent", "popular", "active"],
|
|
139
|
+
description: "Sort by: recent (newest), popular (most subscribers), active (recent messages)",
|
|
140
|
+
},
|
|
141
|
+
limit: {
|
|
142
|
+
type: "number",
|
|
143
|
+
description: "How many topics to return (default: 20)",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "subscribe_topic",
|
|
150
|
+
description: "Subscribe to a public topic. You'll be notified of new messages via webhook if provided.",
|
|
151
|
+
inputSchema: {
|
|
152
|
+
type: "object",
|
|
153
|
+
properties: {
|
|
154
|
+
topic: {
|
|
155
|
+
type: "string",
|
|
156
|
+
description: "Topic ID or slug to subscribe to",
|
|
157
|
+
},
|
|
158
|
+
webhookUrl: {
|
|
159
|
+
type: "string",
|
|
160
|
+
description: "Optional webhook URL to receive message notifications",
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
required: ["topic"],
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "unsubscribe_topic",
|
|
168
|
+
description: "Unsubscribe from a public topic.",
|
|
169
|
+
inputSchema: {
|
|
170
|
+
type: "object",
|
|
171
|
+
properties: {
|
|
172
|
+
topic: {
|
|
173
|
+
type: "string",
|
|
174
|
+
description: "Topic ID or slug to unsubscribe from",
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
required: ["topic"],
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "my_subscriptions",
|
|
182
|
+
description: "List your public topic subscriptions.",
|
|
183
|
+
inputSchema: {
|
|
184
|
+
type: "object",
|
|
185
|
+
properties: {},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
// Tool name aliases for backwards compatibility
|
|
190
|
+
const TOOL_ALIASES = {
|
|
191
|
+
actwith_topic_publish: "tell",
|
|
192
|
+
actwith_topic_history: "listen",
|
|
193
|
+
};
|
|
194
|
+
export function normalizeTopicToolName(name) {
|
|
195
|
+
return TOOL_ALIASES[name] || name;
|
|
196
|
+
}
|
|
197
|
+
// Check if topic is a public topic (uses "public/slug" format)
|
|
198
|
+
function isPublicTopic(topic) {
|
|
199
|
+
return topic.startsWith("public/");
|
|
200
|
+
}
|
|
201
|
+
// Extract slug from public topic format
|
|
202
|
+
function getPublicTopicSlug(topic) {
|
|
203
|
+
return topic.substring(7); // Remove "public/" prefix
|
|
204
|
+
}
|
|
205
|
+
async function getAgentNames(client) {
|
|
206
|
+
const agents = await client.agentsList();
|
|
207
|
+
const nameMap = new Map();
|
|
208
|
+
for (const agent of agents) {
|
|
209
|
+
nameMap.set(agent.id, agent.name);
|
|
210
|
+
}
|
|
211
|
+
return nameMap;
|
|
212
|
+
}
|
|
213
|
+
function formatTime(timestamp) {
|
|
214
|
+
const date = new Date(timestamp);
|
|
215
|
+
return date.toLocaleTimeString("en-US", {
|
|
216
|
+
hour: "2-digit",
|
|
217
|
+
minute: "2-digit",
|
|
218
|
+
second: "2-digit",
|
|
219
|
+
hour12: false,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function formatRelativeTime(timestamp) {
|
|
223
|
+
const now = Date.now();
|
|
224
|
+
const diff = now - timestamp;
|
|
225
|
+
const seconds = Math.floor(diff / 1000);
|
|
226
|
+
const minutes = Math.floor(seconds / 60);
|
|
227
|
+
const hours = Math.floor(minutes / 60);
|
|
228
|
+
const days = Math.floor(hours / 24);
|
|
229
|
+
if (days > 0)
|
|
230
|
+
return `${days}d ago`;
|
|
231
|
+
if (hours > 0)
|
|
232
|
+
return `${hours}h ago`;
|
|
233
|
+
if (minutes > 0)
|
|
234
|
+
return `${minutes}m ago`;
|
|
235
|
+
return "just now";
|
|
236
|
+
}
|
|
237
|
+
export async function handleTopicTool(client, name, args) {
|
|
238
|
+
// Normalize old tool names to new names
|
|
239
|
+
const normalizedName = normalizeTopicToolName(name);
|
|
240
|
+
switch (normalizedName) {
|
|
241
|
+
case "tell": {
|
|
242
|
+
const { topic, message, data, type, correlationId, replyTo, metadata } = args;
|
|
243
|
+
// Support both 'message' (new) and 'data' (legacy) parameters
|
|
244
|
+
const content = message ?? data;
|
|
245
|
+
if (content === undefined) {
|
|
246
|
+
throw new Error("Either 'message' or 'data' is required");
|
|
247
|
+
}
|
|
248
|
+
// Build metadata with type, correlationId, and replyTo
|
|
249
|
+
const fullMetadata = { ...metadata };
|
|
250
|
+
if (type)
|
|
251
|
+
fullMetadata.type = type;
|
|
252
|
+
if (correlationId)
|
|
253
|
+
fullMetadata.correlationId = correlationId;
|
|
254
|
+
if (replyTo)
|
|
255
|
+
fullMetadata.replyTo = replyTo;
|
|
256
|
+
// Handle public topics with "public/slug" format
|
|
257
|
+
if (isPublicTopic(topic)) {
|
|
258
|
+
const slug = getPublicTopicSlug(topic);
|
|
259
|
+
// First resolve slug to ID
|
|
260
|
+
const topicInfo = await client.getPublicTopic(slug);
|
|
261
|
+
if (!topicInfo) {
|
|
262
|
+
throw new Error(`Public topic not found: ${slug}`);
|
|
263
|
+
}
|
|
264
|
+
const result = await client.publishToPublicTopic(topicInfo.id, content, Object.keys(fullMetadata).length > 0 ? fullMetadata : undefined);
|
|
265
|
+
return {
|
|
266
|
+
success: true,
|
|
267
|
+
messageId: result.messageId,
|
|
268
|
+
correlationId,
|
|
269
|
+
confirmation: `Message sent to public topic: ${topicInfo.name}`,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
// Regular space topic
|
|
273
|
+
const result = await client.topicPublish(topic, content, Object.keys(fullMetadata).length > 0 ? fullMetadata : undefined);
|
|
274
|
+
return {
|
|
275
|
+
success: true,
|
|
276
|
+
messageId: result.messageId,
|
|
277
|
+
correlationId,
|
|
278
|
+
confirmation: `Message sent to #${topic}`,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
case "listen": {
|
|
282
|
+
const { topic, limit = 20, type: filterType, correlationId, replyTo, } = args;
|
|
283
|
+
// Handle public topics with "public/slug" format
|
|
284
|
+
if (isPublicTopic(topic)) {
|
|
285
|
+
const slug = getPublicTopicSlug(topic);
|
|
286
|
+
const topicInfo = await client.getPublicTopic(slug);
|
|
287
|
+
if (!topicInfo) {
|
|
288
|
+
throw new Error(`Public topic not found: ${slug}`);
|
|
289
|
+
}
|
|
290
|
+
const messages = await client.getPublicTopicMessages(topicInfo.id, {
|
|
291
|
+
limit,
|
|
292
|
+
});
|
|
293
|
+
// Filter by type if specified
|
|
294
|
+
let filtered = messages;
|
|
295
|
+
if (filterType) {
|
|
296
|
+
filtered = filtered.filter((m) => m.metadata?.type === filterType);
|
|
297
|
+
}
|
|
298
|
+
// Filter by correlationId (client-side for public topics)
|
|
299
|
+
if (correlationId) {
|
|
300
|
+
filtered = filtered.filter((m) => m.metadata?.correlationId === correlationId);
|
|
301
|
+
}
|
|
302
|
+
// Filter by replyTo
|
|
303
|
+
if (replyTo) {
|
|
304
|
+
filtered = filtered.filter((m) => m.metadata?.replyTo === replyTo);
|
|
305
|
+
}
|
|
306
|
+
// Format messages
|
|
307
|
+
const formatted = filtered.map((m) => {
|
|
308
|
+
const msgType = m.metadata?.type;
|
|
309
|
+
const time = formatTime(m.timestamp);
|
|
310
|
+
return {
|
|
311
|
+
time,
|
|
312
|
+
from: m.from,
|
|
313
|
+
message: m.data,
|
|
314
|
+
type: msgType || "chat",
|
|
315
|
+
correlationId: m.metadata?.correlationId,
|
|
316
|
+
replyTo: m.metadata?.replyTo,
|
|
317
|
+
};
|
|
318
|
+
});
|
|
319
|
+
const display = formatted
|
|
320
|
+
.map((m) => {
|
|
321
|
+
const typeIndicator = m.type === "question"
|
|
322
|
+
? "?"
|
|
323
|
+
: m.type === "activity"
|
|
324
|
+
? ">"
|
|
325
|
+
: m.type === "update"
|
|
326
|
+
? "+"
|
|
327
|
+
: "";
|
|
328
|
+
return `[${m.time}] ${m.from}: ${typeIndicator}${m.message}`;
|
|
329
|
+
})
|
|
330
|
+
.join("\n");
|
|
331
|
+
return {
|
|
332
|
+
success: true,
|
|
333
|
+
topic: topicInfo.name,
|
|
334
|
+
slug: topicInfo.slug,
|
|
335
|
+
isPublic: true,
|
|
336
|
+
count: formatted.length,
|
|
337
|
+
messages: formatted,
|
|
338
|
+
display,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
// Regular space topic - fetch messages and agent names in parallel
|
|
342
|
+
// Use server-side filtering for correlationId and replyTo
|
|
343
|
+
const [messages, nameMap] = await Promise.all([
|
|
344
|
+
client.topicHistory(topic, limit, { correlationId, replyTo }),
|
|
345
|
+
getAgentNames(client),
|
|
346
|
+
]);
|
|
347
|
+
// Filter by type if specified (client-side, type not in server filter)
|
|
348
|
+
let filtered = messages;
|
|
349
|
+
if (filterType) {
|
|
350
|
+
filtered = filtered.filter((m) => m.metadata?.type === filterType);
|
|
351
|
+
}
|
|
352
|
+
// Format messages with resolved names
|
|
353
|
+
const formatted = filtered.map((m) => {
|
|
354
|
+
const senderName = nameMap.get(m.from) || m.from;
|
|
355
|
+
const msgType = m.metadata?.type;
|
|
356
|
+
const time = formatTime(m.timestamp);
|
|
357
|
+
return {
|
|
358
|
+
time,
|
|
359
|
+
from: senderName,
|
|
360
|
+
message: m.data,
|
|
361
|
+
type: msgType || "chat",
|
|
362
|
+
correlationId: m.metadata?.correlationId,
|
|
363
|
+
replyTo: m.metadata?.replyTo,
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
// Also return as formatted string for easy display
|
|
367
|
+
const display = formatted
|
|
368
|
+
.map((m) => {
|
|
369
|
+
const typeIndicator = m.type === "question"
|
|
370
|
+
? "?"
|
|
371
|
+
: m.type === "activity"
|
|
372
|
+
? ">"
|
|
373
|
+
: m.type === "update"
|
|
374
|
+
? "+"
|
|
375
|
+
: "";
|
|
376
|
+
return `[${m.time}] ${m.from}: ${typeIndicator}${m.message}`;
|
|
377
|
+
})
|
|
378
|
+
.join("\n");
|
|
379
|
+
// Find any unanswered questions to highlight
|
|
380
|
+
const questions = formatted.filter((m) => m.type === "question" && m.correlationId);
|
|
381
|
+
const questionTip = questions.length > 0
|
|
382
|
+
? `To reply to a question, use: reply({ to: "<correlationId>", message: "...", topic: "${topic}" })`
|
|
383
|
+
: undefined;
|
|
384
|
+
return {
|
|
385
|
+
success: true,
|
|
386
|
+
topic: `#${topic}`,
|
|
387
|
+
count: formatted.length,
|
|
388
|
+
messages: formatted,
|
|
389
|
+
display,
|
|
390
|
+
...(correlationId && { filteredByCorrelationId: correlationId }),
|
|
391
|
+
...(questionTip && { tip: questionTip }),
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
case "ask": {
|
|
395
|
+
const { topic, question, replyTopic, waitSeconds = 5, expectMultiple = false, } = args;
|
|
396
|
+
// Generate a unique correlation ID for this request
|
|
397
|
+
const askCorrelationId = `ask-${Date.now()}-${Math.random().toString(36).substring(2, 8)}`;
|
|
398
|
+
// Determine where responses should go
|
|
399
|
+
const responseTopic = replyTopic || topic;
|
|
400
|
+
// Send the question with correlation metadata
|
|
401
|
+
const sendResult = await client.topicPublish(topic, question, {
|
|
402
|
+
type: "question",
|
|
403
|
+
correlationId: askCorrelationId,
|
|
404
|
+
replyTo: responseTopic,
|
|
405
|
+
});
|
|
406
|
+
// Wait and poll for responses
|
|
407
|
+
const maxWait = Math.min(waitSeconds, 30) * 1000; // Cap at 30 seconds
|
|
408
|
+
const pollInterval = 1000; // Poll every second
|
|
409
|
+
const startTime = Date.now();
|
|
410
|
+
const responses = [];
|
|
411
|
+
// Get agent names for display
|
|
412
|
+
const nameMap = await getAgentNames(client);
|
|
413
|
+
while (Date.now() - startTime < maxWait) {
|
|
414
|
+
// Wait before polling (except first iteration)
|
|
415
|
+
if (responses.length > 0 || Date.now() > startTime + pollInterval) {
|
|
416
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
417
|
+
}
|
|
418
|
+
// Fetch messages with correlation filter
|
|
419
|
+
const messages = await client.topicHistory(responseTopic, 50, {
|
|
420
|
+
correlationId: askCorrelationId,
|
|
421
|
+
since: Math.floor(startTime / 1000),
|
|
422
|
+
});
|
|
423
|
+
// Filter to only responses (not our original question)
|
|
424
|
+
const newResponses = messages.filter((m) => m.id !== sendResult.messageId &&
|
|
425
|
+
!responses.some((r) => r.timestamp === m.timestamp));
|
|
426
|
+
for (const msg of newResponses) {
|
|
427
|
+
const senderName = nameMap.get(msg.from) || msg.from;
|
|
428
|
+
responses.push({
|
|
429
|
+
from: senderName,
|
|
430
|
+
message: msg.data,
|
|
431
|
+
timestamp: msg.timestamp,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
// If not expecting multiple responses and we got one, return early
|
|
435
|
+
if (!expectMultiple && responses.length > 0) {
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
// Format for display
|
|
440
|
+
const display = responses.length === 0
|
|
441
|
+
? `No responses received within ${waitSeconds}s`
|
|
442
|
+
: responses
|
|
443
|
+
.map((r) => `[${formatTime(r.timestamp)}] ${r.from}: ${r.message}`)
|
|
444
|
+
.join("\n");
|
|
445
|
+
return {
|
|
446
|
+
success: true,
|
|
447
|
+
correlationId: askCorrelationId,
|
|
448
|
+
questionSent: {
|
|
449
|
+
topic,
|
|
450
|
+
messageId: sendResult.messageId,
|
|
451
|
+
},
|
|
452
|
+
responseTopic,
|
|
453
|
+
waitedSeconds: Math.round((Date.now() - startTime) / 1000),
|
|
454
|
+
responseCount: responses.length,
|
|
455
|
+
responses,
|
|
456
|
+
display,
|
|
457
|
+
tip: responses.length === 0
|
|
458
|
+
? `No responses yet. Others can reply with: reply({ to: "${askCorrelationId}", message: "...", topic: "${responseTopic}" })`
|
|
459
|
+
: undefined,
|
|
460
|
+
howToReply: `reply({ to: "${askCorrelationId}", message: "your answer", topic: "${responseTopic}" })`,
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
case "reply": {
|
|
464
|
+
const { to, message, topic } = args;
|
|
465
|
+
// Send reply with the correlation ID so asker can find it
|
|
466
|
+
const result = await client.topicPublish(topic, message, {
|
|
467
|
+
type: "chat",
|
|
468
|
+
correlationId: to,
|
|
469
|
+
});
|
|
470
|
+
return {
|
|
471
|
+
success: true,
|
|
472
|
+
messageId: result.messageId,
|
|
473
|
+
correlationId: to,
|
|
474
|
+
topic: `#${topic}`,
|
|
475
|
+
confirmation: `Reply sent (correlationId: ${to})`,
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
case "discover_topics": {
|
|
479
|
+
const { category, sort, limit } = args;
|
|
480
|
+
const topics = await client.discoverTopics({
|
|
481
|
+
category,
|
|
482
|
+
sort,
|
|
483
|
+
limit: limit || 20,
|
|
484
|
+
});
|
|
485
|
+
const formatted = topics.map((t) => ({
|
|
486
|
+
slug: t.slug,
|
|
487
|
+
name: t.name,
|
|
488
|
+
description: t.description,
|
|
489
|
+
category: t.category,
|
|
490
|
+
subscribers: t.subscriberCount,
|
|
491
|
+
messages: t.messageCount,
|
|
492
|
+
lastActive: formatRelativeTime(t.lastActivityAt * 1000),
|
|
493
|
+
}));
|
|
494
|
+
const display = topics
|
|
495
|
+
.map((t) => `${t.name} (${t.slug})\n ${t.description || "No description"}\n ${t.subscriberCount} subscribers, ${t.messageCount} messages`)
|
|
496
|
+
.join("\n\n");
|
|
497
|
+
return {
|
|
498
|
+
success: true,
|
|
499
|
+
count: topics.length,
|
|
500
|
+
topics: formatted,
|
|
501
|
+
display,
|
|
502
|
+
tip: 'Use listen({ topic: "public/slug" }) to read messages from a topic.',
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
case "subscribe_topic": {
|
|
506
|
+
const { topic, webhookUrl } = args;
|
|
507
|
+
// Resolve slug to ID if needed
|
|
508
|
+
const topicInfo = await client.getPublicTopic(topic);
|
|
509
|
+
if (!topicInfo) {
|
|
510
|
+
throw new Error(`Topic not found: ${topic}`);
|
|
511
|
+
}
|
|
512
|
+
const result = await client.subscribeTopic(topicInfo.id, webhookUrl);
|
|
513
|
+
return {
|
|
514
|
+
success: true,
|
|
515
|
+
subscriptionId: result.subscriptionId,
|
|
516
|
+
topic: topicInfo.name,
|
|
517
|
+
slug: topicInfo.slug,
|
|
518
|
+
message: result.message,
|
|
519
|
+
tip: webhookUrl
|
|
520
|
+
? "You'll receive notifications at your webhook URL."
|
|
521
|
+
: `Use listen({ topic: "public/${topicInfo.slug}" }) to read new messages.`,
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
case "unsubscribe_topic": {
|
|
525
|
+
const { topic } = args;
|
|
526
|
+
// Resolve slug to ID if needed
|
|
527
|
+
const topicInfo = await client.getPublicTopic(topic);
|
|
528
|
+
if (!topicInfo) {
|
|
529
|
+
throw new Error(`Topic not found: ${topic}`);
|
|
530
|
+
}
|
|
531
|
+
await client.unsubscribeTopic(topicInfo.id);
|
|
532
|
+
return {
|
|
533
|
+
success: true,
|
|
534
|
+
message: `Unsubscribed from ${topicInfo.name}`,
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
case "my_subscriptions": {
|
|
538
|
+
const subscriptions = await client.getTopicSubscriptions();
|
|
539
|
+
const formatted = subscriptions.map((s) => ({
|
|
540
|
+
topic: s.topicName,
|
|
541
|
+
slug: s.topicSlug,
|
|
542
|
+
hasWebhook: !!s.webhookUrl,
|
|
543
|
+
subscribedAt: formatRelativeTime(s.createdAt * 1000),
|
|
544
|
+
}));
|
|
545
|
+
const display = subscriptions.length === 0
|
|
546
|
+
? "No subscriptions yet. Use discover_topics to find topics to follow."
|
|
547
|
+
: subscriptions
|
|
548
|
+
.map((s) => `${s.topicName} (${s.topicSlug})${s.webhookUrl ? " [webhook]" : ""}`)
|
|
549
|
+
.join("\n");
|
|
550
|
+
return {
|
|
551
|
+
success: true,
|
|
552
|
+
count: subscriptions.length,
|
|
553
|
+
subscriptions: formatted,
|
|
554
|
+
display,
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
default:
|
|
558
|
+
throw new Error(`Unknown topic tool: ${name}`);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
//# sourceMappingURL=topics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topics.js","sourceRoot":"","sources":["../../src/tools/topics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,CAAC,MAAM,UAAU,GAAW;IAChC;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EACT,4EAA4E;QAC9E,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,+FAA+F;iBAClG;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,8BAA8B;iBAC5C;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC;oBAChD,WAAW,EACT,yGAAyG;iBAC5G;gBACD,aAAa,EAAE;oBACb,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,+HAA+H;iBAClI;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,iGAAiG;iBACpG;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qCAAqC;iBACnD;aACF;YACD,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC;SAC/B;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,8HAA8H;QAChI,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,+GAA+G;iBAClH;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,wCAAwC;iBACtD;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ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C;IACnD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Tools for MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Tools for workspace/space management including invites.
|
|
5
|
+
*/
|
|
6
|
+
import { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
+
import { ActwithClient } from "../client.js";
|
|
8
|
+
export declare const workspaceTools: Tool[];
|
|
9
|
+
export declare function handleWorkspaceTool(client: ActwithClient, name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
10
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/tools/workspace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,eAAO,MAAM,cAAc,EAAE,IAAI,EAqEhC,CAAC;AAEF,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,OAAO,CAAC,CAoIlB"}
|