Merge branch 'main' into fix-env-var-parsing
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
|||||||
Root,
|
Root,
|
||||||
ServerNotification,
|
ServerNotification,
|
||||||
Tool,
|
Tool,
|
||||||
|
LoggingLevel,
|
||||||
} from "@modelcontextprotocol/sdk/types.js";
|
} from "@modelcontextprotocol/sdk/types.js";
|
||||||
import React, { Suspense, useEffect, useRef, useState } from "react";
|
import React, { Suspense, useEffect, useRef, useState } from "react";
|
||||||
import { useConnection } from "./lib/hooks/useConnection";
|
import { useConnection } from "./lib/hooks/useConnection";
|
||||||
@@ -91,6 +92,7 @@ const App = () => {
|
|||||||
(localStorage.getItem("lastTransportType") as "stdio" | "sse") || "stdio"
|
(localStorage.getItem("lastTransportType") as "stdio" | "sse") || "stdio"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
const [logLevel, setLogLevel] = useState<LoggingLevel>("debug");
|
||||||
const [notifications, setNotifications] = useState<ServerNotification[]>([]);
|
const [notifications, setNotifications] = useState<ServerNotification[]>([]);
|
||||||
const [stdErrNotifications, setStdErrNotifications] = useState<
|
const [stdErrNotifications, setStdErrNotifications] = useState<
|
||||||
StdErrNotification[]
|
StdErrNotification[]
|
||||||
@@ -412,6 +414,17 @@ const App = () => {
|
|||||||
await sendNotification({ method: "notifications/roots/list_changed" });
|
await sendNotification({ method: "notifications/roots/list_changed" });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const sendLogLevelRequest = async (level: LoggingLevel) => {
|
||||||
|
await makeRequest(
|
||||||
|
{
|
||||||
|
method: "logging/setLevel" as const,
|
||||||
|
params: { level },
|
||||||
|
},
|
||||||
|
z.object({}),
|
||||||
|
);
|
||||||
|
setLogLevel(level);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen bg-background">
|
<div className="flex h-screen bg-background">
|
||||||
<Sidebar
|
<Sidebar
|
||||||
@@ -430,6 +443,9 @@ const App = () => {
|
|||||||
setBearerToken={setBearerToken}
|
setBearerToken={setBearerToken}
|
||||||
onConnect={connectMcpServer}
|
onConnect={connectMcpServer}
|
||||||
stdErrNotifications={stdErrNotifications}
|
stdErrNotifications={stdErrNotifications}
|
||||||
|
logLevel={logLevel}
|
||||||
|
sendLogLevelRequest={sendLogLevelRequest}
|
||||||
|
loggingSupported={!!serverCapabilities?.logging || false}
|
||||||
/>
|
/>
|
||||||
<div className="flex-1 flex flex-col overflow-hidden">
|
<div className="flex-1 flex flex-col overflow-hidden">
|
||||||
<div className="flex-1 overflow-auto">
|
<div className="flex-1 overflow-auto">
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ import {
|
|||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { StdErrNotification } from "@/lib/notificationTypes";
|
import { StdErrNotification } from "@/lib/notificationTypes";
|
||||||
|
import {
|
||||||
|
LoggingLevel,
|
||||||
|
LoggingLevelSchema,
|
||||||
|
} from "@modelcontextprotocol/sdk/types.js";
|
||||||
|
|
||||||
import useTheme from "../lib/useTheme";
|
import useTheme from "../lib/useTheme";
|
||||||
import { version } from "../../../package.json";
|
import { version } from "../../../package.json";
|
||||||
@@ -39,6 +43,9 @@ interface SidebarProps {
|
|||||||
setBearerToken: (token: string) => void;
|
setBearerToken: (token: string) => void;
|
||||||
onConnect: () => void;
|
onConnect: () => void;
|
||||||
stdErrNotifications: StdErrNotification[];
|
stdErrNotifications: StdErrNotification[];
|
||||||
|
logLevel: LoggingLevel;
|
||||||
|
sendLogLevelRequest: (level: LoggingLevel) => void;
|
||||||
|
loggingSupported: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Sidebar = ({
|
const Sidebar = ({
|
||||||
@@ -57,6 +64,9 @@ const Sidebar = ({
|
|||||||
setBearerToken,
|
setBearerToken,
|
||||||
onConnect,
|
onConnect,
|
||||||
stdErrNotifications,
|
stdErrNotifications,
|
||||||
|
logLevel,
|
||||||
|
sendLogLevelRequest,
|
||||||
|
loggingSupported,
|
||||||
}: SidebarProps) => {
|
}: SidebarProps) => {
|
||||||
const [theme, setTheme] = useTheme();
|
const [theme, setTheme] = useTheme();
|
||||||
const [showEnvVars, setShowEnvVars] = useState(false);
|
const [showEnvVars, setShowEnvVars] = useState(false);
|
||||||
@@ -290,6 +300,28 @@ const Sidebar = ({
|
|||||||
: "Disconnected"}
|
: "Disconnected"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{loggingSupported && connectionStatus === "connected" && (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium">Logging Level</label>
|
||||||
|
<Select
|
||||||
|
value={logLevel}
|
||||||
|
onValueChange={(value: LoggingLevel) =>
|
||||||
|
sendLogLevelRequest(value)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select logging level" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{Object.values(LoggingLevelSchema.enum).map((level) => (
|
||||||
|
<SelectItem value={level}>{level}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{stdErrNotifications.length > 0 && (
|
{stdErrNotifications.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className="mt-4 border-t border-gray-200 pt-4">
|
<div className="mt-4 border-t border-gray-200 pt-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user