mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-25 22:18:40 +02:00
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:
@@ -944,18 +944,33 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
|
||||
.filter((s): s is McpServerDefinition => !!s && s.transport !== 'local')
|
||||
.filter((s) => s.transport === 'http' || s.transport === 'sse');
|
||||
|
||||
if (httpServers.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[aryx oauth] Probing ${httpServers.length} HTTP MCP server(s) for OAuth requirements…`);
|
||||
|
||||
for (const server of httpServers) {
|
||||
if (server.transport === 'local') continue;
|
||||
const existingToken = getStoredToken(server.url);
|
||||
if (existingToken) continue;
|
||||
if (existingToken) {
|
||||
console.log(`[aryx oauth] Skipping ${server.name} — token already stored`);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
const needsAuth = await requiresOAuth(server.url);
|
||||
if (!needsAuth) continue;
|
||||
if (!needsAuth) {
|
||||
console.log(`[aryx oauth] ${server.name} does not require OAuth`);
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(`[aryx oauth] ${server.name} requires OAuth — starting flow…`);
|
||||
const result = await performMcpOAuthFlow({ serverUrl: server.url });
|
||||
|
||||
if (!result.success) {
|
||||
if (result.success) {
|
||||
console.log(`[aryx oauth] ${server.name} authenticated successfully`);
|
||||
} else {
|
||||
console.warn(`[aryx oauth] Proactive auth failed for ${server.name}: ${result.error}`);
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user