(serverId: string)
| 291 | let writeChain = Promise.resolve() |
| 292 | |
| 293 | function setMcpAuthCacheEntry(serverId: string): void { |
| 294 | writeChain = writeChain |
| 295 | .then(async () => { |
| 296 | const cache = await getMcpAuthCache() |
| 297 | cache[serverId] = { timestamp: Date.now() } |
| 298 | const cachePath = getMcpAuthCachePath() |
| 299 | await mkdir(dirname(cachePath), { recursive: true }) |
| 300 | await writeFile(cachePath, jsonStringify(cache)) |
| 301 | // Invalidate the read cache so subsequent reads see the new entry. |
| 302 | // Safe because writeChain serializes writes: the next write's |
| 303 | // getMcpAuthCache() call will re-read the file with this entry present. |
| 304 | authCachePromise = null |
| 305 | }) |
| 306 | .catch(() => { |
| 307 | // Best-effort cache write |
| 308 | }) |
| 309 | } |
| 310 | |
| 311 | export function clearMcpAuthCache(): void { |
| 312 | authCachePromise = null |
no test coverage detected