@diviops/mcp-server 1.5.53 → 1.5.54
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 +24 -1
- package/dist/bounded-page-read.d.ts +9 -0
- package/dist/bounded-page-read.js +67 -0
- package/dist/index.js +29 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,30 @@ The Node.js MCP server inside the DiviOps harness. It gives Claude Code, Codex,
|
|
|
8
8
|
Claude Code <-> MCP Server (stdio) <-> WordPress REST API <-> DiviOps Agent plugin
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## 1.5.
|
|
11
|
+
## 1.5.54 candidate release note
|
|
12
|
+
|
|
13
|
+
Adds optional `bounded:true` to `diviops_page_get` for UTF-8-safe raw content
|
|
14
|
+
chunks of at most 4096 bytes, with a full-page checksum and byte-offset
|
|
15
|
+
continuation. Start at offset zero, then pass each `next_offset` and the initial
|
|
16
|
+
`expected_checksum` until `complete:true`. Content drift refuses continuation;
|
|
17
|
+
discard collected chunks and restart. Free 1.5.26 supplies the precise
|
|
18
|
+
`page_get_bounded_utf8_v1` capability; unsupported older plugins are refused
|
|
19
|
+
before any page fetch, without an unbounded fallback. Reconnect after supported
|
|
20
|
+
plugin updates to refresh the capability handshake.
|
|
21
|
+
|
|
22
|
+
Default reads, authentication, permissions, writes, dependencies and global
|
|
23
|
+
compatibility floors are unchanged. Each chunk request still reads and hashes
|
|
24
|
+
the full upstream content. Bounded responses are not memory-bounded streaming,
|
|
25
|
+
a snapshot service or a universal client-delivery guarantee. This is source
|
|
26
|
+
candidate preparation, not new-package qualification or publication.
|
|
27
|
+
|
|
28
|
+
Independent public builder companion 1.4.7 carries three pending references:
|
|
29
|
+
targeted inspection and checksum-bound continuation in `tools.md`, a native CTA
|
|
30
|
+
preset-ownership example in `presets.md`, and opt-in native image-reveal guidance
|
|
31
|
+
in `design-effects.md`. The image-reveal runtime is already delivered separately
|
|
32
|
+
in Design Library 1.0.0-beta.24; this preparation does not re-release Design.
|
|
33
|
+
|
|
34
|
+
## Previous 1.5.53 candidate release note
|
|
12
35
|
|
|
13
36
|
The only MCP change is an inspector tool-description clarification: direct variable
|
|
14
37
|
references and partial coverage are now explicit. No new tools or input-schema,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const BOUNDED_PAGE_CAPABILITY = "page_get_bounded_utf8_v1";
|
|
2
|
+
export declare const BOUNDED_PAGE_TEXT_LIMIT: number;
|
|
3
|
+
export declare function boundedPageError(code: string, message: string): string;
|
|
4
|
+
/** Validate only this optional wire contract; never forward upstream diagnostics. */
|
|
5
|
+
export declare function serializeBoundedPageRead(result: unknown, request: {
|
|
6
|
+
page_id: number;
|
|
7
|
+
offset: number;
|
|
8
|
+
expected_checksum?: string;
|
|
9
|
+
}): string;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { serializeEnvelope } from "./envelope.js";
|
|
4
|
+
export const BOUNDED_PAGE_CAPABILITY = "page_get_bounded_utf8_v1";
|
|
5
|
+
export const BOUNDED_PAGE_TEXT_LIMIT = 32 * 1024;
|
|
6
|
+
const TOOL = "diviops_page_get";
|
|
7
|
+
const checksum = z.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
8
|
+
const byteCount = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
9
|
+
const chunkEnvelope = z.object({
|
|
10
|
+
ok: z.literal(true),
|
|
11
|
+
data: z.object({
|
|
12
|
+
id: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
13
|
+
encoding: z.literal("utf-8"),
|
|
14
|
+
content_raw: z.string().max(4096),
|
|
15
|
+
content_checksum: checksum,
|
|
16
|
+
total_bytes: byteCount,
|
|
17
|
+
offset: byteCount,
|
|
18
|
+
chunk_bytes: byteCount.max(4096),
|
|
19
|
+
next_offset: byteCount.nullable(),
|
|
20
|
+
complete: z.boolean(),
|
|
21
|
+
}).strict(),
|
|
22
|
+
}).strict();
|
|
23
|
+
export function boundedPageError(code, message) {
|
|
24
|
+
return serializeEnvelope({ ok: false, error: { code, message } }, TOOL);
|
|
25
|
+
}
|
|
26
|
+
const errors = {
|
|
27
|
+
not_found: "Page not found.",
|
|
28
|
+
forbidden: "Page read permission denied.",
|
|
29
|
+
invalid_input: "Invalid bounded read parameters; use the returned byte offset and checksum.",
|
|
30
|
+
"page.content_drift": "Page content changed; discard prior chunks and restart at offset zero.",
|
|
31
|
+
"page.invalid_encoding": "Page content is not valid UTF-8; no bytes were returned.",
|
|
32
|
+
};
|
|
33
|
+
/** Validate only this optional wire contract; never forward upstream diagnostics. */
|
|
34
|
+
export function serializeBoundedPageRead(result, request) {
|
|
35
|
+
const invalid = () => boundedPageError("page.invalid_bounded_response", "Plugin returned an invalid or oversized bounded page response; no content was forwarded.");
|
|
36
|
+
if (typeof result === "object" && result !== null && "ok" in result && result.ok === false) {
|
|
37
|
+
const error = "error" in result ? result.error : null;
|
|
38
|
+
const code = typeof error === "object" && error !== null && "code" in error ? error.code : null;
|
|
39
|
+
if (typeof code === "string" && Object.hasOwn(errors, code))
|
|
40
|
+
return boundedPageError(code, errors[code]);
|
|
41
|
+
return boundedPageError("page.bounded_read_failed", "Bounded page read failed; no upstream payload was forwarded.");
|
|
42
|
+
}
|
|
43
|
+
const parsed = chunkEnvelope.safeParse(result);
|
|
44
|
+
if (!parsed.success)
|
|
45
|
+
return invalid();
|
|
46
|
+
const data = parsed.data.data;
|
|
47
|
+
const bytes = Buffer.from(data.content_raw, "utf8");
|
|
48
|
+
const end = data.offset + data.chunk_bytes;
|
|
49
|
+
if (data.id !== request.page_id || data.offset !== request.offset
|
|
50
|
+
|| bytes.toString("utf8") !== data.content_raw
|
|
51
|
+
|| bytes.length !== data.chunk_bytes || !Number.isSafeInteger(end) || end > data.total_bytes
|
|
52
|
+
|| data.complete !== (end === data.total_bytes)
|
|
53
|
+
|| data.next_offset !== (data.complete ? null : end)
|
|
54
|
+
|| (!data.complete && data.chunk_bytes < 4093)
|
|
55
|
+
|| (request.offset > 0 && request.expected_checksum === undefined)
|
|
56
|
+
|| (request.expected_checksum !== undefined && data.content_checksum !== request.expected_checksum))
|
|
57
|
+
return invalid();
|
|
58
|
+
if (data.offset === 0 && data.complete
|
|
59
|
+
&& data.content_checksum !== `sha256:${createHash("sha256").update(bytes).digest("hex")}`)
|
|
60
|
+
return invalid();
|
|
61
|
+
const text = serializeEnvelope(parsed.data, TOOL);
|
|
62
|
+
// Also measure the surrounding text block, including its second JSON escaping layer.
|
|
63
|
+
if (Buffer.byteLength(text, "utf8") > BOUNDED_PAGE_TEXT_LIMIT
|
|
64
|
+
|| Buffer.byteLength(JSON.stringify({ content: [{ type: "text", text }] }), "utf8") > BOUNDED_PAGE_TEXT_LIMIT)
|
|
65
|
+
return invalid();
|
|
66
|
+
return text;
|
|
67
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
12
12
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
import { WPClient } from "./wp-client.js";
|
|
15
|
+
import { BOUNDED_PAGE_CAPABILITY, boundedPageError, serializeBoundedPageRead } from "./bounded-page-read.js";
|
|
15
16
|
import { requestAuthoringWrite } from "./authoring-shape-integration.js";
|
|
16
17
|
import { capabilityUpgradeHint, MissingCapabilityError, observedVersion, proToolGatesSatisfied, } from "./compatibility.js";
|
|
17
18
|
import { missingCapabilityEnvelope, } from "./capability-envelope.js";
|
|
@@ -566,13 +567,39 @@ registerPluginTool("diviops_page_list", {
|
|
|
566
567
|
};
|
|
567
568
|
});
|
|
568
569
|
registerPluginTool("diviops_page_get", {
|
|
569
|
-
description: "Get detailed info about a specific page including its raw Divi block content and content_checksum (`sha256:` over the exact post_content bytes) for stale-write protection. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing page_id returns ok:false with code 'not_found' and a hint pointing to diviops_page_list.",
|
|
570
|
+
description: "Get detailed info about a specific page including its raw Divi block content and content_checksum (`sha256:` over the exact post_content bytes) for stale-write protection. Default response is unchanged and unbounded. Optional bounded:true requires page_get_bounded_utf8_v1 and returns only raw UTF-8 content chunks (at most 4096 bytes), id, encoding, full-page content_checksum, total_bytes, offset, chunk_bytes, next_offset (null at completion), and complete. MCP text is limited to 32 KiB including escaping/metadata. Start at offset:0; continue with next_offset and the initial expected_checksum until complete:true. Drift refuses even same-length edits; discard chunks and restart. No parser reconstruction, fallback, or snapshot storage. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing page_id returns ok:false with code 'not_found' and a hint pointing to diviops_page_list in legacy mode.",
|
|
570
571
|
inputSchema: {
|
|
571
572
|
page_id: z.number().describe("WordPress post/page ID"),
|
|
573
|
+
bounded: z.boolean().optional().describe("Opt into checksum-bound UTF-8 chunks; omitted/false preserves the legacy response."),
|
|
574
|
+
offset: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional().describe("Byte offset for bounded mode; defaults to zero. Use the returned next_offset."),
|
|
575
|
+
expected_checksum: z.string().regex(/^sha256:[a-f0-9]{64}$/).optional().describe("Required for nonzero bounded offsets; the exact initial full-page content_checksum."),
|
|
572
576
|
},
|
|
573
577
|
annotations: { idempotentHint: true },
|
|
574
578
|
_meta: { idempotent: "true" },
|
|
575
|
-
}, async ({ page_id }) => {
|
|
579
|
+
}, async ({ page_id, bounded, offset, expected_checksum }) => {
|
|
580
|
+
if (bounded || offset !== undefined || expected_checksum !== undefined) {
|
|
581
|
+
const reply = (text) => ({ content: [{ type: "text", text }] });
|
|
582
|
+
if (!bounded || !Number.isSafeInteger(page_id) || page_id <= 0 || ((offset ?? 0) > 0 && expected_checksum === undefined)) {
|
|
583
|
+
return reply(boundedPageError("invalid_input", "Use bounded:true, a positive integer page_id, and expected_checksum for every nonzero offset."));
|
|
584
|
+
}
|
|
585
|
+
// Unlike the legacy gate, unavailable handshake evidence must not dispatch a page read.
|
|
586
|
+
if (handshakeState.kind !== "ok" || handshakeState.capabilities[BOUNDED_PAGE_CAPABILITY] !== true) {
|
|
587
|
+
return reply(boundedPageError("capability_missing", "Bounded page read capability page_get_bounded_utf8_v1 is absent or unavailable. Install a compatible plugin and reconnect; no page was fetched."));
|
|
588
|
+
}
|
|
589
|
+
try {
|
|
590
|
+
const result = await wp.requestEnveloped(`/page/get/${page_id}`, {
|
|
591
|
+
params: {
|
|
592
|
+
bounded: "true",
|
|
593
|
+
offset: String(offset ?? 0),
|
|
594
|
+
...(expected_checksum === undefined ? {} : { expected_checksum }),
|
|
595
|
+
},
|
|
596
|
+
});
|
|
597
|
+
return reply(serializeBoundedPageRead(result, { page_id, offset: offset ?? 0, expected_checksum }));
|
|
598
|
+
}
|
|
599
|
+
catch {
|
|
600
|
+
return reply(boundedPageError("page.bounded_read_failed", "Bounded page read failed; no upstream payload was forwarded."));
|
|
601
|
+
}
|
|
602
|
+
}
|
|
576
603
|
const result = await wp.requestEnveloped(`/page/get/${page_id}`);
|
|
577
604
|
return {
|
|
578
605
|
content: [
|