@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-запуска.
137 lines • 4.89 kB
TypeScript
import { type Dispatcher } from 'undici';
import type { Logger } from 'pino';
import type { SearchLogsRawResponse, ErrorLog, HistogramBucket } from './types.js';
export interface ElsClientOptions {
baseUrl: string;
apiKey: string;
timeoutMs?: number;
log?: Logger;
/** Внешний dispatcher (для тестов через MockAgent). */
dispatcher?: Dispatcher;
}
export interface RequestOptions {
/** ISO timestamp filter (по умолчанию — не передаётся). */
query?: Record<string, string | number | boolean | undefined | null>;
/** Принудительно отключить retry (для отдельных вызовов). */
noRetry?: boolean;
/** HTTP method, default GET. */
method?: 'GET' | 'POST';
/** JSON body (для POST). */
body?: unknown;
}
export declare class ElsClient {
private readonly baseUrl;
private readonly origin;
private readonly basePath;
private readonly apiKey;
private readonly timeoutMs;
private readonly log;
private readonly dispatcher;
private readonly ownDispatcher;
constructor(opts: ElsClientOptions);
close(): Promise<void>;
/** Низкоуровневый GET с retry/backoff. Возвращает уже-распарсенный JSON. */
private request;
searchLogs(params: Record<string, string | number | boolean | undefined>): Promise<{
data: SearchLogsRawResponse;
elsRequestId: string | null;
}>;
getLogDetails(traceId: string): Promise<{
data: ErrorLog;
elsRequestId: string | null;
}>;
findSimilarErrors(traceId: string, params?: Record<string, string | undefined>): Promise<{
data: unknown;
elsRequestId: string | null;
}>;
findCorrelatedErrors(traceId: string, params?: Record<string, string | number | undefined>): Promise<{
data: unknown;
elsRequestId: string | null;
}>;
topErrorMessages(params: Record<string, string | number | undefined>): Promise<{
data: {
data: unknown[];
take: number;
};
elsRequestId: string | null;
}>;
errorHistogram(params: Record<string, string | undefined>): Promise<{
data: {
data: HistogramBucket[];
interval: string;
from: string;
to: string;
};
elsRequestId: string | null;
}>;
trafficStats(params: Record<string, string | undefined>): Promise<{
data: unknown;
elsRequestId: string | null;
}>;
/**
* GET /apps — требует master-key (`requireMaster`). Для обычного ELS-key
* вернёт 403. Tool listApps в свою очередь обрабатывает 403 и возвращает
* derived-from-context результат.
*/
listApps(): Promise<{
data: {
apps: Array<{
slug: string;
name: string;
isActive: boolean;
rateLimitTier?: string;
createdAt?: string;
}>;
};
elsRequestId: string | null;
}>;
/**
* POST /errors/query — JQL-style structured filter (AST + pagination + search).
* Возвращает items + total + facets + histogram (та же форма что GET /errors).
*/
queryLogsJql(body: unknown): Promise<{
data: SearchLogsRawResponse & {
offset?: number;
};
elsRequestId: string | null;
}>;
/** GET /analytics/stats. */
errorStats(params: Record<string, string | undefined>): Promise<{
data: unknown;
elsRequestId: string | null;
}>;
/** GET /analytics/grouped-errors. */
groupedErrors(params: Record<string, string | number | undefined>): Promise<{
data: unknown;
elsRequestId: string | null;
}>;
/** GET /analytics/impact. */
impact(params: Record<string, string | undefined>): Promise<{
data: unknown;
elsRequestId: string | null;
}>;
/** GET /analytics/baseline. */
baseline(params: Record<string, string | number | undefined>): Promise<{
data: unknown;
elsRequestId: string | null;
}>;
/** GET /analytics/version-timeline. */
versionRegression(params: Record<string, string | undefined>): Promise<{
data: unknown;
elsRequestId: string | null;
}>;
/** GET /analytics/heatmap — 7×24 матрица счётчиков. */
heatmap(params: Record<string, string | undefined>): Promise<{
data: {
data: Array<{
dayOfWeek: number;
hour: number;
count: number;
}>;
from: string;
to: string;
};
elsRequestId: string | null;
}>;
}
//# sourceMappingURL=elsClient.d.ts.map