@mcp-shark/mcp-shark 1.5.6 → 1.5.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.
|
@@ -36,13 +36,10 @@ export class ServerManagementService {
|
|
|
36
36
|
|
|
37
37
|
// If filePath is provided, restore original config if already patched
|
|
38
38
|
// This ensures processSetup reads the original config, not the patched one
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
restoreWarning = restoreResult.warning;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
39
|
+
const restoreWarning =
|
|
40
|
+
filePath && !fileContent
|
|
41
|
+
? this.configPatchingService.restoreIfPatched(filePath).warning || null
|
|
42
|
+
: null;
|
|
46
43
|
|
|
47
44
|
// Process setup
|
|
48
45
|
const setupResult = this.configService.processSetup(filePath, fileContent, selectedServices);
|
|
@@ -80,16 +77,11 @@ export class ServerManagementService {
|
|
|
80
77
|
});
|
|
81
78
|
|
|
82
79
|
// Patch the original config file if it exists
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
89
|
-
if (patchResult.warning) {
|
|
90
|
-
patchWarning = patchResult.warning;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
80
|
+
const patchWarning =
|
|
81
|
+
fileData.resolvedFilePath && this.configService.fileExists(fileData.resolvedFilePath)
|
|
82
|
+
? this.configPatchingService.patchConfigFile(fileData.resolvedFilePath, updatedConfig)
|
|
83
|
+
.warning || null
|
|
84
|
+
: null;
|
|
93
85
|
|
|
94
86
|
return {
|
|
95
87
|
success: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-shark/mcp-shark",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "Aggregate multiple Model Context Protocol (MCP) servers into a single unified interface with a powerful monitoring UI. Prov deep visibility into every request and response.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./bin/mcp-shark.js",
|
|
@@ -5,10 +5,11 @@ import { handleError, handleValidationError } from '../utils/errorHandler.js';
|
|
|
5
5
|
* Controller for server management HTTP endpoints
|
|
6
6
|
*/
|
|
7
7
|
export class ServerManagementController {
|
|
8
|
-
constructor(serverManagementService, logService, logger) {
|
|
8
|
+
constructor(serverManagementService, logService, logger, configService = null) {
|
|
9
9
|
this.serverManagementService = serverManagementService;
|
|
10
10
|
this.logService = logService;
|
|
11
11
|
this.logger = logger;
|
|
12
|
+
this.configService = configService;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -76,7 +77,7 @@ export class ServerManagementController {
|
|
|
76
77
|
stop = async (_req, res) => {
|
|
77
78
|
try {
|
|
78
79
|
const stopped = await this.serverManagementService.stopServer();
|
|
79
|
-
const restored = this.configService.restoreOriginalConfig();
|
|
80
|
+
const restored = this.configService ? this.configService.restoreOriginalConfig() : false;
|
|
80
81
|
|
|
81
82
|
if (stopped) {
|
|
82
83
|
if (restored) {
|
|
@@ -37,6 +37,7 @@ export function createCompositeRoutes(
|
|
|
37
37
|
const serverManagementService = container.getService('serverManagement');
|
|
38
38
|
const logService = container.getService('log');
|
|
39
39
|
const logger = container.getLibrary('logger');
|
|
40
|
+
const configService = container.getService('config');
|
|
40
41
|
|
|
41
42
|
// Initialize log service with the log array
|
|
42
43
|
logService.initialize(mcpSharkLogs);
|
|
@@ -56,7 +57,8 @@ export function createCompositeRoutes(
|
|
|
56
57
|
const serverManagementController = new ServerManagementController(
|
|
57
58
|
serverManagementService,
|
|
58
59
|
logService,
|
|
59
|
-
logger
|
|
60
|
+
logger,
|
|
61
|
+
configService
|
|
60
62
|
);
|
|
61
63
|
|
|
62
64
|
// Set cleanup function for shutdown endpoint
|
package/ui/server/setup.js
CHANGED
|
@@ -24,7 +24,6 @@ import { createSmartScanRoutes } from './routes/smartscan.js';
|
|
|
24
24
|
import { createStatisticsRoutes } from './routes/statistics.js';
|
|
25
25
|
import { swaggerSpec } from './swagger/swagger.js';
|
|
26
26
|
import { performCleanup } from './utils/cleanup.js';
|
|
27
|
-
import { restoreConfig } from './utils/config.js';
|
|
28
27
|
import { getMcpSharkProcess, setMcpSharkProcess } from './utils/processState.js';
|
|
29
28
|
import { broadcastLogUpdate, notifyClients } from './websocket/broadcast.js';
|
|
30
29
|
import { handleWebSocketConnection } from './websocket/handler.js';
|
|
@@ -110,9 +109,7 @@ export function createUIServer() {
|
|
|
110
109
|
app.post('/api/config/backup/delete', backupRoutes.deleteBackup);
|
|
111
110
|
|
|
112
111
|
app.post('/api/composite/setup', compositeRoutes.setup);
|
|
113
|
-
app.post('/api/composite/stop',
|
|
114
|
-
compositeRoutes.stop(req, res, () => restoreConfig(container));
|
|
115
|
-
});
|
|
112
|
+
app.post('/api/composite/stop', compositeRoutes.stop);
|
|
116
113
|
app.get('/api/composite/status', compositeRoutes.getStatus);
|
|
117
114
|
app.get('/api/mcp-server/status', compositeRoutes.getMcpServerStatus);
|
|
118
115
|
app.post('/api/composite/shutdown', compositeRoutes.shutdown);
|
|
@@ -9,8 +9,11 @@ import { Server as ServerConstants } from '#core/constants/Server.js';
|
|
|
9
9
|
export function handleWebSocketConnection(clients, ws, logger) {
|
|
10
10
|
clients.add(ws);
|
|
11
11
|
|
|
12
|
+
// Use object to hold timeout ID (allows reassignment while keeping const)
|
|
13
|
+
const timeoutState = { id: null };
|
|
14
|
+
|
|
12
15
|
// Set up timeout to close stale connections
|
|
13
|
-
|
|
16
|
+
timeoutState.id = setTimeout(() => {
|
|
14
17
|
if (ws.readyState === 1) {
|
|
15
18
|
logger?.warn('WebSocket connection timeout, closing');
|
|
16
19
|
ws.close();
|
|
@@ -28,8 +31,8 @@ export function handleWebSocketConnection(clients, ws, logger) {
|
|
|
28
31
|
|
|
29
32
|
ws.on('pong', () => {
|
|
30
33
|
// Reset timeout on pong
|
|
31
|
-
clearTimeout(
|
|
32
|
-
|
|
34
|
+
clearTimeout(timeoutState.id);
|
|
35
|
+
timeoutState.id = setTimeout(() => {
|
|
33
36
|
if (ws.readyState === 1) {
|
|
34
37
|
logger?.warn('WebSocket connection timeout, closing');
|
|
35
38
|
ws.close();
|
|
@@ -38,14 +41,14 @@ export function handleWebSocketConnection(clients, ws, logger) {
|
|
|
38
41
|
});
|
|
39
42
|
|
|
40
43
|
ws.on('close', () => {
|
|
41
|
-
clearTimeout(
|
|
44
|
+
clearTimeout(timeoutState.id);
|
|
42
45
|
clearInterval(heartbeatInterval);
|
|
43
46
|
clients.delete(ws);
|
|
44
47
|
});
|
|
45
48
|
|
|
46
49
|
ws.on('error', (error) => {
|
|
47
50
|
logger?.error({ error: error.message }, 'WebSocket error');
|
|
48
|
-
clearTimeout(
|
|
51
|
+
clearTimeout(timeoutState.id);
|
|
49
52
|
clearInterval(heartbeatInterval);
|
|
50
53
|
clients.delete(ws);
|
|
51
54
|
});
|