Merge pull request #706 from cliffhall/add-toast-for-misconfigured-logging

Add toast for misconfigured logging
This commit is contained in:
Ola Hungerford 2025-08-12 13:07:11 -07:00 • committed by GitHub
commit e36f8808e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -351,6 +351,7 @@ export function useConnection({
return; return;
} }
let lastRequest = "";
try { try {
// Inject auth manually instead of using SSEClientTransport, because we're // Inject auth manually instead of using SSEClientTransport, because we're
// proxying through the inspector server first. // proxying through the inspector server first.
@ -564,7 +565,9 @@ export function useConnection({
} }
if (capabilities?.logging && defaultLoggingLevel) { if (capabilities?.logging && defaultLoggingLevel) {
lastRequest = "logging/setLevel";
await client.setLoggingLevel(defaultLoggingLevel); await client.setLoggingLevel(defaultLoggingLevel);
lastRequest = "";
} }
if (onElicitationRequest) { if (onElicitationRequest) {
@ -578,6 +581,17 @@ export function useConnection({
setMcpClient(client); setMcpClient(client);
setConnectionStatus("connected"); setConnectionStatus("connected");
} catch (e) { } catch (e) {
if (
lastRequest === "logging/setLevel" &&
e instanceof McpError &&
e.code === ErrorCode.MethodNotFound
) {
toast({
title: "Error",
description: `Server declares logging capability but doesn't implement method: "${lastRequest}"`,
variant: "destructive",
});
}
console.error(e); console.error(e);
setConnectionStatus("error"); setConnectionStatus("error");
} }