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

40 lines 1.49 kB
import { getMetricsContentType, getMetricsText } from '../../observability/metrics.js'; import { checkLiveness, checkReadiness } from '../../observability/health.js'; /** * Lightweight HTTP handlers для Express-like транспорта. * * Каждый handler — `(req, res) => Promise<void>` (совместимо с Node http * и Express `(req, res, next?)`). Используются так: * * app.get('/els/metrics', metricsHandler); * app.get('/els/healthz', healthzHandler); * app.get('/els/readyz', readyzHandler(deps)); */ export async function metricsHandler(_req, res) { try { const body = await getMetricsText(); res.statusCode = 200; res.setHeader('content-type', getMetricsContentType()); res.end(body); } catch (err) { res.statusCode = 500; res.setHeader('content-type', 'text/plain; charset=utf-8'); res.end(`# metrics error: ${err.message}\n`); } } export function healthzHandler(_req, res) { const body = checkLiveness(); res.statusCode = 200; res.setHeader('content-type', 'application/json'); res.end(JSON.stringify(body)); } export function readyzHandler(deps) { return async (_req, res) => { const result = await checkReadiness(deps); res.statusCode = result.status === 'ready' ? 200 : 503; res.setHeader('content-type', 'application/json'); res.end(JSON.stringify(result)); }; } //# sourceMappingURL=metrics.js.map