@automattic/mcp-wordpress-remote 0.1.12 → 0.1.14
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 +6 -2
- package/dist/proxy.js +23 -7
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
The mcp-wordpress-remote package acts as a bridge between local Model Context Protocol (MCP) clients and remote WordPress MCP servers. By leveraging npx, you can execute this package without a global installation, simplifying the setup process.
|
|
4
4
|
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js version 22 or higher
|
|
8
|
+
|
|
5
9
|
## WordPress MCP plugin
|
|
6
10
|
|
|
7
11
|
You have to install the [wordpress-mcp](https://github.com/Automattic/wordpress-mcp) plugin on your WordPress website, and enable MCP Functionality on Settings > MCP Settings.
|
|
@@ -43,7 +47,7 @@ Example configuration:
|
|
|
43
47
|
"mcpServers": {
|
|
44
48
|
"wordpress-mcp": {
|
|
45
49
|
"command": "npx",
|
|
46
|
-
"args": ["-y", "@automattic/mcp-wordpress-remote"],
|
|
50
|
+
"args": ["-y", "@automattic/mcp-wordpress-remote@latest"],
|
|
47
51
|
"env": {
|
|
48
52
|
"WP_API_URL": "https://your-wordpress-site.com",
|
|
49
53
|
"WP_API_USERNAME": "your-username",
|
|
@@ -70,7 +74,7 @@ Example configuration:
|
|
|
70
74
|
"mcpServers": {
|
|
71
75
|
"wordpress-mcp": {
|
|
72
76
|
"command": "npx",
|
|
73
|
-
"args": ["-y", "@automattic/mcp-wordpress-remote"],
|
|
77
|
+
"args": ["-y", "@automattic/mcp-wordpress-remote@latest"],
|
|
74
78
|
"env": {
|
|
75
79
|
"WP_API_URL": "https://your-wordpress-site.com",
|
|
76
80
|
"WP_API_USERNAME": "your-username",
|
package/dist/proxy.js
CHANGED
|
@@ -8,9 +8,8 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
8
8
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
import * as path from "node:path";
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
if (process.env.LOG_FILE || process.env.LOG_DIR) {
|
|
11
|
+
var LOG_FILE = process.env.LOG_FILE || null;
|
|
12
|
+
if (LOG_FILE) {
|
|
14
13
|
const logDir = path.dirname(LOG_FILE);
|
|
15
14
|
if (!fs.existsSync(logDir)) {
|
|
16
15
|
fs.mkdirSync(logDir, { recursive: true });
|
|
@@ -21,7 +20,7 @@ function log(message, ...args) {
|
|
|
21
20
|
const formattedArgs = args.length > 0 ? args.map((arg) => typeof arg === "object" ? JSON.stringify(arg) : arg).join(" ") : "";
|
|
22
21
|
const logMessage = `${timestamp}: ${message}${formattedArgs ? " " + formattedArgs : ""}
|
|
23
22
|
`;
|
|
24
|
-
if (
|
|
23
|
+
if (LOG_FILE) {
|
|
25
24
|
fs.appendFileSync(LOG_FILE, logMessage);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
@@ -38,11 +37,14 @@ function validateEnvironment() {
|
|
|
38
37
|
);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
40
|
+
function removeTrailingSlash(url) {
|
|
41
|
+
return url.replace(/\/+$/, "");
|
|
42
|
+
}
|
|
41
43
|
async function wpRequest(params = { method: "init" }) {
|
|
42
44
|
validateEnvironment();
|
|
43
|
-
const endpoint = "wp/v2/wpmcp";
|
|
45
|
+
const endpoint = "/wp/v2/wpmcp";
|
|
44
46
|
const method = "POST";
|
|
45
|
-
const baseUrl = process.env.WP_API_URL;
|
|
47
|
+
const baseUrl = removeTrailingSlash(process.env.WP_API_URL);
|
|
46
48
|
log(`Request method: ${params.method || "init"}`);
|
|
47
49
|
log(`Request args: ${JSON.stringify(params.args || {})}`);
|
|
48
50
|
let username;
|
|
@@ -67,7 +69,7 @@ async function wpRequest(params = { method: "init" }) {
|
|
|
67
69
|
log(`API URL: ${baseUrl}`);
|
|
68
70
|
const auth = Buffer.from(`${username}:${password}`).toString("base64");
|
|
69
71
|
log(`Auth header length: ${auth.length}`);
|
|
70
|
-
const url = new URL(
|
|
72
|
+
const url = new URL(`/?rest_route=${endpoint}`, baseUrl).toString();
|
|
71
73
|
log(`Requesting URL: ${url}`);
|
|
72
74
|
const headers = {
|
|
73
75
|
Authorization: `Basic ${auth}`,
|
|
@@ -111,6 +113,20 @@ import {
|
|
|
111
113
|
CompleteRequestSchema,
|
|
112
114
|
ListRootsRequestSchema
|
|
113
115
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
116
|
+
var requiredNodeVersion = 22;
|
|
117
|
+
var currentNodeVersion = parseInt(process.version.slice(1).split(".")[0]);
|
|
118
|
+
if (currentNodeVersion < requiredNodeVersion) {
|
|
119
|
+
log(`Error: This application requires Node.js version ${requiredNodeVersion} or higher.`);
|
|
120
|
+
log(`Current version: ${process.version}`);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
if (typeof globalThis.fetch !== "function") {
|
|
124
|
+
log(
|
|
125
|
+
"Error: This application requires the fetch API, which is not available in your Node.js environment."
|
|
126
|
+
);
|
|
127
|
+
log("Please ensure you are using Node.js 22 or later, or install node-fetch.");
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
114
130
|
async function WordPressProxy() {
|
|
115
131
|
const init = await wpRequest({ method: "init" });
|
|
116
132
|
const server = new Server(
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/mcp-wordpress-remote",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "MCP WordPress Remote proxy server",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=22.0.0"
|
|
7
|
+
},
|
|
5
8
|
"keywords": [
|
|
6
9
|
"mcp",
|
|
7
10
|
"wordpress",
|
|
@@ -27,7 +30,7 @@
|
|
|
27
30
|
"build": "tsup",
|
|
28
31
|
"build:watch": "tsup --watch",
|
|
29
32
|
"check": "prettier --check . && tsc",
|
|
30
|
-
"start": "
|
|
33
|
+
"start": "NODE_ENV=development tsup --watch",
|
|
31
34
|
"dev": "NODE_ENV=development node dist/proxy.js",
|
|
32
35
|
"test": "jest",
|
|
33
36
|
"test:watch": "jest --watch"
|