UNPKG

@ithena-one/mcp-governance

Version:

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

34 lines 1.36 kB
/* eslint-disable @typescript-eslint/no-explicit-any */ import { v4 as uuidv4 } from 'uuid'; /** Generates a unique event ID. */ export function generateEventId() { return uuidv4(); } /** Builds the TransportContext from a Transport instance. */ export 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