@diviops/mcp-server 1.5.38 → 1.5.39
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 +7 -0
- package/dist/canonical-tool-registry.d.ts +21 -0
- package/dist/canonical-tool-registry.js +33 -0
- package/dist/compatibility.d.ts +7 -0
- package/dist/health-tools.d.ts +53 -0
- package/dist/health-tools.js +83 -0
- package/dist/index.d.ts +26 -1
- package/dist/index.js +63 -31
- package/dist/target-evidence.d.ts +40 -0
- package/dist/target-evidence.js +152 -0
- package/dist/wp-client.d.ts +6 -2
- package/dist/wp-client.js +14 -7
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -65,6 +65,13 @@ Then ask your AI client: **"List the pages on my site."** It calls `diviops_page
|
|
|
65
65
|
|
|
66
66
|
For Claude Desktop JSON, use `"command": "npx"` with args `["-y", "--package", "@diviops/mcp-server", "diviops-mcp"]`. The package also ships `diviops-preset`, so the explicit package/bin form is required; shorthand package invocation cannot reliably infer which bin to run.
|
|
67
67
|
|
|
68
|
+
The public npm package exposes exactly three supported CLIs:
|
|
69
|
+
`diviops-mcp`, `diviops-preset`, and `diviops-cross-env-preflight`. The
|
|
70
|
+
launcher-managed MCP sidecar is a separate future artifact identity; it is not
|
|
71
|
+
a public npm bin or part of the npm tarball. Repository launcher development
|
|
72
|
+
builds and supplies that private entrypoint explicitly. This boundary does not
|
|
73
|
+
change direct npm/stdio support.
|
|
74
|
+
|
|
68
75
|
For a deeper walkthrough (containerized environments, WP-CLI configuration, troubleshooting installation), see [setup-guide.md](../docs/setup-guide.md).
|
|
69
76
|
|
|
70
77
|
## Example workflow
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport-neutral ownership of DiviOps MCP registrations.
|
|
3
|
+
*
|
|
4
|
+
* The shipped server still materializes this registry into the v1 SDK. The
|
|
5
|
+
* non-publishing v2 compatibility spike materializes the same definitions
|
|
6
|
+
* into the split v2 server package. Keeping the registry ignorant of either
|
|
7
|
+
* SDK is the guard against a second tool catalog or a wire-shape translator.
|
|
8
|
+
*/
|
|
9
|
+
export type ToolRegistrar = {
|
|
10
|
+
registerTool(name: string, config: any, handler: any): unknown;
|
|
11
|
+
};
|
|
12
|
+
export type ResourceRegistrar = {
|
|
13
|
+
registerResource(name: string, uri: string, config: any, handler: any): unknown;
|
|
14
|
+
};
|
|
15
|
+
export type RegistryTarget = ToolRegistrar & ResourceRegistrar;
|
|
16
|
+
export declare class CanonicalToolRegistry implements RegistryTarget {
|
|
17
|
+
#private;
|
|
18
|
+
registerTool(name: string, config: any, handler: any): void;
|
|
19
|
+
registerResource(name: string, uri: string, config: any, handler: any): void;
|
|
20
|
+
install(target: RegistryTarget): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport-neutral ownership of DiviOps MCP registrations.
|
|
3
|
+
*
|
|
4
|
+
* The shipped server still materializes this registry into the v1 SDK. The
|
|
5
|
+
* non-publishing v2 compatibility spike materializes the same definitions
|
|
6
|
+
* into the split v2 server package. Keeping the registry ignorant of either
|
|
7
|
+
* SDK is the guard against a second tool catalog or a wire-shape translator.
|
|
8
|
+
*/
|
|
9
|
+
export class CanonicalToolRegistry {
|
|
10
|
+
#tools = new Map();
|
|
11
|
+
#resources = new Map();
|
|
12
|
+
registerTool(name, config, handler) {
|
|
13
|
+
if (this.#tools.has(name)) {
|
|
14
|
+
throw new Error(`Duplicate canonical MCP tool registration: ${name}`);
|
|
15
|
+
}
|
|
16
|
+
this.#tools.set(name, { name, config, handler });
|
|
17
|
+
}
|
|
18
|
+
registerResource(name, uri, config, handler) {
|
|
19
|
+
if (this.#resources.has(name)) {
|
|
20
|
+
throw new Error(`Duplicate canonical MCP resource registration: ${name}`);
|
|
21
|
+
}
|
|
22
|
+
this.#resources.set(name, { name, uri, config, handler });
|
|
23
|
+
}
|
|
24
|
+
install(target) {
|
|
25
|
+
for (const registration of this.#tools.values()) {
|
|
26
|
+
target.registerTool(registration.name, registration.config, registration.handler);
|
|
27
|
+
}
|
|
28
|
+
for (const registration of this.#resources.values()) {
|
|
29
|
+
target.registerResource(registration.name, registration.uri, registration.config, registration.handler);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -80,6 +80,13 @@ export interface HandshakeResult {
|
|
|
80
80
|
active_modules?: Record<string, boolean>;
|
|
81
81
|
/** Advisory installed-plugin versions for S0 preflight reports. */
|
|
82
82
|
plugins?: Record<string, HandshakePluginInfo>;
|
|
83
|
+
/** Permission-gated non-secret identity of the authenticated App Password owner. */
|
|
84
|
+
authenticated_user?: {
|
|
85
|
+
id: number;
|
|
86
|
+
login: string;
|
|
87
|
+
};
|
|
88
|
+
/** Observed WordPress site URL; normalized and pinned by launcher mode. */
|
|
89
|
+
site_url?: string;
|
|
83
90
|
}
|
|
84
91
|
export declare function proToolGatesSatisfied(state: {
|
|
85
92
|
proActive: boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ToolRegistrar } from "./canonical-tool-registry.js";
|
|
2
|
+
import type { WPClient } from "./wp-client.js";
|
|
3
|
+
import type { TargetEvidence } from "./target-evidence.js";
|
|
4
|
+
export declare const LAUNCHER_HEALTH_TOOL_NAMES: readonly ["diviops_meta_ping", "diviops_meta_info"];
|
|
5
|
+
export declare const META_PING_CONFIG: {
|
|
6
|
+
readonly description: "Test the connection to the WordPress site and verify the Divi MCP plugin is active. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; success payload is { connected: true, message: \"Connected to Divi <version>\" } and connection failure surfaces as { ok: false, error: { code: 'wp_error', message } } with the underlying transport message preserved.";
|
|
7
|
+
readonly annotations: {
|
|
8
|
+
readonly readOnlyHint: true;
|
|
9
|
+
readonly idempotentHint: true;
|
|
10
|
+
};
|
|
11
|
+
readonly _meta: {
|
|
12
|
+
readonly idempotent: "true";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const META_INFO_CONFIG: {
|
|
16
|
+
readonly description: "Returns DiviOps MCP server identity, server_version, license type, numeric tool_count, registered tool catalog summary, active plugin version summary, WP-CLI allowlist, and plugin handshake/slice state including Pro and FluentCart target readiness. Use as the S0 preflight before dogfooding or product work. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.";
|
|
17
|
+
readonly annotations: {
|
|
18
|
+
readonly readOnlyHint: true;
|
|
19
|
+
readonly idempotentHint: true;
|
|
20
|
+
};
|
|
21
|
+
readonly _meta: {
|
|
22
|
+
readonly idempotent: "true";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare function modelVisibleHealthResult(response: unknown, target: TargetEvidence, toolName: string): {
|
|
26
|
+
content: {
|
|
27
|
+
type: "text";
|
|
28
|
+
text: string;
|
|
29
|
+
}[];
|
|
30
|
+
structuredContent: {
|
|
31
|
+
result: unknown;
|
|
32
|
+
diviops_target: TargetEvidence;
|
|
33
|
+
};
|
|
34
|
+
_meta: {
|
|
35
|
+
diviops_target: TargetEvidence;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
type ToolCancellationContext = {
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
mcpReq?: {
|
|
41
|
+
signal?: AbortSignal;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare function requestAbortSignal(args: unknown, context?: ToolCancellationContext): AbortSignal | undefined;
|
|
45
|
+
export declare function registerLauncherHealthTools(options: {
|
|
46
|
+
server: ToolRegistrar;
|
|
47
|
+
wp: {
|
|
48
|
+
testConnection(signal?: AbortSignal): ReturnType<WPClient["testConnection"]>;
|
|
49
|
+
};
|
|
50
|
+
observe: (signal?: AbortSignal) => Promise<TargetEvidence>;
|
|
51
|
+
serverVersion: string;
|
|
52
|
+
}): void;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ErrorCodes, recordIdempotent, serializeEnvelope, withCode, wrapResponse, } from "./envelope.js";
|
|
2
|
+
export const LAUNCHER_HEALTH_TOOL_NAMES = [
|
|
3
|
+
"diviops_meta_ping",
|
|
4
|
+
"diviops_meta_info",
|
|
5
|
+
];
|
|
6
|
+
export const META_PING_CONFIG = {
|
|
7
|
+
description: "Test the connection to the WordPress site and verify the Divi MCP plugin is active. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; success payload is { connected: true, message: \"Connected to Divi <version>\" } and connection failure surfaces as { ok: false, error: { code: 'wp_error', message } } with the underlying transport message preserved.",
|
|
8
|
+
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
9
|
+
_meta: { idempotent: "true" },
|
|
10
|
+
};
|
|
11
|
+
export const META_INFO_CONFIG = {
|
|
12
|
+
description: "Returns DiviOps MCP server identity, server_version, license type, numeric tool_count, registered tool catalog summary, active plugin version summary, WP-CLI allowlist, and plugin handshake/slice state including Pro and FluentCart target readiness. Use as the S0 preflight before dogfooding or product work. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
|
|
13
|
+
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
14
|
+
_meta: { idempotent: "true" },
|
|
15
|
+
};
|
|
16
|
+
export function modelVisibleHealthResult(response, target, toolName) {
|
|
17
|
+
const visible = {
|
|
18
|
+
...response,
|
|
19
|
+
diviops_target: target,
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: "text",
|
|
25
|
+
text: serializeEnvelope(visible, toolName),
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
structuredContent: {
|
|
29
|
+
result: response,
|
|
30
|
+
diviops_target: target,
|
|
31
|
+
},
|
|
32
|
+
_meta: { diviops_target: target },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function requestAbortSignal(args, context) {
|
|
36
|
+
const fallback = args;
|
|
37
|
+
return (context?.mcpReq?.signal ??
|
|
38
|
+
context?.signal ??
|
|
39
|
+
fallback?.mcpReq?.signal ??
|
|
40
|
+
fallback?.signal);
|
|
41
|
+
}
|
|
42
|
+
export function registerLauncherHealthTools(options) {
|
|
43
|
+
const { server, wp, observe, serverVersion } = options;
|
|
44
|
+
recordIdempotent("diviops_meta_ping", META_PING_CONFIG._meta);
|
|
45
|
+
recordIdempotent("diviops_meta_info", META_INFO_CONFIG._meta);
|
|
46
|
+
server.registerTool("diviops_meta_ping", META_PING_CONFIG, async (_args, context) => {
|
|
47
|
+
const signal = requestAbortSignal(_args, context);
|
|
48
|
+
const target = await observe(signal);
|
|
49
|
+
const response = await wrapResponse(async () => {
|
|
50
|
+
const ping = await wp.testConnection(signal);
|
|
51
|
+
if (!ping.ok)
|
|
52
|
+
withCode(ErrorCodes.WP_ERROR, ping.message);
|
|
53
|
+
return { connected: true, message: ping.message };
|
|
54
|
+
});
|
|
55
|
+
return modelVisibleHealthResult(response, target, "diviops_meta_ping");
|
|
56
|
+
});
|
|
57
|
+
server.registerTool("diviops_meta_info", META_INFO_CONFIG, async (_args, context) => {
|
|
58
|
+
const target = await observe(requestAbortSignal(_args, context));
|
|
59
|
+
const response = await wrapResponse(async () => ({
|
|
60
|
+
brand: "DiviOps",
|
|
61
|
+
server: "diviops-mcp",
|
|
62
|
+
server_version: serverVersion,
|
|
63
|
+
version: serverVersion,
|
|
64
|
+
license: "MIT",
|
|
65
|
+
launcher_mode: true,
|
|
66
|
+
tool_count: LAUNCHER_HEALTH_TOOL_NAMES.length,
|
|
67
|
+
tools: {
|
|
68
|
+
registered_total: LAUNCHER_HEALTH_TOOL_NAMES.length,
|
|
69
|
+
registered_tool_names: [...LAUNCHER_HEALTH_TOOL_NAMES],
|
|
70
|
+
},
|
|
71
|
+
plugins: {
|
|
72
|
+
diviops_agent: { active: true, version: target.plugin_version },
|
|
73
|
+
},
|
|
74
|
+
handshake: {
|
|
75
|
+
state: "ok",
|
|
76
|
+
plugin_version: target.plugin_version,
|
|
77
|
+
capability_count: Object.values(target.capabilities).filter(Boolean).length,
|
|
78
|
+
},
|
|
79
|
+
wp_cli: false,
|
|
80
|
+
}));
|
|
81
|
+
return modelVisibleHealthResult(response, target, "diviops_meta_info");
|
|
82
|
+
});
|
|
83
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,29 @@
|
|
|
8
8
|
* Auth: WordPress Application Passwords (Basic Auth).
|
|
9
9
|
* Config: Environment variables WP_URL, WP_USER, WP_APP_PASSWORD.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
import { type HandshakePluginInfo } from "./compatibility.js";
|
|
12
|
+
import { CanonicalToolRegistry } from "./canonical-tool-registry.js";
|
|
13
|
+
export type HandshakeState = {
|
|
14
|
+
kind: "ok";
|
|
15
|
+
capabilities: Record<string, boolean>;
|
|
16
|
+
pluginVersion: string | null;
|
|
17
|
+
proVersion?: string;
|
|
18
|
+
proActive: boolean;
|
|
19
|
+
availableTargets: Record<string, {
|
|
20
|
+
present: boolean;
|
|
21
|
+
version?: string | null;
|
|
22
|
+
}>;
|
|
23
|
+
activeModules: Record<string, boolean>;
|
|
24
|
+
plugins: Record<string, HandshakePluginInfo>;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "failed";
|
|
27
|
+
} | {
|
|
28
|
+
kind: "pending";
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Complete the canonical registry after the connected site's handshake has
|
|
32
|
+
* settled. Production startup and the credential-free dual-era compatibility
|
|
33
|
+
* fixture deliberately share this seam so the v2 proof materializes the real
|
|
34
|
+
* Free/Pro-gated catalog instead of maintaining a second set of definitions.
|
|
35
|
+
*/
|
|
36
|
+
export declare function finalizeProductionRegistryForHandshake(state: HandshakeState): CanonicalToolRegistry;
|
package/dist/index.js
CHANGED
|
@@ -22,8 +22,10 @@ import { createSourcePayloadRef, loadSourcePayloadRef, } from "./cross-env-prefl
|
|
|
22
22
|
import { optimizeSchema } from "./schema-optimizer.js";
|
|
23
23
|
import { schemaModuleRoute } from "./schema-route.js";
|
|
24
24
|
import { createWpCli } from "./wp-cli.js";
|
|
25
|
+
import { META_INFO_CONFIG, META_PING_CONFIG, requestAbortSignal, } from "./health-tools.js";
|
|
26
|
+
import { CanonicalToolRegistry } from "./canonical-tool-registry.js";
|
|
25
27
|
import { isolationFailure, scanValueForForeignVarRefs, writerIsolationErrorResult, } from "./validate-attrs.js";
|
|
26
|
-
import { readFileSync, readdirSync } from "fs";
|
|
28
|
+
import { readFileSync, readdirSync, realpathSync } from "fs";
|
|
27
29
|
import { join, dirname } from "path";
|
|
28
30
|
import { fileURLToPath } from "url";
|
|
29
31
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -31,7 +33,9 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
31
33
|
const WP_URL = process.env.WP_URL ?? "";
|
|
32
34
|
const WP_USER = process.env.WP_USER ?? "";
|
|
33
35
|
const WP_APP_PASSWORD = process.env.WP_APP_PASSWORD ?? "";
|
|
34
|
-
|
|
36
|
+
function requireCredentials() {
|
|
37
|
+
if (WP_URL && WP_USER && WP_APP_PASSWORD)
|
|
38
|
+
return;
|
|
35
39
|
const missing = [
|
|
36
40
|
!WP_URL && "WP_URL",
|
|
37
41
|
!WP_USER && "WP_USER",
|
|
@@ -86,10 +90,7 @@ const SERVER_VERSION = (() => {
|
|
|
86
90
|
}
|
|
87
91
|
})();
|
|
88
92
|
// ── MCP Server ───────────────────────────────────────────────────────
|
|
89
|
-
const
|
|
90
|
-
name: "diviops-mcp",
|
|
91
|
-
version: SERVER_VERSION,
|
|
92
|
-
});
|
|
93
|
+
const registry = new CanonicalToolRegistry();
|
|
93
94
|
let handshakeState = { kind: "pending" };
|
|
94
95
|
const toolCatalog = [];
|
|
95
96
|
function recordToolCatalog(entry) {
|
|
@@ -351,7 +352,7 @@ function registerPluginTool(name, config, handler) {
|
|
|
351
352
|
return handler(args);
|
|
352
353
|
});
|
|
353
354
|
recordIdempotent(name, config?._meta);
|
|
354
|
-
|
|
355
|
+
registry.registerTool(name, config, wrapped);
|
|
355
356
|
}
|
|
356
357
|
/**
|
|
357
358
|
* Server-local tools (no plugin dependency) register via this thin shim
|
|
@@ -363,7 +364,7 @@ function registerPluginTool(name, config, handler) {
|
|
|
363
364
|
function registerLocalTool(name, config, handler) {
|
|
364
365
|
recordToolCatalog({ name, kind: "server_local", registered: true });
|
|
365
366
|
recordIdempotent(name, config?._meta);
|
|
366
|
-
|
|
367
|
+
registry.registerTool(name, config, handler);
|
|
367
368
|
}
|
|
368
369
|
/**
|
|
369
370
|
* Register a Pro-coverage-slice tool (ADR-003 / ADR-007).
|
|
@@ -416,7 +417,7 @@ function registerProTool(name, config, handler, gates) {
|
|
|
416
417
|
return;
|
|
417
418
|
catalogEntry.registered = true;
|
|
418
419
|
recordIdempotent(name, config?._meta);
|
|
419
|
-
|
|
420
|
+
registry.registerTool(name, config, handler);
|
|
420
421
|
}
|
|
421
422
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
422
423
|
// ── dry_run convention ──────────────────────────────────────────────
|
|
@@ -3490,12 +3491,12 @@ registerLocalTool("diviops_scf_field_group_get", {
|
|
|
3490
3491
|
});
|
|
3491
3492
|
// ── Connection ──────────────────────────────────────────────────────
|
|
3492
3493
|
registerLocalTool("diviops_meta_ping", {
|
|
3493
|
-
|
|
3494
|
-
annotations: { idempotentHint: true },
|
|
3494
|
+
...META_PING_CONFIG,
|
|
3495
3495
|
_meta: { idempotent: "true" },
|
|
3496
|
-
}, async () => {
|
|
3496
|
+
}, async (_args, context) => {
|
|
3497
|
+
const signal = requestAbortSignal(_args, context);
|
|
3497
3498
|
const response = await wrapResponse(async () => {
|
|
3498
|
-
const ping = await wp.testConnection();
|
|
3499
|
+
const ping = await wp.testConnection(signal);
|
|
3499
3500
|
if (!ping.ok) {
|
|
3500
3501
|
withCode(ErrorCodes.WP_ERROR, ping.message);
|
|
3501
3502
|
}
|
|
@@ -3508,8 +3509,7 @@ registerLocalTool("diviops_meta_ping", {
|
|
|
3508
3509
|
};
|
|
3509
3510
|
});
|
|
3510
3511
|
registerLocalTool("diviops_meta_info", {
|
|
3511
|
-
|
|
3512
|
-
annotations: { idempotentHint: true },
|
|
3512
|
+
...META_INFO_CONFIG,
|
|
3513
3513
|
_meta: { idempotent: "true" },
|
|
3514
3514
|
}, async () => {
|
|
3515
3515
|
const response = await wrapResponse(async () => buildMetaInfo());
|
|
@@ -3520,7 +3520,7 @@ registerLocalTool("diviops_meta_info", {
|
|
|
3520
3520
|
};
|
|
3521
3521
|
});
|
|
3522
3522
|
// ── Resources ────────────────────────────────────────────────────────
|
|
3523
|
-
|
|
3523
|
+
registry.registerResource("divi-block-format-guide", "divi://block-format-guide", {}, async () => ({
|
|
3524
3524
|
contents: [
|
|
3525
3525
|
{
|
|
3526
3526
|
uri: "divi://block-format-guide",
|
|
@@ -5151,9 +5151,9 @@ function registerProTools() {
|
|
|
5151
5151
|
// ── V3.1 — order/license/activation read + guarded mark-paid ───────
|
|
5152
5152
|
//
|
|
5153
5153
|
// FluentCart commerce-artifact readback surface plus a single
|
|
5154
|
-
// mutating tool: a guarded offline mark-paid that
|
|
5155
|
-
//
|
|
5156
|
-
// smoke off of eval-file PHP probes.
|
|
5154
|
+
// mutating tool: a guarded offline mark-paid that uses FluentCart 1.6's
|
|
5155
|
+
// canonical charge + StatusHelper synchronization contract. Lifts the local
|
|
5156
|
+
// checkout/license smoke off of eval-file PHP probes.
|
|
5157
5157
|
// diviops_fc_order_list — POST /diviops/v1/pro/fluentcart/orders
|
|
5158
5158
|
registerProTool("diviops_fc_order_list", {
|
|
5159
5159
|
description: "List FluentCart orders for commerce dogfooding / smoke baselines (Pro tier; V3.1; requires FluentCart installed + activated). Returns a paginated summary with order identity (id, status, payment_status), gateway info (payment_method + payment_method_title, mode), totals (currency, total_amount, total_paid), fulfillment_type, type (payment/subscription), customer (customer_id + customer_email), item_count, license_count, and timestamps (created_at, updated_at, completed_at). Filterable by status, payment_status, payment_method, product_id, customer_email, and mode (test/live). Read-only. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; the success payload is { orders: OrderSummary[], pagination: { page, per_page, total, total_pages }, filters: { ... } }. Error codes: invalid_input (HTTP 400) when status/payment_status/mode is out of range; fluentcart.module_inactive (HTTP 412); fluentcart.query_failed (HTTP 500). Use this alongside diviops_fc_order_get / diviops_fc_license_list to verify a smoke run without raw SQL probes.",
|
|
@@ -5273,7 +5273,7 @@ function registerProTools() {
|
|
|
5273
5273
|
}, { target: "fluentcart", capabilityKey: "fluentcart_order_get" });
|
|
5274
5274
|
// diviops_fc_order_mark_paid — POST /diviops/v1/pro/fluentcart/orders/{id}/mark-paid
|
|
5275
5275
|
registerProTool("diviops_fc_order_mark_paid", {
|
|
5276
|
-
description: "Guarded local/offline mark-paid for a FluentCart order (Pro tier; V3.1;
|
|
5276
|
+
description: "Guarded local/offline mark-paid for a FluentCart order (Pro tier; V3.1; exact audited FluentCart 1.6.0 contract). DiviOps serializes apply on the FluentCart order row, creates or updates one canonical succeeded `transaction_type=charge` transaction, then delegates the atomic paid transition and every derived cart/event/subscription/license/fulfillment effect to `FluentCart\\App\\Helpers\\StatusHelper::syncOrderStatuses`; it never dispatches vendor events or mutates subscriptions/licenses directly. Initial payment/subscription orders use FluentCart's `order_paid` and initial-activation family; renewal invoices use `renewal_paid` and store-managed subscription advancement without replaying new-order effects. Exact Free/installed-Pro version, transaction-lock, and StatusHelper shapes are checked before querying or mutation; older, newer, mixed, and unsupported shapes fail closed with component evidence. Refuses real gateways, canceled orders, missing subscription context, non-manual/system subscription collection, and conflicting legacy/duplicate transaction candidates. Already-paid and concurrent retries are no-ops after locked readback, while interrupted retries reuse the single matching succeeded charge before synchronization. **dry_run defaults to TRUE**; apply requires `dry_run:false` plus matching `confirm_order_id`, `confirm_payment_method`, and `confirm_due_amount`. Dry-run returns the transaction action plus canonical sync effect scope. Apply returns exact order/charge readback, initial-vs-renewal transition evidence, redacted license readback, and subscription before/after summaries. Exceptions after transaction mutation starts return `fluentcart.mutation_uncertain` with best-effort readback and explicitly require manual inspection instead of a blind retry. Error codes include invalid_input (400), not_found (404), fluentcart.unsupported_version (412), fluentcart.order_canceled / fluentcart.unsupported_payment_method / fluentcart.unsupported_order_shape / fluentcart.missing_subscription_context / fluentcart.unsupported_subscription_shape (422), fluentcart.transaction_conflict / fluentcart.concurrent_state_changed (409), fluentcart.readback_failed / fluentcart.mutation_uncertain (500), fluentcart.module_inactive (412), and fluentcart.command_failed (500). Idempotency is conditional and retry-safe only when the response says so." +
|
|
5277
5277
|
" Pass dry_run: false plus the confirm_* fields to apply.",
|
|
5278
5278
|
inputSchema: {
|
|
5279
5279
|
id: z
|
|
@@ -5554,8 +5554,26 @@ function registerProTools() {
|
|
|
5554
5554
|
};
|
|
5555
5555
|
}, { target: "fluentcart", capabilityKey: "fluentcart_gateway_get" });
|
|
5556
5556
|
}
|
|
5557
|
+
let productionRegistryFinalized = false;
|
|
5558
|
+
/**
|
|
5559
|
+
* Complete the canonical registry after the connected site's handshake has
|
|
5560
|
+
* settled. Production startup and the credential-free dual-era compatibility
|
|
5561
|
+
* fixture deliberately share this seam so the v2 proof materializes the real
|
|
5562
|
+
* Free/Pro-gated catalog instead of maintaining a second set of definitions.
|
|
5563
|
+
*/
|
|
5564
|
+
export function finalizeProductionRegistryForHandshake(state) {
|
|
5565
|
+
if (productionRegistryFinalized) {
|
|
5566
|
+
throw new Error("Production MCP registry has already been finalized");
|
|
5567
|
+
}
|
|
5568
|
+
handshakeState = state;
|
|
5569
|
+
registerCrossEnvEvidenceTools();
|
|
5570
|
+
registerProTools();
|
|
5571
|
+
productionRegistryFinalized = true;
|
|
5572
|
+
return registry;
|
|
5573
|
+
}
|
|
5557
5574
|
// ── Start ────────────────────────────────────────────────────────────
|
|
5558
5575
|
async function main() {
|
|
5576
|
+
requireCredentials();
|
|
5559
5577
|
// Capability handshake — populate the per-tool gate map (#486)
|
|
5560
5578
|
// and the ADR-003 / ADR-007 Pro-extension surface (target presence,
|
|
5561
5579
|
// module activation). On Free-only sites the Pro fields are
|
|
@@ -5603,18 +5621,32 @@ async function main() {
|
|
|
5603
5621
|
// The cross-env evidence schema is additive-capability aware: older Free
|
|
5604
5622
|
// plugins retain the existing header-only enum, while current plugins prove
|
|
5605
5623
|
// footer support through cross_env_footer_layout_evidence.
|
|
5606
|
-
|
|
5607
|
-
//
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5624
|
+
// Cross-env evidence and Pro coverage-slice registration must run AFTER
|
|
5625
|
+
// the handshake so capability and tier gates reflect the connected site.
|
|
5626
|
+
const finalizedRegistry = finalizeProductionRegistryForHandshake(handshakeState);
|
|
5627
|
+
const server = new McpServer({
|
|
5628
|
+
name: "diviops-mcp",
|
|
5629
|
+
version: SERVER_VERSION,
|
|
5630
|
+
});
|
|
5631
|
+
finalizedRegistry.install(server);
|
|
5613
5632
|
const transport = new StdioServerTransport();
|
|
5614
5633
|
await server.connect(transport);
|
|
5615
5634
|
console.error("Divi MCP Server running on stdio");
|
|
5616
5635
|
}
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5636
|
+
function isDirectEntryPoint() {
|
|
5637
|
+
const entryPoint = process.argv[1];
|
|
5638
|
+
if (!entryPoint)
|
|
5639
|
+
return false;
|
|
5640
|
+
try {
|
|
5641
|
+
return realpathSync(entryPoint) === fileURLToPath(import.meta.url);
|
|
5642
|
+
}
|
|
5643
|
+
catch {
|
|
5644
|
+
return false;
|
|
5645
|
+
}
|
|
5646
|
+
}
|
|
5647
|
+
if (isDirectEntryPoint()) {
|
|
5648
|
+
main().catch((error) => {
|
|
5649
|
+
console.error("Fatal error:", error);
|
|
5650
|
+
process.exit(1);
|
|
5651
|
+
});
|
|
5652
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { HandshakeResult } from "./compatibility.js";
|
|
2
|
+
export declare const TARGET_EVIDENCE_SCHEMA_VERSION = 1;
|
|
3
|
+
export type LauncherProfileIdentity = {
|
|
4
|
+
profile_id: string;
|
|
5
|
+
profile_revision: number;
|
|
6
|
+
profile_label: string;
|
|
7
|
+
endpoint: string;
|
|
8
|
+
credential_ref: string;
|
|
9
|
+
};
|
|
10
|
+
export type TargetEvidence = {
|
|
11
|
+
schema_version: 1;
|
|
12
|
+
profile_id: string;
|
|
13
|
+
profile_revision: number;
|
|
14
|
+
profile_label: string;
|
|
15
|
+
endpoint: string;
|
|
16
|
+
credential_ref: string;
|
|
17
|
+
authenticated_user: {
|
|
18
|
+
id: number;
|
|
19
|
+
login: string;
|
|
20
|
+
};
|
|
21
|
+
observed_site_url: string;
|
|
22
|
+
plugin_version: string | null;
|
|
23
|
+
divi: {
|
|
24
|
+
active: boolean;
|
|
25
|
+
version: string | null;
|
|
26
|
+
};
|
|
27
|
+
capabilities: Record<string, boolean>;
|
|
28
|
+
capability_digest: string;
|
|
29
|
+
target_evidence_hash: string;
|
|
30
|
+
observed_at: string;
|
|
31
|
+
drift_state: "healthy";
|
|
32
|
+
};
|
|
33
|
+
export type TargetIdentityForHash = Omit<TargetEvidence, "profile_label" | "target_evidence_hash" | "observed_at" | "drift_state">;
|
|
34
|
+
export declare function canonicalJson(value: unknown): string;
|
|
35
|
+
export declare function normalizeWordPressEndpoint(raw: string): string;
|
|
36
|
+
export declare function canonicalCapabilities(value: unknown): Record<string, boolean>;
|
|
37
|
+
export declare function targetIdentityForHash(evidence: TargetEvidence): TargetIdentityForHash;
|
|
38
|
+
export declare function targetEvidenceHash(evidence: TargetEvidence): string;
|
|
39
|
+
export declare function createTargetEvidence(profile: LauncherProfileIdentity, handshake: HandshakeResult, observedAt?: Date): TargetEvidence;
|
|
40
|
+
export declare function targetDriftAxes(approved: TargetEvidence, current: TargetEvidence): string[];
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
export const TARGET_EVIDENCE_SCHEMA_VERSION = 1;
|
|
3
|
+
function sha256(value) {
|
|
4
|
+
return `sha256:${createHash("sha256").update(value, "utf8").digest("hex")}`;
|
|
5
|
+
}
|
|
6
|
+
function assertPlainRecord(value, name) {
|
|
7
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
8
|
+
throw new Error(`launcher.target_evidence_invalid: ${name} must be an object`);
|
|
9
|
+
}
|
|
10
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) {
|
|
11
|
+
throw new Error(`launcher.target_evidence_invalid: ${name} must be a plain object`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function canonicalJson(value) {
|
|
15
|
+
const visit = (input) => {
|
|
16
|
+
if (input === null || typeof input === "string" || typeof input === "boolean")
|
|
17
|
+
return input;
|
|
18
|
+
if (typeof input === "number") {
|
|
19
|
+
if (!Number.isFinite(input) || !Number.isSafeInteger(input)) {
|
|
20
|
+
throw new Error("launcher.target_evidence_invalid: canonical numbers must be safe integers");
|
|
21
|
+
}
|
|
22
|
+
return input;
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(input))
|
|
25
|
+
return input.map(visit);
|
|
26
|
+
assertPlainRecord(input, "canonical value");
|
|
27
|
+
const out = {};
|
|
28
|
+
for (const key of Object.keys(input).sort()) {
|
|
29
|
+
if (input[key] === undefined) {
|
|
30
|
+
throw new Error("launcher.target_evidence_invalid: undefined values are forbidden");
|
|
31
|
+
}
|
|
32
|
+
out[key] = visit(input[key]);
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
};
|
|
36
|
+
return JSON.stringify(visit(value));
|
|
37
|
+
}
|
|
38
|
+
export function normalizeWordPressEndpoint(raw) {
|
|
39
|
+
if (raw.trim() !== raw || raw.length === 0) {
|
|
40
|
+
throw new Error("launcher.endpoint_invalid: endpoint must be non-empty without surrounding whitespace");
|
|
41
|
+
}
|
|
42
|
+
let url;
|
|
43
|
+
try {
|
|
44
|
+
url = new URL(raw);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
throw new Error("launcher.endpoint_invalid: endpoint must be an absolute URL");
|
|
48
|
+
}
|
|
49
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
50
|
+
throw new Error("launcher.endpoint_invalid: endpoint scheme must be http or https");
|
|
51
|
+
}
|
|
52
|
+
if (url.username || url.password || url.search || url.hash) {
|
|
53
|
+
throw new Error("launcher.endpoint_invalid: userinfo, query, and fragment are forbidden");
|
|
54
|
+
}
|
|
55
|
+
if (!url.hostname || url.hostname.includes("%")) {
|
|
56
|
+
throw new Error("launcher.endpoint_invalid: endpoint host is invalid");
|
|
57
|
+
}
|
|
58
|
+
url.hostname = url.hostname.toLowerCase();
|
|
59
|
+
url.pathname = url.pathname.replace(/\/+$/, "") || "/";
|
|
60
|
+
return url.toString().replace(/\/$/, "");
|
|
61
|
+
}
|
|
62
|
+
export function canonicalCapabilities(value) {
|
|
63
|
+
assertPlainRecord(value, "capabilities");
|
|
64
|
+
const sorted = {};
|
|
65
|
+
for (const key of Object.keys(value).sort()) {
|
|
66
|
+
if (!/^[a-z0-9_]+$/.test(key) || typeof value[key] !== "boolean") {
|
|
67
|
+
throw new Error("launcher.target_evidence_invalid: capabilities must be boolean slug entries");
|
|
68
|
+
}
|
|
69
|
+
sorted[key] = value[key];
|
|
70
|
+
}
|
|
71
|
+
return sorted;
|
|
72
|
+
}
|
|
73
|
+
export function targetIdentityForHash(evidence) {
|
|
74
|
+
return {
|
|
75
|
+
schema_version: evidence.schema_version,
|
|
76
|
+
profile_id: evidence.profile_id,
|
|
77
|
+
profile_revision: evidence.profile_revision,
|
|
78
|
+
endpoint: evidence.endpoint,
|
|
79
|
+
credential_ref: evidence.credential_ref,
|
|
80
|
+
authenticated_user: evidence.authenticated_user,
|
|
81
|
+
observed_site_url: evidence.observed_site_url,
|
|
82
|
+
plugin_version: evidence.plugin_version,
|
|
83
|
+
divi: evidence.divi,
|
|
84
|
+
capabilities: evidence.capabilities,
|
|
85
|
+
capability_digest: evidence.capability_digest,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export function targetEvidenceHash(evidence) {
|
|
89
|
+
return sha256(canonicalJson(targetIdentityForHash(evidence)));
|
|
90
|
+
}
|
|
91
|
+
export function createTargetEvidence(profile, handshake, observedAt = new Date()) {
|
|
92
|
+
const endpoint = normalizeWordPressEndpoint(profile.endpoint);
|
|
93
|
+
const observedSiteUrl = normalizeWordPressEndpoint(handshake.site_url ?? "");
|
|
94
|
+
const user = handshake.authenticated_user;
|
|
95
|
+
if (!user ||
|
|
96
|
+
!Number.isSafeInteger(user.id) ||
|
|
97
|
+
user.id < 1 ||
|
|
98
|
+
typeof user.login !== "string" ||
|
|
99
|
+
user.login.length === 0) {
|
|
100
|
+
throw new Error("launcher.target_evidence_invalid: handshake owner evidence is missing or malformed");
|
|
101
|
+
}
|
|
102
|
+
const capabilities = canonicalCapabilities(handshake.capabilities);
|
|
103
|
+
const capabilityDigest = sha256(canonicalJson(capabilities));
|
|
104
|
+
const evidence = {
|
|
105
|
+
schema_version: TARGET_EVIDENCE_SCHEMA_VERSION,
|
|
106
|
+
profile_id: profile.profile_id,
|
|
107
|
+
profile_revision: profile.profile_revision,
|
|
108
|
+
profile_label: profile.profile_label,
|
|
109
|
+
endpoint,
|
|
110
|
+
credential_ref: profile.credential_ref,
|
|
111
|
+
authenticated_user: { id: user.id, login: user.login },
|
|
112
|
+
observed_site_url: observedSiteUrl,
|
|
113
|
+
plugin_version: typeof handshake.plugin_version === "string" && handshake.plugin_version.length > 0
|
|
114
|
+
? handshake.plugin_version
|
|
115
|
+
: null,
|
|
116
|
+
divi: {
|
|
117
|
+
active: handshake.divi.active === true,
|
|
118
|
+
version: typeof handshake.divi.version === "string" && handshake.divi.version.length > 0
|
|
119
|
+
? handshake.divi.version
|
|
120
|
+
: null,
|
|
121
|
+
},
|
|
122
|
+
capabilities,
|
|
123
|
+
capability_digest: capabilityDigest,
|
|
124
|
+
target_evidence_hash: "",
|
|
125
|
+
observed_at: observedAt.toISOString(),
|
|
126
|
+
drift_state: "healthy",
|
|
127
|
+
};
|
|
128
|
+
evidence.target_evidence_hash = targetEvidenceHash(evidence);
|
|
129
|
+
return evidence;
|
|
130
|
+
}
|
|
131
|
+
export function targetDriftAxes(approved, current) {
|
|
132
|
+
const axes = [];
|
|
133
|
+
const pairs = [
|
|
134
|
+
["profile_id", approved.profile_id, current.profile_id],
|
|
135
|
+
["profile_revision", approved.profile_revision, current.profile_revision],
|
|
136
|
+
["endpoint", approved.endpoint, current.endpoint],
|
|
137
|
+
["credential_ref", approved.credential_ref, current.credential_ref],
|
|
138
|
+
["authenticated_user.id", approved.authenticated_user.id, current.authenticated_user.id],
|
|
139
|
+
["authenticated_user.login", approved.authenticated_user.login, current.authenticated_user.login],
|
|
140
|
+
["observed_site_url", approved.observed_site_url, current.observed_site_url],
|
|
141
|
+
["plugin_version", approved.plugin_version, current.plugin_version],
|
|
142
|
+
["divi.active", approved.divi.active, current.divi.active],
|
|
143
|
+
["divi.version", approved.divi.version, current.divi.version],
|
|
144
|
+
["capability_digest", approved.capability_digest, current.capability_digest],
|
|
145
|
+
["target_evidence_hash", approved.target_evidence_hash, current.target_evidence_hash],
|
|
146
|
+
];
|
|
147
|
+
for (const [axis, before, after] of pairs) {
|
|
148
|
+
if (before !== after)
|
|
149
|
+
axes.push(axis);
|
|
150
|
+
}
|
|
151
|
+
return axes;
|
|
152
|
+
}
|
package/dist/wp-client.d.ts
CHANGED
|
@@ -10,10 +10,12 @@ export interface WPClientConfig {
|
|
|
10
10
|
siteUrl: string;
|
|
11
11
|
username: string;
|
|
12
12
|
applicationPassword: string;
|
|
13
|
+
fetch?: typeof globalThis.fetch;
|
|
13
14
|
}
|
|
14
15
|
export declare class WPClient {
|
|
15
16
|
private baseUrl;
|
|
16
17
|
private authHeader;
|
|
18
|
+
private fetchImpl;
|
|
17
19
|
constructor(config: WPClientConfig);
|
|
18
20
|
/**
|
|
19
21
|
* Make a request to the diviops/v1 REST namespace.
|
|
@@ -22,6 +24,7 @@ export declare class WPClient {
|
|
|
22
24
|
method?: string;
|
|
23
25
|
body?: Record<string, unknown>;
|
|
24
26
|
params?: Record<string, string>;
|
|
27
|
+
signal?: AbortSignal;
|
|
25
28
|
}): Promise<T>;
|
|
26
29
|
/**
|
|
27
30
|
* Envelope-aware sibling of `request()`.
|
|
@@ -52,6 +55,7 @@ export declare class WPClient {
|
|
|
52
55
|
method?: string;
|
|
53
56
|
body?: Record<string, unknown>;
|
|
54
57
|
params?: Record<string, string>;
|
|
58
|
+
signal?: AbortSignal;
|
|
55
59
|
}): Promise<DiviopsResponse<T>>;
|
|
56
60
|
/**
|
|
57
61
|
* Test the connection to WordPress.
|
|
@@ -63,7 +67,7 @@ export declare class WPClient {
|
|
|
63
67
|
* silently regresses meta_ping to "Connected to Divi unknown" on
|
|
64
68
|
* healthy sites.
|
|
65
69
|
*/
|
|
66
|
-
testConnection(): Promise<{
|
|
70
|
+
testConnection(signal?: AbortSignal): Promise<{
|
|
67
71
|
ok: boolean;
|
|
68
72
|
message: string;
|
|
69
73
|
}>;
|
|
@@ -80,5 +84,5 @@ export declare class WPClient {
|
|
|
80
84
|
* The plugin still rejects servers below its own MIN_SERVER_VERSION
|
|
81
85
|
* with HTTP 426 — that error surfaces here as a regular request error.
|
|
82
86
|
*/
|
|
83
|
-
handshake(serverVersion: string): Promise<HandshakeResult>;
|
|
87
|
+
handshake(serverVersion: string, signal?: AbortSignal): Promise<HandshakeResult>;
|
|
84
88
|
}
|
package/dist/wp-client.js
CHANGED
|
@@ -121,9 +121,11 @@ function normalizeBody(value, withinBlockTree = false) {
|
|
|
121
121
|
export class WPClient {
|
|
122
122
|
baseUrl;
|
|
123
123
|
authHeader;
|
|
124
|
+
fetchImpl;
|
|
124
125
|
constructor(config) {
|
|
125
126
|
// Strip trailing slash.
|
|
126
127
|
this.baseUrl = config.siteUrl.replace(/\/+$/, '');
|
|
128
|
+
this.fetchImpl = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
127
129
|
// WP Application Passwords use Basic Auth.
|
|
128
130
|
const credentials = Buffer.from(`${config.username}:${config.applicationPassword}`).toString('base64');
|
|
129
131
|
this.authHeader = `Basic ${credentials}`;
|
|
@@ -132,7 +134,7 @@ export class WPClient {
|
|
|
132
134
|
* Make a request to the diviops/v1 REST namespace.
|
|
133
135
|
*/
|
|
134
136
|
async request(endpoint, options = {}) {
|
|
135
|
-
const { method = 'GET', body, params } = options;
|
|
137
|
+
const { method = 'GET', body, params, signal } = options;
|
|
136
138
|
let url = `${this.baseUrl}/wp-json/diviops/v1${endpoint}`;
|
|
137
139
|
if (params) {
|
|
138
140
|
const searchParams = new URLSearchParams(params);
|
|
@@ -145,12 +147,13 @@ export class WPClient {
|
|
|
145
147
|
'Content-Type': 'application/json',
|
|
146
148
|
Accept: 'application/json',
|
|
147
149
|
},
|
|
150
|
+
signal,
|
|
148
151
|
};
|
|
149
152
|
if (body && method !== 'GET') {
|
|
150
153
|
const normalized = endpointSkipsNormalization(endpoint) ? body : normalizeBody(body);
|
|
151
154
|
fetchOptions.body = JSON.stringify(normalized);
|
|
152
155
|
}
|
|
153
|
-
const response = await
|
|
156
|
+
const response = await this.fetchImpl(url, fetchOptions);
|
|
154
157
|
if (!response.ok) {
|
|
155
158
|
const errorBody = await response.text();
|
|
156
159
|
let errorMessage;
|
|
@@ -195,7 +198,7 @@ export class WPClient {
|
|
|
195
198
|
* `request()` becomes orphan and is removed.
|
|
196
199
|
*/
|
|
197
200
|
async requestEnveloped(endpoint, options = {}) {
|
|
198
|
-
const { method = 'GET', body, params } = options;
|
|
201
|
+
const { method = 'GET', body, params, signal } = options;
|
|
199
202
|
let url = `${this.baseUrl}/wp-json/diviops/v1${endpoint}`;
|
|
200
203
|
if (params) {
|
|
201
204
|
const searchParams = new URLSearchParams(params);
|
|
@@ -208,12 +211,13 @@ export class WPClient {
|
|
|
208
211
|
'Content-Type': 'application/json',
|
|
209
212
|
Accept: 'application/json',
|
|
210
213
|
},
|
|
214
|
+
signal,
|
|
211
215
|
};
|
|
212
216
|
if (body && method !== 'GET') {
|
|
213
217
|
const normalized = endpointSkipsNormalization(endpoint) ? body : normalizeBody(body);
|
|
214
218
|
fetchOptions.body = JSON.stringify(normalized);
|
|
215
219
|
}
|
|
216
|
-
const response = await
|
|
220
|
+
const response = await this.fetchImpl(url, fetchOptions);
|
|
217
221
|
const rawBody = await response.text();
|
|
218
222
|
// Try to parse the body as JSON. Failure is recoverable for non-2xx
|
|
219
223
|
// responses (HTML/plain-text error pages from a misconfigured host or
|
|
@@ -311,9 +315,9 @@ export class WPClient {
|
|
|
311
315
|
* silently regresses meta_ping to "Connected to Divi unknown" on
|
|
312
316
|
* healthy sites.
|
|
313
317
|
*/
|
|
314
|
-
async testConnection() {
|
|
318
|
+
async testConnection(signal) {
|
|
315
319
|
try {
|
|
316
|
-
const response = await this.requestEnveloped('/schema/settings');
|
|
320
|
+
const response = await this.requestEnveloped('/schema/settings', { signal });
|
|
317
321
|
if (!response.ok) {
|
|
318
322
|
return {
|
|
319
323
|
ok: false,
|
|
@@ -326,6 +330,8 @@ export class WPClient {
|
|
|
326
330
|
};
|
|
327
331
|
}
|
|
328
332
|
catch (error) {
|
|
333
|
+
if (signal?.aborted)
|
|
334
|
+
throw signal.reason ?? error;
|
|
329
335
|
return {
|
|
330
336
|
ok: false,
|
|
331
337
|
message: `Connection failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -345,10 +351,11 @@ export class WPClient {
|
|
|
345
351
|
* The plugin still rejects servers below its own MIN_SERVER_VERSION
|
|
346
352
|
* with HTTP 426 — that error surfaces here as a regular request error.
|
|
347
353
|
*/
|
|
348
|
-
async handshake(serverVersion) {
|
|
354
|
+
async handshake(serverVersion, signal) {
|
|
349
355
|
const result = await this.request('/handshake', {
|
|
350
356
|
method: 'POST',
|
|
351
357
|
body: { mcp_server_version: serverVersion },
|
|
358
|
+
signal,
|
|
352
359
|
});
|
|
353
360
|
// Pre-1.2.0 plugins emit `capabilities` as a string[] of coarse
|
|
354
361
|
// namespace tags. Coerce to an empty map so per-tool gates fail fast
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diviops/mcp-server",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.39",
|
|
4
4
|
"description": "MCP server exposing Divi 5 Visual Builder as tools for Claude",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"dist/**/*",
|
|
14
14
|
"!dist/**/__tests__/**",
|
|
15
|
+
"!dist/launcher-bootstrap.js",
|
|
16
|
+
"!dist/launcher-bootstrap.d.ts",
|
|
17
|
+
"!dist/launcher-sidecar.js",
|
|
18
|
+
"!dist/launcher-sidecar.d.ts",
|
|
15
19
|
"templates",
|
|
16
20
|
"data/verified-attrs.json",
|
|
17
21
|
"data/verified-attrs-backlog.json",
|
|
@@ -21,7 +25,7 @@
|
|
|
21
25
|
"build": "tsc",
|
|
22
26
|
"start": "node dist/index.js",
|
|
23
27
|
"dev": "tsc --watch",
|
|
24
|
-
"test": "npm run build && node --test dist/__tests__/*.test.js dist/preset-cli/__tests__/*.test.js dist/cross-env-preflight/__tests__/*.test.js",
|
|
28
|
+
"test": "npm run build && node --test dist/__tests__/*.test.js dist/preset-cli/__tests__/*.test.js dist/cross-env-preflight/__tests__/*.test.js && node scripts/check-release-boundary.mjs",
|
|
25
29
|
"prepublishOnly": "npm run build",
|
|
26
30
|
"regen:skill": "node scripts/regen-module-formats.mjs"
|
|
27
31
|
},
|
|
@@ -51,6 +55,9 @@
|
|
|
51
55
|
"zod": "^4.3.6"
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
58
|
+
"@modelcontextprotocol/client": "2.0.0",
|
|
59
|
+
"@modelcontextprotocol/core": "2.0.0",
|
|
60
|
+
"@modelcontextprotocol/server": "2.0.0",
|
|
54
61
|
"@types/node": "^22.0.0",
|
|
55
62
|
"typescript": "^5.7.0"
|
|
56
63
|
}
|