UNPKG

@ithena-one/mcp-governance

Version:

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

26 lines (25 loc) 1.11 kB
import { UserIdentity, OperationContext } from '../types.js'; /** * Interface for resolving the identity of the caller based on the operation context. */ export interface IdentityResolver { /** * Optional asynchronous initialization logic. Called once during GovernedServer.connect(). * Useful for setting up connections, caches, etc. * Should throw an error if initialization fails. */ initialize?(): Promise<void>; /** * Resolves the identity of the caller based on transport/message context. * @param opCtx - The context of the current operation. * @returns The resolved UserIdentity, or null if identity cannot be determined. * @throws {AuthenticationError} or other specific error on failure if necessary. */ resolveIdentity(opCtx: OperationContext): Promise<UserIdentity | null>; /** * Optional asynchronous cleanup logic. Called once during GovernedServer.close(). * Useful for closing connections, flushing buffers, etc. * Should handle errors gracefully and not prevent shutdown. */ shutdown?(): Promise<void>; }