elementor-mcp-agent 0.1.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.
@@ -0,0 +1,60 @@
1
+ # Architecture
2
+
3
+ ## Layers
4
+
5
+ ```
6
+ ┌─────────────────────────────────────────────────────────┐
7
+ │ MCP stdio (Claude Desktop / Code / any MCP client) │
8
+ └────────────────────────────────────────────────────┬────┘
9
+
10
+ ┌─────────▼────────┐
11
+ │ server.ts │
12
+ │ (MCP entry) │
13
+ └─────────┬────────┘
14
+
15
+ ┌─────────────────────────────────────┼──────────────────────────────┐
16
+ │ │ │
17
+ ┌──────▼──────┐ ┌───────▼─────┐ ┌───────▼──────┐
18
+ │ tools/ │ │ resources/ │ │ config.ts │
19
+ │ │ │ (docs) │ │ (sites pool)│
20
+ └──────┬──────┘ └─────────────┘ └──────────────┘
21
+
22
+ ┌──────────┼──────────────┐
23
+ │ │ │
24
+ ┌──▼───┐ ┌────▼─────┐ ┌──────▼────────┐
25
+ │ api/ │ │ elementor│ │ throttle/ │
26
+ │ wp- │ │ data- │ │ token-bucket │
27
+ │ rest │ │ parser │ │ (per-site) │
28
+ └──────┘ │ safety │ └───────────────┘
29
+ └──────────┘
30
+ ```
31
+
32
+ ## Design decisions
33
+
34
+ - **Stdio transport** — same as every other MCP. No HTTP server, no auth surface. The MCP client (Claude Desktop, Claude Code, etc.) spawns the binary, talks JSON-RPC over its stdin/stdout.
35
+ - **Per-site config, not per-call** — the LLM doesn't get to inject credentials. Sites are configured once in the env via JSON; tools take a `site_id` to pick one.
36
+ - **Zod everywhere** — every tool's input is validated with Zod before the handler runs. Same Zod schema is converted to JSON Schema Draft 7 for the MCP `tools/list` response.
37
+ - **Logs to stderr only** — stdio transport is sacred. A single `console.log` would corrupt the JSON-RPC stream. `pino.destination(2)` enforces stderr.
38
+ - **Token bucket per site** — 60 req/min default. Each site has its own bucket so one slow site doesn't block another.
39
+ - **Confirmation tokens for destructive ops** — 8-byte random hex, TTL 60s, single-use, intent-locked. Stored in-memory only (no disk). Surface area for accidental destruction is minimised.
40
+ - **Backup before edit** — `_elementor_data` is fragile. Every edit creates a timestamped postmeta backup first.
41
+
42
+ ## Why not WP-CLI as primary transport?
43
+
44
+ WP-CLI is more powerful than the REST API (can do anything WordPress can do), but:
45
+
46
+ 1. Requires SSH access — many managed hosts don't expose it.
47
+ 2. Slower per-call (SSH handshake overhead).
48
+ 3. Output is text — needs parsing each time.
49
+
50
+ So: REST API is the primary surface. WP-CLI is reserved for the v0.2 escape hatch.
51
+
52
+ ## Why not include Elementor Pro version check?
53
+
54
+ Elementor Pro is paid and updates through Elementor's own server (not wordpress.org). Reliably detecting "is there a newer version?" requires either:
55
+
56
+ 1. Hitting Elementor's licence server (not public).
57
+ 2. Scraping `elementor.com/changelog/` (fragile).
58
+ 3. Reading the Pro update transient on each site (works, in roadmap).
59
+
60
+ For v0.1 we surface the **installed** Pro version per site (good enough to spot fleet-wide drift) but don't compare against a "latest" until we wire option 3 properly.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MogaCode SARL-AU
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
package/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # elementor-mcp-agent
2
+
3
+ [![npm version](https://img.shields.io/npm/v/elementor-mcp-agent.svg)](https://www.npmjs.com/package/elementor-mcp-agent)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
5
+
6
+ > **Agency-grade MCP server for WordPress Elementor.** Multi-site management, safe Elementor data editing with backup + dry-run + CSS-flush, template export/import across sites, version tracking, and a curated Elementor docs corpus exposed as MCP resources.
7
+
8
+ Built for agencies running many client sites on Elementor / Elementor Pro who want Claude (or any MCP client) to drive the toil — without breaking pages.
9
+
10
+ ---
11
+
12
+ ## Why this exists
13
+
14
+ There are ~25 WordPress MCP servers on GitHub today. None target the **agency** use case:
15
+
16
+ - **Multi-site** — list, ping, and act on a pool of sites in one prompt.
17
+ - **Elementor-aware** — understands `_elementor_data` structure, not just generic WP REST.
18
+ - **Defensive editing** — auto-backup before any change, dry-run + confirmation token for destructive ops, CSS regeneration on save.
19
+ - **Cross-site template sync** — export from staging, import on every client site in one shot.
20
+ - **Version oversight** — see who's running which Elementor / Elementor Pro version across the whole fleet.
21
+
22
+ This MCP starts with these four pillars and grows from there.
23
+
24
+ ---
25
+
26
+ ## ⚠️ Status: early days
27
+
28
+ v0.1.0 is shipped end-to-end (CI green, 14 tests passing, npm + MCP Registry listed) but the tool surface is intentionally focused. Expect rapid iteration. Don't run destructive operations on production without testing on staging first.
29
+
30
+ ---
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ npx -y elementor-mcp-agent
36
+ ```
37
+
38
+ Or globally:
39
+
40
+ ```bash
41
+ npm install -g elementor-mcp-agent
42
+ ```
43
+
44
+ ## Configure
45
+
46
+ The server needs to know about your sites. The simplest path: an env var with a JSON array.
47
+
48
+ ```bash
49
+ export ELEMENTOR_MCP_SITES='[
50
+ {
51
+ "id": "client-acme",
52
+ "url": "https://acme.example.com",
53
+ "username": "admin",
54
+ "application_password": "xxxx xxxx xxxx xxxx xxxx xxxx"
55
+ },
56
+ {
57
+ "id": "client-beta",
58
+ "url": "https://beta.example.com",
59
+ "username": "admin",
60
+ "application_password": "yyyy yyyy yyyy yyyy yyyy yyyy"
61
+ }
62
+ ]'
63
+ ```
64
+
65
+ Generate the **WordPress Application Password** at:
66
+ `https://{your-site}/wp-admin/profile.php#application-passwords-section`
67
+
68
+ (`Application Passwords` is a built-in WordPress 5.6+ feature. No plugin required.)
69
+
70
+ Or use a config file:
71
+
72
+ ```bash
73
+ export ELEMENTOR_MCP_CONFIG_PATH="/path/to/sites.json"
74
+ ```
75
+
76
+ With `sites.json`:
77
+ ```json
78
+ {
79
+ "sites": [
80
+ { "id": "...", "url": "...", "username": "...", "application_password": "..." }
81
+ ],
82
+ "default_site_id": "client-acme",
83
+ "rate_limit_per_minute": 60,
84
+ "confirmation_ttl_seconds": 60
85
+ }
86
+ ```
87
+
88
+ ### Configure Claude Desktop
89
+
90
+ `~/Library/Application Support/Claude/claude_desktop_config.json`:
91
+
92
+ ```json
93
+ {
94
+ "mcpServers": {
95
+ "elementor": {
96
+ "command": "npx",
97
+ "args": ["-y", "elementor-mcp-agent"],
98
+ "env": {
99
+ "ELEMENTOR_MCP_SITES": "[{\"id\":\"acme\",\"url\":\"https://acme.com\",\"username\":\"admin\",\"application_password\":\"xxxx...\"}]"
100
+ }
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ ### Configure Claude Code
107
+
108
+ ```bash
109
+ claude mcp add elementor \
110
+ -e ELEMENTOR_MCP_SITES='[{"id":"acme","url":"https://acme.com","username":"admin","application_password":"xxxx..."}]' \
111
+ -- npx -y elementor-mcp-agent
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Tools (v0.1)
117
+
118
+ | Tool | What it does |
119
+ |---|---|
120
+ | `list_sites` | Lists every site in the pool (id, url, username, has_ssh). |
121
+ | `ping_site` | Verifies auth + reports WP / Elementor / Elementor Pro versions. |
122
+ | `list_elementor_pages` | Lists pages built with Elementor on a given site. |
123
+ | `read_page_elementor` | Returns a structured summary of a page's `_elementor_data` (widget counts by type, depth). Full tree with `verbose=true`. |
124
+ | `elementor_find_replace` | Find/replace plain text in every widget on a page. **Two-call destructive flow**: dry-run returns a count + token; second call with token applies after auto-backup. |
125
+ | `list_elementor_templates` | Lists library templates (sections, pages, popups, headers, footers). |
126
+ | `export_elementor_template` | Exports a template as portable JSON. |
127
+ | `import_elementor_template` | Imports a portable JSON template into a target site. |
128
+ | `check_elementor_versions` | Fleet-wide Elementor version audit. Flags outdated installs against wordpress.org latest. |
129
+
130
+ ## Resources
131
+
132
+ The server exposes a hand-curated set of Elementor reference docs as MCP `resources`, so the LLM can look up hook names, widget structure, and safe editing patterns without leaving its context:
133
+
134
+ - `elementor-docs://hooks-actions.md` — common action hooks + filters
135
+ - `elementor-docs://widget-structure.md` — `_elementor_data` schema + common widget types
136
+ - `elementor-docs://safe-editing.md` — backup, dry-run, CSS flush patterns
137
+
138
+ ---
139
+
140
+ ## Safety patterns
141
+
142
+ Every destructive operation follows the same dance:
143
+
144
+ 1. **First call** (no `confirmation` arg) → dry-run. Returns `match_count` + `confirmation_token` (TTL 60s, configurable).
145
+ 2. **Second call** (same args + token) → applies after backing up the page's `_elementor_data` to a timestamped postmeta key.
146
+ 3. **CSS flush** is triggered automatically (REST `/elementor/v1/css?action=regenerate`, falls back to re-save).
147
+
148
+ The backup is **never deleted** — purge old `_elementor_data_backup_*` postmeta keys yourself when no longer needed.
149
+
150
+ ---
151
+
152
+ ## Rate limiting
153
+
154
+ Per-site token bucket, default **60 req/min** (matches what most managed WordPress hosts allow on `wp-json`). Override via `rate_limit_per_minute` in config.
155
+
156
+ ---
157
+
158
+ ## Roadmap
159
+
160
+ **v0.2**
161
+ - [ ] `widget_swap` — replace one widget by another with field mapping
162
+ - [ ] `restore_elementor_backup` — restore a page from a timestamped backup
163
+ - [ ] `bulk_find_replace` — apply find/replace across all pages of a site
164
+ - [ ] WP-CLI runner via SSH for ops the REST API can't do
165
+
166
+ **v0.3**
167
+ - [ ] Cross-site template push (`push_template_to_all`)
168
+ - [ ] Fleet health: outdated plugins, broken links, PageSpeed snapshot
169
+ - [ ] Visual diff (screenshot before/after)
170
+ - [ ] Elementor Pro version detection from Pro server (currently free-only)
171
+
172
+ **v1.0**
173
+ - [ ] Mature widget mutation API (typed setters per widget type)
174
+ - [ ] Automated docs ingestion from developer.elementor.com
175
+ - [ ] Per-tool happy-path tests against a real Elementor install
176
+
177
+ ---
178
+
179
+ ## Architecture
180
+
181
+ See [ARCHITECTURE.md](./ARCHITECTURE.md) for the full design rationale.
182
+
183
+ Short version: stdio MCP, Zod-validated tools, token-bucket throttling, confirmation tokens for destructive ops, pino logs to stderr (never stdout), tsup bundle, vitest tests.
184
+
185
+ ---
186
+
187
+ ## License
188
+
189
+ [MIT](./LICENSE) — © 2026 [MogaCode](https://mogacode.ma).
@@ -0,0 +1,2 @@
1
+
2
+ export { }