mcp-wordpress 1.2.2 → 1.3.0

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.
Files changed (251) hide show
  1. package/README.md +210 -182
  2. package/dist/cache/CacheInvalidation.d.ts +3 -3
  3. package/dist/cache/CacheInvalidation.d.ts.map +1 -1
  4. package/dist/cache/CacheInvalidation.js +119 -119
  5. package/dist/cache/CacheInvalidation.js.map +1 -1
  6. package/dist/cache/CacheManager.d.ts +5 -0
  7. package/dist/cache/CacheManager.d.ts.map +1 -1
  8. package/dist/cache/CacheManager.js +26 -16
  9. package/dist/cache/CacheManager.js.map +1 -1
  10. package/dist/cache/HttpCacheWrapper.d.ts +1 -1
  11. package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
  12. package/dist/cache/HttpCacheWrapper.js +29 -29
  13. package/dist/cache/HttpCacheWrapper.js.map +1 -1
  14. package/dist/cache/__tests__/CacheInvalidation.test.js +96 -94
  15. package/dist/cache/__tests__/CacheInvalidation.test.js.map +1 -1
  16. package/dist/cache/__tests__/CacheManager.test.js +113 -113
  17. package/dist/cache/__tests__/CacheManager.test.js.map +1 -1
  18. package/dist/cache/__tests__/CachedWordPressClient.test.js +102 -99
  19. package/dist/cache/__tests__/CachedWordPressClient.test.js.map +1 -1
  20. package/dist/cache/__tests__/HttpCacheWrapper.test.js +98 -95
  21. package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +1 -1
  22. package/dist/cache/index.d.ts +7 -7
  23. package/dist/cache/index.d.ts.map +1 -1
  24. package/dist/cache/index.js +4 -4
  25. package/dist/cache/index.js.map +1 -1
  26. package/dist/client/CachedWordPressClient.d.ts +4 -4
  27. package/dist/client/CachedWordPressClient.d.ts.map +1 -1
  28. package/dist/client/CachedWordPressClient.js +55 -51
  29. package/dist/client/CachedWordPressClient.js.map +1 -1
  30. package/dist/client/api.d.ts +10 -10
  31. package/dist/client/api.js +158 -158
  32. package/dist/client/api.js.map +1 -1
  33. package/dist/client/auth.d.ts +2 -2
  34. package/dist/client/auth.js +72 -72
  35. package/dist/client/managers/AuthenticationManager.d.ts +2 -2
  36. package/dist/client/managers/AuthenticationManager.js +46 -46
  37. package/dist/client/managers/BaseManager.d.ts +1 -1
  38. package/dist/client/managers/BaseManager.js +9 -9
  39. package/dist/client/managers/RequestManager.d.ts +5 -3
  40. package/dist/client/managers/RequestManager.d.ts.map +1 -1
  41. package/dist/client/managers/RequestManager.js +39 -19
  42. package/dist/client/managers/RequestManager.js.map +1 -1
  43. package/dist/client/managers/index.d.ts +3 -3
  44. package/dist/client/managers/index.js +3 -3
  45. package/dist/config/ConfigurationSchema.d.ts +2 -2
  46. package/dist/config/ConfigurationSchema.d.ts.map +1 -1
  47. package/dist/config/ConfigurationSchema.js +40 -40
  48. package/dist/config/ConfigurationSchema.js.map +1 -1
  49. package/dist/config/ServerConfiguration.d.ts +2 -2
  50. package/dist/config/ServerConfiguration.js +35 -35
  51. package/dist/config/ServerConfiguration.js.map +1 -1
  52. package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
  53. package/dist/docs/DocumentationGenerator.js +296 -255
  54. package/dist/docs/DocumentationGenerator.js.map +1 -1
  55. package/dist/docs/MarkdownFormatter.d.ts +1 -1
  56. package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
  57. package/dist/docs/MarkdownFormatter.js +60 -51
  58. package/dist/docs/MarkdownFormatter.js.map +1 -1
  59. package/dist/docs/index.d.ts +3 -3
  60. package/dist/docs/index.d.ts.map +1 -1
  61. package/dist/docs/index.js +2 -2
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +16 -16
  64. package/dist/index.js.map +1 -1
  65. package/dist/mcp-wordpress-1.3.0.tgz +0 -0
  66. package/dist/performance/MetricsCollector.d.ts +3 -3
  67. package/dist/performance/MetricsCollector.d.ts.map +1 -1
  68. package/dist/performance/MetricsCollector.js +33 -27
  69. package/dist/performance/MetricsCollector.js.map +1 -1
  70. package/dist/performance/PerformanceAnalytics.d.ts +12 -12
  71. package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
  72. package/dist/performance/PerformanceAnalytics.js +200 -154
  73. package/dist/performance/PerformanceAnalytics.js.map +1 -1
  74. package/dist/performance/PerformanceMonitor.d.ts +5 -5
  75. package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
  76. package/dist/performance/PerformanceMonitor.js +53 -52
  77. package/dist/performance/PerformanceMonitor.js.map +1 -1
  78. package/dist/performance/index.d.ts +6 -6
  79. package/dist/performance/index.d.ts.map +1 -1
  80. package/dist/performance/index.js +3 -3
  81. package/dist/security/InputValidator.d.ts +1 -1
  82. package/dist/security/InputValidator.d.ts.map +1 -1
  83. package/dist/security/InputValidator.js +111 -88
  84. package/dist/security/InputValidator.js.map +1 -1
  85. package/dist/security/SecurityConfig.d.ts +5 -5
  86. package/dist/security/SecurityConfig.js +92 -92
  87. package/dist/security/SecurityConfig.js.map +1 -1
  88. package/dist/server/ConnectionTester.d.ts +1 -1
  89. package/dist/server/ConnectionTester.d.ts.map +1 -1
  90. package/dist/server/ConnectionTester.js +4 -4
  91. package/dist/server/ConnectionTester.js.map +1 -1
  92. package/dist/server/ToolRegistry.d.ts +2 -2
  93. package/dist/server/ToolRegistry.d.ts.map +1 -1
  94. package/dist/server/ToolRegistry.js +35 -32
  95. package/dist/server/ToolRegistry.js.map +1 -1
  96. package/dist/server.d.ts +2 -2
  97. package/dist/server.js +2 -2
  98. package/dist/tools/BaseToolManager.js +5 -5
  99. package/dist/tools/auth.d.ts +2 -2
  100. package/dist/tools/auth.d.ts.map +1 -1
  101. package/dist/tools/auth.js +32 -31
  102. package/dist/tools/auth.js.map +1 -1
  103. package/dist/tools/cache.d.ts +1 -1
  104. package/dist/tools/cache.d.ts.map +1 -1
  105. package/dist/tools/cache.js +71 -71
  106. package/dist/tools/cache.js.map +1 -1
  107. package/dist/tools/comments.d.ts +2 -2
  108. package/dist/tools/comments.d.ts.map +1 -1
  109. package/dist/tools/comments.js +79 -79
  110. package/dist/tools/comments.js.map +1 -1
  111. package/dist/tools/index.d.ts +10 -10
  112. package/dist/tools/index.js +10 -10
  113. package/dist/tools/media.d.ts +2 -2
  114. package/dist/tools/media.js +80 -80
  115. package/dist/tools/pages.d.ts +2 -2
  116. package/dist/tools/pages.d.ts.map +1 -1
  117. package/dist/tools/pages.js +75 -75
  118. package/dist/tools/pages.js.map +1 -1
  119. package/dist/tools/performance.d.ts +1 -1
  120. package/dist/tools/performance.d.ts.map +1 -1
  121. package/dist/tools/performance.js +311 -287
  122. package/dist/tools/performance.js.map +1 -1
  123. package/dist/tools/posts.d.ts +2 -2
  124. package/dist/tools/posts.d.ts.map +1 -1
  125. package/dist/tools/posts.js +94 -94
  126. package/dist/tools/posts.js.map +1 -1
  127. package/dist/tools/site.d.ts +2 -2
  128. package/dist/tools/site.d.ts.map +1 -1
  129. package/dist/tools/site.js +60 -60
  130. package/dist/tools/site.js.map +1 -1
  131. package/dist/tools/taxonomies.d.ts +2 -2
  132. package/dist/tools/taxonomies.js +89 -89
  133. package/dist/tools/users.d.ts +2 -2
  134. package/dist/tools/users.js +68 -68
  135. package/dist/tools/users.js.map +1 -1
  136. package/dist/types/client.d.ts +13 -13
  137. package/dist/types/client.d.ts.map +1 -1
  138. package/dist/types/client.js +12 -12
  139. package/dist/types/client.js.map +1 -1
  140. package/dist/types/index.d.ts +19 -19
  141. package/dist/types/index.d.ts.map +1 -1
  142. package/dist/types/index.js +3 -3
  143. package/dist/types/mcp.d.ts +7 -7
  144. package/dist/types/wordpress.d.ts +21 -21
  145. package/dist/types/wordpress.d.ts.map +1 -1
  146. package/dist/utils/debug.d.ts +2 -2
  147. package/dist/utils/debug.js +28 -28
  148. package/dist/utils/error.d.ts.map +1 -1
  149. package/dist/utils/error.js +13 -13
  150. package/dist/utils/error.js.map +1 -1
  151. package/dist/utils/toolWrapper.d.ts.map +1 -1
  152. package/dist/utils/toolWrapper.js +5 -5
  153. package/dist/utils/toolWrapper.js.map +1 -1
  154. package/dist/utils/validation.d.ts.map +1 -1
  155. package/dist/utils/validation.js +41 -31
  156. package/dist/utils/validation.js.map +1 -1
  157. package/docs/CACHING.md +36 -2
  158. package/docs/DOCKER.md +24 -18
  159. package/docs/PERFORMANCE_MONITORING.md +49 -1
  160. package/docs/SECURITY_TESTING.md +30 -1
  161. package/docs/api/README.md +9 -1
  162. package/docs/api/summary.json +1 -1
  163. package/docs/contract-testing.md +24 -3
  164. package/docs/developer/GITHUB_ACTIONS_SETUP.md +8 -2
  165. package/docs/developer/MAINTENANCE.md +29 -3
  166. package/docs/developer/MIGRATION_GUIDE.md +13 -1
  167. package/docs/developer/NPM_AUTH_SETUP.md +13 -2
  168. package/docs/developer/REFACTORING.md +31 -1
  169. package/docs/releases/COMMUNITY_ANNOUNCEMENT_v1.1.2.md +18 -7
  170. package/docs/releases/RELEASE_NOTES_v1.1.2.md +31 -5
  171. package/docs/user-guides/DOCKER_SETUP.md +264 -0
  172. package/docs/user-guides/DTX_SETUP.md +327 -0
  173. package/docs/user-guides/NPM_SETUP.md +109 -0
  174. package/docs/user-guides/NPX_SETUP.md +281 -0
  175. package/docs/wordpress-rest-api-authentication-troubleshooting.md +13 -2
  176. package/package.json +27 -8
  177. package/src/cache/CacheInvalidation.ts +140 -132
  178. package/src/cache/CacheManager.ts +40 -29
  179. package/src/cache/HttpCacheWrapper.ts +105 -68
  180. package/src/cache/__tests__/CacheInvalidation.test.ts +123 -118
  181. package/src/cache/__tests__/CacheManager.test.ts +156 -152
  182. package/src/cache/__tests__/CachedWordPressClient.test.ts +131 -116
  183. package/src/cache/__tests__/HttpCacheWrapper.test.ts +118 -115
  184. package/src/cache/index.ts +13 -13
  185. package/src/client/CachedWordPressClient.ts +90 -80
  186. package/src/client/api.ts +205 -205
  187. package/src/client/auth.ts +80 -80
  188. package/src/client/managers/AuthenticationManager.ts +61 -61
  189. package/src/client/managers/BaseManager.ts +11 -11
  190. package/src/client/managers/RequestManager.ts +79 -47
  191. package/src/client/managers/index.ts +3 -3
  192. package/src/config/ConfigurationSchema.ts +44 -44
  193. package/src/config/ServerConfiguration.ts +39 -39
  194. package/src/docs/DocumentationGenerator.ts +402 -295
  195. package/src/docs/MarkdownFormatter.ts +94 -69
  196. package/src/docs/index.ts +4 -4
  197. package/src/index.ts +24 -21
  198. package/src/performance/MetricsCollector.ts +90 -58
  199. package/src/performance/PerformanceAnalytics.ts +386 -262
  200. package/src/performance/PerformanceMonitor.ts +152 -118
  201. package/src/performance/index.ts +9 -9
  202. package/src/security/InputValidator.ts +148 -91
  203. package/src/security/SecurityConfig.ts +94 -94
  204. package/src/server/ConnectionTester.ts +21 -15
  205. package/src/server/ToolRegistry.ts +64 -51
  206. package/src/server.ts +2 -2
  207. package/src/tools/BaseToolManager.ts +6 -6
  208. package/src/tools/auth.ts +42 -37
  209. package/src/tools/cache.ts +85 -81
  210. package/src/tools/comments.ts +93 -91
  211. package/src/tools/index.ts +10 -10
  212. package/src/tools/media.ts +89 -89
  213. package/src/tools/pages.ts +89 -87
  214. package/src/tools/performance.ts +443 -352
  215. package/src/tools/posts.ts +109 -107
  216. package/src/tools/site.ts +86 -77
  217. package/src/tools/taxonomies.ts +102 -102
  218. package/src/tools/users.ts +77 -77
  219. package/src/types/client.ts +157 -60
  220. package/src/types/index.ts +49 -27
  221. package/src/types/mcp.ts +15 -15
  222. package/src/types/wordpress.ts +57 -29
  223. package/src/utils/debug.ts +37 -37
  224. package/src/utils/error.ts +47 -25
  225. package/src/utils/toolWrapper.ts +12 -8
  226. package/src/utils/validation.ts +116 -65
  227. package/dist/client/WordPressClient.d.ts +0 -81
  228. package/dist/client/WordPressClient.d.ts.map +0 -1
  229. package/dist/client/WordPressClient.js +0 -354
  230. package/dist/client/WordPressClient.js.map +0 -1
  231. package/dist/performance/AnomalyDetector.d.ts +0 -63
  232. package/dist/performance/AnomalyDetector.d.ts.map +0 -1
  233. package/dist/performance/AnomalyDetector.js +0 -222
  234. package/dist/performance/AnomalyDetector.js.map +0 -1
  235. package/dist/performance/BenchmarkAnalyzer.d.ts +0 -67
  236. package/dist/performance/BenchmarkAnalyzer.d.ts.map +0 -1
  237. package/dist/performance/BenchmarkAnalyzer.js +0 -301
  238. package/dist/performance/BenchmarkAnalyzer.js.map +0 -1
  239. package/dist/performance/TrendAnalyzer.d.ts +0 -69
  240. package/dist/performance/TrendAnalyzer.d.ts.map +0 -1
  241. package/dist/performance/TrendAnalyzer.js +0 -203
  242. package/dist/performance/TrendAnalyzer.js.map +0 -1
  243. package/dist/tools/BaseToolClass.d.ts +0 -76
  244. package/dist/tools/BaseToolClass.d.ts.map +0 -1
  245. package/dist/tools/BaseToolClass.js +0 -104
  246. package/dist/tools/BaseToolClass.js.map +0 -1
  247. package/dist/tools/base.d.ts +0 -37
  248. package/dist/tools/base.d.ts.map +0 -1
  249. package/dist/tools/base.js +0 -60
  250. package/dist/tools/base.js.map +0 -1
  251. package/docs/user-guides/CLAUDE_DESKTOP_SETUP.md +0 -187
