Skip to content

Commit db1f589

Browse files
feat: display session ID and protocol version in sidebar
This commit makes the session ID and protocol version visible in the Inspector UI by: 1. Exporting mcpSessionId and mcpProtocolVersion from useConnection hook 2. Passing these values to the Sidebar component 3. Displaying them in a new section below the server information The session ID is shown with a copy-to-clipboard button for easy access. This addresses issue #1033 where users requested visibility of session IDs. Co-authored-by: Ola Hungerford <olaservo@users.noreply.github.com>
1 parent 885c8bc commit db1f589

4 files changed

Lines changed: 139 additions & 34 deletions

File tree

client/src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ const App = () => {
353353
completionsSupported,
354354
connect: connectMcpServer,
355355
disconnect: disconnectMcpServer,
356+
mcpSessionId,
357+
mcpProtocolVersion,
356358
} = useConnection({
357359
transportType,
358360
command,
@@ -1251,6 +1253,8 @@ const App = () => {
12511253
connectionType={connectionType}
12521254
setConnectionType={setConnectionType}
12531255
serverImplementation={serverImplementation}
1256+
mcpSessionId={mcpSessionId}
1257+
mcpProtocolVersion={mcpProtocolVersion}
12541258
/>
12551259
<div
12561260
onMouseDown={handleSidebarDragStart}

client/src/components/Sidebar.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ interface SidebarProps {
7676
serverImplementation?:
7777
| (WithIcons & { name?: string; version?: string; websiteUrl?: string })
7878
| null;
79+
mcpSessionId: string | null;
80+
mcpProtocolVersion: string | null;
7981
}
8082

8183
const Sidebar = ({
@@ -108,6 +110,8 @@ const Sidebar = ({
108110
connectionType,
109111
setConnectionType,
110112
serverImplementation,
113+
mcpSessionId,
114+
mcpProtocolVersion,
111115
}: SidebarProps) => {
112116
const [theme, setTheme] = useTheme();
113117
const [showEnvVars, setShowEnvVars] = useState(false);
@@ -117,6 +121,7 @@ const Sidebar = ({
117121
const [showClientSecret, setShowClientSecret] = useState(false);
118122
const [copiedServerEntry, setCopiedServerEntry] = useState(false);
119123
const [copiedServerFile, setCopiedServerFile] = useState(false);
124+
const [copiedSessionId, setCopiedSessionId] = useState(false);
120125
const { toast } = useToast();
121126

122127
const connectionTypeTip =
@@ -234,6 +239,26 @@ const Sidebar = ({
234239
}
235240
}, [generateMCPServerFile, toast, reportError]);
236241

242+
const handleCopySessionId = useCallback(() => {
243+
if (!mcpSessionId) return;
244+
245+
navigator.clipboard
246+
.writeText(mcpSessionId)
247+
.then(() => {
248+
setCopiedSessionId(true);
249+
toast({
250+
title: "Session ID copied",
251+
description: "Session ID has been copied to clipboard.",
252+
});
253+
setTimeout(() => {
254+
setCopiedSessionId(false);
255+
}, 2000);
256+
})
257+
.catch((error) => {
258+
reportError(error);
259+
});
260+
}, [mcpSessionId, toast, reportError]);
261+
237262
return (
238263
<div className="bg-card border-r border-border flex flex-col h-full">
239264
<div className="flex items-center justify-between p-4 border-b border-gray-200 dark:border-border">
@@ -821,6 +846,41 @@ const Sidebar = ({
821846
</div>
822847
)}
823848

849+
{connectionStatus === "connected" && mcpSessionId && (
850+
<div className="bg-gray-50 dark:bg-gray-900 p-3 rounded-lg mb-4">
851+
<div className="flex items-center justify-between mb-1">
852+
<span className="text-xs font-medium text-gray-600 dark:text-gray-400">
853+
Session ID
854+
</span>
855+
<Tooltip>
856+
<TooltipTrigger asChild>
857+
<Button
858+
variant="ghost"
859+
size="sm"
860+
onClick={handleCopySessionId}
861+
className="h-6 px-2"
862+
>
863+
{copiedSessionId ? (
864+
<CheckCheck className="h-3 w-3" />
865+
) : (
866+
<Copy className="h-3 w-3" />
867+
)}
868+
</Button>
869+
</TooltipTrigger>
870+
<TooltipContent>Copy Session ID</TooltipContent>
871+
</Tooltip>
872+
</div>
873+
<div className="text-xs text-gray-700 dark:text-gray-300 font-mono break-all">
874+
{mcpSessionId}
875+
</div>
876+
{mcpProtocolVersion && (
877+
<div className="text-xs text-gray-500 dark:text-gray-400 mt-1">
878+
Protocol: {mcpProtocolVersion}
879+
</div>
880+
)}
881+
</div>
882+
)}
883+
824884
{loggingSupported && connectionStatus === "connected" && (
825885
<div className="space-y-2">
826886
<label

client/src/lib/hooks/useConnection.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,5 +1217,7 @@ export function useConnection({
12171217
completionsSupported,
12181218
connect,
12191219
disconnect,
1220+
mcpSessionId,
1221+
mcpProtocolVersion,
12201222
};
12211223
}

0 commit comments

Comments
 (0)