MCP Server Framework - v1.0.0
    Preparing search index...

    Variable FrameworkErrorFactoryConst

    FrameworkErrorFactory: {
        auth: {
            forbidden: (reason?: string) => AuthorizationError;
            insufficientScope: (
                required: string[],
                actual: string[],
            ) => AuthorizationError;
            invalidToken: (reason?: string) => AuthenticationError;
            missingToken: () => AuthenticationError;
            tokenExpired: () => AuthenticationError;
            unauthorized: (message: string) => AuthenticationError;
        };
        cancellation: {
            custom: (
                message: string,
                requestId?: string | number,
            ) => OperationCancelledError;
            fromAbortSignal: (
                signal: AbortSignal,
                requestId?: string | number,
            ) => OperationCancelledError;
            fromRequest: (
                requestId: string | number,
                reason?: string,
            ) => OperationCancelledError;
        };
        configuration: {
            constraintViolation: (
                message: string,
                fields: string[],
            ) => ConfigurationError;
            custom: (message: string, configKey?: string) => ConfigurationError;
            fileNotFound: (filePath: string) => ConfigurationError;
            fileParseFailed: (filePath: string, cause?: Error) => ConfigurationError;
            fileReadFailed: (filePath: string, cause?: Error) => ConfigurationError;
            fileValidationFailed: (
                filePath: string,
                zodError: ZodError,
            ) => ConfigurationError;
            invalid: (message: string) => ConfigurationError;
            invalidEnvVar: (varName: string, reason: string) => ConfigurationError;
            missingEnvVar: (varName: string) => ConfigurationError;
            unsupportedFormat: (extension: string) => ConfigurationError;
        };
        connection: {
            custom: (message: string, target: string) => ConnectionError;
            failed: (target: string, reason?: string) => ConnectionError;
            healthCheckFailed: (reason: string, target?: string) => ConnectionError;
            lost: (target: string) => ConnectionError;
            refused: (target: string) => ConnectionError;
            reset: (target: string) => ConnectionError;
            timeout: (target: string, timeoutMs?: number) => ConnectionError;
        };
        internal: {
            custom: (message: string) => InternalError;
            notImplemented: (feature: string) => InternalError;
            unexpectedState: (description: string) => InternalError;
            wrap: (error: unknown, context?: string) => InternalError;
        };
        isAppError: (error: unknown) => error is AppError;
        mcp: {
            custom: (message: string, code?: number) => McpProtocolError;
            invalidParams: (reason: string) => McpProtocolError;
            invalidRequest: (reason: string) => McpProtocolError;
            methodNotFound: (method: string) => McpProtocolError;
            parseError: (reason: string) => McpProtocolError;
        };
        normalize: (error: unknown, fallbackMessage?: string) => AppError;
        operation: {
            custom: (message: string, operation?: string) => OperationError;
            failed: (operation: string, reason?: string) => OperationError;
            timeout: (operation: string, timeoutMs: number) => OperationError;
            unavailable: (operation: string) => OperationError;
        };
        registry: {
            duplicatePrompt: (name: string) => RegistryError;
            duplicateResource: (name: string) => RegistryError;
            duplicateTool: (name: string) => RegistryError;
            promptNotFound: (name: string) => RegistryError;
            resourceNotFound: (name: string) => RegistryError;
            toolNotFound: (name: string) => RegistryError;
        };
        session: {
            custom: (message: string, sessionId?: string) => SessionError;
            expired: (sessionId: string) => SessionError;
            invalidState: (
                sessionId: string,
                currentState: string,
                expectedState: string,
            ) => SessionError;
            limitReached: (maxSessions: number) => SessionError;
            notFound: (sessionId: string) => SessionError;
        };
        transport: {
            connectionClosed: (reason?: string) => TransportError;
            connectionFailed: (reason: string) => TransportError;
            custom: (
                message: string,
                transportType?: "http" | "sse" | "stdio",
            ) => TransportError;
            dnsRebinding: (host: string) => TransportError;
            invalidHeader: (header: string, reason: string) => TransportError;
            portInUse: (bind: string) => TransportError;
            privilegesRequired: (bind: string) => TransportError;
            protocolMismatch: (expected: string, received: string) => TransportError;
            rateLimited: (retryAfterSeconds?: number) => TransportError;
        };
        validation: {
            custom: (message: string, field?: string) => ValidationError;
            fieldInvalid: (field: string, value?: unknown) => ValidationError;
            fieldMax: (field: string, max: number) => ValidationError;
            fieldMin: (field: string, min: number) => ValidationError;
            fieldPattern: (field: string) => ValidationError;
            fieldRequired: (field: string) => ValidationError;
            fieldTypeMismatch: (
                field: string,
                expectedType: string,
            ) => ValidationError;
            fromZodError: (error: ZodError, message?: string) => ValidationError;
        };
    } = ...

    Framework Error Factory

    Provides static methods for creating framework-level errors. This factory is generic and can be extended by application code.

    Type Declaration

    • Readonlyauth: {
          forbidden: (reason?: string) => AuthorizationError;
          insufficientScope: (
              required: string[],
              actual: string[],
          ) => AuthorizationError;
          invalidToken: (reason?: string) => AuthenticationError;
          missingToken: () => AuthenticationError;
          tokenExpired: () => AuthenticationError;
          unauthorized: (message: string) => AuthenticationError;
      }
    • Readonlycancellation: {
          custom: (
              message: string,
              requestId?: string | number,
          ) => OperationCancelledError;
          fromAbortSignal: (
              signal: AbortSignal,
              requestId?: string | number,
          ) => OperationCancelledError;
          fromRequest: (
              requestId: string | number,
              reason?: string,
          ) => OperationCancelledError;
      }
      • Readonlycustom: (message: string, requestId?: string | number) => OperationCancelledError

        Create a custom cancellation error

      • ReadonlyfromAbortSignal: (signal: AbortSignal, requestId?: string | number) => OperationCancelledError

        Create from an AbortSignal

      • ReadonlyfromRequest: (requestId: string | number, reason?: string) => OperationCancelledError

        Create from a cancelled request

    • Readonlyconfiguration: {
          constraintViolation: (
              message: string,
              fields: string[],
          ) => ConfigurationError;
          custom: (message: string, configKey?: string) => ConfigurationError;
          fileNotFound: (filePath: string) => ConfigurationError;
          fileParseFailed: (filePath: string, cause?: Error) => ConfigurationError;
          fileReadFailed: (filePath: string, cause?: Error) => ConfigurationError;
          fileValidationFailed: (
              filePath: string,
              zodError: ZodError,
          ) => ConfigurationError;
          invalid: (message: string) => ConfigurationError;
          invalidEnvVar: (varName: string, reason: string) => ConfigurationError;
          missingEnvVar: (varName: string) => ConfigurationError;
          unsupportedFormat: (extension: string) => ConfigurationError;
      }
      • ReadonlyconstraintViolation: (message: string, fields: string[]) => ConfigurationError

        Cross-field constraint violation

      • Readonlycustom: (message: string, configKey?: string) => ConfigurationError

        Create a custom configuration error

      • ReadonlyfileNotFound: (filePath: string) => ConfigurationError

        Config file not found (explicit MCP_CONFIG_FILE path)

      • ReadonlyfileParseFailed: (filePath: string, cause?: Error) => ConfigurationError

        Config file TOML/YAML parse failure

      • ReadonlyfileReadFailed: (filePath: string, cause?: Error) => ConfigurationError

        Config file could not be read

      • ReadonlyfileValidationFailed: (filePath: string, zodError: ZodError) => ConfigurationError

        Config file schema validation failed (typos, wrong types)

      • Readonlyinvalid: (message: string) => ConfigurationError

        Create an invalid configuration error

      • ReadonlyinvalidEnvVar: (varName: string, reason: string) => ConfigurationError

        Create an invalid env var error

      • ReadonlymissingEnvVar: (varName: string) => ConfigurationError

        Create a missing env var error

      • ReadonlyunsupportedFormat: (extension: string) => ConfigurationError

        Unsupported config file extension

    • Readonlyconnection: {
          custom: (message: string, target: string) => ConnectionError;
          failed: (target: string, reason?: string) => ConnectionError;
          healthCheckFailed: (reason: string, target?: string) => ConnectionError;
          lost: (target: string) => ConnectionError;
          refused: (target: string) => ConnectionError;
          reset: (target: string) => ConnectionError;
          timeout: (target: string, timeoutMs?: number) => ConnectionError;
      }
      • Readonlycustom: (message: string, target: string) => ConnectionError

        Create a custom connection error

      • Readonlyfailed: (target: string, reason?: string) => ConnectionError

        Create a generic connection failed error

      • ReadonlyhealthCheckFailed: (reason: string, target?: string) => ConnectionError

        Create a health check failed error

      • Readonlylost: (target: string) => ConnectionError

        Create a connection lost error

      • Readonlyrefused: (target: string) => ConnectionError

        Create a connection refused error

      • Readonlyreset: (target: string) => ConnectionError

        Create a connection reset error

      • Readonlytimeout: (target: string, timeoutMs?: number) => ConnectionError

        Create a connection timeout error

    • Readonlyinternal: {
          custom: (message: string) => InternalError;
          notImplemented: (feature: string) => InternalError;
          unexpectedState: (description: string) => InternalError;
          wrap: (error: unknown, context?: string) => InternalError;
      }
      • Readonlycustom: (message: string) => InternalError

        Create a custom internal error

      • ReadonlynotImplemented: (feature: string) => InternalError

        Create a not implemented error

      • ReadonlyunexpectedState: (description: string) => InternalError

        Create an unexpected state error

      • Readonlywrap: (error: unknown, context?: string) => InternalError

        Wrap an unknown error

    • ReadonlyisAppError: (error: unknown) => error is AppError

      Check if an error is an AppError (framework or app error)

    • Readonlymcp: {
          custom: (message: string, code?: number) => McpProtocolError;
          invalidParams: (reason: string) => McpProtocolError;
          invalidRequest: (reason: string) => McpProtocolError;
          methodNotFound: (method: string) => McpProtocolError;
          parseError: (reason: string) => McpProtocolError;
      }
      • Readonlycustom: (message: string, code?: number) => McpProtocolError

        Create a custom MCP error

      • ReadonlyinvalidParams: (reason: string) => McpProtocolError

        Create an invalid params error

      • ReadonlyinvalidRequest: (reason: string) => McpProtocolError

        Create an invalid request error

      • ReadonlymethodNotFound: (method: string) => McpProtocolError

        Create a method not found error

      • ReadonlyparseError: (reason: string) => McpProtocolError

        Create a parse error

    • Readonlynormalize: (error: unknown, fallbackMessage?: string) => AppError

      Normalize any error to an AppError

    • Readonlyoperation: {
          custom: (message: string, operation?: string) => OperationError;
          failed: (operation: string, reason?: string) => OperationError;
          timeout: (operation: string, timeoutMs: number) => OperationError;
          unavailable: (operation: string) => OperationError;
      }
      • Readonlycustom: (message: string, operation?: string) => OperationError

        Create a custom operation error

      • Readonlyfailed: (operation: string, reason?: string) => OperationError

        Create a failed operation error

      • Readonlytimeout: (operation: string, timeoutMs: number) => OperationError

        Create a timeout error

      • Readonlyunavailable: (operation: string) => OperationError

        Create an unavailable error

    • Readonlyregistry: {
          duplicatePrompt: (name: string) => RegistryError;
          duplicateResource: (name: string) => RegistryError;
          duplicateTool: (name: string) => RegistryError;
          promptNotFound: (name: string) => RegistryError;
          resourceNotFound: (name: string) => RegistryError;
          toolNotFound: (name: string) => RegistryError;
      }
      • ReadonlyduplicatePrompt: (name: string) => RegistryError

        Duplicate prompt

      • ReadonlyduplicateResource: (name: string) => RegistryError

        Duplicate resource

      • ReadonlyduplicateTool: (name: string) => RegistryError

        Duplicate tool

      • ReadonlypromptNotFound: (name: string) => RegistryError

        Prompt not found

      • ReadonlyresourceNotFound: (name: string) => RegistryError

        Resource not found

      • ReadonlytoolNotFound: (name: string) => RegistryError

        Tool not found

    • Readonlysession: {
          custom: (message: string, sessionId?: string) => SessionError;
          expired: (sessionId: string) => SessionError;
          invalidState: (
              sessionId: string,
              currentState: string,
              expectedState: string,
          ) => SessionError;
          limitReached: (maxSessions: number) => SessionError;
          notFound: (sessionId: string) => SessionError;
      }
      • Readonlycustom: (message: string, sessionId?: string) => SessionError

        Create a custom session error

      • Readonlyexpired: (sessionId: string) => SessionError

        Create a session expired error

      • ReadonlyinvalidState: (sessionId: string, currentState: string, expectedState: string) => SessionError

        Create an invalid session state error

      • ReadonlylimitReached: (maxSessions: number) => SessionError

        Create a session limit reached error

      • ReadonlynotFound: (sessionId: string) => SessionError

        Create a session not found error

    • Readonlytransport: {
          connectionClosed: (reason?: string) => TransportError;
          connectionFailed: (reason: string) => TransportError;
          custom: (
              message: string,
              transportType?: "http" | "sse" | "stdio",
          ) => TransportError;
          dnsRebinding: (host: string) => TransportError;
          invalidHeader: (header: string, reason: string) => TransportError;
          portInUse: (bind: string) => TransportError;
          privilegesRequired: (bind: string) => TransportError;
          protocolMismatch: (expected: string, received: string) => TransportError;
          rateLimited: (retryAfterSeconds?: number) => TransportError;
      }
      • ReadonlyconnectionClosed: (reason?: string) => TransportError

        Create a connection closed error

      • ReadonlyconnectionFailed: (reason: string) => TransportError

        Create a connection failed error

      • Readonlycustom: (message: string, transportType?: "http" | "sse" | "stdio") => TransportError

        Create a custom transport error

      • ReadonlydnsRebinding: (host: string) => TransportError

        Create a DNS rebinding error

      • ReadonlyinvalidHeader: (header: string, reason: string) => TransportError

        Create an invalid header error

      • ReadonlyportInUse: (bind: string) => TransportError

        Create a port-in-use error

      • ReadonlyprivilegesRequired: (bind: string) => TransportError

        Create a privileges-required error

      • ReadonlyprotocolMismatch: (expected: string, received: string) => TransportError

        Create a protocol mismatch error

      • ReadonlyrateLimited: (retryAfterSeconds?: number) => TransportError

        Create a rate limited error

    • Readonlyvalidation: {
          custom: (message: string, field?: string) => ValidationError;
          fieldInvalid: (field: string, value?: unknown) => ValidationError;
          fieldMax: (field: string, max: number) => ValidationError;
          fieldMin: (field: string, min: number) => ValidationError;
          fieldPattern: (field: string) => ValidationError;
          fieldRequired: (field: string) => ValidationError;
          fieldTypeMismatch: (field: string, expectedType: string) => ValidationError;
          fromZodError: (error: ZodError, message?: string) => ValidationError;
      }
      • Readonlycustom: (message: string, field?: string) => ValidationError

        Create a custom validation error

      • ReadonlyfieldInvalid: (field: string, value?: unknown) => ValidationError

        Create a field invalid error

      • ReadonlyfieldMax: (field: string, max: number) => ValidationError

        Create a max constraint error

      • ReadonlyfieldMin: (field: string, min: number) => ValidationError

        Create a min constraint error

      • ReadonlyfieldPattern: (field: string) => ValidationError

        Create a pattern mismatch error

      • ReadonlyfieldRequired: (field: string) => ValidationError

        Create a field required error

      • ReadonlyfieldTypeMismatch: (field: string, expectedType: string) => ValidationError

        Create a type mismatch error

      • ReadonlyfromZodError: (error: ZodError, message?: string) => ValidationError

        Create from a Zod error

    // MCP errors
    throw FrameworkErrorFactory.mcp.invalidRequest('Missing params');
    throw FrameworkErrorFactory.session.expired('sess-123');

    // Validation errors
    throw FrameworkErrorFactory.validation.fromZodError(zodError);
    throw FrameworkErrorFactory.validation.fieldRequired('name');

    // Operation errors
    throw FrameworkErrorFactory.operation.failed('deploy', 'timeout');