@gravitykit/block-mcp 2.0.0-beta → 2.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.
- package/README.md +34 -7
- package/dist/index.cjs +2556 -967
- package/package.json +12 -4
- package/src/__tests__/coerce.test.ts +57 -0
- package/src/__tests__/fixtures/error-envelopes.ts +19 -7
- package/src/__tests__/integration/dual-storage.test.ts +22 -26
- package/src/__tests__/integration/error-envelopes.test.ts +2 -2
- package/src/__tests__/integration/posts-terms-media.test.ts +271 -0
- package/src/__tests__/integration/read-discovery.test.ts +313 -0
- package/src/__tests__/integration/upload-roundtrip.test.ts +54 -0
- package/src/__tests__/integration/write-surface.test.ts +603 -0
- package/src/__tests__/integration/yoast-bridge.test.ts +39 -0
- package/src/__tests__/tools/discovery/list_patterns.test.ts +25 -6
- package/src/__tests__/tools/mutate/edit_block_tree.test.ts +53 -0
- package/src/__tests__/tools/patterns/insert_pattern.test.ts +16 -0
- package/src/__tests__/tools/posts/update_post.test.ts +14 -0
- package/src/__tests__/tools/read/get_block.test.ts +35 -0
- package/src/__tests__/tools/read/get_page_blocks.test.ts +18 -0
- package/src/__tests__/tools/read/pagination.test.ts +65 -0
- package/src/__tests__/tools/write/delete_block.test.ts +18 -0
- package/src/__tests__/tools/write/insert_blocks.test.ts +21 -0
- package/src/__tests__/tools/write/replace_block_range.test.ts +71 -0
- package/src/__tests__/tools/write/rewrite_post_blocks.test.ts +39 -0
- package/src/__tests__/tools/write/update_block.test.ts +16 -0
- package/src/__tests__/tools/write/update_blocks.test.ts +21 -0
- package/src/__tests__/tools/yoast/yoast_get_seo.test.ts +11 -3
- package/src/__tests__/tools/yoast/yoast_update_seo.test.ts +16 -0
- package/src/__tests__/unit/client/ref-endpoints.test.ts +3 -6
- package/src/__tests__/unit/enrichers/cbp-enricher.test.ts +21 -0
- package/src/__tests__/unit/error-translator/translate-wp-error.test.ts +101 -30
- package/src/__tests__/unit/instructions.test.ts +3 -3
- package/src/__tests__/unit/preferences/enrich-pattern-list.test.ts +26 -10
- package/src/__tests__/unit/rest-url.test.ts +23 -0
- package/src/agent-guide.ts +85 -0
- package/src/client.ts +104 -40
- package/src/coerce.ts +41 -0
- package/src/config.ts +96 -0
- package/src/connect.ts +123 -38
- package/src/enrichers.ts +6 -2
- package/src/error-translator.ts +63 -11
- package/src/index.ts +49 -79
- package/src/instructions.ts +3 -3
- package/src/preferences.ts +56 -43
- package/src/rest-url.ts +18 -0
- package/src/tools/discovery.ts +10 -14
- package/src/tools/mutate.ts +21 -20
- package/src/tools/patterns.ts +3 -2
- package/src/tools/posts.ts +26 -26
- package/src/tools/read.ts +23 -6
- package/src/tools/write.ts +37 -36
- package/src/tools/yoast.ts +30 -31
- package/src/types.ts +45 -31
- package/src/validate-args.ts +109 -0
package/README.md
CHANGED
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
* [Blocks that store data in two places](#blocks-that-store-data-in-two-places)
|
|
35
35
|
* [Post types AI agents can create](#post-types-ai-agents-can-create)
|
|
36
36
|
* [Storage-mode scan + reset](#storage-mode-scan--reset)
|
|
37
|
+
* [Security](#security)
|
|
38
|
+
* [Seal mode (Claude Desktop)](#seal-mode-claude-desktop)
|
|
37
39
|
* [Examples](#examples)
|
|
38
40
|
* [Testing](#testing)
|
|
39
41
|
* [Requirements](#requirements)
|
|
@@ -175,7 +177,7 @@ These can coexist. Block MCP could (and likely will) be exposed through the offi
|
|
|
175
177
|
AI Agent ←stdio→ MCP server (your machine) ←HTTPS→ WordPress plugin (your site)
|
|
176
178
|
```
|
|
177
179
|
|
|
178
|
-
**WordPress plugin** (`wordpress-plugin/gk-block-
|
|
180
|
+
**WordPress plugin** (`wordpress-plugin/gk-block-mcp/`) — REST API at `gk-block-api/v1`. Handles block parsing, serialization, safety checks, preference scoring, rate limiting, revisions. Works with any post type that stores Gutenberg blocks in `post_content`.
|
|
179
181
|
|
|
180
182
|
**MCP server** (`src/`) — TypeScript stdio server that exposes the REST API as MCP tools. Authenticates as a normal WordPress user via Application Password. No special privileges, no direct DB access from the MCP side.
|
|
181
183
|
|
|
@@ -183,14 +185,14 @@ AI Agent ←stdio→ MCP server (your machine) ←HTTPS→ WordPress plugin
|
|
|
183
185
|
|
|
184
186
|
### 1. Install the WordPress plugin
|
|
185
187
|
|
|
186
|
-
**Easiest — download the latest ZIP:** [gk-block-
|
|
188
|
+
**Easiest — download the latest ZIP:** [gk-block-mcp.zip](https://github.com/GravityKit/block-mcp/releases/download/latest/gk-block-mcp.zip) (auto-built from `main` on every push).
|
|
187
189
|
|
|
188
190
|
Then in WordPress: **Plugins → Add New → Upload Plugin** and pick the ZIP.
|
|
189
191
|
|
|
190
|
-
Or copy `wordpress-plugin/gk-block-
|
|
192
|
+
Or copy `wordpress-plugin/gk-block-mcp/` to your site's `wp-content/plugins/` and activate manually. Or via WP-CLI:
|
|
191
193
|
|
|
192
194
|
```bash
|
|
193
|
-
wp plugin install https://github.com/GravityKit/block-mcp/releases/download/latest/gk-block-
|
|
195
|
+
wp plugin install https://github.com/GravityKit/block-mcp/releases/download/latest/gk-block-mcp.zip --activate
|
|
194
196
|
```
|
|
195
197
|
|
|
196
198
|
### 2. Connect your AI assistant
|
|
@@ -231,8 +233,9 @@ In WordPress admin: **Users → Profile → Application Passwords**. Or via CLI:
|
|
|
231
233
|
wp user application-password create <username> "Block MCP" --porcelain
|
|
232
234
|
```
|
|
233
235
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
+
Read endpoints require the `edit_posts` capability; write endpoints require
|
|
237
|
+
`edit_post` on the specific post being changed. Then build and register the
|
|
238
|
+
server:
|
|
236
239
|
|
|
237
240
|
```bash
|
|
238
241
|
git clone https://github.com/GravityKit/block-mcp
|
|
@@ -374,6 +377,30 @@ The scan walks every published post and classifies each distinct block as static
|
|
|
374
377
|
|
|
375
378
|

|
|
376
379
|
|
|
380
|
+
## Security
|
|
381
|
+
|
|
382
|
+
Block MCP gives an AI assistant exactly the access it needs to edit content — and nothing more.
|
|
383
|
+
|
|
384
|
+
- **A separate, limited account.** Connecting creates a dedicated account just for the assistant. It can write and edit your posts, pages, and media, but it can't change site settings, delete other people's content, or sign in to your dashboard — and disconnecting it removes all of that access at once. (You can connect through your own account instead; it's clearly marked as the higher-access option, and a site owner can turn that option off entirely.)
|
|
385
|
+
- **Your password stays private.** It's never shown in a web address or saved to your browser history, and the connection is set up locally on your own computer. Any config files written are readable only by you.
|
|
386
|
+
- **Stored secrets are encrypted.** Any credential held between setup steps is encrypted (AES‑256‑GCM) before it's saved, and cleared once it's used — never kept as plain text.
|
|
387
|
+
- **The assistant can't inject code.** Everything it writes is sanitized, so it can't slip scripts or trackers into your pages.
|
|
388
|
+
|
|
389
|
+
### Seal mode (Claude Desktop)
|
|
390
|
+
|
|
391
|
+
The one-click Claude Desktop installer can either include your credential or leave it out:
|
|
392
|
+
|
|
393
|
+
| Mode | What happens |
|
|
394
|
+
|---|---|
|
|
395
|
+
| `prefill` *(default)* | The installer includes the password, so setup is one click; Claude Desktop saves it to your OS keychain. |
|
|
396
|
+
| `paste` | The installer leaves the password out — you paste it in yourself, so it never lands in a downloaded file. |
|
|
397
|
+
|
|
398
|
+
Developers can force paste mode with a filter, or by defining `GK_BLOCK_MCP_FORCE_PASTE_SECRET` as `true` in `wp-config.php`:
|
|
399
|
+
|
|
400
|
+
```php
|
|
401
|
+
add_filter( 'gk/block-mcp/credential/seal-mode', fn() => 'paste' );
|
|
402
|
+
```
|
|
403
|
+
|
|
377
404
|
## Examples
|
|
378
405
|
|
|
379
406
|
**Update a heading by URL**
|
|
@@ -415,7 +442,7 @@ Run all suites locally:
|
|
|
415
442
|
npm test
|
|
416
443
|
|
|
417
444
|
# PHP (PHPUnit, stub WP bootstrap) — 335 tests
|
|
418
|
-
cd wordpress-plugin/gk-block-
|
|
445
|
+
cd wordpress-plugin/gk-block-mcp && phpunit -c tests/phpunit.xml
|
|
419
446
|
```
|
|
420
447
|
|
|
421
448
|
The PHP suite uses a minimal WordPress stub layer (no full WP install required) to exercise validation, error paths, mutation engine, ref resolution, HTML auto-transforms, post lifecycle, term listing, media validation, and REST summary/outline.
|