-
-
Notifications
You must be signed in to change notification settings - Fork 199
feat(client): add JSON-RPC log export functionality #1462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
251b193
79bce95
dcf21d8
37a906a
01fc037
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { | |
| Trash2, | ||
| PanelRightClose, | ||
| Copy, | ||
| Download, | ||
| } from "lucide-react"; | ||
| import { JsonEditor } from "@/components/ui/json-editor"; | ||
| import { Input } from "@/components/ui/input"; | ||
|
|
@@ -45,6 +46,7 @@ import { cn } from "@/lib/utils"; | |
|
|
||
| type RpcDirection = "in" | "out" | string; | ||
| type TrafficSource = "mcp-server" | "mcp-apps"; | ||
| type LogEntrySnapshot = Omit<RenderableRpcItem, 'id'>; | ||
|
|
||
| interface RpcEventMessage { | ||
| serverId: string; | ||
|
|
@@ -206,16 +208,43 @@ export function LoggerView({ | |
| setExpanded(new Set()); | ||
| }; | ||
|
|
||
| const copyLogs = async () => { | ||
| const logs = filteredItems.map((item) => ({ | ||
| const extractLogs = (): Array<LogEntrySnapshot> => { | ||
| return filteredItems.map((item) => ({ | ||
| timestamp: item.timestamp, | ||
| source: item.source, | ||
| serverId: item.serverId, | ||
| direction: item.direction, | ||
| method: item.method, | ||
| payload: item.payload, | ||
| ...(item.protocol && { protocol: item.protocol }), | ||
| ...(item.widgetId && { widgetId: item.widgetId }), | ||
| })); | ||
| }; | ||
|
|
||
| const exportLogs = () => { | ||
| try { | ||
| const logs = extractLogs(); | ||
|
|
||
| const blob = new Blob([JSON.stringify(logs, null, 2)], { | ||
| type: "application/json", | ||
| }); | ||
| const url = URL.createObjectURL(blob); | ||
| const a = document.createElement("a"); | ||
| a.href = url; | ||
| a.download = `mcp-logs-${new Date().toISOString()}.json`; | ||
| document.body.appendChild(a); | ||
| a.click(); | ||
| document.body.removeChild(a); | ||
| URL.revokeObjectURL(url); | ||
| toast.success("Logs exported"); | ||
| } catch { | ||
| toast.error("Failed to export logs"); | ||
| } | ||
| }; | ||
|
|
||
| const copyLogs = async () => { | ||
| try { | ||
| const logs = extractLogs(); | ||
| await navigator.clipboard.writeText(JSON.stringify(logs, null, 2)); | ||
| toast.success("Logs copied to clipboard"); | ||
| } catch { | ||
|
|
@@ -415,6 +444,16 @@ export function LoggerView({ | |
| {/* Push action buttons to the right when search is hidden */} | ||
| {!isSearchVisible && <div className="flex-1" />} | ||
|
|
||
| <Button | ||
| variant="ghost" | ||
| size="icon" | ||
| onClick={exportLogs} | ||
| disabled={filteredItemCount === 0} | ||
| className="h-7 w-7" | ||
| title="Export logs" | ||
| > | ||
| <Download className="h-3.5 w-3.5" /> | ||
| </Button> | ||
| <Button | ||
| variant="ghost" | ||
| size="icon" | ||
|
|
@@ -544,4 +583,4 @@ export function LoggerView({ | |
| ); | ||
| } | ||
|
|
||
| export default LoggerView; | ||
| export default LoggerView; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Search for all imports of LoggerView to determine usage pattern
rg "import\s+(\{.*\s+)?LoggerView" --type ts --type tsx -B 1 -A 1Repository: MCPJam/inspector Length of output: 87 🏁 Script executed: # Also search for default imports without destructuring
rg "import\s+LoggerView\s+from" --type ts --type tsx -B 1 -A 1Repository: MCPJam/inspector Length of output: 87 🏁 Script executed: # Search for LoggerView imports using glob patterns
rg "import.*LoggerView" -g "*.ts" -g "*.tsx" -B 1 -A 1Repository: MCPJam/inspector Length of output: 2116 🏁 Script executed: # Specifically search for default imports (import LoggerView from)
rg "import\s+LoggerView\s+from" -g "*.ts" -g "*.tsx" -B 1 -A 1Repository: MCPJam/inspector Length of output: 42 🏁 Script executed: # List the logger-view file to understand its exports
cat -n mcpjam-inspector/client/src/components/logger-view.tsx | grep -E "export|LoggerView" | head -20Repository: MCPJam/inspector Length of output: 368 Remove the unused default export.
🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Export button is missing
flex-shrink-0— inconsistent with its siblings.All adjacent buttons (Copy, Clear, Close) carry
flex-shrink-0; the Export button does not, so it could compress under a narrow toolbar while they stay fixed.🛠️ One-liner fix
<Button variant="ghost" size="icon" onClick={exportLogs} disabled={filteredItemCount === 0} - className="h-7 w-7" + className="h-7 w-7 flex-shrink-0" title="Export logs" >🤖 Prompt for AI Agents