mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
Some checks failed
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Has been cancelled
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been cancelled
* refactor: Restructure MCP registry system with caching - Split MCPServersRegistry into modular components: - MCPServerInspector: handles server inspection and health checks - MCPServersInitializer: manages server initialization logic - MCPServersRegistry: simplified registry coordination - Add distributed caching layer: - ServerConfigsCacheRedis: Redis-backed configuration cache - ServerConfigsCacheInMemory: in-memory fallback cache - RegistryStatusCache: distributed leader election state - Add promise utilities (withTimeout) replacing Promise.race patterns - Add comprehensive cache integration tests for all cache implementations - Remove unused MCPManager.getAllToolFunctions method * fix: Update OAuth flow to include user-specific headers * chore: Update Jest configuration to ignore additional test files - Added patterns to ignore files ending with .helper.ts and .helper.d.ts in testPathIgnorePatterns for cleaner test runs. * fix: oauth headers in callback * chore: Update Jest testPathIgnorePatterns to exclude helper files - Modified testPathIgnorePatterns in package.json to ignore files ending with .helper.ts and .helper.d.ts for cleaner test execution. * ci: update test mocks --------- Co-authored-by: Danny Avila <danny@librechat.ai>
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { standardCache } from '~/cache';
|
|
import { BaseRegistryCache } from './BaseRegistryCache';
|
|
|
|
// Status keys
|
|
const INITIALIZED = 'INITIALIZED';
|
|
|
|
/**
|
|
* Cache for tracking MCP Servers Registry metadata and status across distributed instances.
|
|
* Uses Redis-backed storage to coordinate state between leader and follower nodes.
|
|
* Currently, tracks initialization status to ensure only the leader performs initialization
|
|
* while followers wait for completion. Designed to be extended with additional 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();
|