@myea/aem-mcp-handler
Version:
Advanced AEM MCP request handler with intelligent search, multi-locale support, and comprehensive content management capabilities
64 lines (63 loc) • 2.23 kB
JavaScript
export const DEFAULT_AEM_CONFIG = {
contentPaths: {
sitesRoot: process.env.AEM_SITES_ROOT || '/content',
assetsRoot: process.env.AEM_ASSETS_ROOT || '/content/dam',
templatesRoot: process.env.AEM_TEMPLATES_ROOT || '/conf',
experienceFragmentsRoot: process.env.AEM_XF_ROOT || '/content/experience-fragments',
},
replication: {
publisherUrls: process.env.AEM_PUBLISHER_URLS?.split(',') || ['http://localhost:4503'],
defaultReplicationAgent: process.env.AEM_DEFAULT_AGENT || 'publish',
},
components: {
allowedTypes: process.env.AEM_ALLOWED_COMPONENTS?.split(',') || [
'text',
'image',
'hero',
'button',
'list',
'teaser',
'carousel'
],
defaultProperties: {
'jcr:primaryType': 'nt:unstructured',
'sling:resourceType': 'foundation/components/text'
},
},
queries: {
maxLimit: parseInt(process.env.AEM_QUERY_MAX_LIMIT || '100'),
defaultLimit: parseInt(process.env.AEM_QUERY_DEFAULT_LIMIT || '20'),
timeoutMs: parseInt(process.env.AEM_QUERY_TIMEOUT || '30000'),
},
validation: {
maxDepth: parseInt(process.env.AEM_MAX_DEPTH || '5'),
allowedLocales: process.env.AEM_ALLOWED_LOCALES?.split(',') || [
'en_US', 'en_GB', 'fr_FR', 'de_DE', 'es_ES', 'it_IT', 'ja_JP', 'ko_KR', 'zh_CN'
],
},
};
/**
* Get AEM configuration with environment overrides
*/
export function getAEMConfig() {
return DEFAULT_AEM_CONFIG;
}
/**
* Validate if a path is within allowed content roots
*/
export function isValidContentPath(path, config = DEFAULT_AEM_CONFIG) {
const allowedRoots = Object.values(config.contentPaths);
return allowedRoots.some(root => path.startsWith(root));
}
/**
* Validate if a component type is allowed
*/
export function isValidComponentType(componentType, config = DEFAULT_AEM_CONFIG) {
return config.components.allowedTypes.includes(componentType);
}
/**
* Validate if a locale is supported
*/
export function isValidLocale(locale, config = DEFAULT_AEM_CONFIG) {
return config.validation.allowedLocales.includes(locale);
}