file-share-mcp 1.0.5 → 1.0.7

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/dist/gui.js CHANGED
@@ -31,22 +31,35 @@ app.get('/api/files', (req, res) => {
31
31
  }
32
32
  });
33
33
  app.get('/api/download', async (req, res) => {
34
+ const relativePath = req.query.path || '';
34
35
  try {
35
- const relativePath = req.query.path || '';
36
36
  const safePath = validateSafePath(relativePath);
37
- if (fs.existsSync(safePath) && fs.statSync(safePath).isFile()) {
38
- res.download(safePath, path.basename(safePath), (err) => {
39
- if (err && !res.headersSent) {
40
- res.status(500).send('Download failed');
41
- }
42
- });
43
- }
44
- else {
45
- res.status(404).send('File not found');
37
+ console.log(`[download] path="${relativePath}" → safePath="${safePath}"`);
38
+ if (!fs.existsSync(safePath) || !fs.statSync(safePath).isFile()) {
39
+ console.log(`[download] Not found or not a file: "${safePath}"`);
40
+ res.status(404).send(`File not found: ${relativePath}`);
41
+ return;
46
42
  }
43
+ const filename = path.basename(safePath);
44
+ const { size } = fs.statSync(safePath);
45
+ res.setHeader('Content-Disposition', `attachment; filename="${encodeURIComponent(filename)}"`);
46
+ res.setHeader('Content-Type', 'application/octet-stream');
47
+ res.setHeader('Content-Length', size);
48
+ const stream = fs.createReadStream(safePath);
49
+ stream.on('error', (err) => {
50
+ console.error(`[download] Stream error for "${safePath}": ${err.message}`);
51
+ if (!res.headersSent) {
52
+ res.status(500).send(`Stream error: ${err.message}`);
53
+ }
54
+ });
55
+ stream.on('end', () => {
56
+ console.log(`[download] Completed: "${safePath}"`);
57
+ });
58
+ stream.pipe(res);
47
59
  }
48
60
  catch (error) {
49
- res.status(400).send(error.message);
61
+ console.error(`[download] Validation error for "${relativePath}": ${error.message}`);
62
+ res.status(400).send(`Invalid path: ${error.message}`);
50
63
  }
51
64
  });
52
65
  app.delete('/api/files', (req, res) => {
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.0.5';
1
+ export const VERSION = '1.0.7';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-share-mcp",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "MCP server for bidirectional file sharing between AI agents and users, with a built-in web GUI",
5
5
  "author": "",
6
6
  "license": "ISC",