@jtalk22/slack-mcp 1.1.9 → 1.2.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/src/cli.js ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * slack-mcp package entrypoint dispatcher.
4
+ *
5
+ * Supports:
6
+ * - default stdio server startup
7
+ * - web/http server modes
8
+ * - setup wizard and its status/help/version flags
9
+ */
10
+
11
+ import { spawn } from "node:child_process";
12
+ import { dirname, join } from "node:path";
13
+ import { fileURLToPath } from "node:url";
14
+
15
+ const __dirname = dirname(fileURLToPath(import.meta.url));
16
+
17
+ const args = process.argv.slice(2);
18
+ const firstArg = args[0];
19
+
20
+ const WIZARD_ARGS = new Set([
21
+ "--setup", "setup",
22
+ "--status", "status",
23
+ "--version", "-v",
24
+ "--help", "-h", "help",
25
+ ]);
26
+
27
+ let scriptPath = join(__dirname, "server.js");
28
+ let scriptArgs = args;
29
+
30
+ if (firstArg === "web") {
31
+ scriptPath = join(__dirname, "web-server.js");
32
+ scriptArgs = args.slice(1);
33
+ } else if (firstArg === "http") {
34
+ scriptPath = join(__dirname, "server-http.js");
35
+ scriptArgs = args.slice(1);
36
+ } else if (WIZARD_ARGS.has(firstArg)) {
37
+ scriptPath = join(__dirname, "../scripts/setup-wizard.js");
38
+ scriptArgs = args;
39
+ }
40
+
41
+ const child = spawn(process.execPath, [scriptPath, ...scriptArgs], {
42
+ stdio: "inherit",
43
+ env: process.env,
44
+ });
45
+
46
+ child.on("error", (error) => {
47
+ console.error(`Failed to start ${scriptPath}: ${error.message}`);
48
+ process.exit(1);
49
+ });
50
+
51
+ child.on("exit", (code, signal) => {
52
+ if (signal) {
53
+ process.kill(process.pid, signal);
54
+ return;
55
+ }
56
+ process.exit(code ?? 0);
57
+ });
@@ -30,7 +30,7 @@ import {
30
30
  } from "../lib/handlers.js";
31
31
 
32
32
  const SERVER_NAME = "slack-mcp-server";
33
- const SERVER_VERSION = "1.1.8";
33
+ const SERVER_VERSION = "1.2.1";
34
34
  const PORT = process.env.PORT || 3000;
35
35
 
36
36
  // Create MCP server
package/src/server.js CHANGED
@@ -11,7 +11,7 @@
11
11
  * - Network error retry with exponential backoff
12
12
  * - Background token health monitoring
13
13
  *
14
- * @version 1.1.7
14
+ * @version 1.2.1
15
15
  */
16
16
 
17
17
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -19,6 +19,10 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
19
19
  import {
20
20
  CallToolRequestSchema,
21
21
  ListToolsRequestSchema,
22
+ ListPromptsRequestSchema,
23
+ GetPromptRequestSchema,
24
+ ListResourcesRequestSchema,
25
+ ReadResourceRequestSchema,
22
26
  } from "@modelcontextprotocol/sdk/types.js";
23
27
 
24
28
  import { loadTokens } from "../lib/token-store.js";
@@ -43,12 +47,70 @@ const BACKGROUND_REFRESH_INTERVAL = 4 * 60 * 60 * 1000;
43
47
 
44
48
  // Package info
45
49
  const SERVER_NAME = "slack-mcp-server";
46
- const SERVER_VERSION = "1.1.7";
50
+ const SERVER_VERSION = "1.2.1";
51
+
52
+ // MCP Prompts - predefined prompt templates for common Slack operations
53
+ const PROMPTS = [
54
+ {
55
+ name: "search-recent",
56
+ description: "Search workspace for messages from the past week",
57
+ arguments: [
58
+ {
59
+ name: "query",
60
+ description: "Search terms to look for",
61
+ required: true
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ name: "summarize-channel",
67
+ description: "Get recent activity from a channel for summarization",
68
+ arguments: [
69
+ {
70
+ name: "channel_id",
71
+ description: "Channel ID to summarize",
72
+ required: true
73
+ },
74
+ {
75
+ name: "days",
76
+ description: "Number of days to look back (default 7)",
77
+ required: false
78
+ }
79
+ ]
80
+ },
81
+ {
82
+ name: "find-messages-from",
83
+ description: "Find all messages from a specific user",
84
+ arguments: [
85
+ {
86
+ name: "username",
87
+ description: "Username or display name to search for",
88
+ required: true
89
+ }
90
+ ]
91
+ }
92
+ ];
93
+
94
+ // MCP Resources - data sources the server provides
95
+ const RESOURCES = [
96
+ {
97
+ uri: "slack://workspace/info",
98
+ name: "Workspace Info",
99
+ description: "Current workspace name, team, and authenticated user",
100
+ mimeType: "application/json"
101
+ },
102
+ {
103
+ uri: "slack://conversations/list",
104
+ name: "Conversations",
105
+ description: "List of available channels and DMs",
106
+ mimeType: "application/json"
107
+ }
108
+ ];
47
109
 
48
110
  // Initialize server
49
111
  const server = new Server(
50
112
  { name: SERVER_NAME, version: SERVER_VERSION },
51
- { capabilities: { tools: {} } }
113
+ { capabilities: { tools: {}, prompts: {}, resources: {} } }
52
114
  );
53
115
 
54
116
  // Register tool list handler
@@ -56,6 +118,103 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
56
118
  tools: TOOLS
57
119
  }));
