@mcp-shark/mcp-shark 1.4.1 → 1.5.0
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/README.md +84 -645
- package/bin/mcp-shark.js +30 -36
- package/mcp-server/index.js +115 -0
- package/mcp-server/lib/auditor/audit.js +34 -42
- package/mcp-server/lib/common/error.js +1 -1
- package/mcp-server/lib/server/external/all.js +5 -6
- package/mcp-server/lib/server/external/config.js +1 -3
- package/mcp-server/lib/server/external/kv.js +21 -40
- package/mcp-server/lib/server/external/single/request.js +3 -6
- package/mcp-server/lib/server/external/single/run.js +8 -19
- package/mcp-server/lib/server/internal/handlers/prompts-get.js +5 -7
- package/mcp-server/lib/server/internal/handlers/prompts-list.js +5 -4
- package/mcp-server/lib/server/internal/handlers/resources-list.js +5 -4
- package/mcp-server/lib/server/internal/handlers/resources-read.js +5 -4
- package/mcp-server/lib/server/internal/handlers/tools-call.js +8 -10
- package/mcp-server/lib/server/internal/handlers/tools-list.js +6 -5
- package/mcp-server/lib/server/internal/run.js +5 -17
- package/mcp-server/lib/server/internal/server.js +14 -15
- package/mcp-server/lib/server/internal/session.js +8 -13
- package/mcp-server/mcp-shark.js +16 -66
- package/package.json +23 -38
- package/ui/dist/assets/index-Cc-IUa83.css +1 -0
- package/ui/dist/assets/index-srLDlk97.js +35 -0
- package/ui/dist/index.html +17 -0
- package/ui/dist/og-image.png +0 -0
- package/ui/server/routes/backups/deleteBackup.js +54 -0
- package/ui/server/routes/backups/index.js +15 -0
- package/ui/server/routes/backups/listBackups.js +75 -0
- package/ui/server/routes/backups/restoreBackup.js +83 -0
- package/ui/server/routes/backups/viewBackup.js +47 -0
- package/ui/server/routes/composite/index.js +46 -0
- package/ui/server/routes/composite/servers.js +18 -0
- package/ui/server/routes/composite/setup.js +129 -0
- package/ui/server/routes/composite/status.js +7 -0
- package/ui/server/routes/composite/stop.js +39 -0
- package/ui/server/routes/composite/utils.js +45 -0
- package/ui/server/routes/config.js +34 -30
- package/ui/server/routes/conversations.js +3 -3
- package/ui/server/routes/help.js +2 -2
- package/ui/server/routes/logs.js +5 -5
- package/ui/server/routes/playground.js +91 -62
- package/ui/server/routes/requests.js +112 -108
- package/ui/server/routes/sessions.js +4 -4
- package/ui/server/routes/settings.js +199 -0
- package/ui/server/routes/smartscan/discover.js +7 -6
- package/ui/server/routes/smartscan/scans/clearCache.js +3 -2
- package/ui/server/routes/smartscan/scans/createBatchScans.js +4 -3
- package/ui/server/routes/smartscan/scans/createScan.js +2 -1
- package/ui/server/routes/smartscan/scans/getCachedResults.js +2 -1
- package/ui/server/routes/smartscan/scans/getScan.js +2 -1
- package/ui/server/routes/smartscan/scans/listScans.js +5 -4
- package/ui/server/routes/smartscan/scans.js +3 -3
- package/ui/server/routes/smartscan/token.js +4 -3
- package/ui/server/routes/smartscan/transport.js +1 -1
- package/ui/server/routes/smartscan.js +1 -1
- package/ui/server/routes/statistics.js +13 -10
- package/ui/server/utils/config-update.js +140 -112
- package/ui/server/utils/config.js +4 -4
- package/ui/server/utils/logger.js +2 -0
- package/ui/server/utils/paths.js +210 -2
- package/ui/server/utils/port.js +2 -2
- package/ui/server/utils/process.js +0 -67
- package/ui/server/utils/scan-cache/all-results.js +76 -59
- package/ui/server/utils/scan-cache/directory.js +1 -1
- package/ui/server/utils/scan-cache/file-operations.js +19 -16
- package/ui/server/utils/scan-cache/server-operations.js +14 -9
- package/ui/server/utils/serialization.js +9 -3
- package/ui/server/utils/smartscan-token.js +4 -3
- package/ui/server.js +87 -41
- package/ui/src/App.jsx +5 -5
- package/ui/src/CompositeLogs.jsx +20 -20
- package/ui/src/CompositeSetup.jsx +9 -9
- package/ui/src/HelpGuide/HelpGuideFooter.jsx +1 -0
- package/ui/src/HelpGuide/HelpGuideHeader.jsx +2 -1
- package/ui/src/HelpGuide.jsx +17 -4
- package/ui/src/IntroTour.jsx +19 -5
- package/ui/src/LogDetail.jsx +1 -0
- package/ui/src/LogTable.jsx +24 -6
- package/ui/src/PacketDetail.jsx +21 -16
- package/ui/src/PacketFilters.jsx +29 -14
- package/ui/src/PacketList.jsx +4 -5
- package/ui/src/SmartScan.jsx +5 -5
- package/ui/src/TabNavigation.jsx +5 -5
- package/ui/src/components/App/HelpButton.jsx +4 -0
- package/ui/src/components/App/TrafficTab.jsx +4 -4
- package/ui/src/components/App/useAppState.js +118 -24
- package/ui/src/components/BackupList.jsx +6 -2
- package/ui/src/components/CollapsibleSection.jsx +16 -2
- package/ui/src/components/ConfigViewerModal.jsx +17 -3
- package/ui/src/components/ConfirmationModal.jsx +20 -3
- package/ui/src/components/DetailsTab/BodySection.jsx +3 -1
- package/ui/src/components/DetailsTab/CollapsibleRequestResponse.jsx +14 -3
- package/ui/src/components/DetailsTab/InfoSection.jsx +4 -2
- package/ui/src/components/DetailsTab/RequestDetailsSection.jsx +7 -5
- package/ui/src/components/DetailsTab/ResponseDetailsSection.jsx +7 -5
- package/ui/src/components/DetectedPathsList.jsx +5 -2
- package/ui/src/components/FileInput.jsx +3 -1
- package/ui/src/components/GroupHeader.jsx +14 -0
- package/ui/src/components/GroupedByMcpView.jsx +3 -10
- package/ui/src/components/GroupedByServerView.jsx +1 -1
- package/ui/src/components/GroupedBySessionView.jsx +1 -1
- package/ui/src/components/HexTab.jsx +17 -4
- package/ui/src/components/LogsToolbar.jsx +3 -1
- package/ui/src/components/McpPlayground/LoadingModal.jsx +7 -3
- package/ui/src/components/McpPlayground/PromptsSection/PromptCallPanel.jsx +5 -0
- package/ui/src/components/McpPlayground/PromptsSection/PromptItem.jsx +52 -23
- package/ui/src/components/McpPlayground/PromptsSection/PromptsList.jsx +13 -11
- package/ui/src/components/McpPlayground/PromptsSection.jsx +2 -1
- package/ui/src/components/McpPlayground/ResourcesSection/ResourceCallPanel.jsx +3 -0
- package/ui/src/components/McpPlayground/ResourcesSection/ResourceItem.jsx +66 -34
- package/ui/src/components/McpPlayground/ResourcesSection/ResourcesList.jsx +13 -11
- package/ui/src/components/McpPlayground/ResourcesSection.jsx +2 -1
- package/ui/src/components/McpPlayground/ToolsSection/ToolCallPanel.jsx +5 -0
- package/ui/src/components/McpPlayground/ToolsSection/ToolItem.jsx +52 -23
- package/ui/src/components/McpPlayground/ToolsSection/ToolsList.jsx +13 -11
- package/ui/src/components/McpPlayground/ToolsSection.jsx +2 -1
- package/ui/src/components/McpPlayground/hooks/useMcpDataLoader.js +107 -0
- package/ui/src/components/McpPlayground/hooks/useMcpRequest.js +70 -0
- package/ui/src/components/McpPlayground/hooks/useMcpServerStatus.js +90 -0
- package/ui/src/components/McpPlayground/useMcpPlayground.js +118 -159
- package/ui/src/components/McpPlayground.jsx +105 -23
- package/ui/src/components/PacketDetailHeader.jsx +8 -3
- package/ui/src/components/PacketFilters/ExportControls.jsx +2 -1
- package/ui/src/components/PacketFilters/FilterInput.jsx +1 -1
- package/ui/src/components/RawTab.jsx +15 -2
- package/ui/src/components/RequestRow/OrphanedResponseRow.jsx +10 -2
- package/ui/src/components/RequestRow/RequestRowMain.jsx +12 -3
- package/ui/src/components/RequestRow/ResponseRow.jsx +11 -3
- package/ui/src/components/RequestRow.jsx +17 -9
- package/ui/src/components/ServerControl.jsx +3 -1
- package/ui/src/components/ServiceSelector.jsx +2 -0
- package/ui/src/components/SmartScan/AnalysisResult.jsx +2 -2
- package/ui/src/components/SmartScan/BatchResultsDisplay/BatchResultItem.jsx +2 -1
- package/ui/src/components/SmartScan/BatchResultsDisplay/BatchResultsHeader.jsx +1 -1
- package/ui/src/components/SmartScan/BatchResultsDisplay.jsx +9 -3
- package/ui/src/components/SmartScan/EmptyState.jsx +3 -0
- package/ui/src/components/SmartScan/ErrorDisplay.jsx +4 -2
- package/ui/src/components/SmartScan/ExpandableSection.jsx +4 -0
- package/ui/src/components/SmartScan/FindingsTable.jsx +46 -42
- package/ui/src/components/SmartScan/ListViewContent.jsx +2 -2
- package/ui/src/components/SmartScan/NotablePatternsSection.jsx +13 -8
- package/ui/src/components/SmartScan/OverallSummarySection.jsx +36 -29
- package/ui/src/components/SmartScan/RecommendationsSection.jsx +10 -8
- package/ui/src/components/SmartScan/ScanDetailHeader.jsx +2 -1
- package/ui/src/components/SmartScan/ScanDetailView.jsx +4 -4
- package/ui/src/components/SmartScan/ScanListView/ScanListHeader.jsx +2 -1
- package/ui/src/components/SmartScan/ScanListView/ScanListItem.jsx +15 -1
- package/ui/src/components/SmartScan/ScanOverviewSection.jsx +3 -1
- package/ui/src/components/SmartScan/ScanResultsDisplay.jsx +1 -1
- package/ui/src/components/SmartScan/ScanViewContent.jsx +2 -2
- package/ui/src/components/SmartScan/ScanningProgress.jsx +4 -2
- package/ui/src/components/SmartScan/ServerInfoSection.jsx +3 -1
- package/ui/src/components/SmartScan/ServerSelectionRow.jsx +4 -2
- package/ui/src/components/SmartScan/SingleResultDisplay.jsx +5 -3
- package/ui/src/components/SmartScan/SmartScanControls.jsx +11 -7
- package/ui/src/components/SmartScan/SmartScanHeader.jsx +1 -1
- package/ui/src/components/SmartScan/ViewModeTabs.jsx +2 -0
- package/ui/src/components/SmartScan/hooks/useCacheManagement.js +1 -2
- package/ui/src/components/SmartScan/hooks/useMcpDiscovery.js +22 -26
- package/ui/src/components/SmartScan/hooks/useScanList.js +10 -9
- package/ui/src/components/SmartScan/hooks/useScanOperations.js +23 -14
- package/ui/src/components/SmartScan/hooks/useServerStatus.js +2 -2
- package/ui/src/components/SmartScan/hooks/useTokenManagement.js +2 -2
- package/ui/src/components/SmartScan/scanDataUtils.js +22 -17
- package/ui/src/components/SmartScan/useSmartScan.js +4 -4
- package/ui/src/components/SmartScan/utils.js +3 -1
- package/ui/src/components/SmartScanIcons.jsx +6 -3
- package/ui/src/components/TabNavigation/DesktopTabs.jsx +8 -3
- package/ui/src/components/TabNavigation/MobileDropdown.jsx +3 -1
- package/ui/src/components/TabNavigation.jsx +8 -3
- package/ui/src/components/TabNavigationIcons.jsx +4 -4
- package/ui/src/components/TourOverlay.jsx +1 -1
- package/ui/src/components/TourTooltip/TourTooltipButtons.jsx +3 -0
- package/ui/src/components/TourTooltip/TourTooltipHeader.jsx +1 -0
- package/ui/src/components/TourTooltip/TourTooltipIcons.jsx +9 -0
- package/ui/src/components/TourTooltip/useTooltipPosition.js +63 -36
- package/ui/src/components/TourTooltip.jsx +11 -3
- package/ui/src/components/ViewModeTabs.jsx +3 -1
- package/ui/src/config/tourSteps.jsx +0 -2
- package/ui/src/hooks/useAnimation.js +15 -12
- package/ui/src/hooks/useConfigManagement.js +8 -8
- package/ui/src/hooks/useServiceExtraction.js +1 -1
- package/ui/src/index.css +3 -8
- package/ui/src/theme.js +3 -3
- package/ui/src/utils/hexUtils.js +11 -5
- package/ui/src/utils/mcpGroupingUtils.js +18 -10
- package/ui/src/utils/requestPairing.js +89 -0
- package/ui/src/utils/requestUtils.js +37 -105
- package/ui/vite.config.js +1 -1
- package/mcp-server/.editorconfig +0 -15
- package/mcp-server/.prettierignore +0 -11
- package/mcp-server/.prettierrc +0 -12
- package/mcp-server/README.md +0 -280
- package/mcp-server/commitlint.config.cjs +0 -42
- package/mcp-server/eslint.config.js +0 -131
- package/mcp-server/package-lock.json +0 -4784
- package/mcp-server/package.json +0 -30
- package/ui/README.md +0 -212
- package/ui/package-lock.json +0 -3574
- package/ui/package.json +0 -12
- package/ui/paths.js +0 -282
- package/ui/server/routes/backups.js +0 -251
- package/ui/server/routes/composite.js +0 -244
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { getBy
|
|
1
|
+
import { getBy } from '../../external/kv.js';
|
|
2
2
|
import { InternalServerError } from './error.js';
|
|
3
3
|
|
|
4
|
-
export function createPromptsGetHandler(logger, mcpServers) {
|
|
5
|
-
return async req => {
|
|
4
|
+
export function createPromptsGetHandler(logger, mcpServers, requestedMcpServer) {
|
|
5
|
+
return async (req) => {
|
|
6
6
|
const name = req.params.name;
|
|
7
7
|
const promptArgs = req?.params?.arguments || {};
|
|
8
8
|
logger.debug('Prompt get', name, promptArgs);
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const getPrompt = getBy(mcpServers, name, 'getPrompt', promptArgs);
|
|
10
|
+
const getPrompt = getBy(mcpServers, requestedMcpServer, name, 'getPrompt', promptArgs);
|
|
13
11
|
if (!getPrompt) {
|
|
14
12
|
throw new InternalServerError(`Prompt not found: ${name}`);
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
const result = await getPrompt(
|
|
15
|
+
const result = await getPrompt(name, promptArgs);
|
|
18
16
|
logger.debug('Prompt get result', result);
|
|
19
17
|
|
|
20
18
|
return result;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { listAll } from '../../external/kv.js';
|
|
2
2
|
|
|
3
|
-
export function createPromptsListHandler(logger, mcpServers) {
|
|
4
|
-
return async
|
|
5
|
-
|
|
3
|
+
export function createPromptsListHandler(logger, mcpServers, requestedMcpServer) {
|
|
4
|
+
return async (req) => {
|
|
5
|
+
const path = req.path;
|
|
6
|
+
logger.debug('Prompts list', path);
|
|
6
7
|
|
|
7
|
-
const res = await listAll(mcpServers, 'prompts');
|
|
8
|
+
const res = await listAll(mcpServers, requestedMcpServer, 'prompts');
|
|
8
9
|
const result = Array.isArray(res) ? { prompts: res } : res;
|
|
9
10
|
|
|
10
11
|
return result;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { listAll } from '../../external/kv.js';
|
|
2
2
|
|
|
3
|
-
export function createResourcesListHandler(logger, mcpServers) {
|
|
4
|
-
return async
|
|
5
|
-
|
|
3
|
+
export function createResourcesListHandler(logger, mcpServers, requestedMcpServer) {
|
|
4
|
+
return async (req) => {
|
|
5
|
+
const path = req.path;
|
|
6
|
+
logger.debug('Resources list', path);
|
|
6
7
|
|
|
7
|
-
const res = await listAll(mcpServers, 'resources');
|
|
8
|
+
const res = await listAll(mcpServers, requestedMcpServer, 'resources');
|
|
8
9
|
const result = Array.isArray(res) ? { resources: res } : res;
|
|
9
10
|
|
|
10
11
|
return result;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { getBy } from '../../external/kv.js';
|
|
2
2
|
import { InternalServerError } from './error.js';
|
|
3
3
|
|
|
4
|
-
export function createResourcesReadHandler(logger, mcpServers) {
|
|
5
|
-
return async req => {
|
|
4
|
+
export function createResourcesReadHandler(logger, mcpServers, requestedMcpServer) {
|
|
5
|
+
return async (req) => {
|
|
6
|
+
const path = req.path;
|
|
6
7
|
const uri = req.params.uri;
|
|
7
|
-
logger.debug('Resource read', uri);
|
|
8
|
+
logger.debug('Resource read', path, uri);
|
|
8
9
|
|
|
9
|
-
const readResource = getBy(mcpServers, uri, 'readResource');
|
|
10
|
+
const readResource = getBy(mcpServers, requestedMcpServer, uri, 'readResource');
|
|
10
11
|
if (!readResource) {
|
|
11
12
|
throw new InternalServerError(`Resource not found: ${uri}`);
|
|
12
13
|
}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { getBy
|
|
1
|
+
import { getBy } from '../../external/kv.js';
|
|
2
2
|
import { InternalServerError } from './error.js';
|
|
3
3
|
|
|
4
|
-
const isAsyncIterable = v => v && typeof v[Symbol.asyncIterator] === 'function';
|
|
4
|
+
const isAsyncIterable = (v) => v && typeof v[Symbol.asyncIterator] === 'function';
|
|
5
5
|
|
|
6
|
-
export function createToolsCallHandler(logger, mcpServers) {
|
|
7
|
-
return async req => {
|
|
6
|
+
export function createToolsCallHandler(logger, mcpServers, requestedMcpServer) {
|
|
7
|
+
return async (req) => {
|
|
8
|
+
const path = req.path;
|
|
8
9
|
const { name, arguments: args } = req.params;
|
|
9
|
-
logger.debug('Tool call', name, args);
|
|
10
|
+
logger.debug('Tool call', path, name, args);
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
const { typeName } = extractName(name);
|
|
13
|
-
|
|
14
|
-
const callTool = getBy(mcpServers, name, 'callTool', args || {});
|
|
12
|
+
const callTool = getBy(mcpServers, requestedMcpServer, name, 'callTool', args || {});
|
|
15
13
|
if (!callTool) {
|
|
16
14
|
throw new InternalServerError(`Tool not found: ${name}`);
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
const result = await callTool({
|
|
20
18
|
...req.params,
|
|
21
|
-
name
|
|
19
|
+
name,
|
|
22
20
|
});
|
|
23
21
|
logger.debug('Tool call result', result);
|
|
24
22
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { listAll } from '../../external/kv.js';
|
|
2
2
|
|
|
3
|
-
export function createToolsListHandler(logger, mcpServers) {
|
|
4
|
-
return async req => {
|
|
5
|
-
|
|
3
|
+
export function createToolsListHandler(logger, mcpServers, requestedMcpServer) {
|
|
4
|
+
return async (req) => {
|
|
5
|
+
const path = req.path;
|
|
6
|
+
logger.debug('Listing tools', path);
|
|
6
7
|
|
|
7
|
-
const res = await listAll(mcpServers, 'tools');
|
|
8
|
-
logger.debug('Tools list result', res);
|
|
8
|
+
const res = await listAll(mcpServers, requestedMcpServer, 'tools');
|
|
9
|
+
logger.debug('Tools list result', JSON.stringify(res));
|
|
9
10
|
|
|
10
11
|
const result = Array.isArray(res) ? { tools: res } : res;
|
|
11
12
|
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
1
|
import cors from 'cors';
|
|
2
|
+
import express from 'express';
|
|
3
3
|
|
|
4
4
|
import { withSession } from './session.js';
|
|
5
5
|
|
|
6
|
-
export function getInternalServer(
|
|
7
|
-
serverFactory,
|
|
8
|
-
auditLogger,
|
|
9
|
-
withAuditRequestResponseHandler
|
|
10
|
-
) {
|
|
6
|
+
export function getInternalServer(serverFactory, auditLogger, withAuditRequestResponseHandler) {
|
|
11
7
|
const app = express();
|
|
12
8
|
|
|
13
9
|
// Parse JSON body for POST requests
|
|
@@ -22,14 +18,8 @@ export function getInternalServer(
|
|
|
22
18
|
})
|
|
23
19
|
);
|
|
24
20
|
|
|
25
|
-
app.all('/mcp', async (req, res) => {
|
|
26
|
-
await withSession(
|
|
27
|
-
serverFactory,
|
|
28
|
-
withAuditRequestResponseHandler,
|
|
29
|
-
req,
|
|
30
|
-
res,
|
|
31
|
-
auditLogger
|
|
32
|
-
);
|
|
21
|
+
app.all('/mcp/*', async (req, res) => {
|
|
22
|
+
await withSession(serverFactory, withAuditRequestResponseHandler, req, res, auditLogger);
|
|
33
23
|
});
|
|
34
24
|
|
|
35
25
|
// Catch-all for other routes (404)
|
|
@@ -42,8 +32,6 @@ export function getInternalServer(
|
|
|
42
32
|
|
|
43
33
|
export function runInternalServer(logger, port, app) {
|
|
44
34
|
app.listen(port, '0.0.0.0', () => {
|
|
45
|
-
logger.info(
|
|
46
|
-
`MCP proxy HTTP server listening on http://localhost:${port}/mcp`
|
|
47
|
-
);
|
|
35
|
+
logger.info(`MCP proxy HTTP server listening on http://localhost:${port}/mcp`);
|
|
48
36
|
});
|
|
49
37
|
}
|
|
@@ -1,63 +1,62 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
ListToolsRequestSchema,
|
|
5
4
|
CallToolRequestSchema,
|
|
6
|
-
ListPromptsRequestSchema,
|
|
7
5
|
GetPromptRequestSchema,
|
|
6
|
+
ListPromptsRequestSchema,
|
|
8
7
|
ListResourcesRequestSchema,
|
|
8
|
+
ListToolsRequestSchema,
|
|
9
9
|
ReadResourceRequestSchema,
|
|
10
10
|
} from '@modelcontextprotocol/sdk/types.js';
|
|
11
11
|
|
|
12
|
-
import { createToolsListHandler } from './handlers/tools-list.js';
|
|
13
|
-
import { createToolsCallHandler } from './handlers/tools-call.js';
|
|
14
|
-
import { createPromptsListHandler } from './handlers/prompts-list.js';
|
|
15
12
|
import { createPromptsGetHandler } from './handlers/prompts-get.js';
|
|
13
|
+
import { createPromptsListHandler } from './handlers/prompts-list.js';
|
|
16
14
|
import { createResourcesListHandler } from './handlers/resources-list.js';
|
|
17
15
|
import { createResourcesReadHandler } from './handlers/resources-read.js';
|
|
18
|
-
import {
|
|
16
|
+
import { createToolsCallHandler } from './handlers/tools-call.js';
|
|
17
|
+
import { createToolsListHandler } from './handlers/tools-list.js';
|
|
19
18
|
|
|
20
|
-
export function createInternalServer(logger, mcpServers) {
|
|
19
|
+
export function createInternalServer(logger, mcpServers, requestedMcpServer) {
|
|
21
20
|
// create MCP server
|
|
22
21
|
const server = new Server(
|
|
23
|
-
{ name:
|
|
22
|
+
{ name: requestedMcpServer, version: '1.0.0' },
|
|
24
23
|
{ capabilities: { tools: {}, prompts: {}, resources: {} } }
|
|
25
24
|
);
|
|
26
25
|
|
|
27
26
|
// Register handlers
|
|
28
27
|
server.setRequestHandler(
|
|
29
28
|
ListToolsRequestSchema,
|
|
30
|
-
createToolsListHandler(logger, mcpServers)
|
|
29
|
+
createToolsListHandler(logger, mcpServers, requestedMcpServer)
|
|
31
30
|
);
|
|
32
31
|
|
|
33
32
|
server.setRequestHandler(
|
|
34
33
|
CallToolRequestSchema,
|
|
35
|
-
createToolsCallHandler(logger, mcpServers)
|
|
34
|
+
createToolsCallHandler(logger, mcpServers, requestedMcpServer)
|
|
36
35
|
);
|
|
37
36
|
|
|
38
37
|
server.setRequestHandler(
|
|
39
38
|
ListPromptsRequestSchema,
|
|
40
|
-
createPromptsListHandler(logger, mcpServers)
|
|
39
|
+
createPromptsListHandler(logger, mcpServers, requestedMcpServer)
|
|
41
40
|
);
|
|
42
41
|
|
|
43
42
|
server.setRequestHandler(
|
|
44
43
|
GetPromptRequestSchema,
|
|
45
|
-
createPromptsGetHandler(logger, mcpServers)
|
|
44
|
+
createPromptsGetHandler(logger, mcpServers, requestedMcpServer)
|
|
46
45
|
);
|
|
47
46
|
|
|
48
47
|
server.setRequestHandler(
|
|
49
48
|
ListResourcesRequestSchema,
|
|
50
|
-
createResourcesListHandler(logger, mcpServers)
|
|
49
|
+
createResourcesListHandler(logger, mcpServers, requestedMcpServer)
|
|
51
50
|
);
|
|
52
51
|
|
|
53
52
|
server.setRequestHandler(
|
|
54
53
|
ReadResourceRequestSchema,
|
|
55
|
-
createResourcesReadHandler(logger, mcpServers)
|
|
54
|
+
createResourcesReadHandler(logger, mcpServers, requestedMcpServer)
|
|
56
55
|
);
|
|
57
56
|
|
|
58
57
|
return server;
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
export function createInternalServerFactory(logger, mcpServers) {
|
|
62
|
-
return () => createInternalServer(logger, mcpServers);
|
|
61
|
+
return (requestedMcpServer) => createInternalServer(logger, mcpServers, requestedMcpServer);
|
|
63
62
|
}
|
|
@@ -13,27 +13,22 @@ function getTransportFromSession(sessionId) {
|
|
|
13
13
|
return sessions.get(sessionId);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export async function withSession(
|
|
17
|
-
|
|
18
|
-
requestHandler,
|
|
19
|
-
req,
|
|
20
|
-
res,
|
|
21
|
-
auditLogger
|
|
22
|
-
) {
|
|
16
|
+
export async function withSession(serverFactory, requestHandler, req, res, auditLogger) {
|
|
17
|
+
const requestedMcpServer = req.params[0];
|
|
23
18
|
const sessionId = getSessionFromRequest(req);
|
|
24
19
|
if (!sessionId) {
|
|
25
|
-
const
|
|
20
|
+
const initialSessionId = randomUUID();
|
|
26
21
|
const transport = new StreamableHTTPServerTransport({
|
|
27
|
-
sessionIdGenerator: () =>
|
|
22
|
+
sessionIdGenerator: () => initialSessionId,
|
|
28
23
|
enableJsonResponse: true,
|
|
29
24
|
});
|
|
30
|
-
const server = serverFactory();
|
|
25
|
+
const server = serverFactory(requestedMcpServer);
|
|
31
26
|
await server.connect(transport);
|
|
32
|
-
storeTransportInSession(
|
|
27
|
+
storeTransportInSession(initialSessionId, transport);
|
|
33
28
|
// Session creation will be logged as part of the request packet in audit.js
|
|
34
|
-
return requestHandler(transport, req, res, auditLogger);
|
|
29
|
+
return requestHandler(transport, req, res, auditLogger, requestedMcpServer, initialSessionId);
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
const transport = getTransportFromSession(sessionId);
|
|
38
|
-
return requestHandler(transport, req, res, auditLogger);
|
|
33
|
+
return requestHandler(transport, req, res, auditLogger, requestedMcpServer);
|
|
39
34
|
}
|
package/mcp-server/mcp-shark.js
CHANGED
|
@@ -1,72 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { isError } from './lib/common/error.js';
|
|
5
|
-
|
|
6
|
-
import { createInternalServerFactory } from './lib/server/internal/server.js';
|
|
7
|
-
import {
|
|
8
|
-
getInternalServer,
|
|
9
|
-
runInternalServer,
|
|
10
|
-
} from './lib/server/internal/run.js';
|
|
11
|
-
import { initDb } from 'mcp-shark-common/db/init.js';
|
|
12
|
-
import { getLogger } from 'mcp-shark-common/db/logger.js';
|
|
13
|
-
import {
|
|
14
|
-
getDatabaseFile,
|
|
15
|
-
getMcpConfigPath,
|
|
16
|
-
prepareAppDataSpaces,
|
|
17
|
-
} from 'mcp-shark-common/configs/index.js';
|
|
18
|
-
import { withAuditRequestResponseHandler } from './lib/auditor/audit.js';
|
|
19
|
-
|
|
20
|
-
function initAuditLogger(logger) {
|
|
21
|
-
logger.info('Initializing audit logger at', getDatabaseFile());
|
|
22
|
-
return getLogger(initDb(getDatabaseFile()));
|
|
23
|
-
}
|
|
1
|
+
import logger from '../shared/logger.js';
|
|
2
|
+
// CLI entry point - uses the library
|
|
3
|
+
import { startMcpSharkServer } from './index.js';
|
|
24
4
|
|
|
25
5
|
async function main() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const result = await runAllExternalServers(consola, configPath);
|
|
39
|
-
if (isError(result)) {
|
|
40
|
-
console.error(JSON.stringify(result));
|
|
6
|
+
try {
|
|
7
|
+
await startMcpSharkServer({
|
|
8
|
+
onReady: () => {
|
|
9
|
+
logger.info('[MCP-Shark] MCP server started successfully');
|
|
10
|
+
},
|
|
11
|
+
onError: (error) => {
|
|
12
|
+
logger.error({ error: error.message, stack: error.stack }, 'Error starting MCP server');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
} catch (error) {
|
|
17
|
+
logger.error({ error: error.message, stack: error.stack }, 'Error starting MCP server');
|
|
41
18
|
process.exit(1);
|
|
42
19
|
}
|
|
43
|
-
|
|
44
|
-
const internalServerFactory = createInternalServerFactory(consola, result);
|
|
45
|
-
const app = getInternalServer(
|
|
46
|
-
internalServerFactory,
|
|
47
|
-
auditLogger,
|
|
48
|
-
withAuditRequestResponseHandler
|
|
49
|
-
);
|
|
50
|
-
await runInternalServer(consola, 9851, app);
|
|
51
20
|
}
|
|
52
21
|
|
|
53
|
-
main()
|
|
54
|
-
.then(() => {
|
|
55
|
-
const successMsg = 'MCP server started successfully';
|
|
56
|
-
console.log(`[MCP-Shark] ${successMsg}`);
|
|
57
|
-
consola.info(successMsg);
|
|
58
|
-
})
|
|
59
|
-
.catch(error => {
|
|
60
|
-
const errorMsg = 'Error starting MCP server';
|
|
61
|
-
console.error(`[MCP-Shark] ${errorMsg}:`, error);
|
|
62
|
-
console.error(`[MCP-Shark] Error message: ${error.message}`);
|
|
63
|
-
if (error.stack) {
|
|
64
|
-
console.error(`[MCP-Shark] Error stack:`, error.stack);
|
|
65
|
-
}
|
|
66
|
-
consola.error(errorMsg, error);
|
|
67
|
-
consola.error(`Error message: ${error.message}`);
|
|
68
|
-
if (error.stack) {
|
|
69
|
-
consola.error(`Error stack: ${error.stack}`);
|
|
70
|
-
}
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
22
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-shark/mcp-shark",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./bin/mcp-shark.js",
|
|
9
|
+
"./mcp-server": "./mcp-server/index.js"
|
|
10
|
+
},
|
|
7
11
|
"bin": {
|
|
8
12
|
"mcp-shark": "./bin/mcp-shark.js",
|
|
9
13
|
"@mcp-shark/mcp-shark": "./bin/mcp-shark.js"
|
|
@@ -16,40 +20,25 @@
|
|
|
16
20
|
"bugs": {
|
|
17
21
|
"url": "https://github.com/mcp-shark/mcp-shark/issues"
|
|
18
22
|
},
|
|
19
|
-
"files": [
|
|
20
|
-
"bin",
|
|
21
|
-
"ui",
|
|
22
|
-
"mcp-server",
|
|
23
|
-
"README.md",
|
|
24
|
-
"LICENSE"
|
|
25
|
-
],
|
|
23
|
+
"files": ["bin", "ui", "mcp-server", "README.md", "LICENSE", "package.json"],
|
|
26
24
|
"scripts": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"build:ui": "cd ui &&
|
|
32
|
-
"lint
|
|
33
|
-
"lint:fix
|
|
34
|
-
"format
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"format:ui": "prettier --write \"ui/**/*.{js,jsx,ts,tsx,json,css,md}\"",
|
|
38
|
-
"lint:fix:all": "(npm run lint:fix:server || true) && (npm run lint:fix:ui || true)",
|
|
39
|
-
"format:all": "(npm run format:server || true) && (npm run format:ui || true)",
|
|
40
|
-
"fix:all": "(npm run lint:fix:all || true) && (npm run format:all || true)",
|
|
25
|
+
"start": "node scripts/start-ui.js",
|
|
26
|
+
"predev": "npm run build:ui",
|
|
27
|
+
"dev": "node scripts/start-ui.js'",
|
|
28
|
+
"build": "bash -c 'cd ui && vite build'",
|
|
29
|
+
"build:ui": "bash -c 'cd ui && vite build'",
|
|
30
|
+
"lint": "biome lint .",
|
|
31
|
+
"lint:fix": "biome lint --write .",
|
|
32
|
+
"format": "biome format --write .",
|
|
33
|
+
"check": "biome check .",
|
|
34
|
+
"check:fix": "biome check --write .",
|
|
41
35
|
"prepare": "husky install || true",
|
|
42
|
-
"prepublishOnly": "npm run
|
|
36
|
+
"prepublishOnly": "npm run check:fix && npm run build:ui",
|
|
43
37
|
"publish:public": "npm publish --access public",
|
|
44
38
|
"publish:dry-run": "npm publish --dry-run"
|
|
45
39
|
},
|
|
46
40
|
"lint-staged": {
|
|
47
|
-
"
|
|
48
|
-
"prettier --write"
|
|
49
|
-
],
|
|
50
|
-
"*.{json,css,md,yml,yaml}": [
|
|
51
|
-
"prettier --write"
|
|
52
|
-
]
|
|
41
|
+
"*": ["biome check --write"]
|
|
53
42
|
},
|
|
54
43
|
"keywords": [
|
|
55
44
|
"mcp",
|
|
@@ -78,28 +67,24 @@
|
|
|
78
67
|
"@modelcontextprotocol/sdk": "^1.20.2",
|
|
79
68
|
"@tabler/icons-react": "^3.0.0",
|
|
80
69
|
"animejs": "^3.2.2",
|
|
70
|
+
"commander": "^14.0.2",
|
|
81
71
|
"consola": "^3.4.2",
|
|
82
72
|
"cors": "^2.8.5",
|
|
83
73
|
"express": "^4.18.2",
|
|
84
74
|
"jsonrpc-lite": "^2.2.0",
|
|
85
75
|
"mcp-shark-common": "github:mcp-shark/mcp-shark-common",
|
|
76
|
+
"open": "^11.0.0",
|
|
86
77
|
"react": "^18.2.0",
|
|
87
78
|
"react-dom": "^18.2.0",
|
|
88
|
-
"ws": "^8.16.0"
|
|
89
|
-
"open": "^11.0.0",
|
|
90
|
-
"commander": "^14.0.2"
|
|
79
|
+
"ws": "^8.16.0"
|
|
91
80
|
},
|
|
92
81
|
"devDependencies": {
|
|
82
|
+
"@biomejs/biome": "^1.9.4",
|
|
93
83
|
"@commitlint/cli": "^19.5.0",
|
|
94
84
|
"@commitlint/config-conventional": "^19.5.0",
|
|
95
|
-
"@eslint/js": "^9.15.0",
|
|
96
85
|
"@vitejs/plugin-react": "^4.2.1",
|
|
97
|
-
"eslint": "^9.15.0",
|
|
98
|
-
"eslint-config-prettier": "^9.1.0",
|
|
99
|
-
"eslint-plugin-prettier": "^5.2.1",
|
|
100
86
|
"husky": "^9.1.6",
|
|
101
87
|
"lint-staged": "^15.2.10",
|
|
102
|
-
"
|
|
103
|
-
"vite": "^5.1.0"
|
|
88
|
+
"vite": "^7.3.0"
|
|
104
89
|
}
|
|
105
90
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import"https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Roboto+Mono:wght@400;500&display=swap";*{margin:0;padding:0;box-sizing:border-box}body{font-family:Roboto,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;background:#fff;color:#202124;overflow:hidden;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code,pre,.monospace{font-family:Roboto Mono,JetBrains Mono,Fira Code,Consolas,monospace}#root{height:100vh;display:flex;flex-direction:column}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
|