Class McpConfigurationChecker

java.lang.Object
com.github.thought2code.mcp.annotated.configuration.McpConfigurationChecker

public final class McpConfigurationChecker extends Object
Utility class for validating MCP server configuration properties.

This class provides static methods to perform comprehensive validation of MCP server configuration objects, ensuring that all required fields are present and properly configured. It validates both base configuration properties and mode-specific settings for SSE and STREAMABLE server modes.

Author:
codeboyzhou
See Also:
  • Method Details

    • check

      public static void check(McpServerConfiguration configuration)
      Performs comprehensive validation of the MCP server configuration.

      This method validates all required configuration properties including:

      • Basic server information (enabled, mode, name, version, type, instructions)
      • Timeout and capabilities settings
      • Change notification configuration
      • Mode-specific settings (SSE or STREAMABLE)
      Parameters:
      configuration - the MCP server configuration to validate
      Throws:
      McpServerConfigurationException - if any required configuration property is missing
    • checkNull

      public static <T> void checkNull(String configKey, T baseValue, T profileValue)
      Validates that at least one of two configuration values is not null.

      This method is typically used to validate profile-based configurations where a base value and a profile-specific value can both provide the same configuration property. At least one of them must be non-null.

      Type Parameters:
      T - the type of the configuration values
      Parameters:
      configKey - the configuration key name used for error reporting
      baseValue - the base configuration value
      profileValue - the profile-specific configuration value
      Throws:
      McpServerConfigurationException - if both values are null
    • checkNull

      public static <T> void checkNull(String configKey, T value)
      Validates that a single configuration value is not null.

      This method performs a simple null check on a configuration value and throws an exception if the value is null, indicating that a required configuration property is missing.

      Type Parameters:
      T - the type of the configuration value
      Parameters:
      configKey - the configuration key name used for error reporting
      value - the configuration value to validate
      Throws:
      McpServerConfigurationException - if the value is null
    • checkBlank

      public static void checkBlank(String configKey, String baseValue, String profileValue)
      Validates that at least one of two string configuration values is not blank.

      This method is typically used to validate profile-based configurations where a base value and a profile-specific value can both provide the same string configuration property. At least one of them must be non-blank. A value is considered blank if it is null, empty, or contains only whitespace.

      Parameters:
      configKey - the configuration key name used for error reporting
      baseValue - the base configuration string value
      profileValue - the profile-specific configuration string value
      Throws:
      McpServerConfigurationException - if both values are blank
    • checkBlank

      public static void checkBlank(String configKey, String value)
      Validates that a single string configuration value is not blank.

      This method performs a blank check on a string configuration value and throws an exception if the value is blank. A value is considered blank if it is null, empty, or contains only whitespace.

      Parameters:
      configKey - the configuration key name used for error reporting
      value - the configuration string value to validate
      Throws:
      McpServerConfigurationException - if the value is blank