@automattic/mcp-wordpress-remote 0.2.18 → 0.2.20
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 +31 -31
- package/dist/lib.d.ts +86 -2
- package/dist/lib.js +7853 -1074
- package/dist/proxy.js +315 -29
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ Add to your MCP client configuration (e.g., Claude Desktop's `claude_desktop_con
|
|
|
50
50
|
You can add custom headers to all API requests using the `CUSTOM_HEADERS` environment variable. This is useful for API keys, custom authentication, or other header requirements.
|
|
51
51
|
|
|
52
52
|
#### JSON Format (Recommended):
|
|
53
|
+
|
|
53
54
|
```json
|
|
54
55
|
{
|
|
55
56
|
"mcpServers": {
|
|
@@ -66,6 +67,7 @@ You can add custom headers to all API requests using the `CUSTOM_HEADERS` enviro
|
|
|
66
67
|
```
|
|
67
68
|
|
|
68
69
|
#### Comma-Separated Format:
|
|
70
|
+
|
|
69
71
|
```json
|
|
70
72
|
{
|
|
71
73
|
"mcpServers": {
|
|
@@ -82,6 +84,7 @@ You can add custom headers to all API requests using the `CUSTOM_HEADERS` enviro
|
|
|
82
84
|
```
|
|
83
85
|
|
|
84
86
|
#### Command Line Usage:
|
|
87
|
+
|
|
85
88
|
```bash
|
|
86
89
|
CUSTOM_HEADERS='{"X-MCP-API-Key": "wc_mcp_FaQduhQcW0mfVaZgP3yaaqDuXaZ3mw7j"}' \
|
|
87
90
|
WP_API_URL="https://your-site.com" \
|
|
@@ -89,6 +92,7 @@ npx @automattic/mcp-wordpress-remote
|
|
|
89
92
|
```
|
|
90
93
|
|
|
91
94
|
Custom headers are included in:
|
|
95
|
+
|
|
92
96
|
- All WordPress API requests
|
|
93
97
|
- OAuth discovery requests
|
|
94
98
|
- OAuth token exchange requests
|
|
@@ -105,7 +109,7 @@ Custom headers are included in:
|
|
|
105
109
|
|
|
106
110
|
## WordPress MCP Plugin
|
|
107
111
|
|
|
108
|
-
You need to install the [wordpress-mcp](https://github.com/
|
|
112
|
+
You need to install the [wordpress-mcp](https://github.com/WordPress/mcp-adapter) plugin on your WordPress website and enable MCP Functionality in Settings > MCP Settings.
|
|
109
113
|
|
|
110
114
|
## Authentication Methods
|
|
111
115
|
|
|
@@ -130,8 +134,6 @@ OAuth 2.1 provides the most secure and user-friendly experience with full MCP Au
|
|
|
130
134
|
}
|
|
131
135
|
```
|
|
132
136
|
|
|
133
|
-
|
|
134
|
-
|
|
135
137
|
**MCP Authorization Specification Features:**
|
|
136
138
|
|
|
137
139
|
- **OAuth 2.1 authorization code flow** with PKCE (RFC 7636)
|
|
@@ -240,34 +242,32 @@ For WooCommerce-specific tools and reports:
|
|
|
240
242
|
|
|
241
243
|
### Environment Variables
|
|
242
244
|
|
|
243
|
-
| Variable
|
|
244
|
-
|
|
|
245
|
-
| `WP_API_URL`
|
|
246
|
-
| `OAUTH_ENABLED`
|
|
247
|
-
| `OAUTH_CALLBACK_PORT`
|
|
248
|
-
| `OAUTH_HOST`
|
|
249
|
-
| `WP_OAUTH_CLIENT_ID`
|
|
250
|
-
| **OAuth Endpoints**
|
|
251
|
-
| `OAUTH_AUTHORIZE_ENDPOINT`
|
|
252
|
-
| `OAUTH_TOKEN_ENDPOINT`
|
|
253
|
-
| `OAUTH_AUTHENTICATE_ENDPOINT
|
|
254
|
-
| **MCP OAuth 2.1 Settings**
|
|
255
|
-
| `OAUTH_FLOW_TYPE`
|
|
256
|
-
| `OAUTH_USE_PKCE`
|
|
257
|
-
| `OAUTH_DYNAMIC_REGISTRATION`
|
|
258
|
-
| `OAUTH_RESOURCE_INDICATOR`
|
|
259
|
-
| **Configuration**
|
|
260
|
-
| `WP_MCP_CONFIG_DIR`
|
|
261
|
-
| `LOG_FILE`
|
|
262
|
-
| `LOG_LEVEL`
|
|
263
|
-
| **Legacy Authentication**
|
|
264
|
-
| `JWT_TOKEN`
|
|
265
|
-
| `WP_API_USERNAME`
|
|
266
|
-
| `WP_API_PASSWORD`
|
|
267
|
-
| `WOO_CUSTOMER_KEY`
|
|
268
|
-
| `WOO_CUSTOMER_SECRET`
|
|
269
|
-
|
|
270
|
-
|
|
245
|
+
| Variable | Description | Default | Required |
|
|
246
|
+
| ----------------------------- | ------------------------------------------------ | -------------------- | --------------------- |
|
|
247
|
+
| `WP_API_URL` | WordPress site URL | - | ✅ |
|
|
248
|
+
| `OAUTH_ENABLED` | Enable OAuth authentication | `true` | - |
|
|
249
|
+
| `OAUTH_CALLBACK_PORT` | OAuth callback port | `7665` | - |
|
|
250
|
+
| `OAUTH_HOST` | OAuth callback hostname | `127.0.0.1` | - |
|
|
251
|
+
| `WP_OAUTH_CLIENT_ID` | Custom OAuth client ID | - | - |
|
|
252
|
+
| **OAuth Endpoints** | | | |
|
|
253
|
+
| `OAUTH_AUTHORIZE_ENDPOINT` | OAuth authorization endpoint | - | ✅ (for custom OAuth) |
|
|
254
|
+
| `OAUTH_TOKEN_ENDPOINT` | OAuth token endpoint | - | ✅ (for custom OAuth) |
|
|
255
|
+
| `OAUTH_AUTHENTICATE_ENDPOINT` | OAuth authenticate endpoint | - | - |
|
|
256
|
+
| **MCP OAuth 2.1 Settings** | | | |
|
|
257
|
+
| `OAUTH_FLOW_TYPE` | OAuth flow type (authorization_code or implicit) | `authorization_code` | - |
|
|
258
|
+
| `OAUTH_USE_PKCE` | Use PKCE (required for OAuth 2.1) | `true` | - |
|
|
259
|
+
| `OAUTH_DYNAMIC_REGISTRATION` | Enable dynamic client registration | `true` | - |
|
|
260
|
+
| `OAUTH_RESOURCE_INDICATOR` | Use resource indicators (RFC 8707) | `true` | - |
|
|
261
|
+
| **Configuration** | | | |
|
|
262
|
+
| `WP_MCP_CONFIG_DIR` | Config directory override | `~/.mcp-auth` | - |
|
|
263
|
+
| `LOG_FILE` | Log file path | - | - |
|
|
264
|
+
| `LOG_LEVEL` | Log level (0-3) | `2` | - |
|
|
265
|
+
| **Legacy Authentication** | | | |
|
|
266
|
+
| `JWT_TOKEN` | JWT token for authentication | - | - |
|
|
267
|
+
| `WP_API_USERNAME` | WordPress username (legacy) | - | - |
|
|
268
|
+
| `WP_API_PASSWORD` | WordPress app password (legacy) | - | - |
|
|
269
|
+
| `WOO_CUSTOMER_KEY` | WooCommerce consumer key | - | - |
|
|
270
|
+
| `WOO_CUSTOMER_SECRET` | WooCommerce consumer secret | - | - |
|
|
271
271
|
|
|
272
272
|
### Disable OAuth
|
|
273
273
|
|
package/dist/lib.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { SocksProxyAgent } from 'socks-proxy-agent';
|
|
2
|
+
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* WordPress API request parameters
|
|
3
6
|
*/
|
|
@@ -12,7 +15,7 @@ interface WordPressResponse {
|
|
|
12
15
|
[key: string]: any;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
declare const MCP_WORDPRESS_REMOTE_VERSION = "0.2.
|
|
18
|
+
declare const MCP_WORDPRESS_REMOTE_VERSION = "0.2.19";
|
|
16
19
|
/**
|
|
17
20
|
* Centralized configuration for MCP WordPress Remote
|
|
18
21
|
* All default values are defined here and can be overridden via environment variables
|
|
@@ -42,6 +45,7 @@ declare const CONFIG: {
|
|
|
42
45
|
readonly WOO_CUSTOMER_SECRET: string | undefined;
|
|
43
46
|
readonly CUSTOM_HEADERS: string;
|
|
44
47
|
readonly NODE_ENV: string;
|
|
48
|
+
readonly USE_SYSTEM_PROXY: boolean;
|
|
45
49
|
};
|
|
46
50
|
/**
|
|
47
51
|
* Type-safe configuration access with JSDoc descriptions
|
|
@@ -89,6 +93,8 @@ declare const getConfig: () => {
|
|
|
89
93
|
customHeaders: string;
|
|
90
94
|
/** Current environment */
|
|
91
95
|
nodeEnv: string;
|
|
96
|
+
/** Whether to use system proxy (PAC files on macOS, env vars on all platforms) */
|
|
97
|
+
useSystemProxy: boolean;
|
|
92
98
|
};
|
|
93
99
|
/**
|
|
94
100
|
* Get default OAuth scopes
|
|
@@ -219,4 +225,82 @@ declare function isConfigError(error: any): error is ConfigError;
|
|
|
219
225
|
declare function isAuthError(error: any): error is AuthError;
|
|
220
226
|
declare function isAPIError(error: any): error is APIError;
|
|
221
227
|
|
|
222
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Fetch API utilities for MCP WordPress Remote
|
|
230
|
+
*
|
|
231
|
+
* Provides fetch polyfill setup for Node.js environments that don't have native fetch
|
|
232
|
+
* and proxy-aware fetch for routing through system proxies (PAC files, env-based SOCKS/HTTP proxies)
|
|
233
|
+
*/
|
|
234
|
+
/**
|
|
235
|
+
* Setup fetch polyfill for Node.js 18+ compatibility
|
|
236
|
+
*
|
|
237
|
+
* Checks if native fetch is available and loads node-fetch polyfill if needed.
|
|
238
|
+
* This ensures compatibility across different Node.js versions.
|
|
239
|
+
* Also initializes proxy support for system proxies (PAC files, env vars).
|
|
240
|
+
*/
|
|
241
|
+
declare function setupFetchPolyfill(): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* Proxy-aware fetch that routes requests through system proxies when configured
|
|
244
|
+
*
|
|
245
|
+
* On macOS: Evaluates PAC file from system proxy settings to determine proxy per-URL
|
|
246
|
+
* On Linux/other: Uses SOCKS_PROXY, HTTPS_PROXY, etc. environment variables
|
|
247
|
+
* Falls back to direct connection if no proxy is configured or USE_SYSTEM_PROXY=false
|
|
248
|
+
*
|
|
249
|
+
* @param url - The URL to fetch
|
|
250
|
+
* @param init - Optional fetch init options
|
|
251
|
+
* @returns Promise resolving to the Response
|
|
252
|
+
*/
|
|
253
|
+
declare function proxyFetch(url: string, init?: RequestInit): Promise<Response>;
|
|
254
|
+
/**
|
|
255
|
+
* Get proxy status information for logging/debugging
|
|
256
|
+
*/
|
|
257
|
+
declare function getProxyInfo(): {
|
|
258
|
+
configured: boolean;
|
|
259
|
+
type: "pac" | "env" | "none";
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* Check if fetch is available (either native or polyfilled)
|
|
263
|
+
*
|
|
264
|
+
* @returns true if fetch is available, false otherwise
|
|
265
|
+
*/
|
|
266
|
+
declare function isFetchAvailable(): boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Get information about the current fetch implementation
|
|
269
|
+
*
|
|
270
|
+
* @returns Object with details about fetch availability and type
|
|
271
|
+
*/
|
|
272
|
+
declare function getFetchInfo(): {
|
|
273
|
+
available: boolean;
|
|
274
|
+
native: boolean;
|
|
275
|
+
polyfilled: boolean;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Cross-platform proxy utilities for MCP WordPress Remote
|
|
280
|
+
*
|
|
281
|
+
* Supports:
|
|
282
|
+
* - macOS: Automatic PAC file detection from system proxy settings
|
|
283
|
+
* - macOS: System SOCKS proxy detection (AutoProxxy Tunnel All Traffic)
|
|
284
|
+
* - All platforms: Environment variables (SOCKS_PROXY, HTTPS_PROXY, etc.)
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
type ProxyAgent = SocksProxyAgent | HttpsProxyAgent<string>;
|
|
288
|
+
/**
|
|
289
|
+
* Initialize proxy configuration (call once at startup)
|
|
290
|
+
* Guards against concurrent initialization calls
|
|
291
|
+
*/
|
|
292
|
+
declare function initializeProxy(): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* Get appropriate agent for a URL based on proxy configuration
|
|
295
|
+
*/
|
|
296
|
+
declare function getAgentForUrl(url: string): Promise<ProxyAgent | undefined>;
|
|
297
|
+
/**
|
|
298
|
+
* Check if proxy is configured
|
|
299
|
+
*/
|
|
300
|
+
declare function isProxyConfigured(): boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Get proxy configuration type for logging
|
|
303
|
+
*/
|
|
304
|
+
declare function getProxyType(): 'pac' | 'env' | 'none';
|
|
305
|
+
|
|
306
|
+
export { APIError, AuthError, CONFIG, ConfigError, LogLevel, MCP_WORDPRESS_REMOTE_VERSION, OAuthError, type TokenValidationResult, type WPClientInfo, type WPTokens, type WordPressRequestParams, type WordPressResponse, getAgentForUrl, getConfig, getCustomHeaders, getDefaultOAuthScopes, getFetchInfo, getProxyInfo, getProxyType, initializeProxy, isAPIError, isAuthError, isConfigError, isFetchAvailable, isOAuthError, isProxyConfigured, log, logger, parseCustomHeaders, proxyFetch, setupFetchPolyfill, validateConfig, wpRequest };
|