UNPKG

@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-запуска.

69 lines 2.57 kB
import { z } from 'zod'; import { ToolError } from '../lib/errors.js'; /** * Tool: error_heatmap * Mapping: GET /analytics/heatmap → analytics.routes.ts:285 * Upstream Zod: HeatmapSchema (from + to required, + фасет-фильтры). * * Возвращает 7×24 матрицу счётчиков (dayOfWeek × hour). Параметр `timezone` * в input — для будущей версии (upstream сейчас работает только в UTC). */ export const errorHeatmapInputShape = { from: z.string().min(1).describe('ISO timestamp lower bound (required).'), to: z.string().min(1).describe('ISO timestamp upper bound (required).'), level: z.array(z.string().max(16)).optional(), serviceName: z.array(z.string().max(255)).optional(), timezone: z .string() .max(64) .default('UTC') .describe('IANA tz. Upstream computes in UTC only — non-UTC values are ignored with a warning.'), }; export const errorHeatmapToolDef = { name: 'error_heatmap', title: 'Day-of-week x hour-of-day error heatmap', description: '7x24 matrix of error counts (day-of-week x hour-of-day in UTC) for a period. Use for "when do errors usually happen?".', inputShape: errorHeatmapInputShape, }; export async function handleErrorHeatmap(args, client) { try { const params = { from: args.from, to: args.to, levels: args.level?.join(','), serviceName: args.serviceName?.join(','), }; const { data, elsRequestId } = await client.heatmap(params); const warnings = []; if (args.timezone !== 'UTC') { warnings.push(`timezone='${args.timezone}' requested, but upstream computes in UTC only.`); } const meta = { elsRequestId, cached: false, ttlSec: 300, redactionApplied: false, ...(warnings.length > 0 ? { warnings } : {}), }; return { structuredContent: { data: data.data ?? [], from: data.from, to: data.to, _meta: meta, }, content: [ { type: 'text', text: `Heatmap (${(data.data ?? []).length} buckets) from ${data.from} to ${data.to}.`, }, ], }; } catch (err) { if (err instanceof ToolError) return err.toToolResult(); throw err; } } //# sourceMappingURL=errorHeatmap.js.map