请通过LinkedIn或Email Me与我联系以讨论定制化内容!
💡 对于对AEM作为云服务的MCP服务器感兴趣的用户,请查看我的另一个GitHub项目: AEMaaCS MCP Server - 一个专门为AEM作为云服务设计的全面读写MCP服务器,具有高级功能和企业级能力。
许可证更新:此项目现在采用AGPL-V3许可。对于在企业环境中进行商业使用,需要付费许可。
AEM MCP Server 是一个全面、生产就绪的模型上下文协议(MCP)服务器,适用于Adobe Experience Manager(AEM)。它提供了超过35种强大的REST/JSON-RPC API方法,用于完全的内容、组件、资产和模板管理,并具备AI、聊天机器人和自动化工作流的高级集成。该项目专为希望以编程方式或通过自然语言接口管理AEM的AEM开发者、内容团队和自动化工程师设计。
cd clone
npm install
npm run build
npm start
npm run dev
curl -u admin:admin \
-X POST http://localhost:3001/mcp \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "listPages",
"params": {
"siteRoot": "/content/mysite",
"depth": 2,
"limit": 10
}
}'
curl -u admin:admin \
-X POST http://localhost:3001/mcp \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "createPage",
"params": {
"parentPath": "/content/mysite/en",
"title": "新产品页面",
"template": "/conf/mysite/settings/wcm/templates/page-template"
}
}'
curl -u admin:admin \
-X POST http://localhost:3001/mcp \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "updateComponent",
"params": {
"componentPath": "/content/mysite/en/home/jcr:content/root/container/text",
"properties": {
"text": "更新的内容",
"textIsRich": true
}
}
}'
curl -u admin:admin \
-X POST http://localhost:3001/mcp \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 4,
"method": "searchContent",
"params": {
"type": "cq:Page",
"fulltext": "产品",
"path": "/content/mysite",
"limit": 20
}
}'
curl -u admin:admin \
-X POST http://localhost:3001/mcp \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 5,
"method": "uploadAsset",
"params": {
"parentPath": "/content/dam/mysite/images",
"fileName": "hero-image.jpg",
"fileContent": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...",
"mimeType": "image/jpeg",
"metadata": {
"dc:title": "英雄图片",
"dc:description": "首页的主要英雄图片"
}
}
}'
curl -u admin:admin http://localhost:3001/api/methods
curl -u admin:admin http://localhost:3001/api/methods/createPage
curl -u admin:admin \
-X POST http://localhost:3001/api/methods/listPages \
-H 'Content-Type: application/json' \
-d '{
"siteRoot": "/content/mysite",
"depth": 1,
"limit": 10
}'
createPage - 创建页面,正确集成模板deletePage - 删除页面,带强制选项listPages - 列出页面,带深度和分页getPageContent - 提取完整页面内容getPageProperties - 获取页面元数据和属性activatePage / deactivatePage - 发布/取消发布页面getAllTextContent / getPageTextContent - 提取文本内容getPageImages - 提取图像引用validateComponent - 在应用之前验证组件更改updateComponent - 更新组件属性并验证scanPageComponents - 发现页面上的所有组件createComponent - 向页面添加新组件deleteComponent - 删除组件updateImagePath - 更新图像组件引用bulkUpdateComponents - 原子地更新多个组件uploadAsset - 将文件上传到DAM,附带元数据updateAsset - 更新资产元数据和内容deleteAsset - 从DAM中删除资产getAssetMetadata - 检索资产元数据searchContent - 查询构建器搜索,带灵活参数executeJCRQuery - 执行JCR查询(查询构建器包装器)enhancedPageSearch - 智能页面搜索,带有回退策略getTemplates - 列出站点可用的模板getTemplateStructure - 获取详细的模板结构fetchSites - 获取所有可用站点fetchLanguageMasters - 获取站点的语言主站fetchAvailableLocales - 获取可用区域访问位于http://localhost:3001/dashboard的web仪表盘,以:
在项目根目录创建一个.env文件,包含以下内容(根据需要编辑):
AEM_HOST=http://localhost:4502
AEM_SERVICE_USER=admin
AEM_SERVICE_PASSWORD=admin
MCP_PORT=8080
GATEWAY_PORT=3001
MCP_USERNAME=admin
MCP_PASSWORD=admin
示例如下,用于AI代码编辑器或自定义客户端:
{
"mcpServers": {
"aem-mcp": {
"command": "node",
"args": [
"绝对路径到dist/mcp-server.js"
]
}
}
}
# 可选:高级AEM配置
AEM_SITES_ROOT=/content
AEM_ASSETS_ROOT=/content/dam
AEM_TEMPLATES_ROOT=/conf
AEM_XF_ROOT=/content/experience-fragments
AEM_PUBLISHER_URLS=http://localhost:4503
AEM_DEFAULT_AGENT=publish
AEM_ALLOWED_COMPONENTS=text,image,hero,button,list,teaser,carousel
AEM_QUERY_MAX_LIMIT=100
AEM_QUERY_DEFAULT_LIMIT=20
AEM_QUERY_TIMEOUT=30000
AEM_MAX_DEPTH=5
# 可选:AI集成(如有需要)
# OPENAI_API_KEY=your-openai-key
# TELEGRAM_BOT_TOKEN=your-telegram-bot-token
TELEGRAM_BOT_TOKEN连接您的机器人并与您的AEM实例聊天AEM MCP服务器与支持MCP协议的现代AI IDE和代码编辑器兼容,如Cursor和Cline。
node["/绝对路径/to/dist/mcp-server.js"]8080(或按配置).env中的MCP_USERNAME/MCP_PASSWORDMCP_USERNAME/MCP_PASSWORD)进行身份验证。/api端点访问。MCP_USERNAME/MCP_PASSWORD)src/ — TypeScript源代码dist/ — 编译后的JS输出欢迎贡献!请打开问题或拉请求以修复错误、添加功能或改进文档。
# 测试AEM连接
curl -u admin:admin http://localhost:4502/libs/granite/core/content/login.html
# 检查服务器健康状况
curl http://localhost:3001/health
.env文件中的AEM凭据limit参数进行大结果集的分页depth值以列出页面AEM_QUERY_TIMEOUT以处理慢查询# 启用调试日志
DEBUG=aem-mcp:* npm run dev
# 检查详细健康状态
curl http://localhost:3001/health
# 列出所有可用的方法
curl -u admin:admin http://localhost:3001/api/methods
// 1. 列出源页面
const pages = await listPages({ siteRoot: '/content/source', depth: 3 });
// 2. 使用模板创建目标页面
for (const page of pages.data.pages) {
await createPage({
parentPath: '/content/target',
title: page.title,
template: '/conf/target/settings/wcm/templates/page'
});
}
// 3. 复制组件
const components = await scanPageComponents({ pagePath: sourcePage });
for (const component of components.data.components) {
await createComponent({
pagePath: targetPage,
componentType: component.resourceType,
properties: component.properties
});
}
// 更新多个文本组件
const updates = [
{
componentPath: '/content/site/page1/jcr:content/text1',
properties: { text: '更新的内容1' }
},
{
componentPath: '/content/site/page2/jcr:content/text2',
properties: { text: '更新的内容2'