firewalla-mcp-server
Version:
Model Context Protocol (MCP) server for Firewalla MSP API - Provides real-time network monitoring, security analysis, and firewall management through 28 specialized tools compatible with any MCP client
139 lines • 4.68 kB
JavaScript
/**
* Response format configuration for gradual migration to standardized formats
*
* This configuration allows for controlled rollout of response format standardization
* while maintaining backward compatibility for existing integrations.
*/
/**
* Default response format configuration
*
* Starts with a conservative approach: enable standards but maintain legacy compatibility
* for a smooth migration path.
*/
export const DEFAULT_RESPONSE_CONFIG = {
useStandardFormats: true,
legacyCompatibility: {
enabled: false, // Wave 1: Disable legacy compatibility for greenfield project
toolsUsingLegacyFormat: [],
migrationDeadline: '2024-12-31',
showDeprecationWarnings: false,
},
includeMetadata: {
executionTime: true,
cacheStatus: true,
queryOptimizations: false, // Disable by default to reduce response size
statisticalSummary: true,
paginationDetails: true,
},
performance: {
enableCompression: false, // Disable initially to avoid complexity
maxResponseSize: 10000, // 10k results before forcing pagination
enableCaching: true,
},
};
/**
* Environment-specific configuration overrides
*
* @param environment - Current environment (development, production, test)
* @returns Environment-specific configuration
*/
export function getEnvironmentConfig(environment = 'production') {
switch (environment) {
case 'development':
return {
includeMetadata: {
executionTime: true,
cacheStatus: true,
queryOptimizations: true, // Enable in development for debugging
statisticalSummary: true,
paginationDetails: true,
},
legacyCompatibility: {
enabled: false, // Wave 1: Disable legacy compatibility everywhere
toolsUsingLegacyFormat: [],
showDeprecationWarnings: false,
},
};
case 'test':
return {
useStandardFormats: true,
legacyCompatibility: {
enabled: false, // Wave 1: Disable legacy compatibility in tests too
toolsUsingLegacyFormat: [],
showDeprecationWarnings: false,
},
includeMetadata: {
executionTime: true,
cacheStatus: false, // Simplify test expectations
queryOptimizations: false,
statisticalSummary: false,
paginationDetails: true,
},
};
case 'production':
default:
return {}; // Use defaults for production
}
}
/**
* Current runtime configuration
* Initialized with defaults and can be updated at runtime
*/
let currentConfig = { ...DEFAULT_RESPONSE_CONFIG };
/**
* Update response format configuration at runtime
*
* @param newConfig - Partial configuration to merge with current settings
*/
export function updateResponseConfig(newConfig) {
currentConfig = {
...currentConfig,
...newConfig,
legacyCompatibility: {
...currentConfig.legacyCompatibility,
...newConfig.legacyCompatibility,
},
includeMetadata: {
...currentConfig.includeMetadata,
...newConfig.includeMetadata,
},
performance: {
...currentConfig.performance,
...newConfig.performance,
},
};
}
/**
* Get current response format configuration
*
* @returns Current configuration
*/
export function getResponseConfig() {
return { ...currentConfig };
}
/**
* Initialize configuration from environment variables
*
* @param environment - Environment name
*/
export function initializeResponseConfig(environment) {
const envConfig = getEnvironmentConfig(environment || process.env.NODE_ENV || 'production');
updateResponseConfig(envConfig);
}
/**
* Check if a specific tool should use legacy format
*
* @param toolName - Name of the tool
* @returns True if tool should use legacy format
*/
export function shouldUseLegacyFormat(toolName) {
const config = getResponseConfig();
if (!config.legacyCompatibility.enabled) {
return false;
}
return config.legacyCompatibility.toolsUsingLegacyFormat.includes(toolName);
}
// Legacy migration functions removed - greenfield project uses standard responses only
// Initialize configuration on module load
initializeResponseConfig();
//# sourceMappingURL=response-config.js.map