fix(mcp): scope auth status to server URL (#33924)
This commit is contained in:
@@ -963,10 +963,15 @@ export const layer = Layer.effect(
|
||||
})
|
||||
|
||||
const getAuthStatus = Effect.fn("MCP.getAuthStatus")(function* (mcpName: string) {
|
||||
const entry = yield* auth.get(mcpName)
|
||||
const runtimeConfig = (yield* InstanceState.has(state))
|
||||
? (yield* InstanceState.get(state)).config[mcpName]
|
||||
: undefined
|
||||
const mcpConfig = runtimeConfig ?? (yield* cfgSvc.get()).mcp?.[mcpName]
|
||||
if (!mcpConfig || !isMcpConfigured(mcpConfig) || mcpConfig.type !== "remote") return "not_authenticated"
|
||||
const entry = yield* auth.getForUrl(mcpName, mcpConfig.url)
|
||||
if (!entry?.tokens) return "not_authenticated"
|
||||
const expired = yield* auth.isTokenExpired(mcpName)
|
||||
return expired ? "expired" : "authenticated"
|
||||
if (entry.tokens.expiresAt && entry.tokens.expiresAt < Date.now() / 1000) return "expired"
|
||||
return "authenticated"
|
||||
})
|
||||
|
||||
return Service.of({
|
||||
|
||||
Reference in New Issue
Block a user