bn-slack-mcp-server 0.0.1
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/README.md +243 -0
- package/dist/debug-middleware.d.ts +12 -0
- package/dist/debug-middleware.d.ts.map +1 -0
- package/dist/debug-middleware.js +36 -0
- package/dist/debug-middleware.js.map +1 -0
- package/dist/helpers.d.ts +86 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +235 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +162 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas.d.ts +286 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +840 -0
- package/dist/schemas.js.map +1 -0
- package/dist/slack-api-client.d.ts +51 -0
- package/dist/slack-api-client.d.ts.map +1 -0
- package/dist/slack-api-client.js +227 -0
- package/dist/slack-api-client.js.map +1 -0
- package/dist/tool-loader.d.ts +35 -0
- package/dist/tool-loader.d.ts.map +1 -0
- package/dist/tool-loader.js +121 -0
- package/dist/tool-loader.js.map +1 -0
- package/dist/tool-registry.d.ts +44 -0
- package/dist/tool-registry.d.ts.map +1 -0
- package/dist/tool-registry.js +56 -0
- package/dist/tool-registry.js.map +1 -0
- package/dist/tools/cache.d.ts +69 -0
- package/dist/tools/cache.d.ts.map +1 -0
- package/dist/tools/cache.js +94 -0
- package/dist/tools/cache.js.map +1 -0
- package/dist/tools/channels.d.ts +76 -0
- package/dist/tools/channels.d.ts.map +1 -0
- package/dist/tools/channels.js +251 -0
- package/dist/tools/channels.js.map +1 -0
- package/dist/tools/conversations.d.ts +77 -0
- package/dist/tools/conversations.d.ts.map +1 -0
- package/dist/tools/conversations.js +302 -0
- package/dist/tools/conversations.js.map +1 -0
- package/dist/tools/files.d.ts +15 -0
- package/dist/tools/files.d.ts.map +1 -0
- package/dist/tools/files.js +30 -0
- package/dist/tools/files.js.map +1 -0
- package/dist/tools/index.d.ts +12 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +20 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/messages.d.ts +20 -0
- package/dist/tools/messages.d.ts.map +1 -0
- package/dist/tools/messages.js +40 -0
- package/dist/tools/messages.js.map +1 -0
- package/dist/tools/system.d.ts +48 -0
- package/dist/tools/system.d.ts.map +1 -0
- package/dist/tools/system.js +124 -0
- package/dist/tools/system.js.map +1 -0
- package/dist/tools/users.d.ts +69 -0
- package/dist/tools/users.d.ts.map +1 -0
- package/dist/tools/users.js +179 -0
- package/dist/tools/users.js.map +1 -0
- package/dist/tools/workspace.d.ts +50 -0
- package/dist/tools/workspace.d.ts.map +1 -0
- package/dist/tools/workspace.js +56 -0
- package/dist/tools/workspace.js.map +1 -0
- package/dist/types.d.ts +160 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
- package/tools.json +483 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation tool handlers for Slack MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import { getSlackClient } from "../slack-api-client.js";
|
|
5
|
+
import { parseLimit, createUserLookup, createUserNameLookup, extractUserDetails, markdownToSlack, parseSlackUrl, } from "../helpers.js";
|
|
6
|
+
/**
|
|
7
|
+
* Get messages from a channel or DM with enhanced user information
|
|
8
|
+
*/
|
|
9
|
+
export async function conversationsHistory(req, args) {
|
|
10
|
+
const client = getSlackClient(req);
|
|
11
|
+
const { channel_id, limit = "1d", include_activity_messages = false, include_user_details = true, cursor, } = args;
|
|
12
|
+
// Resolve channel name to ID
|
|
13
|
+
const resolvedChannelId = await client.resolveChannelId(channel_id);
|
|
14
|
+
const params = {
|
|
15
|
+
channel: resolvedChannelId,
|
|
16
|
+
include_all_metadata: include_activity_messages,
|
|
17
|
+
};
|
|
18
|
+
if (cursor) {
|
|
19
|
+
params.cursor = cursor;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// Apply limit only when cursor is not provided
|
|
23
|
+
const limitParams = parseLimit(limit);
|
|
24
|
+
if (limitParams.limit)
|
|
25
|
+
params.limit = limitParams.limit;
|
|
26
|
+
if (limitParams.oldest)
|
|
27
|
+
params.oldest = limitParams.oldest;
|
|
28
|
+
}
|
|
29
|
+
const data = await client.makeRequest("conversations.history", params);
|
|
30
|
+
const messages = data.messages || [];
|
|
31
|
+
// Enhance messages with user details if requested
|
|
32
|
+
if (include_user_details && messages.length > 0) {
|
|
33
|
+
const users = await client.getCachedUsers();
|
|
34
|
+
const userLookup = createUserLookup(users);
|
|
35
|
+
for (const message of messages) {
|
|
36
|
+
const userId = message.user;
|
|
37
|
+
if (userId && userLookup.has(userId)) {
|
|
38
|
+
const userData = userLookup.get(userId);
|
|
39
|
+
message.user_details = extractUserDetails(userData);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
success: true,
|
|
45
|
+
messages,
|
|
46
|
+
message_count: messages.length,
|
|
47
|
+
has_more: data.has_more || false,
|
|
48
|
+
next_cursor: data.response_metadata?.next_cursor,
|
|
49
|
+
channel_id: resolvedChannelId,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get thread replies for a conversation
|
|
54
|
+
*/
|
|
55
|
+
export async function conversationsReplies(req, args) {
|
|
56
|
+
const client = getSlackClient(req);
|
|
57
|
+
const { channel_id, thread_ts, limit = "1d", include_activity_messages = false, cursor, } = args;
|
|
58
|
+
// Resolve channel name to ID
|
|
59
|
+
const resolvedChannelId = await client.resolveChannelId(channel_id);
|
|
60
|
+
const params = {
|
|
61
|
+
channel: resolvedChannelId,
|
|
62
|
+
ts: thread_ts,
|
|
63
|
+
include_all_metadata: include_activity_messages,
|
|
64
|
+
};
|
|
65
|
+
if (cursor) {
|
|
66
|
+
params.cursor = cursor;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const limitParams = parseLimit(limit);
|
|
70
|
+
if (limitParams.limit)
|
|
71
|
+
params.limit = limitParams.limit;
|
|
72
|
+
if (limitParams.oldest)
|
|
73
|
+
params.oldest = limitParams.oldest;
|
|
74
|
+
}
|
|
75
|
+
const data = await client.makeRequest("conversations.replies", params);
|
|
76
|
+
return {
|
|
77
|
+
success: true,
|
|
78
|
+
messages: data.messages || [],
|
|
79
|
+
has_more: data.has_more || false,
|
|
80
|
+
next_cursor: data.response_metadata?.next_cursor,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Add a message to a channel or DM
|
|
85
|
+
*/
|
|
86
|
+
export async function conversationsAddMessage(req, args) {
|
|
87
|
+
const client = getSlackClient(req);
|
|
88
|
+
const { channel_id, payload, thread_ts, content_type = "text/markdown", } = args;
|
|
89
|
+
// Resolve channel name to ID
|
|
90
|
+
const resolvedChannelId = await client.resolveChannelId(channel_id);
|
|
91
|
+
// Convert markdown to Slack format if needed
|
|
92
|
+
const text = content_type === "text/markdown" ? markdownToSlack(payload) : payload;
|
|
93
|
+
const body = {
|
|
94
|
+
channel: resolvedChannelId,
|
|
95
|
+
text,
|
|
96
|
+
};
|
|
97
|
+
if (thread_ts) {
|
|
98
|
+
body.thread_ts = thread_ts;
|
|
99
|
+
}
|
|
100
|
+
const data = await client.postRequest("chat.postMessage", body);
|
|
101
|
+
return {
|
|
102
|
+
success: true,
|
|
103
|
+
message: data.message || {},
|
|
104
|
+
ts: data.ts,
|
|
105
|
+
channel: data.channel,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Search messages across Slack
|
|
110
|
+
*/
|
|
111
|
+
export async function conversationsSearchMessages(req, args) {
|
|
112
|
+
const client = getSlackClient(req);
|
|
113
|
+
const { search_query, filter_in_channel, filter_in_im_or_mpim, filter_users_from, filter_users_with, filter_date_before, filter_date_after, filter_date_on, filter_date_during, filter_threads_only = false, limit = 20, cursor, } = args;
|
|
114
|
+
// Check if search_query is a Slack URL
|
|
115
|
+
if (search_query) {
|
|
116
|
+
const urlParsed = parseSlackUrl(search_query);
|
|
117
|
+
if (urlParsed) {
|
|
118
|
+
// Get single message from URL
|
|
119
|
+
const data = await client.makeRequest("conversations.history", {
|
|
120
|
+
channel: urlParsed.channelId,
|
|
121
|
+
latest: urlParsed.ts,
|
|
122
|
+
oldest: urlParsed.ts,
|
|
123
|
+
inclusive: true,
|
|
124
|
+
limit: 1,
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
success: true,
|
|
128
|
+
messages: data.messages || [],
|
|
129
|
+
total: data.messages?.length || 0,
|
|
130
|
+
next_cursor: null,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Require search_query if no filters provided
|
|
135
|
+
if (!search_query &&
|
|
136
|
+
!filter_in_channel &&
|
|
137
|
+
!filter_in_im_or_mpim &&
|
|
138
|
+
!filter_users_from &&
|
|
139
|
+
!filter_users_with) {
|
|
140
|
+
throw new Error("search_query is required when no filters are provided");
|
|
141
|
+
}
|
|
142
|
+
// Build search query with filters
|
|
143
|
+
const queryParts = [];
|
|
144
|
+
if (search_query) {
|
|
145
|
+
queryParts.push(search_query);
|
|
146
|
+
}
|
|
147
|
+
if (filter_in_channel) {
|
|
148
|
+
const resolvedChannel = await client.resolveChannelId(filter_in_channel);
|
|
149
|
+
queryParts.push(`in:${resolvedChannel}`);
|
|
150
|
+
}
|
|
151
|
+
if (filter_in_im_or_mpim) {
|
|
152
|
+
const resolvedChannel = await client.resolveChannelId(filter_in_im_or_mpim);
|
|
153
|
+
queryParts.push(`in:${resolvedChannel}`);
|
|
154
|
+
}
|
|
155
|
+
if (filter_users_from) {
|
|
156
|
+
const resolvedUser = await client.resolveUserId(filter_users_from);
|
|
157
|
+
queryParts.push(`from:${resolvedUser}`);
|
|
158
|
+
}
|
|
159
|
+
if (filter_users_with) {
|
|
160
|
+
const resolvedUser = await client.resolveUserId(filter_users_with);
|
|
161
|
+
queryParts.push(`with:${resolvedUser}`);
|
|
162
|
+
}
|
|
163
|
+
if (filter_date_before) {
|
|
164
|
+
queryParts.push(`before:${filter_date_before}`);
|
|
165
|
+
}
|
|
166
|
+
if (filter_date_after) {
|
|
167
|
+
queryParts.push(`after:${filter_date_after}`);
|
|
168
|
+
}
|
|
169
|
+
if (filter_date_on) {
|
|
170
|
+
queryParts.push(`on:${filter_date_on}`);
|
|
171
|
+
}
|
|
172
|
+
if (filter_date_during) {
|
|
173
|
+
queryParts.push(`during:${filter_date_during}`);
|
|
174
|
+
}
|
|
175
|
+
if (filter_threads_only) {
|
|
176
|
+
queryParts.push("has:thread");
|
|
177
|
+
}
|
|
178
|
+
const query = queryParts.join(" ");
|
|
179
|
+
const params = {
|
|
180
|
+
query,
|
|
181
|
+
count: Math.min(Math.max(limit, 1), 100),
|
|
182
|
+
sort: "timestamp",
|
|
183
|
+
};
|
|
184
|
+
if (cursor) {
|
|
185
|
+
params.cursor = cursor;
|
|
186
|
+
}
|
|
187
|
+
const data = await client.makeRequest("search.messages", params);
|
|
188
|
+
return {
|
|
189
|
+
success: true,
|
|
190
|
+
messages: data.messages?.matches || [],
|
|
191
|
+
total: data.messages?.total || 0,
|
|
192
|
+
next_cursor: data.response_metadata?.next_cursor,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get messages from multiple channels efficiently
|
|
197
|
+
*/
|
|
198
|
+
export async function bulkConversationsHistory(req, args) {
|
|
199
|
+
const client = getSlackClient(req);
|
|
200
|
+
const { channel_ids, limit = "1d", include_user_details = true, include_activity_messages = false, filter_user, } = args;
|
|
201
|
+
// Parse channel list
|
|
202
|
+
const channelList = channel_ids.split(",").map((c) => c.trim()).filter(Boolean);
|
|
203
|
+
const results = [];
|
|
204
|
+
let totalMessages = 0;
|
|
205
|
+
let apiCalls = 0;
|
|
206
|
+
const failedChannels = [];
|
|
207
|
+
// Load user cache once for all channels (efficiency)
|
|
208
|
+
const cachedUsers = await client.getCachedUsers();
|
|
209
|
+
let usersCache = null;
|
|
210
|
+
let userNameLookup = null;
|
|
211
|
+
let filterUserId = null;
|
|
212
|
+
if (include_user_details || filter_user) {
|
|
213
|
+
usersCache = createUserLookup(cachedUsers);
|
|
214
|
+
userNameLookup = createUserNameLookup(cachedUsers);
|
|
215
|
+
// Resolve filter_user to user ID if provided
|
|
216
|
+
if (filter_user && userNameLookup) {
|
|
217
|
+
const cleanFilterUser = filter_user.startsWith("@")
|
|
218
|
+
? filter_user.slice(1)
|
|
219
|
+
: filter_user;
|
|
220
|
+
if (cleanFilterUser.startsWith("U") && cleanFilterUser.length === 11) {
|
|
221
|
+
filterUserId = cleanFilterUser;
|
|
222
|
+
}
|
|
223
|
+
else if (userNameLookup.has(cleanFilterUser)) {
|
|
224
|
+
filterUserId = userNameLookup.get(cleanFilterUser) || null;
|
|
225
|
+
}
|
|
226
|
+
else if (userNameLookup.has(cleanFilterUser.toLowerCase())) {
|
|
227
|
+
filterUserId = userNameLookup.get(cleanFilterUser.toLowerCase()) || null;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// Process each channel
|
|
232
|
+
for (const channelInput of channelList) {
|
|
233
|
+
try {
|
|
234
|
+
// Resolve channel name to ID
|
|
235
|
+
const resolvedChannelId = await client.resolveChannelId(channelInput);
|
|
236
|
+
// Prepare API parameters
|
|
237
|
+
const params = {
|
|
238
|
+
channel: resolvedChannelId,
|
|
239
|
+
include_all_metadata: include_activity_messages,
|
|
240
|
+
};
|
|
241
|
+
// Apply limit
|
|
242
|
+
const limitParams = parseLimit(limit);
|
|
243
|
+
if (limitParams.limit)
|
|
244
|
+
params.limit = limitParams.limit;
|
|
245
|
+
if (limitParams.oldest)
|
|
246
|
+
params.oldest = limitParams.oldest;
|
|
247
|
+
// Make API call
|
|
248
|
+
const data = await client.makeRequest("conversations.history", params);
|
|
249
|
+
let messages = data.messages || [];
|
|
250
|
+
apiCalls++;
|
|
251
|
+
// Filter by user if specified
|
|
252
|
+
if (filterUserId) {
|
|
253
|
+
messages = messages.filter((msg) => msg.user === filterUserId);
|
|
254
|
+
}
|
|
255
|
+
// Enhance messages with user details
|
|
256
|
+
if (include_user_details && messages.length > 0 && usersCache) {
|
|
257
|
+
for (const message of messages) {
|
|
258
|
+
const userId = message.user;
|
|
259
|
+
if (userId && usersCache.has(userId)) {
|
|
260
|
+
const userData = usersCache.get(userId);
|
|
261
|
+
message.user_details = extractUserDetails(userData);
|
|
262
|
+
}
|
|
263
|
+
// Add channel context
|
|
264
|
+
message.channel_context = {
|
|
265
|
+
channel_id: resolvedChannelId,
|
|
266
|
+
channel_input: channelInput,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
totalMessages += messages.length;
|
|
271
|
+
results.push({
|
|
272
|
+
channel_id: resolvedChannelId,
|
|
273
|
+
channel_input: channelInput,
|
|
274
|
+
messages,
|
|
275
|
+
message_count: messages.length,
|
|
276
|
+
success: true,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
failedChannels.push({
|
|
281
|
+
channel_input: channelInput,
|
|
282
|
+
error: error instanceof Error ? error.message : String(error),
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
success: true,
|
|
288
|
+
channels: results,
|
|
289
|
+
summary: {
|
|
290
|
+
total_channels: channelList.length,
|
|
291
|
+
successful_channels: results.length,
|
|
292
|
+
failed_channels: failedChannels.length,
|
|
293
|
+
total_messages: totalMessages,
|
|
294
|
+
api_calls: apiCalls,
|
|
295
|
+
filter_user: filter_user || null,
|
|
296
|
+
filter_user_id: filterUserId,
|
|
297
|
+
},
|
|
298
|
+
failed_channels: failedChannels,
|
|
299
|
+
efficiency_note: `Retrieved messages from ${results.length} channels with ${apiCalls} API calls`,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=conversations.js.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;KACjG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File tool handlers for Slack MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import type { Request } from "express";
|
|
5
|
+
import type { z } from "zod";
|
|
6
|
+
import type { FilesListSchema } from "../schemas.js";
|
|
7
|
+
/**
|
|
8
|
+
* List files in workspace, optionally filtered by channel or user
|
|
9
|
+
*/
|
|
10
|
+
export declare function filesList(req: Request, args: z.infer<typeof FilesListSchema>): Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
files: Record<string, unknown>[];
|
|
13
|
+
paging: Record<string, unknown>;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/tools/files.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;GAEG;AACH,wBAAsB,SAAS,CAC7B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC;;;;GA8BtC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File tool handlers for Slack MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import { getSlackClient } from "../slack-api-client.js";
|
|
5
|
+
/**
|
|
6
|
+
* List files in workspace, optionally filtered by channel or user
|
|
7
|
+
*/
|
|
8
|
+
export async function filesList(req, args) {
|
|
9
|
+
const client = getSlackClient(req);
|
|
10
|
+
const { channel_id, user_id, count = 10, types = "all" } = args;
|
|
11
|
+
const params = {
|
|
12
|
+
count: Math.min(count, 1000),
|
|
13
|
+
types,
|
|
14
|
+
};
|
|
15
|
+
if (channel_id) {
|
|
16
|
+
const resolvedChannelId = await client.resolveChannelId(channel_id);
|
|
17
|
+
params.channel = resolvedChannelId;
|
|
18
|
+
}
|
|
19
|
+
if (user_id) {
|
|
20
|
+
const resolvedUserId = await client.resolveUserId(user_id);
|
|
21
|
+
params.user = resolvedUserId;
|
|
22
|
+
}
|
|
23
|
+
const data = await client.makeRequest("files.list", params);
|
|
24
|
+
return {
|
|
25
|
+
success: true,
|
|
26
|
+
files: data.files || [],
|
|
27
|
+
paging: data.paging || {},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/tools/files.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,GAAY,EACZ,IAAqC;IAErC,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,GAAG,EAAE,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC;IAEhE,MAAM,MAAM,GAAoC;QAC9C,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC;QAC5B,KAAK;KACN,CAAC;IAEF,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,CAAC,OAAO,GAAG,iBAAiB,CAAC;IACrC,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,CAAC,IAAI,GAAG,cAAc,CAAC;IAC/B,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,WAAW,CAGlC,YAAY,EAAE,MAAM,CAAC,CAAC;IAEzB,OAAO;QACL,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;QACvB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool handler exports for Slack MCP Server
|
|
3
|
+
*/
|
|
4
|
+
export { conversationsHistory, conversationsReplies, conversationsAddMessage, conversationsSearchMessages, bulkConversationsHistory, } from "./conversations.js";
|
|
5
|
+
export { usersList, userInfo, userPresence } from "./users.js";
|
|
6
|
+
export { channelInfo, channelMembers, channelsList, channelsDetailed, setChannelTopic, setChannelPurpose, } from "./channels.js";
|
|
7
|
+
export { messagePermalink, addReaction } from "./messages.js";
|
|
8
|
+
export { filesList } from "./files.js";
|
|
9
|
+
export { workspaceInfo } from "./workspace.js";
|
|
10
|
+
export { initializeCache, cacheInfo, clearCache } from "./cache.js";
|
|
11
|
+
export { checkPermissions, analyticsSummary } from "./system.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/D,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGpE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool handler exports for Slack MCP Server
|
|
3
|
+
*/
|
|
4
|
+
// Conversation tools (5)
|
|
5
|
+
export { conversationsHistory, conversationsReplies, conversationsAddMessage, conversationsSearchMessages, bulkConversationsHistory, } from "./conversations.js";
|
|
6
|
+
// User tools (3)
|
|
7
|
+
export { usersList, userInfo, userPresence } from "./users.js";
|
|
8
|
+
// Channel tools (6)
|
|
9
|
+
export { channelInfo, channelMembers, channelsList, channelsDetailed, setChannelTopic, setChannelPurpose, } from "./channels.js";
|
|
10
|
+
// Message tools (2)
|
|
11
|
+
export { messagePermalink, addReaction } from "./messages.js";
|
|
12
|
+
// File tools (1)
|
|
13
|
+
export { filesList } from "./files.js";
|
|
14
|
+
// Workspace tools (1)
|
|
15
|
+
export { workspaceInfo } from "./workspace.js";
|
|
16
|
+
// Cache tools (3)
|
|
17
|
+
export { initializeCache, cacheInfo, clearCache } from "./cache.js";
|
|
18
|
+
// System tools (2)
|
|
19
|
+
export { checkPermissions, analyticsSummary } from "./system.js";
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,yBAAyB;AACzB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,iBAAiB;AACjB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/D,oBAAoB;AACpB,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,oBAAoB;AACpB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE9D,iBAAiB;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,sBAAsB;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,kBAAkB;AAClB,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpE,mBAAmB;AACnB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message tool handlers for Slack MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import type { Request } from "express";
|
|
5
|
+
import type { z } from "zod";
|
|
6
|
+
import type { MessagePermalinkSchema, AddReactionSchema } from "../schemas.js";
|
|
7
|
+
/**
|
|
8
|
+
* Get a permanent link to a specific message
|
|
9
|
+
*/
|
|
10
|
+
export declare function messagePermalink(req: Request, args: z.infer<typeof MessagePermalinkSchema>): Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
permalink: string;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Add an emoji reaction to a message
|
|
16
|
+
*/
|
|
17
|
+
export declare function addReaction(req: Request, args: z.infer<typeof AddReactionSchema>): Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/tools/messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EACV,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC;;;GAoB7C;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC;;GAkBxC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message tool handlers for Slack MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import { getSlackClient } from "../slack-api-client.js";
|
|
5
|
+
/**
|
|
6
|
+
* Get a permanent link to a specific message
|
|
7
|
+
*/
|
|
8
|
+
export async function messagePermalink(req, args) {
|
|
9
|
+
const client = getSlackClient(req);
|
|
10
|
+
const { channel_id, message_ts } = args;
|
|
11
|
+
// Resolve channel name to ID
|
|
12
|
+
const resolvedChannelId = await client.resolveChannelId(channel_id);
|
|
13
|
+
const data = await client.makeRequest("chat.getPermalink", {
|
|
14
|
+
channel: resolvedChannelId,
|
|
15
|
+
message_ts,
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
success: true,
|
|
19
|
+
permalink: data.permalink,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Add an emoji reaction to a message
|
|
24
|
+
*/
|
|
25
|
+
export async function addReaction(req, args) {
|
|
26
|
+
const client = getSlackClient(req);
|
|
27
|
+
const { channel_id, message_ts, emoji_name } = args;
|
|
28
|
+
// Resolve channel name to ID
|
|
29
|
+
const resolvedChannelId = await client.resolveChannelId(channel_id);
|
|
30
|
+
// Note: reactions.add uses POST with different params
|
|
31
|
+
await client.postRequest("reactions.add", {
|
|
32
|
+
channel: resolvedChannelId,
|
|
33
|
+
timestamp: message_ts,
|
|
34
|
+
name: emoji_name,
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
success: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/tools/messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAMxD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAY,EACZ,IAA4C;IAE5C,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAExC,6BAA6B;IAC7B,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAEpE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,WAAW,CACnC,mBAAmB,EACnB;QACE,OAAO,EAAE,iBAAiB;QAC1B,UAAU;KACX,CACF,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAY,EACZ,IAAuC;IAEvC,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAEpD,6BAA6B;IAC7B,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAEpE,sDAAsD;IACtD,MAAM,MAAM,CAAC,WAAW,CAAC,eAAe,EAAE;QACxC,OAAO,EAAE,iBAAiB;QAC1B,SAAS,EAAE,UAAU;QACrB,IAAI,EAAE,UAAU;KACjB,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System tool handlers for Slack MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import type { Request } from "express";
|
|
5
|
+
import type { z } from "zod";
|
|
6
|
+
import type { CheckPermissionsSchema, AnalyticsSummarySchema } from "../schemas.js";
|
|
7
|
+
/**
|
|
8
|
+
* Check what Slack API permissions/scopes are available with current token
|
|
9
|
+
*/
|
|
10
|
+
export declare function checkPermissions(req: Request, _args: z.infer<typeof CheckPermissionsSchema>): Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
permissions: Record<string, {
|
|
13
|
+
endpoint: string;
|
|
14
|
+
status: string;
|
|
15
|
+
}>;
|
|
16
|
+
summary: {
|
|
17
|
+
available_scopes: number;
|
|
18
|
+
failed_scopes: number;
|
|
19
|
+
total_tested: number;
|
|
20
|
+
};
|
|
21
|
+
recommendations: {
|
|
22
|
+
cache_creation: string;
|
|
23
|
+
name_resolution: string;
|
|
24
|
+
messaging: string;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Get workspace analytics summary using cached data
|
|
29
|
+
*/
|
|
30
|
+
export declare function analyticsSummary(req: Request, args: z.infer<typeof AnalyticsSummarySchema>): Promise<{
|
|
31
|
+
success: boolean;
|
|
32
|
+
date_range: string;
|
|
33
|
+
user_stats: {
|
|
34
|
+
total_users: number;
|
|
35
|
+
active_users: number;
|
|
36
|
+
bot_users: number;
|
|
37
|
+
admin_users: number;
|
|
38
|
+
};
|
|
39
|
+
channel_stats: {
|
|
40
|
+
public_channels: number;
|
|
41
|
+
private_channels: number;
|
|
42
|
+
dm_channels: number;
|
|
43
|
+
group_dm_channels: number;
|
|
44
|
+
total_channels: number;
|
|
45
|
+
};
|
|
46
|
+
note: string;
|
|
47
|
+
}>;
|
|
48
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/tools/system.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC;;;kBAO/B,MAAM;gBAAU,MAAM;;;;;;;;;;;;GAsFrC;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC;;;;;;;;;;;;;;;;;GA0C7C"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System tool handlers for Slack MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import { getSlackClient } from "../slack-api-client.js";
|
|
5
|
+
/**
|
|
6
|
+
* Check what Slack API permissions/scopes are available with current token
|
|
7
|
+
*/
|
|
8
|
+
export async function checkPermissions(req, _args) {
|
|
9
|
+
const client = getSlackClient(req);
|
|
10
|
+
// Test various endpoints to see what works
|
|
11
|
+
const permissions = {
|
|
12
|
+
"users:read": { endpoint: "users.list", status: "unknown" },
|
|
13
|
+
"channels:read": {
|
|
14
|
+
endpoint: "conversations.list (public_channel)",
|
|
15
|
+
status: "unknown",
|
|
16
|
+
},
|
|
17
|
+
"groups:read": {
|
|
18
|
+
endpoint: "conversations.list (private_channel)",
|
|
19
|
+
status: "unknown",
|
|
20
|
+
},
|
|
21
|
+
"im:read": { endpoint: "conversations.list (im)", status: "unknown" },
|
|
22
|
+
"mpim:read": { endpoint: "conversations.list (mpim)", status: "unknown" },
|
|
23
|
+
"team:read": { endpoint: "team.info", status: "unknown" },
|
|
24
|
+
"channels:history": {
|
|
25
|
+
endpoint: "conversations.history",
|
|
26
|
+
status: "unknown",
|
|
27
|
+
},
|
|
28
|
+
"chat:write": { endpoint: "chat.postMessage", status: "unknown" },
|
|
29
|
+
};
|
|
30
|
+
// Test users.list
|
|
31
|
+
try {
|
|
32
|
+
await client.makeRequest("users.list", { limit: 1 });
|
|
33
|
+
permissions["users:read"].status = "Available";
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
permissions["users:read"].status = `Failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
37
|
+
}
|
|
38
|
+
// Test different conversation types
|
|
39
|
+
const conversationTests = [
|
|
40
|
+
["channels:read", "public_channel"],
|
|
41
|
+
["groups:read", "private_channel"],
|
|
42
|
+
["im:read", "im"],
|
|
43
|
+
["mpim:read", "mpim"],
|
|
44
|
+
];
|
|
45
|
+
for (const [scope, channelType] of conversationTests) {
|
|
46
|
+
try {
|
|
47
|
+
await client.makeRequest("conversations.list", {
|
|
48
|
+
types: channelType,
|
|
49
|
+
limit: 1,
|
|
50
|
+
});
|
|
51
|
+
permissions[scope].status = "Available";
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
permissions[scope].status = `Failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Test team.info
|
|
58
|
+
try {
|
|
59
|
+
await client.makeRequest("team.info");
|
|
60
|
+
permissions["team:read"].status = "Available";
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
permissions["team:read"].status = `Failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
64
|
+
}
|
|
65
|
+
// Count available vs failed
|
|
66
|
+
const available = Object.values(permissions).filter((p) => p.status === "Available").length;
|
|
67
|
+
const failed = Object.values(permissions).filter((p) => p.status.startsWith("Failed")).length;
|
|
68
|
+
return {
|
|
69
|
+
success: true,
|
|
70
|
+
permissions,
|
|
71
|
+
summary: {
|
|
72
|
+
available_scopes: available,
|
|
73
|
+
failed_scopes: failed,
|
|
74
|
+
total_tested: Object.keys(permissions).length,
|
|
75
|
+
},
|
|
76
|
+
recommendations: {
|
|
77
|
+
cache_creation: available > 0 ? "Possible" : "Needs permissions",
|
|
78
|
+
name_resolution: permissions["channels:read"].status === "Available"
|
|
79
|
+
? "Possible"
|
|
80
|
+
: "Needs channels:read",
|
|
81
|
+
messaging: permissions["channels:history"].status === "Available"
|
|
82
|
+
? "Possible"
|
|
83
|
+
: "Limited (needs channels:history)",
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get workspace analytics summary using cached data
|
|
89
|
+
*/
|
|
90
|
+
export async function analyticsSummary(req, args) {
|
|
91
|
+
const client = getSlackClient(req);
|
|
92
|
+
const { date_range = "30d" } = args;
|
|
93
|
+
// Get cached data for analysis
|
|
94
|
+
const users = await client.getCachedUsers();
|
|
95
|
+
const channels = await client.getCachedChannels();
|
|
96
|
+
// Basic analytics from cached data
|
|
97
|
+
const totalUsers = users.filter((u) => !u.deleted).length;
|
|
98
|
+
const activeUsers = users.filter((u) => !u.deleted && !u.is_bot).length;
|
|
99
|
+
const botUsers = users.filter((u) => u.is_bot).length;
|
|
100
|
+
const adminUsers = users.filter((u) => u.is_admin).length;
|
|
101
|
+
const publicChannels = channels.filter((c) => !c.is_private && !c.is_im && !c.is_mpim).length;
|
|
102
|
+
const privateChannels = channels.filter((c) => c.is_private && !c.is_im && !c.is_mpim).length;
|
|
103
|
+
const dmChannels = channels.filter((c) => c.is_im).length;
|
|
104
|
+
const groupDmChannels = channels.filter((c) => c.is_mpim).length;
|
|
105
|
+
return {
|
|
106
|
+
success: true,
|
|
107
|
+
date_range,
|
|
108
|
+
user_stats: {
|
|
109
|
+
total_users: totalUsers,
|
|
110
|
+
active_users: activeUsers,
|
|
111
|
+
bot_users: botUsers,
|
|
112
|
+
admin_users: adminUsers,
|
|
113
|
+
},
|
|
114
|
+
channel_stats: {
|
|
115
|
+
public_channels: publicChannels,
|
|
116
|
+
private_channels: privateChannels,
|
|
117
|
+
dm_channels: dmChannels,
|
|
118
|
+
group_dm_channels: groupDmChannels,
|
|
119
|
+
total_channels: channels.length,
|
|
120
|
+
},
|
|
121
|
+
note: "Basic analytics from cached data. For detailed activity metrics, use conversations_search_messages with date filters.",
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=system.js.map
|