@automattic/mcp-wordpress-remote 0.2.11 → 0.2.13

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/dist/lib.d.ts ADDED
@@ -0,0 +1,205 @@
1
+ /**
2
+ * WordPress API request parameters
3
+ */
4
+ interface WordPressRequestParams {
5
+ method: string;
6
+ [key: string]: any;
7
+ }
8
+ /**
9
+ * WordPress API response
10
+ */
11
+ interface WordPressResponse {
12
+ [key: string]: any;
13
+ }
14
+
15
+ declare const MCP_WORDPRESS_REMOTE_VERSION = "0.2.1";
16
+ declare enum LogLevel {
17
+ ERROR = 0,
18
+ WARN = 1,
19
+ INFO = 2,
20
+ DEBUG = 3
21
+ }
22
+ /**
23
+ * Enhanced logging function with levels and categories
24
+ *
25
+ * @param message - The message to log
26
+ * @param level - Log level (default: INFO)
27
+ * @param category - Log category for filtering (default: 'GENERAL')
28
+ * @param args - Additional arguments to log
29
+ */
30
+ declare function log(message: string, level?: LogLevel, category?: string, ...args: any[]): void;
31
+ /**
32
+ * Convenience logging functions
33
+ */
34
+ declare const logger: {
35
+ error: (message: string, category?: string, ...args: any[]) => void;
36
+ warn: (message: string, category?: string, ...args: any[]) => void;
37
+ info: (message: string, category?: string, ...args: any[]) => void;
38
+ debug: (message: string, category?: string, ...args: any[]) => void;
39
+ auth: (message: string, level?: LogLevel, ...args: any[]) => void;
40
+ oauth: (message: string, level?: LogLevel, ...args: any[]) => void;
41
+ api: (message: string, level?: LogLevel, ...args: any[]) => void;
42
+ config: (message: string, level?: LogLevel, ...args: any[]) => void;
43
+ };
44
+
45
+ /**
46
+ * Centralized configuration for MCP WordPress Remote
47
+ * All default values are defined here and can be overridden via environment variables
48
+ */
49
+ declare const CONFIG: {
50
+ readonly WP_API_URL: string;
51
+ readonly OAUTH_ENABLED: boolean;
52
+ readonly OAUTH_CALLBACK_PORT: number | undefined;
53
+ readonly OAUTH_HOST: string;
54
+ readonly WP_OAUTH_CLIENT_ID: string;
55
+ readonly OAUTH_FLOW_TYPE: "authorization_code" | "implicit";
56
+ readonly OAUTH_USE_PKCE: boolean;
57
+ readonly OAUTH_DYNAMIC_REGISTRATION: boolean;
58
+ readonly OAUTH_AUTHORIZE_ENDPOINT: string;
59
+ readonly OAUTH_TOKEN_ENDPOINT: string;
60
+ readonly OAUTH_AUTHENTICATE_ENDPOINT: string;
61
+ readonly OAUTH_RESOURCE_INDICATOR: boolean;
62
+ readonly OAUTH_SCOPES: string;
63
+ readonly OAUTH_TIMEOUT: 30000;
64
+ readonly LOCK_TIMEOUT: 300000;
65
+ readonly WP_MCP_CONFIG_DIR: string;
66
+ readonly LOG_FILE: string | null;
67
+ readonly WP_API_USERNAME: string | undefined;
68
+ readonly WP_API_PASSWORD: string | undefined;
69
+ readonly JWT_TOKEN: string | undefined;
70
+ readonly WOO_CUSTOMER_KEY: string | undefined;
71
+ readonly WOO_CUSTOMER_SECRET: string | undefined;
72
+ readonly NODE_ENV: string;
73
+ };
74
+ /**
75
+ * Type-safe configuration access with JSDoc descriptions
76
+ */
77
+ declare const getConfig: () => {
78
+ /** WordPress site API endpoint */
79
+ wpApiUrl: string;
80
+ /** Whether OAuth authentication is enabled */
81
+ oauthEnabled: boolean;
82
+ /** Port for OAuth callback server (undefined for auto-detection on self-hosted sites) */
83
+ oauthCallbackPort: number | undefined;
84
+ /** Hostname for OAuth callback */
85
+ oauthHost: string;
86
+ /** WordPress OAuth client ID */
87
+ wpOAuthClientId: string;
88
+ /** OAuth flow type (authorization_code recommended, implicit for legacy) */
89
+ oauthFlowType: "authorization_code" | "implicit";
90
+ /** Whether to use PKCE (required for OAuth 2.1) */
91
+ oauthUsePKCE: boolean;
92
+ /** Whether to support dynamic client registration */
93
+ oauthDynamicRegistration: boolean;
94
+ /** Whether to use resource indicators (RFC 8707) */
95
+ oauthResourceIndicator: boolean;
96
+ /** Custom OAuth scopes (comma-separated) */
97
+ oauthScopes: string;
98
+ /** OAuth operation timeout in milliseconds */
99
+ oauthTimeout: 30000;
100
+ /** Lock operation timeout in milliseconds */
101
+ lockTimeout: 300000;
102
+ /** Configuration directory path */
103
+ configDir: string;
104
+ /** Log file path (null if not set) */
105
+ logFile: string | null;
106
+ /** WordPress API username (legacy) */
107
+ wpApiUsername: string | undefined;
108
+ /** WordPress API password (legacy) */
109
+ wpApiPassword: string | undefined;
110
+ /** JWT token for authentication */
111
+ jwtToken: string | undefined;
112
+ /** WooCommerce customer key */
113
+ wooCustomerKey: string | undefined;
114
+ /** WooCommerce customer secret */
115
+ wooCustomerSecret: string | undefined;
116
+ /** Current environment */
117
+ nodeEnv: string;
118
+ };
119
+ /**
120
+ * Get default OAuth scopes
121
+ */
122
+ declare function getDefaultOAuthScopes(): string[];
123
+ /**
124
+ * Validation function for required configuration
125
+ */
126
+ declare function validateConfig(): {
127
+ isValid: boolean;
128
+ errors: string[];
129
+ };
130
+
131
+ /**
132
+ * WordPress OAuth types and error definitions
133
+ * Updated for MCP Authorization specification 2025-06-18 compliance
134
+ */
135
+ /**
136
+ * WordPress OAuth tokens structure
137
+ */
138
+ interface WPTokens {
139
+ access_token: string;
140
+ token_type: string;
141
+ expires_in?: number;
142
+ scope?: string;
143
+ obtained_at: number;
144
+ refresh_token?: string;
145
+ }
146
+ /**
147
+ * WordPress OAuth client information
148
+ */
149
+ interface WPClientInfo {
150
+ client_id: string;
151
+ client_secret?: string;
152
+ authorization_endpoint?: string;
153
+ token_endpoint?: string;
154
+ scope?: string;
155
+ }
156
+ /**
157
+ * Token validation result
158
+ */
159
+ interface TokenValidationResult {
160
+ isValid: boolean;
161
+ expiresIn?: number;
162
+ error?: string;
163
+ }
164
+ /**
165
+ * Custom OAuth error class
166
+ */
167
+ declare class OAuthError extends Error {
168
+ readonly code: string;
169
+ readonly details?: any;
170
+ constructor(message: string, code?: string, details?: any);
171
+ }
172
+ /**
173
+ * Custom configuration error class
174
+ */
175
+ declare class ConfigError extends Error {
176
+ readonly field: string;
177
+ readonly value?: any;
178
+ constructor(message: string, field: string, value?: any);
179
+ }
180
+ /**
181
+ * Custom authentication error class
182
+ */
183
+ declare class AuthError extends Error {
184
+ readonly method: string;
185
+ readonly statusCode?: number;
186
+ constructor(message: string, method: string, statusCode?: number);
187
+ }
188
+ /**
189
+ * Custom API error class
190
+ */
191
+ declare class APIError extends Error {
192
+ readonly statusCode: number;
193
+ readonly endpoint: string;
194
+ readonly response?: any;
195
+ constructor(message: string, statusCode: number, endpoint: string, response?: any);
196
+ }
197
+ /**
198
+ * Error type guards
199
+ */
200
+ declare function isOAuthError(error: any): error is OAuthError;
201
+ declare function isConfigError(error: any): error is ConfigError;
202
+ declare function isAuthError(error: any): error is AuthError;
203
+ declare function isAPIError(error: any): error is APIError;
204
+
205
+ export { APIError, AuthError, CONFIG, ConfigError, LogLevel, MCP_WORDPRESS_REMOTE_VERSION, OAuthError, type TokenValidationResult, type WPClientInfo, type WPTokens, type WordPressRequestParams, type WordPressResponse, getConfig, getDefaultOAuthScopes, isAPIError, isAuthError, isConfigError, isOAuthError, log, logger, validateConfig };