UNPKG

@ithena-one/mcp-governance

Version:

Governance layer (Identity, RBAC, Credentials, Audit, Logging, Tracing) for Model Context Protocol (MCP) servers.

38 lines 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateEventId = generateEventId; exports.buildTransportContext = buildTransportContext; /* eslint-disable @typescript-eslint/no-explicit-any */ const uuid_1 = require("uuid"); /** Generates a unique event ID. */ function generateEventId() { return (0, uuid_1.v4)(); } /** Builds the TransportContext from a Transport instance. */ function buildTransportContext(transport) { let transportType = 'unknown'; if (transport) { // Try different ways to get the transport class name const className = transport.__className || // Check custom property first transport[Symbol.toStringTag] || // Then check Symbol.toStringTag transport.constructor?.name; // Finally check constructor name if (className?.includes('Stdio')) transportType = 'stdio'; else if (className?.includes('SSE')) transportType = 'sse'; else if (className?.includes('WebSocket')) transportType = 'websocket'; else if (className?.includes('InMemory')) transportType = 'in-memory'; } // Attempt to access potential non-standard properties, default to undefined const headers = transport?.headers; const remoteAddress = transport?.remoteAddress; return { transportType, sessionId: transport?.sessionId, headers: headers, remoteAddress: remoteAddress, }; } //# sourceMappingURL=helpers.js.map