file-share-mcp 1.0.8 → 1.0.11
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 +20 -10
- package/dist/mcp-server.js +15 -2
- package/dist/utils/config-manager.js +3 -4
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/gui.js
CHANGED
|
@@ -202,17 +202,24 @@ app.get(/^(?!\/api\/|\/proxy\/)/, (req, res) => {
|
|
|
202
202
|
}
|
|
203
203
|
});
|
|
204
204
|
// Proxy registration & server startup
|
|
205
|
+
if (!process.env.PROXY_URL) {
|
|
206
|
+
process.stderr.write('[GUI] PROXY_URL non défini — arrêt.\n');
|
|
207
|
+
process.exit(0);
|
|
208
|
+
}
|
|
205
209
|
const config = getConfig();
|
|
206
|
-
const proxyClient =
|
|
210
|
+
const proxyClient = new ProxyClient(process.env.PROXY_URL);
|
|
207
211
|
let server;
|
|
208
212
|
async function startServer() {
|
|
209
|
-
|
|
210
|
-
if (
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
const result = await proxyClient.register({ path: config.PROXY_APP_PATH, name: config.PROXY_APP_NAME });
|
|
214
|
+
if (!result.success) {
|
|
215
|
+
process.stderr.write('[GUI] Enregistrement proxy échoué — arrêt.\n');
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
const port = result.port;
|
|
219
|
+
// Signal the master that the GUI is registered and reachable, so
|
|
220
|
+
// reconnect_gui resolves immediately instead of waiting for the timeout.
|
|
221
|
+
if (process.send && process.connected) {
|
|
222
|
+
process.send({ type: 'READY', data: { url: result.url } });
|
|
216
223
|
}
|
|
217
224
|
server = app.listen(port, () => {
|
|
218
225
|
logger.info(`GUI API server listening on port ${port}`);
|
|
@@ -220,6 +227,9 @@ async function startServer() {
|
|
|
220
227
|
server.on('error', (err) => {
|
|
221
228
|
if (err.code === 'EADDRINUSE') {
|
|
222
229
|
logger.error(`PORT CONFLICT: Port ${port} is already in use. Another GUI instance is running.`);
|
|
230
|
+
if (process.send && process.connected) {
|
|
231
|
+
process.send({ type: 'ALREADY_RUNNING', data: { url: result.url } });
|
|
232
|
+
}
|
|
223
233
|
process.exit(0);
|
|
224
234
|
}
|
|
225
235
|
});
|
|
@@ -230,7 +240,7 @@ process.on('message', async (msg) => {
|
|
|
230
240
|
const type = typeof msg === 'string' ? msg : msg?.type;
|
|
231
241
|
if (type === 'STOP') {
|
|
232
242
|
logger.info('GUI received STOP signal');
|
|
233
|
-
await proxyClient
|
|
243
|
+
await proxyClient.unregister();
|
|
234
244
|
server?.close(() => process.exit(0));
|
|
235
245
|
}
|
|
236
246
|
});
|
|
@@ -246,6 +256,6 @@ process.on('disconnect', () => {
|
|
|
246
256
|
process.exit(0);
|
|
247
257
|
});
|
|
248
258
|
process.on('SIGTERM', async () => {
|
|
249
|
-
await proxyClient
|
|
259
|
+
await proxyClient.unregister();
|
|
250
260
|
process.exit(0);
|
|
251
261
|
});
|
package/dist/mcp-server.js
CHANGED
|
@@ -6,7 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import fs from 'fs';
|
|
9
|
-
import { GuiLauncher, setupLogging, createLogger } from '@imenam/mcp-gui-interface';
|
|
9
|
+
import { GuiLauncher, setupLogging, createLogger, reconnectGuiToolDefinition } from '@imenam/mcp-gui-interface';
|
|
10
10
|
import { getConfig } from './utils/config-manager.js';
|
|
11
11
|
import { getSharedFiles, validateSafePath, writeSharedFile, copyToSharedFolder, createDirectory, deleteDirectory, moveFile, } from './utils/file-manager.js';
|
|
12
12
|
import { VERSION } from './version.js';
|
|
@@ -24,6 +24,7 @@ const server = new Server({
|
|
|
24
24
|
});
|
|
25
25
|
const gui = new GuiLauncher({
|
|
26
26
|
guiPath: path.join(__dirname, 'gui.js'),
|
|
27
|
+
reloadEnv: () => { getConfig(); },
|
|
27
28
|
onMessage: (msg) => {
|
|
28
29
|
if (msg.type === 'RESTART') {
|
|
29
30
|
logger.info('GUI requested restart...');
|
|
@@ -178,6 +179,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
178
179
|
required: ['from', 'to'],
|
|
179
180
|
},
|
|
180
181
|
},
|
|
182
|
+
reconnectGuiToolDefinition(),
|
|
181
183
|
],
|
|
182
184
|
};
|
|
183
185
|
});
|
|
@@ -285,6 +287,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
285
287
|
content: [{ type: 'text', text: `File moved from "${from}" to "${to}".` }],
|
|
286
288
|
};
|
|
287
289
|
}
|
|
290
|
+
case 'reconnect_gui': {
|
|
291
|
+
const res = await gui.handleReconnectTool(args);
|
|
292
|
+
return res.isError
|
|
293
|
+
? { content: res.content, isError: true }
|
|
294
|
+
: { content: res.content };
|
|
295
|
+
}
|
|
288
296
|
default:
|
|
289
297
|
throw new Error(`Tool not found: ${name}`);
|
|
290
298
|
}
|
|
@@ -300,7 +308,12 @@ async function main() {
|
|
|
300
308
|
const transport = new StdioServerTransport();
|
|
301
309
|
await server.connect(transport);
|
|
302
310
|
logger.info('File Share MCP Server started');
|
|
303
|
-
|
|
311
|
+
if (!process.env.PROXY_URL) {
|
|
312
|
+
logger.info('[MASTER] PROXY_URL non défini — GUI désactivée.');
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
gui.start();
|
|
316
|
+
}
|
|
304
317
|
}
|
|
305
318
|
main().catch((error) => {
|
|
306
319
|
console.error('Fatal error in main():', error);
|
|
@@ -9,15 +9,15 @@ const rootDir = path.resolve(__dirname, '../../');
|
|
|
9
9
|
const envPath = path.join(rootDir, '.env');
|
|
10
10
|
// User-level base dir that survives package updates
|
|
11
11
|
const USER_BASE_DIR = path.join(os.homedir(), '.file-share-mcp');
|
|
12
|
-
const DEFAULT_CONFIG = {
|
|
13
|
-
shared_folder_path: path.join(USER_BASE_DIR, 'shared'),
|
|
14
|
-
};
|
|
15
12
|
export function getConfig() {
|
|
16
13
|
dotenv.config({ path: envPath, override: true });
|
|
17
14
|
const dataDirEnv = process.env.MCP_DATA_DIR;
|
|
18
15
|
const dataDir = dataDirEnv
|
|
19
16
|
? (path.isAbsolute(dataDirEnv) ? dataDirEnv : path.resolve(rootDir, dataDirEnv))
|
|
20
17
|
: USER_BASE_DIR;
|
|
18
|
+
const DEFAULT_CONFIG = {
|
|
19
|
+
shared_folder_path: path.join(dataDir, 'shared'),
|
|
20
|
+
};
|
|
21
21
|
if (!fs.existsSync(dataDir)) {
|
|
22
22
|
fs.mkdirSync(dataDir, { recursive: true });
|
|
23
23
|
}
|
|
@@ -37,7 +37,6 @@ export function getConfig() {
|
|
|
37
37
|
}
|
|
38
38
|
return {
|
|
39
39
|
...currentConfig,
|
|
40
|
-
GUI_PORT: parseInt(process.env.GUI_PORT || '3005', 10),
|
|
41
40
|
PROXY_URL: process.env.PROXY_URL,
|
|
42
41
|
PROXY_APP_PATH: process.env.PROXY_APP_PATH || '/file-share',
|
|
43
42
|
PROXY_APP_NAME: process.env.PROXY_APP_NAME || 'File Share MCP',
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.0.
|
|
1
|
+
export const VERSION = '1.0.11';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "file-share-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
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",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@imenam/mcp-gui-interface": "
|
|
40
|
+
"@imenam/mcp-gui-interface": "^1.0.10",
|
|
41
41
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
42
42
|
"axios": "^1.13.5",
|
|
43
43
|
"cors": "^2.8.6",
|