@inso_web/els-mcp
Version:
MCP-сервер поверх INSO Error Logs Service. Read-only tools (search, analytics, fingerprinting, correlations) для подключения Claude Desktop/Code и ChatGPT к логам ошибок. Streamable HTTP transport + stdio для npx-запуска.
71 lines • 4.81 kB
TypeScript
import type { Logger } from 'pino';
import type { ElsClient } from '../elsClient.js';
import type { CacheService } from './wrapper.js';
import { type CacheClass } from './policies.js';
import type { RequestContext } from './types.js';
/**
* Кэширующая обёртка над `ElsClient`.
*
* Дизайн — **composition over inheritance**:
* - сохраняет 100% совместимую сигнатуру с ElsClient;
* - не модифицирует ElsClient (additive only);
* - `ctx` принимается опционально (по умолчанию — fallback context от config).
*
* Если cache недоступен (Redis down или disabled) — все методы прозрачно
* прокидываются в underlying `ElsClient`.
*
* Все cache keys построены через `tenantKey()` (см. `policies.ts`), что
* гарантирует tenant-isolation (cross-tenant leak guard).
*
* Какие методы кэшируем (см. `05-high-load.md` § 2.1):
*
* | Method | Class | TTL |
* |----------------------|------------------|--------|
* | getLogDetails | log_details | 1h |
* | searchLogs | search_recent | 15s |
* | topErrorMessages | top_messages | 2m |
* | errorHistogram | histogram | 1m |
* | trafficStats | traffic_long | 5m |
* | listApps | list_apps | 30s |
* | heatmap | heatmap | 5m |
* | errorStats | stats_breakdown | 2m |
* | groupedErrors | grouped_errors | 2m |
* | baseline | baseline | 5m |
* | versionRegression | version_timeline | 5m |
*
* Что НЕ кэшируем (см. § 2.4):
* - `queryLogsJql` — высокая кардинальность ключей, hit ratio < 5%.
* - `findCorrelatedErrors` — корреляция меняется при ingest.
* - `findSimilarErrors` — агрегаты "за последний час" — слишком волатильны.
*/
export declare class CachedElsClient {
private readonly inner;
private readonly cache;
private readonly policies;
private readonly _log?;
constructor(inner: ElsClient, cache: CacheService, policies?: Record<CacheClass, number>, _log?: Logger | undefined);
/** Доступ к raw client (нужен для методов без кэша). */
get raw(): ElsClient;
close(): Promise<void>;
getLogDetails(traceId: string, ctx?: RequestContext): Promise<ReturnType<ElsClient['getLogDetails']>>;
searchLogs(params: Record<string, string | number | boolean | undefined>, ctx?: RequestContext): Promise<ReturnType<ElsClient['searchLogs']>>;
topErrorMessages(params: Record<string, string | number | undefined>, ctx?: RequestContext): Promise<ReturnType<ElsClient['topErrorMessages']>>;
errorHistogram(params: Record<string, string | undefined>, ctx?: RequestContext): Promise<ReturnType<ElsClient['errorHistogram']>>;
trafficStats(params: Record<string, string | undefined>, ctx?: RequestContext): Promise<ReturnType<ElsClient['trafficStats']>>;
listApps(ctx?: RequestContext): Promise<ReturnType<ElsClient['listApps']>>;
heatmap(params: Record<string, string | undefined>, ctx?: RequestContext): Promise<ReturnType<ElsClient['heatmap']>>;
errorStats(params: Record<string, string | undefined>, ctx?: RequestContext): Promise<ReturnType<ElsClient['errorStats']>>;
groupedErrors(params: Record<string, string | number | undefined>, ctx?: RequestContext): Promise<ReturnType<ElsClient['groupedErrors']>>;
baseline(params: Record<string, string | number | undefined>, ctx?: RequestContext): Promise<ReturnType<ElsClient['baseline']>>;
versionRegression(params: Record<string, string | undefined>, ctx?: RequestContext): Promise<ReturnType<ElsClient['versionRegression']>>;
findSimilarErrors(...args: Parameters<ElsClient['findSimilarErrors']>): Promise<ReturnType<ElsClient['findSimilarErrors']>>;
findCorrelatedErrors(...args: Parameters<ElsClient['findCorrelatedErrors']>): Promise<ReturnType<ElsClient['findCorrelatedErrors']>>;
queryLogsJql(...args: Parameters<ElsClient['queryLogsJql']>): Promise<ReturnType<ElsClient['queryLogsJql']>>;
impact(...args: Parameters<ElsClient['impact']>): Promise<ReturnType<ElsClient['impact']>>;
/**
* Строит cache key с tenant-isolation. Возвращает null если контекст не даёт
* tenant идентификатор — caller обязан в этом случае идти в bypass-path.
*/
private buildKey;
}
//# sourceMappingURL=cachedElsClient.d.ts.map