fix: add diagnostic logging to MCP OAuth probing

Add [aryx oauth] log messages throughout the proactive auth flow so
failures are visible in the Electron main process console (DevTools →
Main Process or terminal output). Logs cover: probe start, HTTP status,
PRM discovery, token skip, flow start, and success/failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-27 19:31:03 +01:00
co-authored by Copilot
parent f0c2b4982b
commit 4f1ae86021
2 changed files with 27 additions and 5 deletions
+9 -2
View File
@@ -27,22 +27,29 @@ export interface McpOAuthFlowResult {
*/
export async function requiresOAuth(serverUrl: string): Promise<boolean> {
try {
console.log(`[aryx oauth] Probing ${serverUrl} for OAuth requirements…`);
const response = await fetch(serverUrl, {
method: 'GET',
signal: AbortSignal.timeout(5_000),
});
console.log(`[aryx oauth] Probe ${serverUrl} returned ${response.status}`);
if (response.status !== 401) {
return false;
}
const base = serverUrl.replace(/\/+$/, '');
const prmResponse = await fetch(`${base}/.well-known/oauth-protected-resource`, {
const prmUrl = `${base}/.well-known/oauth-protected-resource`;
console.log(`[aryx oauth] Checking PRM at ${prmUrl}`);
const prmResponse = await fetch(prmUrl, {
signal: AbortSignal.timeout(5_000),
});
console.log(`[aryx oauth] PRM response: ${prmResponse.status}`);
return prmResponse.ok;
} catch {
} catch (err) {
console.warn(`[aryx oauth] Probe failed for ${serverUrl}:`, err instanceof Error ? err.message : err);
return false;
}
}