mcp-ai-agent-guidelines
Version:
A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices
101 lines • 3.22 kB
JavaScript
/**
* Feature Flags Configuration
*
* Provides environment-based feature flags for gradual rollout of new capabilities
* without breaking existing behavior. Supports gateway integration, spec-kit output,
* and cross-cutting capabilities.
*
* @module config/feature-flags
* @see {@link https://github.com/Anselmoo/mcp-ai-agent-guidelines/blob/development/plan-v0.13.x/adrs/ADR-002-feature-flag-migration.md ADR-002}
*/
/**
* Default feature flags - all disabled for backward compatibility.
*
* @internal
*/
const _defaultFlags = {
usePolyglotGateway: false,
enableSpecKitOutput: false,
enableEnterpriseOutput: false,
enableCrossCuttingCapabilities: false,
enableModeAwareToolFiltering: false,
};
/**
* Get current feature flags from environment variables.
*
* Reads feature flags from process.env and returns configuration.
* Environment variables override defaults:
* - MCP_USE_POLYGLOT_GATEWAY=true
* - MCP_ENABLE_SPECKIT=true
* - MCP_ENABLE_ENTERPRISE=true
* - MCP_ENABLE_CROSS_CUTTING=true
* - MCP_ENABLE_MODE_FILTERING=true
*
* @returns {FeatureFlags} Current feature flag configuration
*
* @example
* ```typescript
* const flags = getFeatureFlags();
* if (flags.usePolyglotGateway) {
* // Use new gateway
* } else {
* // Use legacy code
* }
* ```
*/
export function getFeatureFlags() {
return {
usePolyglotGateway: process.env.MCP_USE_POLYGLOT_GATEWAY === "true",
enableSpecKitOutput: process.env.MCP_ENABLE_SPECKIT === "true",
enableEnterpriseOutput: process.env.MCP_ENABLE_ENTERPRISE === "true",
enableCrossCuttingCapabilities: process.env.MCP_ENABLE_CROSS_CUTTING === "true",
enableModeAwareToolFiltering: process.env.MCP_ENABLE_MODE_FILTERING === "true",
};
}
/**
* Check if any feature flags are enabled.
*
* Useful for determining if new code paths should be activated at all.
*
* @returns {boolean} True if any feature flag is enabled
*
* @example
* ```typescript
* if (hasAnyFlagsEnabled()) {
* initializeNewFeatures();
* }
* ```
*/
export function hasAnyFlagsEnabled() {
const flags = getFeatureFlags();
return (flags.usePolyglotGateway ||
flags.enableSpecKitOutput ||
flags.enableEnterpriseOutput ||
flags.enableCrossCuttingCapabilities ||
flags.enableModeAwareToolFiltering);
}
/**
* Get a summary of current feature flag state.
*
* Returns object with flag names and their current values,
* useful for debugging and logging.
*
* @returns {Record<string, boolean>} Map of flag names to values
*
* @example
* ```typescript
* console.log('Feature flags:', getFeatureFlagSummary());
* // Output: { usePolyglotGateway: false, enableSpecKitOutput: false, ... }
* ```
*/
export function getFeatureFlagSummary() {
const flags = getFeatureFlags();
return {
usePolyglotGateway: flags.usePolyglotGateway,
enableSpecKitOutput: flags.enableSpecKitOutput,
enableEnterpriseOutput: flags.enableEnterpriseOutput,
enableCrossCuttingCapabilities: flags.enableCrossCuttingCapabilities,
enableModeAwareToolFiltering: flags.enableModeAwareToolFiltering,
};
}
//# sourceMappingURL=feature-flags.js.map