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.
- package/README.md +210 -182
- package/dist/cache/CacheInvalidation.d.ts +3 -3
- package/dist/cache/CacheInvalidation.d.ts.map +1 -1
- package/dist/cache/CacheInvalidation.js +119 -119
- package/dist/cache/CacheInvalidation.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +5 -0
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +26 -16
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
- package/dist/cache/HttpCacheWrapper.js +29 -29
- package/dist/cache/HttpCacheWrapper.js.map +1 -1
- package/dist/cache/__tests__/CacheInvalidation.test.js +96 -94
- package/dist/cache/__tests__/CacheInvalidation.test.js.map +1 -1
- package/dist/cache/__tests__/CacheManager.test.js +113 -113
- package/dist/cache/__tests__/CacheManager.test.js.map +1 -1
- package/dist/cache/__tests__/CachedWordPressClient.test.js +102 -99
- package/dist/cache/__tests__/CachedWordPressClient.test.js.map +1 -1
- package/dist/cache/__tests__/HttpCacheWrapper.test.js +98 -95
- package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +1 -1
- package/dist/cache/index.d.ts +7 -7
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +4 -4
- package/dist/cache/index.js.map +1 -1
- package/dist/client/CachedWordPressClient.d.ts +4 -4
- package/dist/client/CachedWordPressClient.d.ts.map +1 -1
- package/dist/client/CachedWordPressClient.js +55 -51
- package/dist/client/CachedWordPressClient.js.map +1 -1
- package/dist/client/api.d.ts +10 -10
- package/dist/client/api.js +158 -158
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts +2 -2
- package/dist/client/auth.js +72 -72
- package/dist/client/managers/AuthenticationManager.d.ts +2 -2
- package/dist/client/managers/AuthenticationManager.js +46 -46
- package/dist/client/managers/BaseManager.d.ts +1 -1
- package/dist/client/managers/BaseManager.js +9 -9
- package/dist/client/managers/RequestManager.d.ts +5 -3
- package/dist/client/managers/RequestManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.js +39 -19
- package/dist/client/managers/RequestManager.js.map +1 -1
- package/dist/client/managers/index.d.ts +3 -3
- package/dist/client/managers/index.js +3 -3
- package/dist/config/ConfigurationSchema.d.ts +2 -2
- package/dist/config/ConfigurationSchema.d.ts.map +1 -1
- package/dist/config/ConfigurationSchema.js +40 -40
- package/dist/config/ConfigurationSchema.js.map +1 -1
- package/dist/config/ServerConfiguration.d.ts +2 -2
- package/dist/config/ServerConfiguration.js +35 -35
- package/dist/config/ServerConfiguration.js.map +1 -1
- package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
- package/dist/docs/DocumentationGenerator.js +296 -255
- package/dist/docs/DocumentationGenerator.js.map +1 -1
- package/dist/docs/MarkdownFormatter.d.ts +1 -1
- package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
- package/dist/docs/MarkdownFormatter.js +60 -51
- package/dist/docs/MarkdownFormatter.js.map +1 -1
- package/dist/docs/index.d.ts +3 -3
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/mcp-wordpress-1.3.0.tgz +0 -0
- package/dist/performance/MetricsCollector.d.ts +3 -3
- package/dist/performance/MetricsCollector.d.ts.map +1 -1
- package/dist/performance/MetricsCollector.js +33 -27
- package/dist/performance/MetricsCollector.js.map +1 -1
- package/dist/performance/PerformanceAnalytics.d.ts +12 -12
- package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
- package/dist/performance/PerformanceAnalytics.js +200 -154
- package/dist/performance/PerformanceAnalytics.js.map +1 -1
- package/dist/performance/PerformanceMonitor.d.ts +5 -5
- package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
- package/dist/performance/PerformanceMonitor.js +53 -52
- package/dist/performance/PerformanceMonitor.js.map +1 -1
- package/dist/performance/index.d.ts +6 -6
- package/dist/performance/index.d.ts.map +1 -1
- package/dist/performance/index.js +3 -3
- package/dist/security/InputValidator.d.ts +1 -1
- package/dist/security/InputValidator.d.ts.map +1 -1
- package/dist/security/InputValidator.js +111 -88
- package/dist/security/InputValidator.js.map +1 -1
- package/dist/security/SecurityConfig.d.ts +5 -5
- package/dist/security/SecurityConfig.js +92 -92
- package/dist/security/SecurityConfig.js.map +1 -1
- package/dist/server/ConnectionTester.d.ts +1 -1
- package/dist/server/ConnectionTester.d.ts.map +1 -1
- package/dist/server/ConnectionTester.js +4 -4
- package/dist/server/ConnectionTester.js.map +1 -1
- package/dist/server/ToolRegistry.d.ts +2 -2
- package/dist/server/ToolRegistry.d.ts.map +1 -1
- package/dist/server/ToolRegistry.js +35 -32
- package/dist/server/ToolRegistry.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/tools/BaseToolManager.js +5 -5
- package/dist/tools/auth.d.ts +2 -2
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +32 -31
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/cache.d.ts +1 -1
- package/dist/tools/cache.d.ts.map +1 -1
- package/dist/tools/cache.js +71 -71
- package/dist/tools/cache.js.map +1 -1
- package/dist/tools/comments.d.ts +2 -2
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +79 -79
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/index.d.ts +10 -10
- package/dist/tools/index.js +10 -10
- package/dist/tools/media.d.ts +2 -2
- package/dist/tools/media.js +80 -80
- package/dist/tools/pages.d.ts +2 -2
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +75 -75
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/performance.d.ts +1 -1
- package/dist/tools/performance.d.ts.map +1 -1
- package/dist/tools/performance.js +311 -287
- package/dist/tools/performance.js.map +1 -1
- package/dist/tools/posts.d.ts +2 -2
- package/dist/tools/posts.d.ts.map +1 -1
- package/dist/tools/posts.js +94 -94
- package/dist/tools/posts.js.map +1 -1
- package/dist/tools/site.d.ts +2 -2
- package/dist/tools/site.d.ts.map +1 -1
- package/dist/tools/site.js +60 -60
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts +2 -2
- package/dist/tools/taxonomies.js +89 -89
- package/dist/tools/users.d.ts +2 -2
- package/dist/tools/users.js +68 -68
- package/dist/tools/users.js.map +1 -1
- package/dist/types/client.d.ts +13 -13
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client.js +12 -12
- package/dist/types/client.js.map +1 -1
- package/dist/types/index.d.ts +19 -19
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -3
- package/dist/types/mcp.d.ts +7 -7
- package/dist/types/wordpress.d.ts +21 -21
- package/dist/types/wordpress.d.ts.map +1 -1
- package/dist/utils/debug.d.ts +2 -2
- package/dist/utils/debug.js +28 -28
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +13 -13
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts.map +1 -1
- package/dist/utils/toolWrapper.js +5 -5
- package/dist/utils/toolWrapper.js.map +1 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +41 -31
- package/dist/utils/validation.js.map +1 -1
- package/docs/CACHING.md +36 -2
- package/docs/DOCKER.md +24 -18
- package/docs/PERFORMANCE_MONITORING.md +49 -1
- package/docs/SECURITY_TESTING.md +30 -1
- package/docs/api/README.md +9 -1
- package/docs/api/summary.json +1 -1
- package/docs/contract-testing.md +24 -3
- package/docs/developer/GITHUB_ACTIONS_SETUP.md +8 -2
- package/docs/developer/MAINTENANCE.md +29 -3
- package/docs/developer/MIGRATION_GUIDE.md +13 -1
- package/docs/developer/NPM_AUTH_SETUP.md +13 -2
- package/docs/developer/REFACTORING.md +31 -1
- package/docs/releases/COMMUNITY_ANNOUNCEMENT_v1.1.2.md +18 -7
- package/docs/releases/RELEASE_NOTES_v1.1.2.md +31 -5
- package/docs/user-guides/DOCKER_SETUP.md +264 -0
- package/docs/user-guides/DTX_SETUP.md +327 -0
- package/docs/user-guides/NPM_SETUP.md +109 -0
- package/docs/user-guides/NPX_SETUP.md +281 -0
- package/docs/wordpress-rest-api-authentication-troubleshooting.md +13 -2
- package/package.json +27 -8
- package/src/cache/CacheInvalidation.ts +140 -132
- package/src/cache/CacheManager.ts +40 -29
- package/src/cache/HttpCacheWrapper.ts +105 -68
- package/src/cache/__tests__/CacheInvalidation.test.ts +123 -118
- package/src/cache/__tests__/CacheManager.test.ts +156 -152
- package/src/cache/__tests__/CachedWordPressClient.test.ts +131 -116
- package/src/cache/__tests__/HttpCacheWrapper.test.ts +118 -115
- package/src/cache/index.ts +13 -13
- package/src/client/CachedWordPressClient.ts +90 -80
- package/src/client/api.ts +205 -205
- package/src/client/auth.ts +80 -80
- package/src/client/managers/AuthenticationManager.ts +61 -61
- package/src/client/managers/BaseManager.ts +11 -11
- package/src/client/managers/RequestManager.ts +79 -47
- package/src/client/managers/index.ts +3 -3
- package/src/config/ConfigurationSchema.ts +44 -44
- package/src/config/ServerConfiguration.ts +39 -39
- package/src/docs/DocumentationGenerator.ts +402 -295
- package/src/docs/MarkdownFormatter.ts +94 -69
- package/src/docs/index.ts +4 -4
- package/src/index.ts +24 -21
- package/src/performance/MetricsCollector.ts +90 -58
- package/src/performance/PerformanceAnalytics.ts +386 -262
- package/src/performance/PerformanceMonitor.ts +152 -118
- package/src/performance/index.ts +9 -9
- package/src/security/InputValidator.ts +148 -91
- package/src/security/SecurityConfig.ts +94 -94
- package/src/server/ConnectionTester.ts +21 -15
- package/src/server/ToolRegistry.ts +64 -51
- package/src/server.ts +2 -2
- package/src/tools/BaseToolManager.ts +6 -6
- package/src/tools/auth.ts +42 -37
- package/src/tools/cache.ts +85 -81
- package/src/tools/comments.ts +93 -91
- package/src/tools/index.ts +10 -10
- package/src/tools/media.ts +89 -89
- package/src/tools/pages.ts +89 -87
- package/src/tools/performance.ts +443 -352
- package/src/tools/posts.ts +109 -107
- package/src/tools/site.ts +86 -77
- package/src/tools/taxonomies.ts +102 -102
- package/src/tools/users.ts +77 -77
- package/src/types/client.ts +157 -60
- package/src/types/index.ts +49 -27
- package/src/types/mcp.ts +15 -15
- package/src/types/wordpress.ts +57 -29
- package/src/utils/debug.ts +37 -37
- package/src/utils/error.ts +47 -25
- package/src/utils/toolWrapper.ts +12 -8
- package/src/utils/validation.ts +116 -65
- package/dist/client/WordPressClient.d.ts +0 -81
- package/dist/client/WordPressClient.d.ts.map +0 -1
- package/dist/client/WordPressClient.js +0 -354
- package/dist/client/WordPressClient.js.map +0 -1
- package/dist/performance/AnomalyDetector.d.ts +0 -63
- package/dist/performance/AnomalyDetector.d.ts.map +0 -1
- package/dist/performance/AnomalyDetector.js +0 -222
- package/dist/performance/AnomalyDetector.js.map +0 -1
- package/dist/performance/BenchmarkAnalyzer.d.ts +0 -67
- package/dist/performance/BenchmarkAnalyzer.d.ts.map +0 -1
- package/dist/performance/BenchmarkAnalyzer.js +0 -301
- package/dist/performance/BenchmarkAnalyzer.js.map +0 -1
- package/dist/performance/TrendAnalyzer.d.ts +0 -69
- package/dist/performance/TrendAnalyzer.d.ts.map +0 -1
- package/dist/performance/TrendAnalyzer.js +0 -203
- package/dist/performance/TrendAnalyzer.js.map +0 -1
- package/dist/tools/BaseToolClass.d.ts +0 -76
- package/dist/tools/BaseToolClass.d.ts.map +0 -1
- package/dist/tools/BaseToolClass.js +0 -104
- package/dist/tools/BaseToolClass.js.map +0 -1
- package/dist/tools/base.d.ts +0 -37
- package/dist/tools/base.d.ts.map +0 -1
- package/dist/tools/base.js +0 -60
- package/dist/tools/base.js.map +0 -1
- 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
|
|
7
|
-
import * as path from
|
|
8
|
-
import * as Tools from
|
|
9
|
-
import type { ToolDefinition } from
|
|
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:
|
|
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(
|
|
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(
|
|
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 ===
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
235
|
-
|
|
245
|
+
private extractParameterDocumentation(
|
|
246
|
+
parameters: any[],
|
|
247
|
+
): ParameterDocumentation[] {
|
|
248
|
+
return parameters.map((param) => ({
|
|
236
249
|
name: param.name,
|
|
237
|
-
type: param.type ||
|
|
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(
|
|
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(
|
|
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)) {
|
|
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(
|
|
313
|
+
expectedResponse: this.generateExpectedResponse(
|
|
314
|
+
toolName,
|
|
315
|
+
category,
|
|
316
|
+
"basic",
|
|
317
|
+
),
|
|
294
318
|
errorExample: {
|
|
295
|
-
scenario:
|
|
319
|
+
scenario: "Authentication failure",
|
|
296
320
|
error: {
|
|
297
|
-
error:
|
|
298
|
-
message:
|
|
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(
|
|
308
|
-
|
|
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(
|
|
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(
|
|
323
|
-
|
|
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:
|
|
365
|
+
description: "Comprehensive example using all available parameters",
|
|
332
366
|
command: toolDef.name,
|
|
333
367
|
parameters: allParams,
|
|
334
|
-
expectedResponse: this.generateExpectedResponse(
|
|
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(
|
|
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(
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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:
|
|
370
|
-
description:
|
|
411
|
+
name: "WordPressPost",
|
|
412
|
+
description: "WordPress blog post object",
|
|
371
413
|
properties: [
|
|
372
|
-
{
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
416
|
-
description:
|
|
477
|
+
"200": {
|
|
478
|
+
description: "Successful response",
|
|
417
479
|
content: {
|
|
418
|
-
|
|
419
|
-
schema: { type:
|
|
420
|
-
}
|
|
421
|
-
}
|
|
480
|
+
"application/json": {
|
|
481
|
+
schema: { type: "object" },
|
|
482
|
+
},
|
|
483
|
+
},
|
|
422
484
|
},
|
|
423
|
-
|
|
424
|
-
description:
|
|
485
|
+
"400": {
|
|
486
|
+
description: "Bad request - invalid parameters",
|
|
425
487
|
},
|
|
426
|
-
|
|
427
|
-
description:
|
|
488
|
+
"401": {
|
|
489
|
+
description: "Authentication failed",
|
|
428
490
|
},
|
|
429
|
-
|
|
430
|
-
description:
|
|
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:
|
|
505
|
+
openapi: "3.0.3",
|
|
444
506
|
info: {
|
|
445
|
-
title:
|
|
446
|
-
description:
|
|
447
|
-
version:
|
|
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:
|
|
450
|
-
url:
|
|
511
|
+
name: "MCP WordPress",
|
|
512
|
+
url: "https://github.com/docdyhr/mcp-wordpress",
|
|
451
513
|
},
|
|
452
514
|
license: {
|
|
453
|
-
name:
|
|
454
|
-
url:
|
|
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(
|
|
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,
|
|
471
|
-
await fs.promises.mkdir(path.join(outputDir,
|
|
472
|
-
await fs.promises.mkdir(path.join(outputDir,
|
|
473
|
-
|
|
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,
|
|
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,
|
|
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(
|
|
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(
|
|
519
|
-
this.wordpressEndpoints.set(
|
|
520
|
-
this.wordpressEndpoints.set(
|
|
521
|
-
this.wordpressEndpoints.set(
|
|
522
|
-
this.wordpressEndpoints.set(
|
|
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(
|
|
528
|
-
|
|
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:
|
|
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)
|
|
546
|
-
|
|
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
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
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
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
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] || [
|
|
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 ===
|
|
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
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
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] ||
|
|
709
|
+
return exampleValues[param.name] || "example_value";
|
|
627
710
|
}
|
|
628
711
|
|
|
629
|
-
private generateExpectedResponse(
|
|
630
|
-
|
|
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:
|
|
635
|
-
{ id: 2, title: `Example ${category} 2`, status:
|
|
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(
|
|
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:
|
|
649
|
-
status:
|
|
650
|
-
date:
|
|
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(
|
|
742
|
+
if (toolName.includes("create") || toolName.includes("update")) {
|
|
656
743
|
return {
|
|
657
744
|
success: true,
|
|
658
745
|
data: {
|
|
659
746
|
id: 123,
|
|
660
|
-
title:
|
|
661
|
-
status:
|
|
662
|
-
}
|
|
747
|
+
title: "Created/Updated successfully",
|
|
748
|
+
status: "publish",
|
|
749
|
+
},
|
|
663
750
|
};
|
|
664
751
|
}
|
|
665
752
|
|
|
666
|
-
if (toolName.includes(
|
|
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(
|
|
763
|
+
if (toolName.includes("performance")) {
|
|
677
764
|
return {
|
|
678
765
|
success: true,
|
|
679
766
|
data: {
|
|
680
767
|
overview: {
|
|
681
|
-
overallHealth:
|
|
768
|
+
overallHealth: "Good",
|
|
682
769
|
performanceScore: 85,
|
|
683
|
-
averageResponseTime:
|
|
684
|
-
cacheHitRate:
|
|
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(
|
|
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 ===
|
|
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 ===
|
|
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
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
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
|
|
819
|
+
return (
|
|
820
|
+
descriptions[categoryName.toLowerCase()] ||
|
|
821
|
+
`${categoryName} management tools`
|
|
822
|
+
);
|
|
730
823
|
}
|
|
731
824
|
|
|
732
|
-
private generateUsagePatterns(
|
|
825
|
+
private generateUsagePatterns(
|
|
826
|
+
categoryName: string,
|
|
827
|
+
tools: ToolDocumentation[],
|
|
828
|
+
): string[] {
|
|
733
829
|
const patterns: Record<string, string[]> = {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
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
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
836
|
+
media: [
|
|
837
|
+
"Upload images and files",
|
|
838
|
+
"Organize media library",
|
|
839
|
+
"Generate thumbnails and variants",
|
|
840
|
+
"Bulk media operations",
|
|
745
841
|
],
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
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
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
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:
|
|
770
|
-
content:
|
|
771
|
-
|
|
772
|
-
|
|
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:
|
|
778
|
-
slug:
|
|
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:
|
|
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:
|
|
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(
|
|
841
|
-
if (toolName.includes(
|
|
842
|
-
if (toolName.includes(
|
|
843
|
-
if (toolName.includes(
|
|
844
|
-
if (toolName.includes(
|
|
845
|
-
if (toolName.includes(
|
|
846
|
-
if (toolName.includes(
|
|
847
|
-
if (toolName.includes(
|
|
848
|
-
return
|
|
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:
|
|
855
|
-
message:
|
|
856
|
-
description:
|
|
857
|
-
resolution:
|
|
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:
|
|
861
|
-
message:
|
|
862
|
-
description:
|
|
863
|
-
resolution:
|
|
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:
|
|
867
|
-
message:
|
|
868
|
-
description:
|
|
869
|
-
resolution:
|
|
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:
|
|
873
|
-
message:
|
|
874
|
-
description:
|
|
875
|
-
resolution:
|
|
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
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
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(
|
|
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,
|
|
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(
|
|
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,
|
|
927
|
-
content
|
|
1027
|
+
path.join(this.config.outputDir, "tools", `${tool.name}.md`),
|
|
1028
|
+
content,
|
|
928
1029
|
);
|
|
929
1030
|
}
|
|
930
1031
|
|
|
931
|
-
private async writeCategoryDocumentation(
|
|
932
|
-
|
|
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(
|
|
938
|
-
|
|
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(
|
|
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,
|
|
949
|
-
content
|
|
1055
|
+
path.join(this.config.outputDir, "types", `${type.name}.md`),
|
|
1056
|
+
content,
|
|
950
1057
|
);
|
|
951
1058
|
}
|
|
952
1059
|
}
|