58
120
 
121
+ // Register prompts handlers
122
+ server.setRequestHandler(ListPromptsRequestSchema, async () => ({
123
+ prompts: PROMPTS
124
+ }));
125
+
126
+ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
127
+ const { name, arguments: args } = request.params;
128
+
129
+ switch (name) {
130
+ case "search-recent": {
131
+ const query = args?.query || "";
132
+ const oneWeekAgo = Math.floor(Date.now() / 1000) - (7 * 24 * 60 * 60);
133
+ return {
134
+ messages: [
135
+ {
136
+ role: "user",
137
+ content: {
138
+ type: "text",
139
+ text: `Search Slack for "${query}" from the past week. Use the slack_search_messages tool with query: "${query} after:${new Date(oneWeekAgo * 1000).toISOString().split('T')[0]}"`
140
+ }
141
+ }
142
+ ]
143
+ };
144
+ }
145
+ case "summarize-channel": {
146
+ const channelId = args?.channel_id || "";
147
+ const days = parseInt(args?.days) || 7;
148
+ const since = Math.floor(Date.now() / 1000) - (days * 24 * 60 * 60);
149
+ return {
150
+ messages: [
151
+ {
152
+ role: "user",
153
+ content: {
154
+ type: "text",
155
+ text: `Get the last ${days} days of messages from channel ${channelId} and provide a summary. Use slack_conversations_history with channel_id: "${channelId}" and oldest: "${since}"`
156
+ }
157
+ }
158
+ ]
159
+ };
160
+ }
161
+ case "find-messages-from": {
162
+ const username = args?.username || "";
163
+ return {
164
+ messages: [
165
+ {
166
+ role: "user",
167
+ content: {
168
+ type: "text",
169
+ text: `Find messages from ${username}. Use slack_search_messages with query: "from:@${username}"`
170
+ }
171
+ }
172
+ ]
173
+ };
174
+ }
175
+ default:
176
+ throw new Error(`Unknown prompt: ${name}`);
177
+ }
178
+ });
179
+
180
+ // Register resources handlers
181
+ server.setRequestHandler(ListResourcesRequestSchema, async () => ({
182
+ resources: RESOURCES
183
+ }));
184
+
185
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
186
+ const { uri } = request.params;
187
+
188
+ switch (uri) {
189
+ case "slack://workspace/info": {
190
+ const result = await handleHealthCheck();
191
+ return {
192
+ contents: [
193
+ {
194
+ uri,
195
+ mimeType: "application/json",
196
+ text: result.content[0].text
197
+ }
198
+ ]
199
+ };
200
+ }
201
+ case "slack://conversations/list": {
202
+ const result = await handleListConversations({ types: "im,mpim,public_channel,private_channel", limit: 50 });
203
+ return {
204
+ contents: [
205
+ {
206
+ uri,
207
+ mimeType: "application/json",
208
+ text: result.content[0].text
209
+ }
210
+ ]
211
+ };
212
+ }
213
+ default:
214
+ throw new Error(`Unknown resource: ${uri}`);
215
+ }
216
+ });
217
+
59
218
  // Register tool call handler
60
219
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
61
220
  const { name, arguments: args } = request.params;
@@ -149,3 +308,11 @@ main().catch(error => {
149
308
  console.error("Fatal error:", error);
150
309
  process.exit(1);
151
310
  });
311
+
312
+ /**
313
+ * Smithery sandbox server for capability scanning
314
+ * Returns a server instance with mock config for tool discovery
315
+ */
316
+ export function createSandboxServer() {
317
+ return server;
318
+ }
package/src/web-server.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Exposes Slack MCP tools as REST endpoints for browser access.
6
6
  * Run alongside or instead of the MCP server for web-based access.
7
7
  *
8
- * @version 1.1.7
8
+ * @version 1.2.1
9
9
  */
10
10
 
11
11
  import express from "express";
@@ -116,7 +116,7 @@ function extractContent(result) {
116
116
  app.get("/", (req, res) => {
117
117
  res.json({
118
118
  name: "Slack Web API Server",
119
- version: "1.0.0",
119
+ version: "1.2.1",
120
120
  status: "running",
121
121
  endpoints: [
122
122
  "GET /health",
@@ -295,7 +295,7 @@ async function main() {
295
295
  app.listen(PORT, '127.0.0.1', () => {
296
296
  // Print to stderr to keep logs clean (stdout reserved for JSON in some setups)
297
297
  console.error(`\n${"═".repeat(60)}`);
298
- console.error(` Slack Web API Server v1.1.7`);
298
+ console.error(` Slack Web API Server v1.2.1`);
299
299
  console.error(`${"═".repeat(60)}`);
300
300
  console.error(`\n Dashboard: http://localhost:${PORT}/?key=${API_KEY}`);
301
301
  console.error(`\n API Key: ${API_KEY}`);