Skip to content

Commit 74d0fcf

Browse files
authored
Merge branch 'main' into fix-env-var-parsing
2 parents 20db043 + de87951 commit 74d0fcf

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

client/src/App.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Root,
1616
ServerNotification,
1717
Tool,
18+
LoggingLevel,
1819
} from "@modelcontextprotocol/sdk/types.js";
1920
import React, { Suspense, useEffect, useRef, useState } from "react";
2021
import { useConnection } from "./lib/hooks/useConnection";
@@ -91,6 +92,7 @@ const App = () => {
9192
(localStorage.getItem("lastTransportType") as "stdio" | "sse") || "stdio"
9293
);
9394
});
95+
const [logLevel, setLogLevel] = useState<LoggingLevel>("debug");
9496
const [notifications, setNotifications] = useState<ServerNotification[]>([]);
9597
const [stdErrNotifications, setStdErrNotifications] = useState<
9698
StdErrNotification[]
@@ -412,6 +414,17 @@ const App = () => {
412414
await sendNotification({ method: "notifications/roots/list_changed" });
413415
};
414416

417+
const sendLogLevelRequest = async (level: LoggingLevel) => {
418+
await makeRequest(
419+
{
420+
method: "logging/setLevel" as const,
421+
params: { level },
422+
},
423+
z.object({}),
424+
);
425+
setLogLevel(level);
426+
};
427+
415428
return (
416429
<div className="flex h-screen bg-background">
417430
<Sidebar
@@ -430,6 +443,9 @@ const App = () => {
430443
setBearerToken={setBearerToken}
431444
onConnect={connectMcpServer}
432445
stdErrNotifications={stdErrNotifications}
446+
logLevel={logLevel}
447+
sendLogLevelRequest={sendLogLevelRequest}
448+
loggingSupported={!!serverCapabilities?.logging || false}
433449
/>
434450
<div className="flex-1 flex flex-col overflow-hidden">
435451
<div className="flex-1 overflow-auto">

client/src/components/Sidebar.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import {
1919
SelectValue,
2020
} from "@/components/ui/select";
2121
import { StdErrNotification } from "@/lib/notificationTypes";
22+
import {
23+
LoggingLevel,
24+
LoggingLevelSchema,
25+
} from "@modelcontextprotocol/sdk/types.js";
2226

2327
import useTheme from "../lib/useTheme";
2428
import { version } from "../../../package.json";
@@ -39,6 +43,9 @@ interface SidebarProps {
3943
setBearerToken: (token: string) => void;
4044
onConnect: () => void;
4145
stdErrNotifications: StdErrNotification[];
46+
logLevel: LoggingLevel;
47+
sendLogLevelRequest: (level: LoggingLevel) => void;
48+
loggingSupported: boolean;
4249
}
4350

4451
const Sidebar = ({
@@ -57,6 +64,9 @@ const Sidebar = ({
5764
setBearerToken,
5865
onConnect,
5966
stdErrNotifications,
67+
logLevel,
68+
sendLogLevelRequest,
69+
loggingSupported,
6070
}: SidebarProps) => {
6171
const [theme, setTheme] = useTheme();
6272
const [showEnvVars, setShowEnvVars] = useState(false);
@@ -290,6 +300,28 @@ const Sidebar = ({
290300
: "Disconnected"}
291301
</span>
292302
</div>
303+
304+
{loggingSupported && connectionStatus === "connected" && (
305+
<div className="space-y-2">
306+
<label className="text-sm font-medium">Logging Level</label>
307+
<Select
308+
value={logLevel}
309+
onValueChange={(value: LoggingLevel) =>
310+
sendLogLevelRequest(value)
311+
}
312+
>
313+
<SelectTrigger>
314+
<SelectValue placeholder="Select logging level" />
315+
</SelectTrigger>
316+
<SelectContent>
317+
{Object.values(LoggingLevelSchema.enum).map((level) => (
318+
<SelectItem value={level}>{level}</SelectItem>
319+
))}
320+
</SelectContent>
321+
</Select>
322+
</div>
323+
)}
324+
293325
{stdErrNotifications.length > 0 && (
294326
<>
295327
<div className="mt-4 border-t border-gray-200 pt-4">

0 commit comments

Comments
 (0)