@@ -3,10 +3,10 @@
3
3
  * Extracts documentation from tool classes, types, and WordPress mappings
4
4
  */
5
5
 
6
- import * as fs from 'fs';
7
- import * as path from 'path';
8
- import * as Tools from '../tools/index.js';
9
- import type { ToolDefinition } from '../server/ToolRegistry.js';
6
+ import * as fs from "fs";
7
+ import * as path from "path";
8
+ import * as Tools from "../tools/index.js";
9
+ import type { ToolDefinition } from "../server/ToolRegistry.js";
10
10
 
11
11
  export interface DocumentationConfig {
12
12
  outputDir: string;
@@ -121,13 +121,13 @@ export class DocumentationGenerator {
121
121
 
122
122
  constructor(config: Partial<DocumentationConfig> = {}) {
123
123
  this.config = {
124
- outputDir: 'docs/api',
124
+ outputDir: "docs/api",
125
125
  includeExamples: true,
126
126
  includeWordPressMapping: true,
127
127
  generateOpenAPI: true,
128
128
  generateInteractiveHtml: true,
129
129
  validateExamples: false,
130
- ...config
130
+ ...config,
131
131
  };
132
132
 
133
133
  this.initializeWordPressMapping();
@@ -138,12 +138,12 @@ export class DocumentationGenerator {
138
138
  * Generate complete documentation for all tools and types
139
139
  */
140
140
  async generateFullDocumentation(): Promise<DocumentationOutput> {
141
- console.log('🚀 Starting API documentation generation...');
141
+ console.log("🚀 Starting API documentation generation...");
142
142
 
143
143
  const tools = await this.extractAllToolDocumentation();
144
144
  const categories = this.generateCategoryDocumentation(tools);
145
145
  const types = await this.extractTypeDocumentation();
146
-
146
+
147
147
  let openApiSpec: OpenAPISpecification | undefined = undefined;
148
148
  if (this.config.generateOpenAPI) {
149
149
  openApiSpec = this.generateOpenAPISpecification(tools, types);
@@ -156,13 +156,15 @@ export class DocumentationGenerator {
156
156
  categories,
157
157
  types,
158
158
  openApiSpec,
159
- summary
159
+ summary,
160
160
  };
161
161
 
162
162
  // Write documentation to files
163
163
  await this.writeDocumentationFiles(output);
164
164
 
165
- console.log(`✅ Documentation generation complete! ${tools.length} tools documented.`);
165
+ console.log(
166
+ `✅ Documentation generation complete! ${tools.length} tools documented.`,
167
+ );
166
168
  return output;
167
169
  }
168
170
 
@@ -177,7 +179,7 @@ export class DocumentationGenerator {
177
179
  try {
178
180
  // Create tool instance
179
181
  let toolInstance: any;
180
- if (className === 'CacheTools' || className === 'PerformanceTools') {
182
+ if (className === "CacheTools" || className === "PerformanceTools") {
181
183
  // These tools need client map - use empty map for doc generation
182
184
  toolInstance = new ToolClass(new Map());
183
185
  } else {
@@ -188,11 +190,18 @@ export class DocumentationGenerator {
188
190
  const category = this.extractCategoryFromClassName(className);
189
191
 
190
192
  for (const toolDef of toolDefinitions) {
191
- const doc = await this.extractToolDocumentation(toolDef, category, className);
193
+ const doc = await this.extractToolDocumentation(
194
+ toolDef,
195
+ category,
196
+ className,
197
+ );
192
198
  toolDocs.push(doc);
193
199
  }
194
200
  } catch (error) {
195
- console.warn(`⚠️ Failed to extract documentation for ${className}:`, error);
201
+ console.warn(
202
+ `⚠️ Failed to extract documentation for ${className}:`,
203
+ error,
204
+ );
196
205
  }
197
206
  }
198
207
 
@@ -203,11 +212,13 @@ export class DocumentationGenerator {
203
212
  * Extract documentation for a single tool
204
213
  */
205
214
  private async extractToolDocumentation(
206
- toolDef: ToolDefinition,
215
+ toolDef: ToolDefinition,
207
216
  category: string,
208
- className: string
217
+ className: string,
209
218
  ): Promise<ToolDocumentation> {
210
- const parameters = this.extractParameterDocumentation(toolDef.parameters || []);
219
+ const parameters = this.extractParameterDocumentation(
220
+ toolDef.parameters || [],
221
+ );
211
222
  const examples = this.generateToolExamples(toolDef, category);
212
223
  const wordpressEndpoint = this.wordpressEndpoints.get(toolDef.name);
213
224
  const returnType = this.inferReturnType(toolDef.name, category);
@@ -224,29 +235,34 @@ export class DocumentationGenerator {
224
235
  requiredPermissions: this.getRequiredPermissions(toolDef.name),
225
236
  returnType,
226
237
  errorCodes,
227
- relatedTools
238
+ relatedTools,
228
239
  };
229
240
  }
230
241
 
231
242
  /**
232
243
  * Extract parameter documentation
233
244
  */
234
- private extractParameterDocumentation(parameters: any[]): ParameterDocumentation[] {
235
- return parameters.map(param => ({
245
+ private extractParameterDocumentation(
246
+ parameters: any[],
247
+ ): ParameterDocumentation[] {
248
+ return parameters.map((param) => ({
236
249
  name: param.name,
237
- type: param.type || 'string',
250
+ type: param.type || "string",
238
251
  required: param.required || false,
239
252
  description: param.description || `${param.name} parameter`,
240
253
  defaultValue: this.getDefaultValue(param),
241
254
  allowedValues: this.getAllowedValues(param) || undefined,
242
- examples: this.generateParameterExamples(param)
255
+ examples: this.generateParameterExamples(param),
243
256
  }));
244
257
  }
245
258
 
246
259
  /**
247
260
  * Generate usage examples for tools
248
261
  */
249
- private generateToolExamples(toolDef: ToolDefinition, category: string): ExampleUsage[] {
262
+ private generateToolExamples(
263
+ toolDef: ToolDefinition,
264
+ category: string,
265
+ ): ExampleUsage[] {
250
266
  const examples: ExampleUsage[] = [];
251
267
 
252
268
  // Basic usage example
@@ -275,13 +291,17 @@ export class DocumentationGenerator {
275
291
  /**
276
292
  * Generate basic usage example
277
293
  */
278
- private generateBasicExample(toolDef: ToolDefinition, category: string): ExampleUsage | null {
294
+ private generateBasicExample(
295
+ toolDef: ToolDefinition,
296
+ category: string,
297
+ ): ExampleUsage | null {
279
298
  const toolName = toolDef.name;
280
299
  const basicParams: Record<string, any> = {};
281
300
 
282
301
  // Add essential parameters
283
- const requiredParams = (toolDef.parameters || []).filter(p => p.required);
284
- for (const param of requiredParams.slice(0, 2)) { // Limit to 2 for basic example
302
+ const requiredParams = (toolDef.parameters || []).filter((p) => p.required);
303
+ for (const param of requiredParams.slice(0, 2)) {
304
+ // Limit to 2 for basic example
285
305
  basicParams[param.name] = this.generateExampleValue(param);
286
306
  }
287
307
 
@@ -290,55 +310,75 @@ export class DocumentationGenerator {
290
310
  description: `Simple example of using ${toolName}`,
291
311
  command: toolName,
292
312
  parameters: basicParams,
293
- expectedResponse: this.generateExpectedResponse(toolName, category, 'basic'),
313
+ expectedResponse: this.generateExpectedResponse(
314
+ toolName,
315
+ category,
316
+ "basic",
317
+ ),
294
318
  errorExample: {
295
- scenario: 'Authentication failure',
319
+ scenario: "Authentication failure",
296
320
  error: {
297
- error: 'Authentication failed',
298
- message: 'Invalid credentials or insufficient permissions'
299
- }
300
- }
321
+ error: "Authentication failed",
322
+ message: "Invalid credentials or insufficient permissions",
323
+ },
324
+ },
301
325
  };
302
326
  }
303
327
 
304
328
  /**
305
329
  * Generate multi-site example
306
330
  */
307
- private generateMultiSiteExample(toolDef: ToolDefinition, category: string): ExampleUsage | null {
308
- const params = { site: 'site1', ...this.getExampleParameters(toolDef, 1) };
331
+ private generateMultiSiteExample(
332
+ toolDef: ToolDefinition,
333
+ category: string,
334
+ ): ExampleUsage | null {
335
+ const params = { site: "site1", ...this.getExampleParameters(toolDef, 1) };
309
336
 
310
337
  return {
311
338
  title: `Multi-Site ${category} Usage`,
312
339
  description: `Using ${toolDef.name} with specific site targeting`,
313
340
  command: toolDef.name,
314
341
  parameters: params,
315
- expectedResponse: this.generateExpectedResponse(toolDef.name, category, 'multisite')
342
+ expectedResponse: this.generateExpectedResponse(
343
+ toolDef.name,
344
+ category,
345
+ "multisite",
346
+ ),
316
347
  };
317
348
  }
318
349
 
319
350
  /**
320
351
  * Generate advanced example with all parameters
321
352
  */
322
- private generateAdvancedExample(toolDef: ToolDefinition, category: string): ExampleUsage | null {
323
- const allParams = this.getExampleParameters(toolDef, 'all');
324
-
353
+ private generateAdvancedExample(
354
+ toolDef: ToolDefinition,
355
+ category: string,
356
+ ): ExampleUsage | null {
357
+ const allParams = this.getExampleParameters(toolDef, "all");
358
+
325
359
  if (Object.keys(allParams).length <= 2) {
326
360
  return null; // Skip if not enough parameters for advanced example
327
361
  }
328
362
 
329
363
  return {
330
364
  title: `Advanced ${category} Configuration`,
331
- description: 'Comprehensive example using all available parameters',
365
+ description: "Comprehensive example using all available parameters",
332
366
  command: toolDef.name,
333
367
  parameters: allParams,
334
- expectedResponse: this.generateExpectedResponse(toolDef.name, category, 'advanced')
368
+ expectedResponse: this.generateExpectedResponse(
369
+ toolDef.name,
370
+ category,
371
+ "advanced",
372
+ ),
335
373
  };
336
374
  }
337
375
 
338
376
  /**
339
377
  * Generate category documentation
340
378
  */
341
- private generateCategoryDocumentation(tools: ToolDocumentation[]): CategoryDocumentation[] {
379
+ private generateCategoryDocumentation(
380
+ tools: ToolDocumentation[],
381
+ ): CategoryDocumentation[] {
342
382
  const categories = new Map<string, ToolDocumentation[]>();
343
383
 
344
384
  // Group tools by category
@@ -349,13 +389,15 @@ export class DocumentationGenerator {
349
389
  categories.get(tool.category)!.push(tool);
350
390
  }
351
391
 
352
- return Array.from(categories.entries()).map(([categoryName, categoryTools]) => ({
353
- name: categoryName,
354
- description: this.getCategoryDescription(categoryName),
355
- toolCount: categoryTools.length,
356
- tools: categoryTools.map(t => t.name).sort(),
357
- usagePatterns: this.generateUsagePatterns(categoryName, categoryTools)
358
- }));
392
+ return Array.from(categories.entries()).map(
393
+ ([categoryName, categoryTools]) => ({
394
+ name: categoryName,
395
+ description: this.getCategoryDescription(categoryName),
396
+ toolCount: categoryTools.length,
397
+ tools: categoryTools.map((t) => t.name).sort(),
398
+ usagePatterns: this.generateUsagePatterns(categoryName, categoryTools),
399
+ }),
400
+ );
359
401
  }
360
402
 
361
403
  /**
@@ -366,17 +408,37 @@ export class DocumentationGenerator {
366
408
  // For now, we'll provide key WordPress and MCP types
367
409
  return [
368
410
  {
369
- name: 'WordPressPost',
370
- description: 'WordPress blog post object',
411
+ name: "WordPressPost",
412
+ description: "WordPress blog post object",
371
413
  properties: [
372
- { name: 'id', type: 'number', required: true, description: 'Unique identifier' },
373
- { name: 'title', type: 'string', required: true, description: 'Post title' },
374
- { name: 'content', type: 'string', required: true, description: 'Post content' },
375
- { name: 'status', type: 'string', required: true, description: 'Publication status' }
414
+ {
415
+ name: "id",
416
+ type: "number",
417
+ required: true,
418
+ description: "Unique identifier",
419
+ },
420
+ {
421
+ name: "title",
422
+ type: "string",
423
+ required: true,
424
+ description: "Post title",
425
+ },
426
+ {
427
+ name: "content",
428
+ type: "string",
429
+ required: true,
430
+ description: "Post content",
431
+ },
432
+ {
433
+ name: "status",
434
+ type: "string",
435
+ required: true,
436
+ description: "Publication status",
437
+ },
376
438
  ],
377
439
  examples: [this.generateWordPressPostExample()],
378
- wordpressSource: '/wp-json/wp/v2/posts'
379
- }
440
+ wordpressSource: "/wp-json/wp/v2/posts",
441
+ },
380
442
  // Add more types as needed
381
443
  ];
382
444
  }
@@ -385,14 +447,14 @@ export class DocumentationGenerator {
385
447
  * Generate OpenAPI specification
386
448
  */
387
449
  private generateOpenAPISpecification(
388
- tools: ToolDocumentation[],
389
- types: TypeDocumentation[]
450
+ tools: ToolDocumentation[],
451
+ types: TypeDocumentation[],
390
452
  ): OpenAPISpecification {
391
453
  const paths: Record<string, any> = {};
392
454
  const components: Record<string, any> = {
393
455
  schemas: {},
394
456
  parameters: {},
395
- responses: {}
457
+ responses: {},
396
458
  };
397
459
 
398
460
  // Convert tools to OpenAPI paths
@@ -406,31 +468,31 @@ export class DocumentationGenerator {
406
468
  requestBody: {
407
469
  required: true,
408
470
  content: {
409
- 'application/json': {
410
- schema: this.generateParameterSchema(tool.parameters)
411
- }
412
- }
471
+ "application/json": {
472
+ schema: this.generateParameterSchema(tool.parameters),
473
+ },
474
+ },
413
475
  },
414
476
  responses: {
415
- '200': {
416
- description: 'Successful response',
477
+ "200": {
478
+ description: "Successful response",
417
479
  content: {
418
- 'application/json': {
419
- schema: { type: 'object' }
420
- }
421
- }
480
+ "application/json": {
481
+ schema: { type: "object" },
482
+ },
483
+ },
422
484
  },
423
- '400': {
424
- description: 'Bad request - invalid parameters'
485
+ "400": {
486
+ description: "Bad request - invalid parameters",
425
487
  },
426
- '401': {
427
- description: 'Authentication failed'
488
+ "401": {
489
+ description: "Authentication failed",
428
490
  },
429
- '500': {
430
- description: 'Internal server error'
431
- }
432
- }
433
- }
491
+ "500": {
492
+ description: "Internal server error",
493
+ },
494
+ },
495
+ },
434
496
  };
435
497
  }
436
498
 
@@ -440,37 +502,43 @@ export class DocumentationGenerator {
440
502
  }
441
503
 
442
504
  return {
443
- openapi: '3.0.3',
505
+ openapi: "3.0.3",
444
506
  info: {
445
- title: 'WordPress MCP Server API',
446
- description: 'Model Context Protocol server for WordPress management',
447
- version: '1.2.0',
507
+ title: "WordPress MCP Server API",
508
+ description: "Model Context Protocol server for WordPress management",
509
+ version: "1.2.0",
448
510
  contact: {
449
- name: 'MCP WordPress',
450
- url: 'https://github.com/docdyhr/mcp-wordpress'
511
+ name: "MCP WordPress",
512
+ url: "https://github.com/docdyhr/mcp-wordpress",
451
513
  },
452
514
  license: {
453
- name: 'MIT',
454
- url: 'https://opensource.org/licenses/MIT'
455
- }
515
+ name: "MIT",
516
+ url: "https://opensource.org/licenses/MIT",
517
+ },
456
518
  },
457
519
  paths,
458
- components
520
+ components,
459
521
  };
460
522
  }
461
523
 
462
524
  /**
463
525
  * Write all documentation files
464
526
  */
465
- private async writeDocumentationFiles(output: DocumentationOutput): Promise<void> {
527
+ private async writeDocumentationFiles(
528
+ output: DocumentationOutput,
529
+ ): Promise<void> {
466
530
  const outputDir = this.config.outputDir;
467
531
 
468
532
  // Ensure output directory exists
469
533
  await fs.promises.mkdir(outputDir, { recursive: true });
470
- await fs.promises.mkdir(path.join(outputDir, 'tools'), { recursive: true });
471
- await fs.promises.mkdir(path.join(outputDir, 'types'), { recursive: true });
472
- await fs.promises.mkdir(path.join(outputDir, 'examples'), { recursive: true });
473
- await fs.promises.mkdir(path.join(outputDir, 'categories'), { recursive: true });
534
+ await fs.promises.mkdir(path.join(outputDir, "tools"), { recursive: true });
535
+ await fs.promises.mkdir(path.join(outputDir, "types"), { recursive: true });
536
+ await fs.promises.mkdir(path.join(outputDir, "examples"), {
537
+ recursive: true,
538
+ });
539
+ await fs.promises.mkdir(path.join(outputDir, "categories"), {
540
+ recursive: true,
541
+ });
474
542
 
475
543
  // Write main API documentation
476
544
  await this.writeApiOverview(output);
@@ -493,58 +561,73 @@ export class DocumentationGenerator {
493
561
  // Write OpenAPI specification
494
562
  if (output.openApiSpec) {
495
563
  await fs.promises.writeFile(
496
- path.join(outputDir, 'openapi.json'),
497
- JSON.stringify(output.openApiSpec, null, 2)
564
+ path.join(outputDir, "openapi.json"),
565
+ JSON.stringify(output.openApiSpec, null, 2),
498
566
  );
499
567
  }
500
568
 
501
569
  // Write summary
502
570
  await fs.promises.writeFile(
503
- path.join(outputDir, 'summary.json'),
504
- JSON.stringify(output.summary, null, 2)
571
+ path.join(outputDir, "summary.json"),
572
+ JSON.stringify(output.summary, null, 2),
505
573
  );
506
574
 
507
575
  console.log(`📁 Documentation written to ${outputDir}/`);
508
576
  }
509
577
 
510
578
  // Helper methods for specific documentation tasks...
511
-
579
+
512
580
  private extractCategoryFromClassName(className: string): string {
513
- return className.replace('Tools', '').toLowerCase();
581
+ return className.replace("Tools", "").toLowerCase();
514
582
  }
515
583
 
516
584
  private initializeWordPressMapping(): void {
517
585
  // Map MCP tools to WordPress REST API endpoints
518
- this.wordpressEndpoints.set('wp_list_posts', '/wp-json/wp/v2/posts');
519
- this.wordpressEndpoints.set('wp_get_post', '/wp-json/wp/v2/posts/{id}');
520
- this.wordpressEndpoints.set('wp_create_post', '/wp-json/wp/v2/posts');
521
- this.wordpressEndpoints.set('wp_update_post', '/wp-json/wp/v2/posts/{id}');
522
- this.wordpressEndpoints.set('wp_delete_post', '/wp-json/wp/v2/posts/{id}');
586
+ this.wordpressEndpoints.set("wp_list_posts", "/wp-json/wp/v2/posts");
587
+ this.wordpressEndpoints.set("wp_get_post", "/wp-json/wp/v2/posts/{id}");
588
+ this.wordpressEndpoints.set("wp_create_post", "/wp-json/wp/v2/posts");
589
+ this.wordpressEndpoints.set("wp_update_post", "/wp-json/wp/v2/posts/{id}");
590
+ this.wordpressEndpoints.set("wp_delete_post", "/wp-json/wp/v2/posts/{id}");
523
591
  // Add more mappings...
524
592
  }
525
593
 
526
594
  private initializeToolCategories(): void {
527
- this.toolCategories.set('Posts', ['wp_list_posts', 'wp_get_post', 'wp_create_post', 'wp_update_post', 'wp_delete_post', 'wp_search_posts']);
528
- this.toolCategories.set('Pages', ['wp_list_pages', 'wp_get_page', 'wp_create_page', 'wp_update_page', 'wp_delete_page', 'wp_search_pages']);
595
+ this.toolCategories.set("Posts", [
596
+ "wp_list_posts",
597
+ "wp_get_post",
598
+ "wp_create_post",
599
+ "wp_update_post",
600
+ "wp_delete_post",
601
+ "wp_search_posts",
602
+ ]);
603
+ this.toolCategories.set("Pages", [
604
+ "wp_list_pages",
605
+ "wp_get_page",
606
+ "wp_create_page",
607
+ "wp_update_page",
608
+ "wp_delete_page",
609
+ "wp_search_pages",
610
+ ]);
529
611
  // Add more categories...
530
612
  }
531
613
 
532
614
  private generateDocumentationSummary(
533
- tools: ToolDocumentation[],
534
- categories: CategoryDocumentation[],
535
- types: TypeDocumentation[]
615
+ tools: ToolDocumentation[],
616
+ categories: CategoryDocumentation[],
617
+ types: TypeDocumentation[],
536
618
  ): DocumentationSummary {
537
619
  return {
538
620
  totalTools: tools.length,
539
621
  totalCategories: categories.length,
540
622
  totalTypes: types.length,
541
623
  lastUpdated: new Date().toISOString(),
542
- version: '1.2.0',
624
+ version: "1.2.0",
543
625
  coverage: {
544
- toolsWithExamples: tools.filter(t => t.examples.length > 0).length,
545
- toolsWithWordPressMapping: tools.filter(t => t.wordpressEndpoint).length,
546
- typesDocumented: types.length
547
- }
626
+ toolsWithExamples: tools.filter((t) => t.examples.length > 0).length,
627
+ toolsWithWordPressMapping: tools.filter((t) => t.wordpressEndpoint)
628
+ .length,
629
+ typesDocumented: types.length,
630
+ },
548
631
  };
549
632
  }
550
633
 
@@ -554,156 +637,163 @@ export class DocumentationGenerator {
554
637
 
555
638
  private getDefaultValue(param: any): any {
556
639
  const defaults: Record<string, any> = {
557
- 'per_page': 10,
558
- 'page': 1,
559
- 'order': 'desc',
560
- 'orderby': 'date',
561
- 'status': 'publish',
562
- 'format': 'summary',
563
- 'category': 'all',
564
- 'includeExamples': true,
565
- 'includeTrends': true
640
+ per_page: 10,
641
+ page: 1,
642
+ order: "desc",
643
+ orderby: "date",
644
+ status: "publish",
645
+ format: "summary",
646
+ category: "all",
647
+ includeExamples: true,
648
+ includeTrends: true,
566
649
  };
567
650
  return defaults[param.name];
568
651
  }
569
652
 
570
653
  private getAllowedValues(param: any): string[] | undefined {
571
654
  const allowedValues: Record<string, string[]> = {
572
- 'status': ['publish', 'draft', 'private', 'pending', 'future'],
573
- 'order': ['asc', 'desc'],
574
- 'orderby': ['date', 'title', 'author', 'modified'],
575
- 'format': ['summary', 'detailed', 'raw'],
576
- 'category': ['overview', 'requests', 'cache', 'system', 'tools', 'all'],
577
- 'timeframe': ['1h', '6h', '12h', '24h', '7d', '30d'],
578
- 'priority': ['quick_wins', 'medium_term', 'long_term', 'all'],
579
- 'focus': ['speed', 'reliability', 'efficiency', 'scaling']
655
+ status: ["publish", "draft", "private", "pending", "future"],
656
+ order: ["asc", "desc"],
657
+ orderby: ["date", "title", "author", "modified"],
658
+ format: ["summary", "detailed", "raw"],
659
+ category: ["overview", "requests", "cache", "system", "tools", "all"],
660
+ timeframe: ["1h", "6h", "12h", "24h", "7d", "30d"],
661
+ priority: ["quick_wins", "medium_term", "long_term", "all"],
662
+ focus: ["speed", "reliability", "efficiency", "scaling"],
580
663
  };
581
664
  return allowedValues[param.name];
582
665
  }
583
666
 
584
667
  private generateParameterExamples(param: any): string[] {
585
668
  const examples: Record<string, string[]> = {
586
- 'id': ['123', '456'],
587
- 'title': ['My Blog Post', 'Hello World'],
588
- 'content': ['<p>Post content here</p>', 'This is my post content'],
589
- 'site': ['site1', 'production', 'staging'],
590
- 'per_page': ['10', '20', '50'],
591
- 'search': ['wordpress', 'tutorial'],
592
- 'author': ['1', '2'],
593
- 'email': ['user@example.com', 'admin@site.com'],
594
- 'username': ['john_doe', 'admin'],
595
- 'limit': ['10', '20', '50'],
596
- 'timeframe': ['24h', '7d', '1h']
669
+ id: ["123", "456"],
670
+ title: ["My Blog Post", "Hello World"],
671
+ content: ["<p>Post content here</p>", "This is my post content"],
672
+ site: ["site1", "production", "staging"],
673
+ per_page: ["10", "20", "50"],
674
+ search: ["wordpress", "tutorial"],
675
+ author: ["1", "2"],
676
+ email: ["user@example.com", "admin@site.com"],
677
+ username: ["john_doe", "admin"],
678
+ limit: ["10", "20", "50"],
679
+ timeframe: ["24h", "7d", "1h"],
597
680
  };
598
- return examples[param.name] || ['example'];
681
+ return examples[param.name] || ["example"];
599
682
  }
600
683
 
601
684
  private supportsMultiSite(toolDef: ToolDefinition): boolean {
602
685
  // All tools support multi-site via the site parameter
603
- return toolDef.parameters?.some(p => p.name === 'site') ?? true;
686
+ return toolDef.parameters?.some((p) => p.name === "site") ?? true;
604
687
  }
605
688
 
606
689
  private generateExampleValue(param: any): any {
607
690
  const exampleValues: Record<string, any> = {
608
- 'id': 123,
609
- 'title': 'Example Post Title',
610
- 'content': 'This is example content for the post.',
611
- 'site': 'site1',
612
- 'per_page': 10,
613
- 'page': 1,
614
- 'search': 'wordpress',
615
- 'author': 1,
616
- 'email': 'user@example.com',
617
- 'username': 'john_doe',
618
- 'status': 'publish',
619
- 'order': 'desc',
620
- 'orderby': 'date',
621
- 'limit': 20,
622
- 'timeframe': '24h',
623
- 'format': 'summary',
624
- 'category': 'overview'
691
+ id: 123,
692
+ title: "Example Post Title",
693
+ content: "This is example content for the post.",
694
+ site: "site1",
695
+ per_page: 10,
696
+ page: 1,
697
+ search: "wordpress",
698
+ author: 1,
699
+ email: "user@example.com",
700
+ username: "john_doe",
701
+ status: "publish",
702
+ order: "desc",
703
+ orderby: "date",
704
+ limit: 20,
705
+ timeframe: "24h",
706
+ format: "summary",
707
+ category: "overview",
625
708
  };
626
- return exampleValues[param.name] || 'example_value';
709
+ return exampleValues[param.name] || "example_value";
627
710
  }
628
711
 
629
- private generateExpectedResponse(toolName: string, category: string, type: string): any {
630
- if (toolName.includes('list')) {
712
+ private generateExpectedResponse(
713
+ toolName: string,
714
+ category: string,
715
+ type: string,
716
+ ): any {
717
+ if (toolName.includes("list")) {
631
718
  return {
632
719
  success: true,
633
720
  data: [
634
- { id: 1, title: `Example ${category} 1`, status: 'publish' },
635
- { id: 2, title: `Example ${category} 2`, status: 'draft' }
721
+ { id: 1, title: `Example ${category} 1`, status: "publish" },
722
+ { id: 2, title: `Example ${category} 2`, status: "draft" },
636
723
  ],
637
724
  total: 2,
638
- pages: 1
725
+ pages: 1,
639
726
  };
640
727
  }
641
728
 
642
- if (toolName.includes('get')) {
729
+ if (toolName.includes("get")) {
643
730
  return {
644
731
  success: true,
645
732
  data: {
646
733
  id: 123,
647
734
  title: `Example ${category}`,
648
- content: 'Example content',
649
- status: 'publish',
650
- date: '2024-01-01T00:00:00Z'
651
- }
735
+ content: "Example content",
736
+ status: "publish",
737
+ date: "2024-01-01T00:00:00Z",
738
+ },
652
739
  };
653
740
  }
654
741
 
655
- if (toolName.includes('create') || toolName.includes('update')) {
742
+ if (toolName.includes("create") || toolName.includes("update")) {
656
743
  return {
657
744
  success: true,
658
745
  data: {
659
746
  id: 123,
660
- title: 'Created/Updated successfully',
661
- status: 'publish'
662
- }
747
+ title: "Created/Updated successfully",
748
+ status: "publish",
749
+ },
663
750
  };
664
751
  }
665
752
 
666
- if (toolName.includes('delete')) {
753
+ if (toolName.includes("delete")) {
667
754
  return {
668
755
  success: true,
669
756
  data: {
670
757
  deleted: true,
671
- id: 123
672
- }
758
+ id: 123,
759
+ },
673
760
  };
674
761
  }
675
762
 
676
- if (toolName.includes('performance')) {
763
+ if (toolName.includes("performance")) {
677
764
  return {
678
765
  success: true,
679
766
  data: {
680
767
  overview: {
681
- overallHealth: 'Good',
768
+ overallHealth: "Good",
682
769
  performanceScore: 85,
683
- averageResponseTime: '245ms',
684
- cacheHitRate: '87.5%'
685
- }
686
- }
770
+ averageResponseTime: "245ms",
771
+ cacheHitRate: "87.5%",
772
+ },
773
+ },
687
774
  };
688
775
  }
689
776
 
690
777
  return {
691
778
  success: true,
692
779
  data: {},
693
- message: `${toolName} executed successfully`
780
+ message: `${toolName} executed successfully`,
694
781
  };
695
782
  }
696
783
 
697
- private getExampleParameters(toolDef: ToolDefinition, type: string | number): Record<string, any> {
784
+ private getExampleParameters(
785
+ toolDef: ToolDefinition,
786
+ type: string | number,
787
+ ): Record<string, any> {
698
788
  const params: Record<string, any> = {};
699
789
  const parameters = toolDef.parameters || [];
700
790
 
701
- if (type === 'all') {
791
+ if (type === "all") {
702
792
  // Include all parameters
703
793
  for (const param of parameters) {
704
794
  params[param.name] = this.generateExampleValue(param);
705
795
  }
706
- } else if (typeof type === 'number') {
796
+ } else if (typeof type === "number") {
707
797
  // Include limited number of parameters
708
798
  for (const param of parameters.slice(0, type)) {
709
799
  params[param.name] = this.generateExampleValue(param);
@@ -715,67 +805,76 @@ export class DocumentationGenerator {
715
805
 
716
806
  private getCategoryDescription(categoryName: string): string {
717
807
  const descriptions: Record<string, string> = {
718
- 'posts': 'Blog post creation, editing, and management tools',
719
- 'pages': 'Static page creation and management tools',
720
- 'media': 'File upload, management, and media library tools',
721
- 'users': 'User account management and authentication tools',
722
- 'comments': 'Comment moderation and management tools',
723
- 'taxonomies': 'Category and tag management tools',
724
- 'site': 'Site settings and configuration tools',
725
- 'auth': 'Authentication testing and management tools',
726
- 'cache': 'Performance caching and optimization tools',
727
- 'performance': 'Performance monitoring and analytics tools'
808
+ posts: "Blog post creation, editing, and management tools",
809
+ pages: "Static page creation and management tools",
810
+ media: "File upload, management, and media library tools",
811
+ users: "User account management and authentication tools",
812
+ comments: "Comment moderation and management tools",
813
+ taxonomies: "Category and tag management tools",
814
+ site: "Site settings and configuration tools",
815
+ auth: "Authentication testing and management tools",
816
+ cache: "Performance caching and optimization tools",
817
+ performance: "Performance monitoring and analytics tools",
728
818
  };
729
- return descriptions[categoryName.toLowerCase()] || `${categoryName} management tools`;
819
+ return (
820
+ descriptions[categoryName.toLowerCase()] ||
821
+ `${categoryName} management tools`
822
+ );
730
823
  }
731
824
 
732
- private generateUsagePatterns(categoryName: string, tools: ToolDocumentation[]): string[] {
825
+ private generateUsagePatterns(
826
+ categoryName: string,
827
+ tools: ToolDocumentation[],
828
+ ): string[] {
733
829
  const patterns: Record<string, string[]> = {
734
- 'posts': [
735
- 'Create and publish blog posts',
736
- 'Bulk edit multiple posts',
737
- 'Search and filter posts by criteria',
738
- 'Schedule posts for future publication'
830
+ posts: [
831
+ "Create and publish blog posts",
832
+ "Bulk edit multiple posts",
833
+ "Search and filter posts by criteria",
834
+ "Schedule posts for future publication",
739
835
  ],
740
- 'media': [
741
- 'Upload images and files',
742
- 'Organize media library',
743
- 'Generate thumbnails and variants',
744
- 'Bulk media operations'
836
+ media: [
837
+ "Upload images and files",
838
+ "Organize media library",
839
+ "Generate thumbnails and variants",
840
+ "Bulk media operations",
745
841
  ],
746
- 'users': [
747
- 'Manage user accounts and roles',
748
- 'User authentication and permissions',
749
- 'Bulk user operations',
750
- 'User profile management'
842
+ users: [
843
+ "Manage user accounts and roles",
844
+ "User authentication and permissions",
845
+ "Bulk user operations",
846
+ "User profile management",
847
+ ],
848
+ performance: [
849
+ "Monitor real-time performance metrics",
850
+ "Analyze historical performance trends",
851
+ "Generate optimization recommendations",
852
+ "Export performance reports",
751
853
  ],
752
- 'performance': [
753
- 'Monitor real-time performance metrics',
754
- 'Analyze historical performance trends',
755
- 'Generate optimization recommendations',
756
- 'Export performance reports'
757
- ]
758
854
  };
759
- return patterns[categoryName.toLowerCase()] || [
760
- `Manage ${categoryName.toLowerCase()} efficiently`,
761
- `Bulk ${categoryName.toLowerCase()} operations`,
762
- `Search and filter ${categoryName.toLowerCase()}`
763
- ];
855
+ return (
856
+ patterns[categoryName.toLowerCase()] || [
857
+ `Manage ${categoryName.toLowerCase()} efficiently`,
858
+ `Bulk ${categoryName.toLowerCase()} operations`,
859
+ `Search and filter ${categoryName.toLowerCase()}`,
860
+ ]
861
+ );
764
862
  }
765
863
 
766
864
  private generateWordPressPostExample(): any {
767
865
  return {
768
866
  id: 123,
769
- title: 'Welcome to WordPress',
770
- content: '<p>This is your first post. Edit or delete it to get started!</p>',
771
- status: 'publish',
772
- date: '2024-01-01T00:00:00Z',
867
+ title: "Welcome to WordPress",
868
+ content:
869
+ "<p>This is your first post. Edit or delete it to get started!</p>",
870
+ status: "publish",
871
+ date: "2024-01-01T00:00:00Z",
773
872
  author: 1,
774
873
  categories: [1],
775
874
  tags: [1, 2],
776
875
  featured_media: 0,
777
- excerpt: 'A sample WordPress post',
778
- slug: 'welcome-to-wordpress'
876
+ excerpt: "A sample WordPress post",
877
+ slug: "welcome-to-wordpress",
779
878
  };
780
879
  }
781
880
 
@@ -786,7 +885,7 @@ export class DocumentationGenerator {
786
885
  for (const param of parameters) {
787
886
  properties[param.name] = {
788
887
  type: param.type,
789
- description: param.description
888
+ description: param.description,
790
889
  };
791
890
 
792
891
  if (param.allowedValues) {
@@ -803,9 +902,9 @@ export class DocumentationGenerator {
803
902
  }
804
903
 
805
904
  return {
806
- type: 'object',
905
+ type: "object",
807
906
  properties,
808
- required: required.length > 0 ? required : undefined
907
+ required: required.length > 0 ? required : undefined,
809
908
  };
810
909
  }
811
910
 
@@ -816,7 +915,7 @@ export class DocumentationGenerator {
816
915
  for (const prop of type.properties) {
817
916
  properties[prop.name] = {
818
917
  type: prop.type,
819
- description: prop.description
918
+ description: prop.description,
820
919
  };
821
920
 
822
921
  if (prop.format) {
@@ -829,75 +928,77 @@ export class DocumentationGenerator {
829
928
  }
830
929
 
831
930
  return {
832
- type: 'object',
931
+ type: "object",
833
932
  description: type.description,
834
933
  properties,
835
- required: required.length > 0 ? required : undefined
934
+ required: required.length > 0 ? required : undefined,
836
935
  };
837
936
  }
838
937
 
839
938
  private inferReturnType(toolName: string, category: string): string {
840
- if (toolName.includes('list')) return `${category}[]`;
841
- if (toolName.includes('get')) return category;
842
- if (toolName.includes('create')) return category;
843
- if (toolName.includes('update')) return category;
844
- if (toolName.includes('delete')) return 'DeleteResult';
845
- if (toolName.includes('search')) return `${category}[]`;
846
- if (toolName.includes('performance')) return 'PerformanceMetrics';
847
- if (toolName.includes('cache')) return 'CacheStats';
848
- return 'object';
939
+ if (toolName.includes("list")) return `${category}[]`;
940
+ if (toolName.includes("get")) return category;
941
+ if (toolName.includes("create")) return category;
942
+ if (toolName.includes("update")) return category;
943
+ if (toolName.includes("delete")) return "DeleteResult";
944
+ if (toolName.includes("search")) return `${category}[]`;
945
+ if (toolName.includes("performance")) return "PerformanceMetrics";
946
+ if (toolName.includes("cache")) return "CacheStats";
947
+ return "object";
849
948
  }
850
949
 
851
950
  private generateErrorDocumentation(toolName: string): ErrorDocumentation[] {
852
951
  return [
853
952
  {
854
- code: 'AUTHENTICATION_FAILED',
855
- message: 'Authentication failed',
856
- description: 'Invalid credentials or insufficient permissions',
857
- resolution: 'Check your authentication credentials and user permissions'
953
+ code: "AUTHENTICATION_FAILED",
954
+ message: "Authentication failed",
955
+ description: "Invalid credentials or insufficient permissions",
956
+ resolution:
957
+ "Check your authentication credentials and user permissions",
858
958
  },
859
959
  {
860
- code: 'VALIDATION_ERROR',
861
- message: 'Parameter validation failed',
862
- description: 'One or more required parameters are missing or invalid',
863
- resolution: 'Review the required parameters and their formats'
960
+ code: "VALIDATION_ERROR",
961
+ message: "Parameter validation failed",
962
+ description: "One or more required parameters are missing or invalid",
963
+ resolution: "Review the required parameters and their formats",
864
964
  },
865
965
  {
866
- code: 'NOT_FOUND',
867
- message: 'Resource not found',
868
- description: 'The requested resource does not exist',
869
- resolution: 'Verify the resource ID and ensure it exists'
966
+ code: "NOT_FOUND",
967
+ message: "Resource not found",
968
+ description: "The requested resource does not exist",
969
+ resolution: "Verify the resource ID and ensure it exists",
870
970
  },
871
971
  {
872
- code: 'PERMISSION_DENIED',
873
- message: 'Insufficient permissions',
874
- description: 'The user does not have permission to perform this action',
875
- resolution: 'Contact an administrator to grant the necessary permissions'
876
- }
972
+ code: "PERMISSION_DENIED",
973
+ message: "Insufficient permissions",
974
+ description: "The user does not have permission to perform this action",
975
+ resolution:
976
+ "Contact an administrator to grant the necessary permissions",
977
+ },
877
978
  ];
878
979
  }
879
980
 
880
981
  private findRelatedTools(toolName: string, category: string): string[] {
881
982
  // Find tools in the same category
882
983
  const categoryTools = this.toolCategories.get(category) || [];
883
- return categoryTools.filter(tool => tool !== toolName).slice(0, 3);
984
+ return categoryTools.filter((tool) => tool !== toolName).slice(0, 3);
884
985
  }
885
986
 
886
987
  private getRequiredPermissions(toolName: string): string[] | undefined {
887
988
  const permissions: Record<string, string[]> = {
888
- 'wp_create_post': ['publish_posts', 'edit_posts'],
889
- 'wp_update_post': ['edit_posts'],
890
- 'wp_delete_post': ['delete_posts'],
891
- 'wp_create_page': ['publish_pages', 'edit_pages'],
892
- 'wp_update_page': ['edit_pages'],
893
- 'wp_delete_page': ['delete_pages'],
894
- 'wp_upload_media': ['upload_files'],
895
- 'wp_delete_media': ['delete_files'],
896
- 'wp_create_user': ['create_users'],
897
- 'wp_update_user': ['edit_users'],
898
- 'wp_delete_user': ['delete_users'],
899
- 'wp_moderate_comment': ['moderate_comments'],
900
- 'wp_get_site_settings': ['manage_options']
989
+ wp_create_post: ["publish_posts", "edit_posts"],
990
+ wp_update_post: ["edit_posts"],
991
+ wp_delete_post: ["delete_posts"],
992
+ wp_create_page: ["publish_pages", "edit_pages"],
993
+ wp_update_page: ["edit_pages"],
994
+ wp_delete_page: ["delete_pages"],
995
+ wp_upload_media: ["upload_files"],
996
+ wp_delete_media: ["delete_files"],
997
+ wp_create_user: ["create_users"],
998
+ wp_update_user: ["edit_users"],
999
+ wp_delete_user: ["delete_users"],
1000
+ wp_moderate_comment: ["moderate_comments"],
1001
+ wp_get_site_settings: ["manage_options"],
901
1002
  };
902
1003
  return permissions[toolName];
903
1004
  }
@@ -907,46 +1008,52 @@ export class DocumentationGenerator {
907
1008
  */
908
1009
 
909
1010
  private async writeApiOverview(output: DocumentationOutput): Promise<void> {
910
- const { MarkdownFormatter } = await import('./MarkdownFormatter.js');
1011
+ const { MarkdownFormatter } = await import("./MarkdownFormatter.js");
911
1012
  const formatter = new MarkdownFormatter();
912
1013
  const content = formatter.generateApiOverview(output);
913
-
1014
+
914
1015
  await fs.promises.writeFile(
915
- path.join(this.config.outputDir, 'README.md'),
916
- content
1016
+ path.join(this.config.outputDir, "README.md"),
1017
+ content,
917
1018
  );
918
1019
  }
919
1020
 
920
1021
  private async writeToolDocumentation(tool: ToolDocumentation): Promise<void> {
921
- const { MarkdownFormatter } = await import('./MarkdownFormatter.js');
1022
+ const { MarkdownFormatter } = await import("./MarkdownFormatter.js");
922
1023
  const formatter = new MarkdownFormatter();
923
1024
  const content = formatter.generateToolDocumentation(tool);
924
-
1025
+
925
1026
  await fs.promises.writeFile(
926
- path.join(this.config.outputDir, 'tools', `${tool.name}.md`),
927
- content
1027
+ path.join(this.config.outputDir, "tools", `${tool.name}.md`),
1028
+ content,
928
1029
  );
929
1030
  }
930
1031
 
931
- private async writeCategoryDocumentation(category: CategoryDocumentation): Promise<void> {
932
- const { MarkdownFormatter } = await import('./MarkdownFormatter.js');
1032
+ private async writeCategoryDocumentation(
1033
+ category: CategoryDocumentation,
1034
+ ): Promise<void> {
1035
+ const { MarkdownFormatter } = await import("./MarkdownFormatter.js");
933
1036
  const formatter = new MarkdownFormatter();
934
1037
  const content = formatter.generateCategoryDocumentation(category);
935
-
1038
+
936
1039
  await fs.promises.writeFile(
937
- path.join(this.config.outputDir, 'categories', `${category.name.toLowerCase()}.md`),
938
- content
1040
+ path.join(
1041
+ this.config.outputDir,
1042
+ "categories",
1043
+ `${category.name.toLowerCase()}.md`,
1044
+ ),
1045
+ content,
939
1046
  );
940
1047
  }
941
1048
 
942
1049
  private async writeTypeDocumentation(type: TypeDocumentation): Promise<void> {
943
- const { MarkdownFormatter } = await import('./MarkdownFormatter.js');
1050
+ const { MarkdownFormatter } = await import("./MarkdownFormatter.js");
944
1051
  const formatter = new MarkdownFormatter();
945
1052
  const content = formatter.generateTypeDocumentation(type);
946
-
1053
+
947
1054
  await fs.promises.writeFile(
948
- path.join(this.config.outputDir, 'types', `${type.name}.md`),
949
- content
1055
+ path.join(this.config.outputDir, "types", `${type.name}.md`),
1056
+ content,
950
1057
  );
951
1058
  }
952
1059
  }