@jtalk22/slack-mcp 1.1.5 → 1.1.6
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/lib/handlers.js +14 -5
- package/package.json +1 -1
- package/src/web-server.js +16 -3
package/lib/handlers.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Implementation of all MCP tool handlers.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { writeFileSync, readFileSync, existsSync, renameSync, unlinkSync } from "fs";
|
|
7
|
+
import { writeFileSync, readFileSync, existsSync, renameSync, unlinkSync, mkdirSync } from "fs";
|
|
8
8
|
import { homedir, platform } from "os";
|
|
9
9
|
import { join } from "path";
|
|
10
10
|
import { loadTokens, saveTokens, extractFromChrome, isAutoRefreshAvailable } from "./token-store.js";
|
|
@@ -404,11 +404,20 @@ export async function handleGetFullConversation(args) {
|
|
|
404
404
|
messages: allMessages
|
|
405
405
|
};
|
|
406
406
|
|
|
407
|
-
// Save to file if requested
|
|
407
|
+
// Save to file if requested (restricted to ~/.slack-mcp-exports/ for security)
|
|
408
408
|
if (args.output_file) {
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
|
|
409
|
+
const exportDir = join(homedir(), '.slack-mcp-exports');
|
|
410
|
+
// Ensure export directory exists
|
|
411
|
+
try { mkdirSync(exportDir, { recursive: true }); } catch {}
|
|
412
|
+
|
|
413
|
+
// Sanitize filename - remove any path traversal attempts
|
|
414
|
+
const sanitizedName = args.output_file
|
|
415
|
+
.replace(/^.*[\\\/]/, '') // Remove any path components
|
|
416
|
+
.replace(/\.\./g, '') // Remove .. sequences
|
|
417
|
+
.replace(/[<>:"|?*]/g, '') // Remove invalid chars
|
|
418
|
+
|| 'export.json';
|
|
419
|
+
|
|
420
|
+
const outputPath = join(exportDir, sanitizedName);
|
|
412
421
|
writeFileSync(outputPath, JSON.stringify(output, null, 2));
|
|
413
422
|
output.saved_to = outputPath;
|
|
414
423
|
}
|
package/package.json
CHANGED
package/src/web-server.js
CHANGED
|
@@ -67,9 +67,20 @@ const API_KEY = getOrCreateAPIKey();
|
|
|
67
67
|
app.use(express.json());
|
|
68
68
|
app.use(express.static(join(__dirname, "../public")));
|
|
69
69
|
|
|
70
|
-
// CORS for
|
|
70
|
+
// CORS - restricted to localhost for security
|
|
71
|
+
// Using * would allow any website to make requests to your local server
|
|
72
|
+
const ALLOWED_ORIGINS = [
|
|
73
|
+
`http://localhost:${PORT}`,
|
|
74
|
+
`http://127.0.0.1:${PORT}`,
|
|
75
|
+
'http://localhost:3000',
|
|
76
|
+
'http://127.0.0.1:3000'
|
|
77
|
+
];
|
|
78
|
+
|
|
71
79
|
app.use((req, res, next) => {
|
|
72
|
-
|
|
80
|
+
const origin = req.headers.origin;
|
|
81
|
+
if (ALLOWED_ORIGINS.includes(origin)) {
|
|
82
|
+
res.header("Access-Control-Allow-Origin", origin);
|
|
83
|
+
}
|
|
73
84
|
res.header("Access-Control-Allow-Headers", "Content-Type, Authorization");
|
|
74
85
|
res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
|
75
86
|
if (req.method === "OPTIONS") {
|
|
@@ -280,7 +291,8 @@ async function main() {
|
|
|
280
291
|
console.log(`Credentials loaded from: ${credentials.source}`);
|
|
281
292
|
}
|
|
282
293
|
|
|
283
|
-
|
|
294
|
+
// Bind to localhost only - prevents access from other devices on the network
|
|
295
|
+
app.listen(PORT, '127.0.0.1', () => {
|
|
284
296
|
// Print to stderr to keep logs clean (stdout reserved for JSON in some setups)
|
|
285
297
|
console.error(`\n${"═".repeat(60)}`);
|
|
286
298
|
console.error(` Slack Web API Server v1.1.0`);
|
|
@@ -288,6 +300,7 @@ async function main() {
|
|
|
288
300
|
console.error(`\n Dashboard: http://localhost:${PORT}/?key=${API_KEY}`);
|
|
289
301
|
console.error(`\n API Key: ${API_KEY}`);
|
|
290
302
|
console.error(`\n curl -H "Authorization: Bearer ${API_KEY}" http://localhost:${PORT}/health`);
|
|
303
|
+
console.error(`\n Security: Bound to localhost only (127.0.0.1)`);
|
|
291
304
|
console.error(`\n${"═".repeat(60)}\n`);
|
|
292
305
|
});
|
|
293
306
|
}
|