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.51 kB
import { z } from 'zod'; import { ToolError } from '../lib/errors.js'; /** * Tool: error_histogram * Mapping: GET /analytics/histogram → analytics.routes.ts:241 * Upstream Zod: HistogramSchema (from + to required, + фасет-фильтры). * * Bucket size auto-selected by range (5m / 30m / 1h / 1d). */ export const errorHistogramInputShape = { 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(), appVersion: z.array(z.string().max(64)).optional(), }; export const errorHistogramToolDef = { name: 'error_histogram', title: 'Error count histogram over time', description: [ 'Time-series histogram of error counts. Bucket size auto-selected by range.', '', 'WHEN TO USE:', ' - Before/after deploy comparison - did error rate spike after release?', ' - Pre-merge baseline - capture current error trend to compare after merge.', ' - Hot-fix verification - confirm the rate dropped after the fix shipped.', ' - User asks "how did errors trend today?".', ].join('\n'), inputShape: errorHistogramInputShape, }; export async function handleErrorHistogram(args, client) { try { const params = { from: args.from, to: args.to, levels: args.level?.join(','), serviceName: args.serviceName?.join(','), appVersion: args.appVersion?.join(','), }; const { data, elsRequestId } = await client.errorHistogram(params); const meta = { elsRequestId, cached: false, ttlSec: 30, redactionApplied: false, }; return { structuredContent: { interval: data.interval, from: data.from, to: data.to, data: data.data, _meta: meta, }, content: [ { type: 'text', text: `Histogram with ${data.data?.length ?? 0} buckets (interval=${data.interval}, from=${data.from}, to=${data.to}).`, }, ], }; } catch (err) { if (err instanceof ToolError) return err.toToolResult(); throw err; } } //# sourceMappingURL=errorHistogram.js.map