@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-запуска.
58 lines • 2.14 kB
JavaScript
import { z } from 'zod';
import { ToolError } from '../lib/errors.js';
import { applyResponseFormatSingle } from '../lib/responseFormat.js';
/**
* Tool: get_log_details
* Mapping: GET /errors/:traceId → analytics.routes.ts:213
*
* Default response_format = "full" (debug-обычное ожидание).
* 404 от ELS → ToolError('NOT_FOUND').
*/
export const getLogDetailsInputShape = {
traceId: z.string().min(1).max(128),
// eslint-disable-next-line camelcase
response_format: z.enum(['compact', 'full']).default('full'),
};
export const getLogDetailsToolDef = {
name: 'get_log_details',
title: 'Get full error log details by traceId',
description: [
'Fetch full details of one error log: stack trace, headers, context, timing.',
'',
'WHEN TO USE:',
' - User pastes a traceId or you spotted one in search_logs - drill down for root cause.',
' - Before calling explain_error - verify the traceId exists and grab raw stack.',
' - Investigating a single incident reported by support.',
'',
'DEFAULT: response_format=full (includes stack).',
].join('\n'),
inputShape: getLogDetailsInputShape,
};
export async function handleGetLogDetails(args, client) {
try {
const { data, elsRequestId } = await client.getLogDetails(args.traceId);
const { log, truncated } = applyResponseFormatSingle(data, args.response_format);
const meta = {
elsRequestId,
cached: false,
ttlSec: 3600,
redactionApplied: false,
truncated,
};
return {
structuredContent: { log, _meta: meta },
content: [
{
type: 'text',
text: `Error log ${data.traceId} (level=${data.level}, service=${data.serviceName || 'unknown'}): ${String(data.message ?? '').slice(0, 200)}`,
},
],
};
}
catch (err) {
if (err instanceof ToolError)
return err.toToolResult();
throw err;
}
}
//# sourceMappingURL=getLogDetails.js.map