@mcp-shark/mcp-shark 1.4.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/LICENSE +85 -0
- package/README.md +724 -0
- package/bin/mcp-shark.js +93 -0
- package/mcp-server/.editorconfig +15 -0
- package/mcp-server/.prettierignore +11 -0
- package/mcp-server/.prettierrc +12 -0
- package/mcp-server/README.md +280 -0
- package/mcp-server/commitlint.config.cjs +42 -0
- package/mcp-server/eslint.config.js +131 -0
- package/mcp-server/lib/auditor/audit.js +228 -0
- package/mcp-server/lib/common/error.js +15 -0
- package/mcp-server/lib/server/external/all.js +32 -0
- package/mcp-server/lib/server/external/config.js +59 -0
- package/mcp-server/lib/server/external/kv.js +102 -0
- package/mcp-server/lib/server/external/single/client.js +35 -0
- package/mcp-server/lib/server/external/single/request.js +49 -0
- package/mcp-server/lib/server/external/single/run.js +75 -0
- package/mcp-server/lib/server/external/single/transport.js +57 -0
- package/mcp-server/lib/server/internal/handlers/common.js +20 -0
- package/mcp-server/lib/server/internal/handlers/error.js +7 -0
- package/mcp-server/lib/server/internal/handlers/prompts-get.js +22 -0
- package/mcp-server/lib/server/internal/handlers/prompts-list.js +12 -0
- package/mcp-server/lib/server/internal/handlers/resources-list.js +12 -0
- package/mcp-server/lib/server/internal/handlers/resources-read.js +19 -0
- package/mcp-server/lib/server/internal/handlers/tools-call.js +37 -0
- package/mcp-server/lib/server/internal/handlers/tools-list.js +14 -0
- package/mcp-server/lib/server/internal/run.js +49 -0
- package/mcp-server/lib/server/internal/server.js +63 -0
- package/mcp-server/lib/server/internal/session.js +39 -0
- package/mcp-server/mcp-shark.js +72 -0
- package/mcp-server/package-lock.json +4784 -0
- package/mcp-server/package.json +30 -0
- package/package.json +103 -0
- package/ui/README.md +212 -0
- package/ui/index.html +16 -0
- package/ui/package-lock.json +3574 -0
- package/ui/package.json +12 -0
- package/ui/paths.js +282 -0
- package/ui/public/og-image.png +0 -0
- package/ui/server/routes/backups.js +251 -0
- package/ui/server/routes/composite.js +244 -0
- package/ui/server/routes/config.js +175 -0
- package/ui/server/routes/conversations.js +25 -0
- package/ui/server/routes/help.js +43 -0
- package/ui/server/routes/logs.js +32 -0
- package/ui/server/routes/playground.js +152 -0
- package/ui/server/routes/requests.js +235 -0
- package/ui/server/routes/sessions.js +27 -0
- package/ui/server/routes/smartscan/discover.js +117 -0
- package/ui/server/routes/smartscan/scans/clearCache.js +22 -0
- package/ui/server/routes/smartscan/scans/createBatchScans.js +123 -0
- package/ui/server/routes/smartscan/scans/createScan.js +42 -0
- package/ui/server/routes/smartscan/scans/getCachedResults.js +51 -0
- package/ui/server/routes/smartscan/scans/getScan.js +41 -0
- package/ui/server/routes/smartscan/scans/listScans.js +24 -0
- package/ui/server/routes/smartscan/scans.js +13 -0
- package/ui/server/routes/smartscan/token.js +56 -0
- package/ui/server/routes/smartscan/transport.js +53 -0
- package/ui/server/routes/smartscan.js +24 -0
- package/ui/server/routes/statistics.js +83 -0
- package/ui/server/utils/config-update.js +212 -0
- package/ui/server/utils/config.js +98 -0
- package/ui/server/utils/paths.js +23 -0
- package/ui/server/utils/port.js +28 -0
- package/ui/server/utils/process.js +80 -0
- package/ui/server/utils/scan-cache/all-results.js +180 -0
- package/ui/server/utils/scan-cache/directory.js +35 -0
- package/ui/server/utils/scan-cache/file-operations.js +104 -0
- package/ui/server/utils/scan-cache/hash.js +47 -0
- package/ui/server/utils/scan-cache/server-operations.js +80 -0
- package/ui/server/utils/scan-cache.js +12 -0
- package/ui/server/utils/serialization.js +13 -0
- package/ui/server/utils/smartscan-token.js +42 -0
- package/ui/server.js +199 -0
- package/ui/src/App.jsx +153 -0
- package/ui/src/CompositeLogs.jsx +164 -0
- package/ui/src/CompositeSetup.jsx +285 -0
- package/ui/src/HelpGuide/HelpGuideContent.jsx +118 -0
- package/ui/src/HelpGuide/HelpGuideFooter.jsx +58 -0
- package/ui/src/HelpGuide/HelpGuideHeader.jsx +56 -0
- package/ui/src/HelpGuide.jsx +65 -0
- package/ui/src/IntroTour.jsx +140 -0
- package/ui/src/LogDetail.jsx +122 -0
- package/ui/src/LogTable.jsx +242 -0
- package/ui/src/PacketDetail.jsx +190 -0
- package/ui/src/PacketFilters.jsx +222 -0
- package/ui/src/PacketList.jsx +183 -0
- package/ui/src/SmartScan.jsx +178 -0
- package/ui/src/TabNavigation.jsx +143 -0
- package/ui/src/components/App/HelpButton.jsx +64 -0
- package/ui/src/components/App/TrafficTab.jsx +69 -0
- package/ui/src/components/App/useAppState.js +163 -0
- package/ui/src/components/BackupList.jsx +192 -0
- package/ui/src/components/CollapsibleSection.jsx +82 -0
- package/ui/src/components/ConfigFileSection.jsx +84 -0
- package/ui/src/components/ConfigViewerModal.jsx +141 -0
- package/ui/src/components/ConfirmationModal.jsx +129 -0
- package/ui/src/components/DetailsTab/BodySection.jsx +27 -0
- package/ui/src/components/DetailsTab/CollapsibleRequestResponse.jsx +70 -0
- package/ui/src/components/DetailsTab/HeadersSection.jsx +25 -0
- package/ui/src/components/DetailsTab/InfoSection.jsx +28 -0
- package/ui/src/components/DetailsTab/NetworkInfoSection.jsx +63 -0
- package/ui/src/components/DetailsTab/ProtocolInfoSection.jsx +75 -0
- package/ui/src/components/DetailsTab/RequestDetailsSection.jsx +46 -0
- package/ui/src/components/DetailsTab/ResponseDetailsSection.jsx +66 -0
- package/ui/src/components/DetailsTab.jsx +31 -0
- package/ui/src/components/DetectedPathsList.jsx +171 -0
- package/ui/src/components/FileInput.jsx +144 -0
- package/ui/src/components/GroupHeader.jsx +76 -0
- package/ui/src/components/GroupedByMcpView.jsx +103 -0
- package/ui/src/components/GroupedByServerView.jsx +134 -0
- package/ui/src/components/GroupedBySessionView.jsx +127 -0
- package/ui/src/components/GroupedViews.jsx +2 -0
- package/ui/src/components/HexTab.jsx +188 -0
- package/ui/src/components/LogsDisplay.jsx +93 -0
- package/ui/src/components/LogsToolbar.jsx +193 -0
- package/ui/src/components/McpPlayground/LoadingModal.jsx +113 -0
- package/ui/src/components/McpPlayground/PromptsSection/PromptCallPanel.jsx +125 -0
- package/ui/src/components/McpPlayground/PromptsSection/PromptItem.jsx +48 -0
- package/ui/src/components/McpPlayground/PromptsSection/PromptsList.jsx +45 -0
- package/ui/src/components/McpPlayground/PromptsSection.jsx +106 -0
- package/ui/src/components/McpPlayground/ResourcesSection/ResourceCallPanel.jsx +89 -0
- package/ui/src/components/McpPlayground/ResourcesSection/ResourceItem.jsx +59 -0
- package/ui/src/components/McpPlayground/ResourcesSection/ResourcesList.jsx +45 -0
- package/ui/src/components/McpPlayground/ResourcesSection.jsx +91 -0
- package/ui/src/components/McpPlayground/ToolsSection/ToolCallPanel.jsx +125 -0
- package/ui/src/components/McpPlayground/ToolsSection/ToolItem.jsx +48 -0
- package/ui/src/components/McpPlayground/ToolsSection/ToolsList.jsx +45 -0
- package/ui/src/components/McpPlayground/ToolsSection.jsx +107 -0
- package/ui/src/components/McpPlayground/common/EmptyState.jsx +17 -0
- package/ui/src/components/McpPlayground/common/ErrorState.jsx +17 -0
- package/ui/src/components/McpPlayground/common/LoadingState.jsx +17 -0
- package/ui/src/components/McpPlayground/useMcpPlayground.js +280 -0
- package/ui/src/components/McpPlayground.jsx +171 -0
- package/ui/src/components/MessageDisplay.jsx +28 -0
- package/ui/src/components/PacketDetailHeader.jsx +88 -0
- package/ui/src/components/PacketFilters/ExportControls.jsx +126 -0
- package/ui/src/components/PacketFilters/FilterInput.jsx +59 -0
- package/ui/src/components/RawTab.jsx +142 -0
- package/ui/src/components/RequestRow/OrphanedResponseRow.jsx +155 -0
- package/ui/src/components/RequestRow/RequestRowMain.jsx +240 -0
- package/ui/src/components/RequestRow/ResponseRow.jsx +158 -0
- package/ui/src/components/RequestRow.jsx +70 -0
- package/ui/src/components/ServerControl.jsx +133 -0
- package/ui/src/components/ServiceSelector.jsx +209 -0
- package/ui/src/components/SetupHeader.jsx +30 -0
- package/ui/src/components/SharkLogo.jsx +21 -0
- package/ui/src/components/SmartScan/AnalysisResult.jsx +64 -0
- package/ui/src/components/SmartScan/BatchResultsDisplay/BatchResultItem.jsx +215 -0
- package/ui/src/components/SmartScan/BatchResultsDisplay/BatchResultsHeader.jsx +94 -0
- package/ui/src/components/SmartScan/BatchResultsDisplay.jsx +26 -0
- package/ui/src/components/SmartScan/DebugInfoSection.jsx +53 -0
- package/ui/src/components/SmartScan/EmptyState.jsx +57 -0
- package/ui/src/components/SmartScan/ErrorDisplay.jsx +48 -0
- package/ui/src/components/SmartScan/ExpandableSection.jsx +93 -0
- package/ui/src/components/SmartScan/FindingsTable.jsx +257 -0
- package/ui/src/components/SmartScan/ListViewContent.jsx +75 -0
- package/ui/src/components/SmartScan/NotablePatternsSection.jsx +75 -0
- package/ui/src/components/SmartScan/OverallSummarySection.jsx +72 -0
- package/ui/src/components/SmartScan/RawDataSection.jsx +52 -0
- package/ui/src/components/SmartScan/RecommendationsSection.jsx +78 -0
- package/ui/src/components/SmartScan/ScanDetailHeader.jsx +92 -0
- package/ui/src/components/SmartScan/ScanDetailView.jsx +141 -0
- package/ui/src/components/SmartScan/ScanListView/ScanListHeader.jsx +49 -0
- package/ui/src/components/SmartScan/ScanListView/ScanListItem.jsx +201 -0
- package/ui/src/components/SmartScan/ScanListView.jsx +73 -0
- package/ui/src/components/SmartScan/ScanOverviewSection.jsx +123 -0
- package/ui/src/components/SmartScan/ScanResultsDisplay.jsx +35 -0
- package/ui/src/components/SmartScan/ScanViewContent.jsx +68 -0
- package/ui/src/components/SmartScan/ScanningProgress.jsx +47 -0
- package/ui/src/components/SmartScan/ServerInfoSection.jsx +43 -0
- package/ui/src/components/SmartScan/ServerSelectionRow.jsx +207 -0
- package/ui/src/components/SmartScan/SingleResultDisplay.jsx +269 -0
- package/ui/src/components/SmartScan/SmartScanControls.jsx +290 -0
- package/ui/src/components/SmartScan/SmartScanHeader.jsx +77 -0
- package/ui/src/components/SmartScan/ViewModeTabs.jsx +57 -0
- package/ui/src/components/SmartScan/hooks/useCacheManagement.js +34 -0
- package/ui/src/components/SmartScan/hooks/useMcpDiscovery.js +121 -0
- package/ui/src/components/SmartScan/hooks/useScanList.js +193 -0
- package/ui/src/components/SmartScan/hooks/useScanOperations.js +87 -0
- package/ui/src/components/SmartScan/hooks/useServerStatus.js +26 -0
- package/ui/src/components/SmartScan/hooks/useTokenManagement.js +53 -0
- package/ui/src/components/SmartScan/scanDataUtils.js +98 -0
- package/ui/src/components/SmartScan/useSmartScan.js +72 -0
- package/ui/src/components/SmartScan/utils.js +19 -0
- package/ui/src/components/SmartScanIcons.jsx +58 -0
- package/ui/src/components/TabNavigation/DesktopTabs.jsx +111 -0
- package/ui/src/components/TabNavigation/MobileDropdown.jsx +140 -0
- package/ui/src/components/TabNavigation.jsx +97 -0
- package/ui/src/components/TabNavigationIcons.jsx +40 -0
- package/ui/src/components/TableHeader.jsx +164 -0
- package/ui/src/components/TourOverlay.jsx +117 -0
- package/ui/src/components/TourTooltip/TourTooltipButtons.jsx +117 -0
- package/ui/src/components/TourTooltip/TourTooltipHeader.jsx +70 -0
- package/ui/src/components/TourTooltip/TourTooltipIcons.jsx +45 -0
- package/ui/src/components/TourTooltip/useTooltipPosition.js +108 -0
- package/ui/src/components/TourTooltip.jsx +83 -0
- package/ui/src/components/ViewModeTabs.jsx +91 -0
- package/ui/src/components/WhatThisDoesSection.jsx +61 -0
- package/ui/src/config/tourSteps.jsx +141 -0
- package/ui/src/hooks/useAnimation.js +92 -0
- package/ui/src/hooks/useConfigManagement.js +124 -0
- package/ui/src/hooks/useServiceExtraction.js +51 -0
- package/ui/src/index.css +42 -0
- package/ui/src/main.jsx +10 -0
- package/ui/src/theme.js +65 -0
- package/ui/src/utils/animations.js +170 -0
- package/ui/src/utils/groupingUtils.js +93 -0
- package/ui/src/utils/hexUtils.js +24 -0
- package/ui/src/utils/mcpGroupingUtils.js +262 -0
- package/ui/src/utils/requestUtils.js +297 -0
- package/ui/vite.config.js +18 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
export function useMcpPlayground() {
|
|
4
|
+
const [activeSection, setActiveSection] = useState('tools');
|
|
5
|
+
const [tools, setTools] = useState([]);
|
|
6
|
+
const [prompts, setPrompts] = useState([]);
|
|
7
|
+
const [resources, setResources] = useState([]);
|
|
8
|
+
const [loading, setLoading] = useState(false);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const [selectedTool, setSelectedTool] = useState(null);
|
|
11
|
+
const [toolArgs, setToolArgs] = useState('{}');
|
|
12
|
+
const [toolResult, setToolResult] = useState(null);
|
|
13
|
+
const [selectedPrompt, setSelectedPrompt] = useState(null);
|
|
14
|
+
const [promptArgs, setPromptArgs] = useState('{}');
|
|
15
|
+
const [promptResult, setPromptResult] = useState(null);
|
|
16
|
+
const [selectedResource, setSelectedResource] = useState(null);
|
|
17
|
+
const [resourceResult, setResourceResult] = useState(null);
|
|
18
|
+
const [serverStatus, setServerStatus] = useState(null);
|
|
19
|
+
const [sessionId, setSessionId] = useState(null);
|
|
20
|
+
const [showLoadingModal, setShowLoadingModal] = useState(false);
|
|
21
|
+
const [toolsLoading, setToolsLoading] = useState(false);
|
|
22
|
+
const [promptsLoading, setPromptsLoading] = useState(false);
|
|
23
|
+
const [resourcesLoading, setResourcesLoading] = useState(false);
|
|
24
|
+
const [toolsLoaded, setToolsLoaded] = useState(false);
|
|
25
|
+
const [promptsLoaded, setPromptsLoaded] = useState(false);
|
|
26
|
+
const [resourcesLoaded, setResourcesLoaded] = useState(false);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
checkServerStatus();
|
|
30
|
+
const interval = setInterval(checkServerStatus, 2000);
|
|
31
|
+
return () => clearInterval(interval);
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (serverStatus?.running && activeSection === 'tools' && tools.length === 0) {
|
|
36
|
+
const timer = setTimeout(() => {
|
|
37
|
+
loadTools();
|
|
38
|
+
}, 2000);
|
|
39
|
+
return () => clearTimeout(timer);
|
|
40
|
+
}
|
|
41
|
+
}, [serverStatus?.running]);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!serverStatus?.running) return;
|
|
45
|
+
|
|
46
|
+
const timer = setTimeout(() => {
|
|
47
|
+
if (activeSection === 'tools' && !toolsLoaded && !toolsLoading) {
|
|
48
|
+
loadTools();
|
|
49
|
+
} else if (activeSection === 'prompts' && !promptsLoaded && !promptsLoading) {
|
|
50
|
+
loadPrompts();
|
|
51
|
+
} else if (activeSection === 'resources' && !resourcesLoaded && !resourcesLoading) {
|
|
52
|
+
loadResources();
|
|
53
|
+
}
|
|
54
|
+
}, 100);
|
|
55
|
+
|
|
56
|
+
return () => clearTimeout(timer);
|
|
57
|
+
}, [
|
|
58
|
+
activeSection,
|
|
59
|
+
serverStatus?.running,
|
|
60
|
+
toolsLoaded,
|
|
61
|
+
promptsLoaded,
|
|
62
|
+
resourcesLoaded,
|
|
63
|
+
toolsLoading,
|
|
64
|
+
promptsLoading,
|
|
65
|
+
resourcesLoading,
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
const checkServerStatus = async () => {
|
|
69
|
+
try {
|
|
70
|
+
const res = await fetch('/api/composite/status');
|
|
71
|
+
if (!res.ok) {
|
|
72
|
+
throw new Error('Server not available');
|
|
73
|
+
}
|
|
74
|
+
const data = await res.json();
|
|
75
|
+
const wasRunning = serverStatus?.running;
|
|
76
|
+
setServerStatus(data);
|
|
77
|
+
|
|
78
|
+
if (!data.running) {
|
|
79
|
+
if (!showLoadingModal || wasRunning) {
|
|
80
|
+
setShowLoadingModal(true);
|
|
81
|
+
}
|
|
82
|
+
} else if (data.running && showLoadingModal) {
|
|
83
|
+
setShowLoadingModal(false);
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
// Silently handle connection errors - server is not running
|
|
87
|
+
setServerStatus({ running: false });
|
|
88
|
+
if (!showLoadingModal) {
|
|
89
|
+
setShowLoadingModal(true);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const makeMcpRequest = async (method, params = {}) => {
|
|
95
|
+
setError(null);
|
|
96
|
+
setLoading(true);
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
100
|
+
if (sessionId) {
|
|
101
|
+
headers['Mcp-Session-Id'] = sessionId;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const response = await fetch('/api/playground/proxy', {
|
|
105
|
+
method: 'POST',
|
|
106
|
+
headers,
|
|
107
|
+
body: JSON.stringify({ method, params }),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const data = await response.json();
|
|
111
|
+
|
|
112
|
+
const responseSessionId =
|
|
113
|
+
response.headers.get('Mcp-Session-Id') ||
|
|
114
|
+
response.headers.get('mcp-session-id') ||
|
|
115
|
+
data._sessionId;
|
|
116
|
+
if (responseSessionId && responseSessionId !== sessionId) {
|
|
117
|
+
setSessionId(responseSessionId);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!response.ok) {
|
|
121
|
+
throw new Error(data.error?.message || data.message || 'Request failed');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return data.result || data;
|
|
125
|
+
} catch (err) {
|
|
126
|
+
setError(err.message);
|
|
127
|
+
throw err;
|
|
128
|
+
} finally {
|
|
129
|
+
setLoading(false);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const loadTools = async () => {
|
|
134
|
+
setToolsLoading(true);
|
|
135
|
+
setError(null);
|
|
136
|
+
try {
|
|
137
|
+
const result = await makeMcpRequest('tools/list');
|
|
138
|
+
setTools(result?.tools || []);
|
|
139
|
+
setToolsLoaded(true);
|
|
140
|
+
} catch (err) {
|
|
141
|
+
const errorMsg = err.message || 'Failed to load tools';
|
|
142
|
+
setError(`tools: ${errorMsg}`);
|
|
143
|
+
setToolsLoaded(true);
|
|
144
|
+
console.error('Failed to load tools:', err);
|
|
145
|
+
} finally {
|
|
146
|
+
setToolsLoading(false);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const loadPrompts = async () => {
|
|
151
|
+
setPromptsLoading(true);
|
|
152
|
+
setError(null);
|
|
153
|
+
try {
|
|
154
|
+
const result = await makeMcpRequest('prompts/list');
|
|
155
|
+
setPrompts(result?.prompts || []);
|
|
156
|
+
setPromptsLoaded(true);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
const errorMsg = err.message || 'Failed to load prompts';
|
|
159
|
+
setError(`prompts: ${errorMsg}`);
|
|
160
|
+
setPromptsLoaded(true);
|
|
161
|
+
console.error('Failed to load prompts:', err);
|
|
162
|
+
} finally {
|
|
163
|
+
setPromptsLoading(false);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const loadResources = async () => {
|
|
168
|
+
setResourcesLoading(true);
|
|
169
|
+
setError(null);
|
|
170
|
+
try {
|
|
171
|
+
const result = await makeMcpRequest('resources/list');
|
|
172
|
+
setResources(result?.resources || []);
|
|
173
|
+
setResourcesLoaded(true);
|
|
174
|
+
} catch (err) {
|
|
175
|
+
const errorMsg = err.message || 'Failed to load resources';
|
|
176
|
+
setError(`resources: ${errorMsg}`);
|
|
177
|
+
setResourcesLoaded(true);
|
|
178
|
+
console.error('Failed to load resources:', err);
|
|
179
|
+
} finally {
|
|
180
|
+
setResourcesLoading(false);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const handleCallTool = async () => {
|
|
185
|
+
if (!selectedTool) return;
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
let args = {};
|
|
189
|
+
try {
|
|
190
|
+
args = JSON.parse(toolArgs);
|
|
191
|
+
} catch (e) {
|
|
192
|
+
setError('Invalid JSON in arguments');
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const result = await makeMcpRequest('tools/call', {
|
|
197
|
+
name: selectedTool.name,
|
|
198
|
+
arguments: args,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
setToolResult(result);
|
|
202
|
+
} catch (err) {
|
|
203
|
+
setToolResult({ error: err.message });
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const handleGetPrompt = async () => {
|
|
208
|
+
if (!selectedPrompt) return;
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
let args = {};
|
|
212
|
+
try {
|
|
213
|
+
args = JSON.parse(promptArgs);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
setError('Invalid JSON in arguments');
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const result = await makeMcpRequest('prompts/get', {
|
|
220
|
+
name: selectedPrompt.name,
|
|
221
|
+
arguments: args,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
setPromptResult(result);
|
|
225
|
+
} catch (err) {
|
|
226
|
+
setPromptResult({ error: err.message });
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const handleReadResource = async () => {
|
|
231
|
+
if (!selectedResource) return;
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
const result = await makeMcpRequest('resources/read', {
|
|
235
|
+
uri: selectedResource.uri,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
setResourceResult(result);
|
|
239
|
+
} catch (err) {
|
|
240
|
+
setResourceResult({ error: err.message });
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
activeSection,
|
|
246
|
+
setActiveSection,
|
|
247
|
+
tools,
|
|
248
|
+
prompts,
|
|
249
|
+
resources,
|
|
250
|
+
loading,
|
|
251
|
+
error,
|
|
252
|
+
selectedTool,
|
|
253
|
+
setSelectedTool,
|
|
254
|
+
toolArgs,
|
|
255
|
+
setToolArgs,
|
|
256
|
+
toolResult,
|
|
257
|
+
selectedPrompt,
|
|
258
|
+
setSelectedPrompt,
|
|
259
|
+
promptArgs,
|
|
260
|
+
setPromptArgs,
|
|
261
|
+
promptResult,
|
|
262
|
+
selectedResource,
|
|
263
|
+
setSelectedResource,
|
|
264
|
+
resourceResult,
|
|
265
|
+
serverStatus,
|
|
266
|
+
showLoadingModal,
|
|
267
|
+
toolsLoading,
|
|
268
|
+
promptsLoading,
|
|
269
|
+
resourcesLoading,
|
|
270
|
+
toolsLoaded,
|
|
271
|
+
promptsLoaded,
|
|
272
|
+
resourcesLoaded,
|
|
273
|
+
loadTools,
|
|
274
|
+
loadPrompts,
|
|
275
|
+
loadResources,
|
|
276
|
+
handleCallTool,
|
|
277
|
+
handleGetPrompt,
|
|
278
|
+
handleReadResource,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { colors, fonts } from '../theme';
|
|
2
|
+
import { useMcpPlayground } from './McpPlayground/useMcpPlayground';
|
|
3
|
+
import LoadingModal from './McpPlayground/LoadingModal';
|
|
4
|
+
import ToolsSection from './McpPlayground/ToolsSection';
|
|
5
|
+
import PromptsSection from './McpPlayground/PromptsSection';
|
|
6
|
+
import ResourcesSection from './McpPlayground/ResourcesSection';
|
|
7
|
+
|
|
8
|
+
function McpPlayground() {
|
|
9
|
+
const {
|
|
10
|
+
activeSection,
|
|
11
|
+
setActiveSection,
|
|
12
|
+
tools,
|
|
13
|
+
prompts,
|
|
14
|
+
resources,
|
|
15
|
+
loading,
|
|
16
|
+
error,
|
|
17
|
+
selectedTool,
|
|
18
|
+
setSelectedTool,
|
|
19
|
+
toolArgs,
|
|
20
|
+
setToolArgs,
|
|
21
|
+
toolResult,
|
|
22
|
+
selectedPrompt,
|
|
23
|
+
setSelectedPrompt,
|
|
24
|
+
promptArgs,
|
|
25
|
+
setPromptArgs,
|
|
26
|
+
promptResult,
|
|
27
|
+
selectedResource,
|
|
28
|
+
setSelectedResource,
|
|
29
|
+
resourceResult,
|
|
30
|
+
serverStatus,
|
|
31
|
+
showLoadingModal,
|
|
32
|
+
toolsLoading,
|
|
33
|
+
promptsLoading,
|
|
34
|
+
resourcesLoading,
|
|
35
|
+
toolsLoaded,
|
|
36
|
+
promptsLoaded,
|
|
37
|
+
resourcesLoaded,
|
|
38
|
+
loadTools,
|
|
39
|
+
loadPrompts,
|
|
40
|
+
loadResources,
|
|
41
|
+
handleCallTool,
|
|
42
|
+
handleGetPrompt,
|
|
43
|
+
handleReadResource,
|
|
44
|
+
} = useMcpPlayground();
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<style>
|
|
49
|
+
{`
|
|
50
|
+
@keyframes spin {
|
|
51
|
+
from { transform: rotate(0deg); }
|
|
52
|
+
to { transform: rotate(360deg); }
|
|
53
|
+
}
|
|
54
|
+
`}
|
|
55
|
+
</style>
|
|
56
|
+
<div
|
|
57
|
+
style={{
|
|
58
|
+
display: 'flex',
|
|
59
|
+
flexDirection: 'column',
|
|
60
|
+
height: '100%',
|
|
61
|
+
background: colors.bgPrimary,
|
|
62
|
+
padding: '20px',
|
|
63
|
+
gap: '16px',
|
|
64
|
+
position: 'relative',
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
<LoadingModal show={showLoadingModal} />
|
|
68
|
+
|
|
69
|
+
{error && !error.includes(':') && (
|
|
70
|
+
<div
|
|
71
|
+
style={{
|
|
72
|
+
padding: '12px 16px',
|
|
73
|
+
background: colors.error,
|
|
74
|
+
color: colors.textInverse,
|
|
75
|
+
borderRadius: '6px',
|
|
76
|
+
fontSize: '13px',
|
|
77
|
+
fontFamily: fonts.body,
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
Error: {error}
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
|
|
84
|
+
<div
|
|
85
|
+
style={{
|
|
86
|
+
display: 'flex',
|
|
87
|
+
gap: '8px',
|
|
88
|
+
borderBottom: `1px solid ${colors.borderLight}`,
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
{['tools', 'prompts', 'resources'].map((section) => (
|
|
92
|
+
<button
|
|
93
|
+
key={section}
|
|
94
|
+
onClick={() => setActiveSection(section)}
|
|
95
|
+
style={{
|
|
96
|
+
padding: '10px 18px',
|
|
97
|
+
background: activeSection === section ? colors.bgSecondary : 'transparent',
|
|
98
|
+
border: 'none',
|
|
99
|
+
borderBottom: `2px solid ${activeSection === section ? colors.accentBlue : 'transparent'}`,
|
|
100
|
+
color: activeSection === section ? colors.textPrimary : colors.textSecondary,
|
|
101
|
+
cursor: 'pointer',
|
|
102
|
+
fontSize: '13px',
|
|
103
|
+
fontFamily: fonts.body,
|
|
104
|
+
fontWeight: activeSection === section ? '500' : '400',
|
|
105
|
+
textTransform: 'capitalize',
|
|
106
|
+
borderRadius: '6px 6px 0 0',
|
|
107
|
+
transition: 'all 0.2s',
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
{section}
|
|
111
|
+
</button>
|
|
112
|
+
))}
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<div style={{ flex: 1, overflow: 'hidden', minHeight: 0 }}>
|
|
116
|
+
{activeSection === 'tools' && (
|
|
117
|
+
<ToolsSection
|
|
118
|
+
tools={tools}
|
|
119
|
+
selectedTool={selectedTool}
|
|
120
|
+
onSelectTool={setSelectedTool}
|
|
121
|
+
toolArgs={toolArgs}
|
|
122
|
+
onToolArgsChange={setToolArgs}
|
|
123
|
+
toolResult={toolResult}
|
|
124
|
+
onCallTool={handleCallTool}
|
|
125
|
+
loading={loading}
|
|
126
|
+
toolsLoading={toolsLoading}
|
|
127
|
+
toolsLoaded={toolsLoaded}
|
|
128
|
+
serverStatus={serverStatus}
|
|
129
|
+
error={error}
|
|
130
|
+
onRefresh={loadTools}
|
|
131
|
+
/>
|
|
132
|
+
)}
|
|
133
|
+
{activeSection === 'prompts' && (
|
|
134
|
+
<PromptsSection
|
|
135
|
+
prompts={prompts}
|
|
136
|
+
selectedPrompt={selectedPrompt}
|
|
137
|
+
onSelectPrompt={setSelectedPrompt}
|
|
138
|
+
promptArgs={promptArgs}
|
|
139
|
+
onPromptArgsChange={setPromptArgs}
|
|
140
|
+
promptResult={promptResult}
|
|
141
|
+
onGetPrompt={handleGetPrompt}
|
|
142
|
+
loading={loading}
|
|
143
|
+
promptsLoading={promptsLoading}
|
|
144
|
+
promptsLoaded={promptsLoaded}
|
|
145
|
+
serverStatus={serverStatus}
|
|
146
|
+
error={error}
|
|
147
|
+
onRefresh={loadPrompts}
|
|
148
|
+
/>
|
|
149
|
+
)}
|
|
150
|
+
{activeSection === 'resources' && (
|
|
151
|
+
<ResourcesSection
|
|
152
|
+
resources={resources}
|
|
153
|
+
selectedResource={selectedResource}
|
|
154
|
+
onSelectResource={setSelectedResource}
|
|
155
|
+
resourceResult={resourceResult}
|
|
156
|
+
onReadResource={handleReadResource}
|
|
157
|
+
loading={loading}
|
|
158
|
+
resourcesLoading={resourcesLoading}
|
|
159
|
+
resourcesLoaded={resourcesLoaded}
|
|
160
|
+
serverStatus={serverStatus}
|
|
161
|
+
error={error}
|
|
162
|
+
onRefresh={loadResources}
|
|
163
|
+
/>
|
|
164
|
+
)}
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
</>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export default McpPlayground;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { colors, fonts, withOpacity } from '../theme';
|
|
2
|
+
|
|
3
|
+
function MessageDisplay({ message, error }) {
|
|
4
|
+
if (!message && !error) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<div
|
|
10
|
+
style={{
|
|
11
|
+
marginBottom: '20px',
|
|
12
|
+
padding: '12px 16px',
|
|
13
|
+
background: message ? withOpacity(colors.info, 0.15) : withOpacity(colors.error, 0.15),
|
|
14
|
+
border: `1px solid ${message ? colors.info : colors.error}`,
|
|
15
|
+
borderRadius: '8px',
|
|
16
|
+
color: message ? colors.textPrimary : colors.error,
|
|
17
|
+
fontSize: '13px',
|
|
18
|
+
lineHeight: '1.6',
|
|
19
|
+
fontFamily: fonts.body,
|
|
20
|
+
boxShadow: `0 2px 4px ${colors.shadowSm}`,
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
{message || error}
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default MessageDisplay;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { colors, fonts } from '../theme';
|
|
2
|
+
import { IconX } from '@tabler/icons-react';
|
|
3
|
+
|
|
4
|
+
function PacketDetailHeader({ request, onClose, matchingPair }) {
|
|
5
|
+
const formatBytes = (bytes) => {
|
|
6
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
7
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)} KB`;
|
|
8
|
+
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
style={{
|
|
14
|
+
padding: '12px 16px',
|
|
15
|
+
borderBottom: `1px solid ${colors.borderLight}`,
|
|
16
|
+
display: 'flex',
|
|
17
|
+
justifyContent: 'space-between',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
background: colors.bgCard,
|
|
20
|
+
boxShadow: `0 1px 3px ${colors.shadowSm}`,
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
|
|
24
|
+
<h3
|
|
25
|
+
style={{
|
|
26
|
+
fontSize: '14px',
|
|
27
|
+
fontWeight: '600',
|
|
28
|
+
color: colors.textPrimary,
|
|
29
|
+
margin: 0,
|
|
30
|
+
fontFamily: fonts.body,
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
#{request.frame_number}:{' '}
|
|
34
|
+
{request.direction === 'request' ? 'HTTP Request' : 'HTTP Response'}
|
|
35
|
+
{matchingPair && (
|
|
36
|
+
<span
|
|
37
|
+
style={{
|
|
38
|
+
fontSize: '11px',
|
|
39
|
+
color: colors.textTertiary,
|
|
40
|
+
fontWeight: '400',
|
|
41
|
+
marginLeft: '8px',
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
(with #{matchingPair.frame_number})
|
|
45
|
+
</span>
|
|
46
|
+
)}
|
|
47
|
+
</h3>
|
|
48
|
+
<span
|
|
49
|
+
style={{
|
|
50
|
+
fontSize: '11px',
|
|
51
|
+
color: colors.textSecondary,
|
|
52
|
+
padding: '4px 8px',
|
|
53
|
+
background: colors.bgSecondary,
|
|
54
|
+
borderRadius: '8px',
|
|
55
|
+
fontFamily: fonts.mono,
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
{formatBytes(request.length)} bytes
|
|
59
|
+
</span>
|
|
60
|
+
</div>
|
|
61
|
+
<button
|
|
62
|
+
onClick={onClose}
|
|
63
|
+
style={{
|
|
64
|
+
background: 'none',
|
|
65
|
+
border: 'none',
|
|
66
|
+
color: colors.textSecondary,
|
|
67
|
+
cursor: 'pointer',
|
|
68
|
+
fontSize: '20px',
|
|
69
|
+
padding: '4px 8px',
|
|
70
|
+
borderRadius: '8px',
|
|
71
|
+
transition: 'all 0.2s',
|
|
72
|
+
}}
|
|
73
|
+
onMouseEnter={(e) => {
|
|
74
|
+
e.currentTarget.style.background = colors.bgHover;
|
|
75
|
+
e.currentTarget.style.color = colors.textPrimary;
|
|
76
|
+
}}
|
|
77
|
+
onMouseLeave={(e) => {
|
|
78
|
+
e.currentTarget.style.background = 'none';
|
|
79
|
+
e.currentTarget.style.color = colors.textSecondary;
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
<IconX size={20} stroke={1.5} />
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default PacketDetailHeader;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { colors, fonts } from '../../theme';
|
|
2
|
+
import { IconDownload } from '@tabler/icons-react';
|
|
3
|
+
import anime from 'animejs';
|
|
4
|
+
|
|
5
|
+
export default function ExportControls({ stats, onExport }) {
|
|
6
|
+
return (
|
|
7
|
+
<div style={{ display: 'flex', gap: '16px', alignItems: 'center', marginLeft: 'auto' }}>
|
|
8
|
+
{stats && (
|
|
9
|
+
<>
|
|
10
|
+
<span style={{ color: colors.textSecondary, fontSize: '12px', fontFamily: fonts.body }}>
|
|
11
|
+
Total:{' '}
|
|
12
|
+
<span style={{ color: colors.textPrimary, fontWeight: '500' }}>
|
|
13
|
+
{stats.total_packets || 0}
|
|
14
|
+
</span>
|
|
15
|
+
</span>
|
|
16
|
+
<span style={{ color: colors.textSecondary, fontSize: '12px', fontFamily: fonts.body }}>
|
|
17
|
+
Requests:{' '}
|
|
18
|
+
<span style={{ color: colors.accentBlue, fontWeight: '500' }}>
|
|
19
|
+
{stats.total_requests || 0}
|
|
20
|
+
</span>
|
|
21
|
+
</span>
|
|
22
|
+
<span style={{ color: colors.textSecondary, fontSize: '12px', fontFamily: fonts.body }}>
|
|
23
|
+
Responses:{' '}
|
|
24
|
+
<span style={{ color: colors.accentGreen, fontWeight: '500' }}>
|
|
25
|
+
{stats.total_responses || 0}
|
|
26
|
+
</span>
|
|
27
|
+
</span>
|
|
28
|
+
<span style={{ color: colors.textSecondary, fontSize: '12px', fontFamily: fonts.body }}>
|
|
29
|
+
Errors:{' '}
|
|
30
|
+
<span style={{ color: colors.error, fontWeight: '500' }}>
|
|
31
|
+
{stats.total_errors || 0}
|
|
32
|
+
</span>
|
|
33
|
+
</span>
|
|
34
|
+
<span style={{ color: colors.textSecondary, fontSize: '12px', fontFamily: fonts.body }}>
|
|
35
|
+
Sessions:{' '}
|
|
36
|
+
<span style={{ color: colors.textPrimary, fontWeight: '500' }}>
|
|
37
|
+
{stats.unique_sessions || 0}
|
|
38
|
+
</span>
|
|
39
|
+
</span>
|
|
40
|
+
</>
|
|
41
|
+
)}
|
|
42
|
+
<div
|
|
43
|
+
style={{
|
|
44
|
+
display: 'flex',
|
|
45
|
+
gap: '6px',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
marginLeft: '12px',
|
|
48
|
+
paddingLeft: '12px',
|
|
49
|
+
borderLeft: `1px solid ${colors.borderLight}`,
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<button
|
|
53
|
+
onClick={() => onExport('json')}
|
|
54
|
+
style={{
|
|
55
|
+
padding: '8px 14px',
|
|
56
|
+
background: colors.buttonPrimary,
|
|
57
|
+
border: 'none',
|
|
58
|
+
color: colors.textInverse,
|
|
59
|
+
fontSize: '12px',
|
|
60
|
+
fontFamily: fonts.body,
|
|
61
|
+
fontWeight: '500',
|
|
62
|
+
borderRadius: '8px',
|
|
63
|
+
cursor: 'pointer',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
gap: '6px',
|
|
67
|
+
transition: 'all 0.2s',
|
|
68
|
+
boxShadow: `0 2px 4px ${colors.shadowSm}`,
|
|
69
|
+
}}
|
|
70
|
+
onMouseEnter={(e) => {
|
|
71
|
+
anime({
|
|
72
|
+
targets: e.currentTarget,
|
|
73
|
+
background: colors.buttonPrimaryHover,
|
|
74
|
+
translateY: -1,
|
|
75
|
+
boxShadow: [`0 2px 4px ${colors.shadowSm}`, `0 4px 8px ${colors.shadowMd}`],
|
|
76
|
+
duration: 200,
|
|
77
|
+
easing: 'easeOutQuad',
|
|
78
|
+
});
|
|
79
|
+
}}
|
|
80
|
+
onMouseLeave={(e) => {
|
|
81
|
+
anime({
|
|
82
|
+
targets: e.currentTarget,
|
|
83
|
+
background: colors.buttonPrimary,
|
|
84
|
+
translateY: 0,
|
|
85
|
+
boxShadow: [`0 4px 8px ${colors.shadowMd}`, `0 2px 4px ${colors.shadowSm}`],
|
|
86
|
+
duration: 200,
|
|
87
|
+
easing: 'easeOutQuad',
|
|
88
|
+
});
|
|
89
|
+
}}
|
|
90
|
+
title="Export as JSON"
|
|
91
|
+
>
|
|
92
|
+
<IconDownload size={14} stroke={1.5} />
|
|
93
|
+
Export
|
|
94
|
+
</button>
|
|
95
|
+
<select
|
|
96
|
+
onChange={(e) => onExport(e.target.value)}
|
|
97
|
+
value=""
|
|
98
|
+
style={{
|
|
99
|
+
padding: '8px 10px',
|
|
100
|
+
background: colors.bgCard,
|
|
101
|
+
border: `1px solid ${colors.borderLight}`,
|
|
102
|
+
color: colors.textPrimary,
|
|
103
|
+
fontSize: '11px',
|
|
104
|
+
fontFamily: fonts.body,
|
|
105
|
+
borderRadius: '8px',
|
|
106
|
+
cursor: 'pointer',
|
|
107
|
+
transition: 'all 0.2s',
|
|
108
|
+
}}
|
|
109
|
+
onFocus={(e) => {
|
|
110
|
+
e.currentTarget.style.borderColor = colors.accentBlue;
|
|
111
|
+
}}
|
|
112
|
+
onBlur={(e) => {
|
|
113
|
+
e.currentTarget.style.borderColor = colors.borderLight;
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
<option value="" disabled>
|
|
117
|
+
Format
|
|
118
|
+
</option>
|
|
119
|
+
<option value="json">JSON</option>
|
|
120
|
+
<option value="csv">CSV</option>
|
|
121
|
+
<option value="txt">TXT</option>
|
|
122
|
+
</select>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|