mcp-magento-cms 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +11 -0
- package/README.md +149 -0
- package/cursor-mcp.example.json +15 -0
- package/package.json +15 -0
- package/samples/figma-category.json +966 -0
- package/samples/figma-slider.json +900 -0
- package/samples/page-7.json +17 -0
- package/samples/page-8.json +15 -0
- package/scripts/create-demo-page.js +237 -0
- package/scripts/create-integration.php +80 -0
- package/scripts/create-melissa-home.js +287 -0
- package/scripts/health-check.js +18 -0
- package/scripts/smoke-e2e.js +42 -0
- package/scripts/test-compose.js +18 -0
- package/src/index.js +515 -0
- package/src/magentoClient.js +165 -0
- package/src/pageBuilder.js +108 -0
package/.env.example
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Magento (ddev or remote) — no trailing slash
|
|
2
|
+
MAGENTO_BASE_URL=https://mage248p3.ddev.site
|
|
3
|
+
|
|
4
|
+
# Integration Access Token from Admin → System → Integrations
|
|
5
|
+
MAGENTO_ACCESS_TOKEN=
|
|
6
|
+
|
|
7
|
+
# Optional store code for REST (default: all / empty uses /rest/V1)
|
|
8
|
+
# MAGENTO_STORE_CODE=default
|
|
9
|
+
|
|
10
|
+
# Optional admin path prefix for edit links (default: admin)
|
|
11
|
+
# MAGENTO_ADMIN_PATH=admin
|
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Magento CMS MCP (Cursor) — zero npm dependencies
|
|
2
|
+
|
|
3
|
+
Create/update Magento **CMS Pages / Blocks** with Page Builder **Row → Text**.
|
|
4
|
+
|
|
5
|
+
- **AI:** your Cursor subscription (chat plans content)
|
|
6
|
+
- **This server:** Magento REST only (Integration Access Token)
|
|
7
|
+
|
|
8
|
+
Requires **Node 18+** only (`fetch` built-in). No `npm install` required.
|
|
9
|
+
|
|
10
|
+
## Tools
|
|
11
|
+
|
|
12
|
+
| Tool | Purpose |
|
|
13
|
+
|------|---------|
|
|
14
|
+
| `magento_health` | Test base URL + token |
|
|
15
|
+
| `get_cms_page` | Load by `page_id` |
|
|
16
|
+
| `create_cms_page` | Create from title + content |
|
|
17
|
+
| `update_cms_page` | Update by `page_id` (e.g. 8) |
|
|
18
|
+
| `get_cms_block` / `create_cms_block` / `update_cms_block` | Blocks |
|
|
19
|
+
| `list_section_types` | Supported layouts (MVP: simple_text) |
|
|
20
|
+
|
|
21
|
+
## Setup
|
|
22
|
+
|
|
23
|
+
### 1. Magento Integration token
|
|
24
|
+
|
|
25
|
+
Automated (recommended, ddev):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
ddev exec php tools/mcp-magento-cms/scripts/create-integration.php
|
|
29
|
+
# prints ACCESS_TOKEN=... (idempotent; reuses the "MCP CMS Studio" integration)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or manually: Admin → **System → Extensions → Integrations** → Add New Integration →
|
|
33
|
+
API tab: allow **CMS Pages/Blocks** and **Content → Design (save_design)** → Save → Activate → copy Access Token.
|
|
34
|
+
|
|
35
|
+
Magento 2.4.4+ blocks integration tokens as bearer by default. Enable once:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
ddev exec bin/magento config:set oauth/consumer/enable_integration_as_bearer 1
|
|
39
|
+
ddev exec bin/magento cache:flush config
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 2. Base URL (ddev)
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
ddev describe
|
|
46
|
+
# e.g. https://mage248p3.ddev.site
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 3. Configure `.env`
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
cd tools/mcp-magento-cms
|
|
53
|
+
cp .env.example .env
|
|
54
|
+
# set:
|
|
55
|
+
# MAGENTO_BASE_URL=https://YOUR-PROJECT.ddev.site
|
|
56
|
+
# MAGENTO_ACCESS_TOKEN=your_access_token
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Test without Cursor (optional):
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# ddev uses a mkcert TLS cert that Node does not trust by default:
|
|
63
|
+
export NODE_EXTRA_CA_CERTS="$HOME/.local/share/mkcert/rootCA.pem"
|
|
64
|
+
|
|
65
|
+
# only works when Magento is up and token is set
|
|
66
|
+
node scripts/health-check.js
|
|
67
|
+
|
|
68
|
+
# full end-to-end: creates a real Page Builder CMS page and reads it back
|
|
69
|
+
node scripts/smoke-e2e.js
|
|
70
|
+
|
|
71
|
+
# local compose smoke test (no Magento):
|
|
72
|
+
node scripts/test-compose.js
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 4. Cursor MCP config
|
|
76
|
+
|
|
77
|
+
**Cursor → Settings → MCP**, or project file `.cursor/mcp.json`:
|
|
78
|
+
|
|
79
|
+
Use **absolute** path to `index.js`:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"mcpServers": {
|
|
84
|
+
"magento-cms": {
|
|
85
|
+
"command": "node",
|
|
86
|
+
"args": [
|
|
87
|
+
"/home/YOUR_USER/htdocs/mage248p3/tools/mcp-magento-cms/src/index.js"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Secrets can stay in `.env` next to the server (auto-loaded). Or pass env:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"mcpServers": {
|
|
99
|
+
"magento-cms": {
|
|
100
|
+
"command": "node",
|
|
101
|
+
"args": [
|
|
102
|
+
"/ABSOLUTE/PATH/tools/mcp-magento-cms/src/index.js"
|
|
103
|
+
],
|
|
104
|
+
"env": {
|
|
105
|
+
"MAGENTO_BASE_URL": "https://mage248p3.ddev.site",
|
|
106
|
+
"MAGENTO_ACCESS_TOKEN": "YOUR_TOKEN"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
See also `cursor-mcp.example.json`. Restart MCP / Cursor after changes.
|
|
114
|
+
|
|
115
|
+
## Prompts to try
|
|
116
|
+
|
|
117
|
+
```text
|
|
118
|
+
Use magento_health to verify Magento.
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
Create a CMS page titled "MCP Demo" with this content:
|
|
123
|
+
First paragraph from Google Docs.
|
|
124
|
+
Second paragraph.
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
Update CMS page_id 8 with content: Updated body for page 8.
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Security
|
|
132
|
+
|
|
133
|
+
- Do not commit `.env` or tokens
|
|
134
|
+
- Integration token should only have CMS permissions
|
|
135
|
+
|
|
136
|
+
## Layout
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
tools/mcp-magento-cms/
|
|
140
|
+
src/index.js MCP server (stdio)
|
|
141
|
+
src/magentoClient.js REST client
|
|
142
|
+
src/pageBuilder.js Row → Text HTML
|
|
143
|
+
.env.example
|
|
144
|
+
scripts/create-integration.php Create integration + token (run via ddev exec)
|
|
145
|
+
scripts/health-check.js
|
|
146
|
+
scripts/smoke-e2e.js End-to-end page creation test
|
|
147
|
+
scripts/test-compose.js
|
|
148
|
+
samples/ Exported reference pages (Page Builder HTML)
|
|
149
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mcpServers": {
|
|
3
|
+
"magento-cms": {
|
|
4
|
+
"command": "node",
|
|
5
|
+
"args": [
|
|
6
|
+
"/home/ajaykumar.prajapati@brainvire.com/htdocs/mage248p3/tools/mcp-magento-cms/src/index.js"
|
|
7
|
+
],
|
|
8
|
+
"env": {
|
|
9
|
+
"MAGENTO_BASE_URL": "https://mage248p3.ddev.site",
|
|
10
|
+
"MAGENTO_ACCESS_TOKEN": "REPLACE_WITH_INTEGRATION_ACCESS_TOKEN",
|
|
11
|
+
"NODE_EXTRA_CA_CERTS": "/home/ajaykumar.prajapati@brainvire.com/.local/share/mkcert/rootCA.pem"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-magento-cms",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Cursor MCP: Magento CMS pages/blocks with Page Builder Row→Text (zero npm deps)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "node src/index.js",
|
|
9
|
+
"health": "node scripts/health-check.js",
|
|
10
|
+
"test:compose": "node scripts/test-compose.js"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18"
|
|
14
|
+
}
|
|
15
|
+
}
|