feat: enhance BearerKeyDaoImpl to handle migration and caching behavior for bearer keys (#507)

This commit is contained in:
samanhappy
2025-12-14 20:40:57 +08:00
committed by GitHub
parent c673afb97e
commit 1f3a6794ea
2 changed files with 101 additions and 1 deletions

View File

@@ -24,7 +24,10 @@ export class BearerKeyDaoImpl extends JsonFileBaseDao implements BearerKeyDao {
private async loadKeysWithMigration(): Promise<BearerKey[]> {
const settings = await this.loadSettings();
if (Array.isArray(settings.bearerKeys) && settings.bearerKeys.length > 0) {
// Treat an existing array (including an empty array) as already migrated.
// Otherwise, when there are no configured keys, we'd rewrite mcp_settings.json
// on every request, which also clears the global settings cache.
if (Array.isArray(settings.bearerKeys)) {
return settings.bearerKeys;
}