@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-запуска.
32 lines • 1.42 kB
JavaScript
/**
* Общие типы для cache-слоя.
*
* `RequestContext` — DTO, который HTTP transport прокидывает в каждый tool
* handler и (через декорированный) ElsClient. Содержит tenant-идентификаторы
* (appSlug / keyPrefix) — это **обязательное** условие tenant-isolation в
* cache key.
*
* В stdio-режиме контекст можно собрать "вручную" из ELS_API_KEY (см. helper
* `deriveContextFromKey`) — fallback для случая, когда один процесс = один
* tenant.
*/
/**
* Хелпер: builds a fallback context из API-key, когда нет HTTP layer.
* keyPrefix = sha256(apiKey).slice(0,16), appSlug = null.
*
* Используется stdio-транспортом и тестами.
*/
export function deriveContextFromKey(apiKey, appSlug = null) {
// Берём не сам ключ, а его хэш-префикс, чтобы не светить материал в логах/key'ах.
// crypto доступен в Node 20+ как глобальный объект.
const enc = new TextEncoder().encode(apiKey);
let h = 5381;
for (const b of enc) {
h = ((h << 5) + h + b) >>> 0;
}
return {
appSlug,
keyPrefix: h.toString(16).padStart(8, '0'),
};
}
//# sourceMappingURL=types.js.map