Skip auth if there's a valid lockfile and saved tokens

This commit is contained in:
Emilis Baliukonis 2025-04-25 16:46:53 +03:00
parent 504aa26761
commit 28b2e65214
3 changed files with 12 additions and 7 deletions

View file

@ -25,9 +25,6 @@ async function runProxy(serverUrl: string, callbackPort: number, headers: Record
// Get the server URL hash for lockfile operations
const serverUrlHash = getServerUrlHash(serverUrl)
// Coordinate authentication with other instances
const { server, waitForAuthCode, skipBrowserAuth } = await coordinateAuth(serverUrlHash, callbackPort, events)
// Create the OAuth client provider
const authProvider = new NodeOAuthClientProvider({
serverUrl,
@ -35,6 +32,10 @@ async function runProxy(serverUrl: string, callbackPort: number, headers: Record
clientName: 'MCP CLI Proxy',
})
// Coordinate authentication with other instances
const hasSavedTokens = !!(await authProvider.tokens())
const { server, waitForAuthCode, skipBrowserAuth } = await coordinateAuth(serverUrlHash, callbackPort, events, hasSavedTokens)
// If auth was completed by another instance, just log that we'll use the auth from disk
if (skipBrowserAuth) {
log('Authentication was completed by another instance - will use tokens from disk')