mcp-magento-cms 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -1,11 +1,14 @@
1
- # Magento CMS MCP (Cursor) — zero npm dependencies
1
+ # Magento CMS MCP (Cursor)
2
2
 
3
- Create/update Magento **CMS Pages / Blocks** with Page Builder **Row → Text**.
3
+ Create/update Magento **CMS Pages / Blocks** with Page Builder **Row → Text** from Cursor chat.
4
4
 
5
- - **AI:** your Cursor subscription (chat plans content)
6
- - **This server:** Magento REST only (Integration Access Token)
5
+ - **AI:** Cursor plans the content
6
+ - **This server:** Magento REST via an Integration Access Token
7
+ - **Install:** `npx` (no local clone, no `tools/` folder, no `.env` file required)
7
8
 
8
- Requires **Node 18+** only (`fetch` built-in). No `npm install` required.
9
+ Requires **Node.js 18+** and [Cursor](https://cursor.com).
10
+
11
+ Package: [npmjs.com/package/mcp-magento-cms](https://www.npmjs.com/package/mcp-magento-cms)
9
12
 
10
13
  ## Tools
11
14
 
@@ -14,113 +17,90 @@ Requires **Node 18+** only (`fetch` built-in). No `npm install` required.
14
17
  | `magento_health` | Test base URL + token |
15
18
  | `get_cms_page` | Load by `page_id` |
16
19
  | `create_cms_page` | Create from title + content |
17
- | `update_cms_page` | Update by `page_id` (e.g. 8) |
20
+ | `update_cms_page` | Update by `page_id` |
18
21
  | `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
22
+ | `list_section_types` | Supported layouts (MVP: `simple_text`) |
24
23
 
25
- Automated (recommended, ddev):
24
+ ## Setup (any machine)
26
25
 
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
- ```
26
+ You do **not** need to clone this repo or create a `.env` file. Cursor runs the package with `npx` and reads credentials from `mcp.json`.
31
27
 
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
- ```
28
+ ### 1. Magento Integration Access Token
41
29
 
42
- ### 2. Base URL (ddev)
30
+ In Magento Admin:
43
31
 
44
- ```bash
45
- ddev describe
46
- # e.g. https://mage248p3.ddev.site
47
- ```
32
+ 1. **System → Extensions → Integrations → Add New Integration**
33
+ 2. Name it (e.g. `MCP CMS`)
34
+ 3. **API** tab: allow **CMS → Pages**, **CMS → Blocks**, and **Content → Design** (`save_design`) as needed
35
+ 4. **Save → Activate** → copy the **Access Token**
48
36
 
49
- ### 3. Configure `.env`
37
+ Magento **2.4.4+** blocks integration tokens as Bearer by default. Enable once on the Magento server:
50
38
 
51
39
  ```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
40
+ bin/magento config:set oauth/consumer/enable_integration_as_bearer 1
41
+ bin/magento cache:flush config
57
42
  ```
58
43
 
59
- Test without Cursor (optional):
44
+ (With ddev: prefix with `ddev exec`.)
60
45
 
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"
46
+ ### 2. Magento base URL
64
47
 
65
- # only works when Magento is up and token is set
66
- node scripts/health-check.js
48
+ Use your storefront base URL **without** a trailing slash, for example:
67
49
 
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
- ```
50
+ - Production: `https://www.example.com`
51
+ - Local ddev: `https://your-project.ddev.site` (`ddev describe` shows the URL)
74
52
 
75
- ### 4. Cursor MCP config
53
+ ### 3. Add the MCP in Cursor
76
54
 
77
- **Cursor → Settings → MCP**, or project file `.cursor/mcp.json`:
78
-
79
- Use **absolute** path to `index.js`:
55
+ **Cursor → Settings → MCP → Edit Config**, or create `.cursor/mcp.json` in your project:
80
56
 
81
57
  ```json
82
58
  {
83
59
  "mcpServers": {
84
60
  "magento-cms": {
85
- "command": "node",
86
- "args": [
87
- "/home/YOUR_USER/htdocs/mage248p3/tools/mcp-magento-cms/src/index.js"
88
- ]
61
+ "command": "npx",
62
+ "args": ["-y", "mcp-magento-cms"],
63
+ "env": {
64
+ "MAGENTO_BASE_URL": "https://www.example.com",
65
+ "MAGENTO_ACCESS_TOKEN": "YOUR_INTEGRATION_ACCESS_TOKEN"
66
+ }
89
67
  }
90
68
  }
91
69
  }
92
70
  ```
93
71
 
94
- Secrets can stay in `.env` next to the server (auto-loaded). Or pass env:
72
+ **Local ddev / mkcert only** — Node may not trust the local TLS cert. Add:
95
73
 
96
74
  ```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
- }
75
+ "NODE_EXTRA_CA_CERTS": "/absolute/path/to/mkcert/rootCA.pem"
111
76
  ```
112
77
 
113
- See also `cursor-mcp.example.json`. Restart MCP / Cursor after changes.
78
+ Typical Linux path: `$HOME/.local/share/mkcert/rootCA.pem`
79
+
80
+ Optional env vars:
81
+
82
+ | Variable | Default | Purpose |
83
+ |----------|---------|---------|
84
+ | `MAGENTO_STORE_CODE` | (empty) | REST store code |
85
+ | `MAGENTO_ADMIN_PATH` | `admin` | Admin path used in edit links |
114
86
 
115
- ## Prompts to try
87
+ ### 4. Restart MCP
88
+
89
+ In Cursor MCP settings, refresh/restart the `magento-cms` server until it shows connected.
90
+
91
+ ### 5. Verify
92
+
93
+ In Cursor chat:
116
94
 
117
95
  ```text
118
96
  Use magento_health to verify Magento.
119
97
  ```
120
98
 
99
+ Then try:
100
+
121
101
  ```text
122
102
  Create a CMS page titled "MCP Demo" with this content:
123
- First paragraph from Google Docs.
103
+ First paragraph.
124
104
  Second paragraph.
125
105
  ```
126
106
 
@@ -130,20 +110,19 @@ Update CMS page_id 8 with content: Updated body for page 8.
130
110
 
131
111
  ## Security
132
112
 
133
- - Do not commit `.env` or tokens
134
- - Integration token should only have CMS permissions
113
+ - Put tokens only in `mcp.json` / Cursor env (do not commit them)
114
+ - Give the Magento integration **CMS-only** permissions
135
115
 
136
- ## Layout
116
+ ## Requirements
137
117
 
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)
118
+ - Node.js **18+** on the machine running Cursor
119
+ - Magento 2 with REST and an Integration token
120
+ - Network access from that machine to `MAGENTO_BASE_URL`
121
+
122
+ ## For package maintainers
123
+
124
+ Clone this repo to develop or republish. Bump `version` in `package.json`, then:
125
+
126
+ ```bash
127
+ npm publish --access public
149
128
  ```
package/package.json CHANGED
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "name": "mcp-magento-cms",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Cursor MCP: Magento CMS pages/blocks with Page Builder Row→Text (zero npm deps)",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
+ "bin": {
8
+ "mcp-magento-cms": "./src/index.js"
9
+ },
10
+ "files": [
11
+ "src",
12
+ "README.md"
13
+ ],
7
14
  "scripts": {
8
15
  "start": "node src/index.js",
9
16
  "health": "node scripts/health-check.js",
package/src/index.js CHANGED
File without changes
package/.env.example DELETED
@@ -1,11 +0,0 @@
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
@@ -1,15 +0,0 @@
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
- }