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

68 lines 2.49 kB
import { z } from 'zod'; import { ToolError } from '../lib/errors.js'; /** * Tool: impact_analysis * Mapping: GET /analytics/impact → analytics.routes.ts:344 * Upstream Zod: ImpactSchema (from, to, +фасет-фильтры). * * Ранжирует ошибки по impact-score (комбинация frequency / affectedUsers / * severity / recency). Upstream сам считает score; tool пробрасывает. * * Поле `weights` в input — на будущее, upstream его пока не принимает. */ export const impactAnalysisInputShape = { from: z.string().optional(), to: z.string().optional(), level: z.array(z.string().max(16)).optional(), serviceName: z.array(z.string().max(255)).optional(), take: z.number().int().min(1).max(100).default(20), }; export const impactAnalysisToolDef = { name: 'impact_analysis', title: 'Business-impact score for top errors', description: [ 'Rank errors by impact score (frequency + affected users + severity + recency).', '', 'WHEN TO USE:', ' - Sprint planning - "what should we fix first this week?".', ' - Post-deploy verify - any new fingerprint already in top-5 impact?', ' - Bug-bash backlog grooming - prioritise by user impact, not just count.', ].join('\n'), inputShape: impactAnalysisInputShape, }; export async function handleImpactAnalysis(args, client) { try { const params = { from: args.from, to: args.to, levels: args.level?.join(','), serviceName: args.serviceName?.join(','), }; const { data, elsRequestId } = await client.impact(params); const body = (data ?? {}); const rawItems = Array.isArray(body.data) ? body.data : Array.isArray(body.items) ? body.items : []; const items = rawItems.slice(0, args.take); const meta = { elsRequestId, cached: false, ttlSec: 300, redactionApplied: false, }; return { structuredContent: { items, _meta: meta }, content: [ { type: 'text', text: `${items.length} errors ranked by impact score.` }, ], }; } catch (err) { if (err instanceof ToolError) return err.toToolResult(); throw err; } } //# sourceMappingURL=impactAnalysis.js.map