mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
* refactor(mcp): simplify registry to two-repository architecture with explicit storage
* Chore: address AI Review comments
* Simplify MCP config cache architecture and remove legacy code:
Follow-up cleanup to commit d2bfdd033 which refactored MCP registry to two-repository architecture. This removes leftover legacy abstractions that were no longer used.
What changed:
- Simplified ServerConfigsCacheFactory.create() from 3 params to 2 (namespace, leaderOnly)
- Removed unused scope: 'Shared' | 'Private' parameter (only 'Shared' was ever used)
- Removed dead set() and getNamespace() methods from cache classes
- Updated JSDoc to reflect two-repository architecture (Cache + DB) instead of old three-tier system
- Fixed stale mocks and comments referencing removed sharedAppServers, sharedUserServers, privateServersCache
Files changed:
- ServerConfigsCacheFactory.ts - Simplified factory signature
- ServerConfigsCacheRedis.ts - Removed scope, renamed owner→namespace
- ServerConfigsCacheInMemory.ts - Removed unused methods
- MCPServersRegistry.ts - Updated JSDoc, simplified factory call
- RegistryStatusCache.ts - Removed stale JSDoc reference
- MCPManager.test.ts - Fixed legacy mock
- ServerConfigsCacheFactory.test.ts - Updated test assertions
* fix: Update error message in MCPServersRegistry for clarity
---------
Co-authored-by: Atef Bellaaj <slalom.bellaaj@external.daimlertruck.com>
Co-authored-by: Danny Avila <danny@librechat.ai>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { standardCache } from '~/cache';
|
|
import { BaseRegistryCache } from './BaseRegistryCache';
|
|
|
|
// Status keys
|
|
const INITIALIZED = 'INITIALIZED';
|
|
|
|
/**
|
|
* Cache for tracking MCP Servers Registry global metadata and status across distributed instances.
|
|
* Uses Redis-backed storage to coordinate state between leader and follower nodes.
|
|
* Tracks global initialization status for the registry.
|
|
*
|
|
* Designed to be extended with additional global registry metadata as needed
|
|
* (e.g., last update timestamps, version info, health status).
|
|
* This cache is only meant to be used internally by registry management components.
|
|
*/
|
|
class RegistryStatusCache extends BaseRegistryCache {
|
|
protected readonly cache = standardCache(`${this.PREFIX}::Status`);
|
|
|
|
public async isInitialized(): Promise<boolean> {
|
|
return (await this.get(INITIALIZED)) === true;
|
|
}
|
|
|
|
public async setInitialized(value: boolean): Promise<void> {
|
|
await this.set(INITIALIZED, value);
|
|
}
|
|
|
|
private async get<T = unknown>(key: string): Promise<T | undefined> {
|
|
return this.cache.get(key);
|
|
}
|
|
|
|
private async set(key: string, value: string | number | boolean, ttl?: number): Promise<void> {
|
|
await this.leaderCheck('set MCP Servers Registry status');
|
|
const success = await this.cache.set(key, value, ttl);
|
|
this.successCheck(`set status key "${key}"`, success);
|
|
}
|
|
}
|
|
|
|
export const registryStatusCache = new RegistryStatusCache();
|