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
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Comprehensive API Documentation Auto-Generation System
|
|
3
3
|
* Extracts documentation from tool classes, types, and WordPress mappings
|
|
4
4
|
*/
|
|
5
|
-
import * as fs from
|
|
6
|
-
import * as path from
|
|
7
|
-
import * as Tools from
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
import * as Tools from "../tools/index.js";
|
|
8
8
|
/**
|
|
9
9
|
* Main Documentation Generator
|
|
10
10
|
*/
|
|
@@ -14,13 +14,13 @@ export class DocumentationGenerator {
|
|
|
14
14
|
wordpressEndpoints = new Map();
|
|
15
15
|
constructor(config = {}) {
|
|
16
16
|
this.config = {
|
|
17
|
-
outputDir:
|
|
17
|
+
outputDir: "docs/api",
|
|
18
18
|
includeExamples: true,
|
|
19
19
|
includeWordPressMapping: true,
|
|
20
20
|
generateOpenAPI: true,
|
|
21
21
|
generateInteractiveHtml: true,
|
|
22
22
|
validateExamples: false,
|
|
23
|
-
...config
|
|
23
|
+
...config,
|
|
24
24
|
};
|
|
25
25
|
this.initializeWordPressMapping();
|
|
26
26
|
this.initializeToolCategories();
|
|
@@ -29,7 +29,7 @@ export class DocumentationGenerator {
|
|
|
29
29
|
* Generate complete documentation for all tools and types
|
|
30
30
|
*/
|
|
31
31
|
async generateFullDocumentation() {
|
|
32
|
-
console.log(
|
|
32
|
+
console.log("🚀 Starting API documentation generation...");
|
|
33
33
|
const tools = await this.extractAllToolDocumentation();
|
|
34
34
|
const categories = this.generateCategoryDocumentation(tools);
|
|
35
35
|
const types = await this.extractTypeDocumentation();
|
|
@@ -43,7 +43,7 @@ export class DocumentationGenerator {
|
|
|
43
43
|
categories,
|
|
44
44
|
types,
|
|
45
45
|
openApiSpec,
|
|
46
|
-
summary
|
|
46
|
+
summary,
|
|
47
47
|
};
|
|
48
48
|
// Write documentation to files
|
|
49
49
|
await this.writeDocumentationFiles(output);
|
|
@@ -60,7 +60,7 @@ export class DocumentationGenerator {
|
|
|
60
60
|
try {
|
|
61
61
|
// Create tool instance
|
|
62
62
|
let toolInstance;
|
|
63
|
-
if (className ===
|
|
63
|
+
if (className === "CacheTools" || className === "PerformanceTools") {
|
|
64
64
|
// These tools need client map - use empty map for doc generation
|
|
65
65
|
toolInstance = new ToolClass(new Map());
|
|
66
66
|
}
|
|
@@ -100,21 +100,21 @@ export class DocumentationGenerator {
|
|
|
100
100
|
requiredPermissions: this.getRequiredPermissions(toolDef.name),
|
|
101
101
|
returnType,
|
|
102
102
|
errorCodes,
|
|
103
|
-
relatedTools
|
|
103
|
+
relatedTools,
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
107
|
* Extract parameter documentation
|
|
108
108
|
*/
|
|
109
109
|
extractParameterDocumentation(parameters) {
|
|
110
|
-
return parameters.map(param => ({
|
|
110
|
+
return parameters.map((param) => ({
|
|
111
111
|
name: param.name,
|
|
112
|
-
type: param.type ||
|
|
112
|
+
type: param.type || "string",
|
|
113
113
|
required: param.required || false,
|
|
114
114
|
description: param.description || `${param.name} parameter`,
|
|
115
115
|
defaultValue: this.getDefaultValue(param),
|
|
116
116
|
allowedValues: this.getAllowedValues(param) || undefined,
|
|
117
|
-
examples: this.generateParameterExamples(param)
|
|
117
|
+
examples: this.generateParameterExamples(param),
|
|
118
118
|
}));
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
@@ -148,8 +148,9 @@ export class DocumentationGenerator {
|
|
|
148
148
|
const toolName = toolDef.name;
|
|
149
149
|
const basicParams = {};
|
|
150
150
|
// Add essential parameters
|
|
151
|
-
const requiredParams = (toolDef.parameters || []).filter(p => p.required);
|
|
152
|
-
for (const param of requiredParams.slice(0, 2)) {
|
|
151
|
+
const requiredParams = (toolDef.parameters || []).filter((p) => p.required);
|
|
152
|
+
for (const param of requiredParams.slice(0, 2)) {
|
|
153
|
+
// Limit to 2 for basic example
|
|
153
154
|
basicParams[param.name] = this.generateExampleValue(param);
|
|
154
155
|
}
|
|
155
156
|
return {
|
|
@@ -157,43 +158,43 @@ export class DocumentationGenerator {
|
|
|
157
158
|
description: `Simple example of using ${toolName}`,
|
|
158
159
|
command: toolName,
|
|
159
160
|
parameters: basicParams,
|
|
160
|
-
expectedResponse: this.generateExpectedResponse(toolName, category,
|
|
161
|
+
expectedResponse: this.generateExpectedResponse(toolName, category, "basic"),
|
|
161
162
|
errorExample: {
|
|
162
|
-
scenario:
|
|
163
|
+
scenario: "Authentication failure",
|
|
163
164
|
error: {
|
|
164
|
-
error:
|
|
165
|
-
message:
|
|
166
|
-
}
|
|
167
|
-
}
|
|
165
|
+
error: "Authentication failed",
|
|
166
|
+
message: "Invalid credentials or insufficient permissions",
|
|
167
|
+
},
|
|
168
|
+
},
|
|
168
169
|
};
|
|
169
170
|
}
|
|
170
171
|
/**
|
|
171
172
|
* Generate multi-site example
|
|
172
173
|
*/
|
|
173
174
|
generateMultiSiteExample(toolDef, category) {
|
|
174
|
-
const params = { site:
|
|
175
|
+
const params = { site: "site1", ...this.getExampleParameters(toolDef, 1) };
|
|
175
176
|
return {
|
|
176
177
|
title: `Multi-Site ${category} Usage`,
|
|
177
178
|
description: `Using ${toolDef.name} with specific site targeting`,
|
|
178
179
|
command: toolDef.name,
|
|
179
180
|
parameters: params,
|
|
180
|
-
expectedResponse: this.generateExpectedResponse(toolDef.name, category,
|
|
181
|
+
expectedResponse: this.generateExpectedResponse(toolDef.name, category, "multisite"),
|
|
181
182
|
};
|
|
182
183
|
}
|
|
183
184
|
/**
|
|
184
185
|
* Generate advanced example with all parameters
|
|
185
186
|
*/
|
|
186
187
|
generateAdvancedExample(toolDef, category) {
|
|
187
|
-
const allParams = this.getExampleParameters(toolDef,
|
|
188
|
+
const allParams = this.getExampleParameters(toolDef, "all");
|
|
188
189
|
if (Object.keys(allParams).length <= 2) {
|
|
189
190
|
return null; // Skip if not enough parameters for advanced example
|
|
190
191
|
}
|
|
191
192
|
return {
|
|
192
193
|
title: `Advanced ${category} Configuration`,
|
|
193
|
-
description:
|
|
194
|
+
description: "Comprehensive example using all available parameters",
|
|
194
195
|
command: toolDef.name,
|
|
195
196
|
parameters: allParams,
|
|
196
|
-
expectedResponse: this.generateExpectedResponse(toolDef.name, category,
|
|
197
|
+
expectedResponse: this.generateExpectedResponse(toolDef.name, category, "advanced"),
|
|
197
198
|
};
|
|
198
199
|
}
|
|
199
200
|
/**
|
|
@@ -212,8 +213,8 @@ export class DocumentationGenerator {
|
|
|
212
213
|
name: categoryName,
|
|
213
214
|
description: this.getCategoryDescription(categoryName),
|
|
214
215
|
toolCount: categoryTools.length,
|
|
215
|
-
tools: categoryTools.map(t => t.name).sort(),
|
|
216
|
-
usagePatterns: this.generateUsagePatterns(categoryName, categoryTools)
|
|
216
|
+
tools: categoryTools.map((t) => t.name).sort(),
|
|
217
|
+
usagePatterns: this.generateUsagePatterns(categoryName, categoryTools),
|
|
217
218
|
}));
|
|
218
219
|
}
|
|
219
220
|
/**
|
|
@@ -224,17 +225,37 @@ export class DocumentationGenerator {
|
|
|
224
225
|
// For now, we'll provide key WordPress and MCP types
|
|
225
226
|
return [
|
|
226
227
|
{
|
|
227
|
-
name:
|
|
228
|
-
description:
|
|
228
|
+
name: "WordPressPost",
|
|
229
|
+
description: "WordPress blog post object",
|
|
229
230
|
properties: [
|
|
230
|
-
{
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
{
|
|
232
|
+
name: "id",
|
|
233
|
+
type: "number",
|
|
234
|
+
required: true,
|
|
235
|
+
description: "Unique identifier",
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: "title",
|
|
239
|
+
type: "string",
|
|
240
|
+
required: true,
|
|
241
|
+
description: "Post title",
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: "content",
|
|
245
|
+
type: "string",
|
|
246
|
+
required: true,
|
|
247
|
+
description: "Post content",
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "status",
|
|
251
|
+
type: "string",
|
|
252
|
+
required: true,
|
|
253
|
+
description: "Publication status",
|
|
254
|
+
},
|
|
234
255
|
],
|
|
235
256
|
examples: [this.generateWordPressPostExample()],
|
|
236
|
-
wordpressSource:
|
|
237
|
-
}
|
|
257
|
+
wordpressSource: "/wp-json/wp/v2/posts",
|
|
258
|
+
},
|
|
238
259
|
// Add more types as needed
|
|
239
260
|
];
|
|
240
261
|
}
|
|
@@ -246,7 +267,7 @@ export class DocumentationGenerator {
|
|
|
246
267
|
const components = {
|
|
247
268
|
schemas: {},
|
|
248
269
|
parameters: {},
|
|
249
|
-
responses: {}
|
|
270
|
+
responses: {},
|
|
250
271
|
};
|
|
251
272
|
// Convert tools to OpenAPI paths
|
|
252
273
|
for (const tool of tools) {
|
|
@@ -259,31 +280,31 @@ export class DocumentationGenerator {
|
|
|
259
280
|
requestBody: {
|
|
260
281
|
required: true,
|
|
261
282
|
content: {
|
|
262
|
-
|
|
263
|
-
schema: this.generateParameterSchema(tool.parameters)
|
|
264
|
-
}
|
|
265
|
-
}
|
|
283
|
+
"application/json": {
|
|
284
|
+
schema: this.generateParameterSchema(tool.parameters),
|
|
285
|
+
},
|
|
286
|
+
},
|
|
266
287
|
},
|
|
267
288
|
responses: {
|
|
268
|
-
|
|
269
|
-
description:
|
|
289
|
+
"200": {
|
|
290
|
+
description: "Successful response",
|
|
270
291
|
content: {
|
|
271
|
-
|
|
272
|
-
schema: { type:
|
|
273
|
-
}
|
|
274
|
-
}
|
|
292
|
+
"application/json": {
|
|
293
|
+
schema: { type: "object" },
|
|
294
|
+
},
|
|
295
|
+
},
|
|
275
296
|
},
|
|
276
|
-
|
|
277
|
-
description:
|
|
297
|
+
"400": {
|
|
298
|
+
description: "Bad request - invalid parameters",
|
|
278
299
|
},
|
|
279
|
-
|
|
280
|
-
description:
|
|
300
|
+
"401": {
|
|
301
|
+
description: "Authentication failed",
|
|
281
302
|
},
|
|
282
|
-
|
|
283
|
-
description:
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
303
|
+
"500": {
|
|
304
|
+
description: "Internal server error",
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
},
|
|
287
308
|
};
|
|
288
309
|
}
|
|
289
310
|
// Add type schemas to components
|
|
@@ -291,22 +312,22 @@ export class DocumentationGenerator {
|
|
|
291
312
|
components.schemas[type.name] = this.convertTypeToJsonSchema(type);
|
|
292
313
|
}
|
|
293
314
|
return {
|
|
294
|
-
openapi:
|
|
315
|
+
openapi: "3.0.3",
|
|
295
316
|
info: {
|
|
296
|
-
title:
|
|
297
|
-
description:
|
|
298
|
-
version:
|
|
317
|
+
title: "WordPress MCP Server API",
|
|
318
|
+
description: "Model Context Protocol server for WordPress management",
|
|
319
|
+
version: "1.2.0",
|
|
299
320
|
contact: {
|
|
300
|
-
name:
|
|
301
|
-
url:
|
|
321
|
+
name: "MCP WordPress",
|
|
322
|
+
url: "https://github.com/docdyhr/mcp-wordpress",
|
|
302
323
|
},
|
|
303
324
|
license: {
|
|
304
|
-
name:
|
|
305
|
-
url:
|
|
306
|
-
}
|
|
325
|
+
name: "MIT",
|
|
326
|
+
url: "https://opensource.org/licenses/MIT",
|
|
327
|
+
},
|
|
307
328
|
},
|
|
308
329
|
paths,
|
|
309
|
-
components
|
|
330
|
+
components,
|
|
310
331
|
};
|
|
311
332
|
}
|
|
312
333
|
/**
|
|
@@ -316,10 +337,14 @@ export class DocumentationGenerator {
|
|
|
316
337
|
const outputDir = this.config.outputDir;
|
|
317
338
|
// Ensure output directory exists
|
|
318
339
|
await fs.promises.mkdir(outputDir, { recursive: true });
|
|
319
|
-
await fs.promises.mkdir(path.join(outputDir,
|
|
320
|
-
await fs.promises.mkdir(path.join(outputDir,
|
|
321
|
-
await fs.promises.mkdir(path.join(outputDir,
|
|
322
|
-
|
|
340
|
+
await fs.promises.mkdir(path.join(outputDir, "tools"), { recursive: true });
|
|
341
|
+
await fs.promises.mkdir(path.join(outputDir, "types"), { recursive: true });
|
|
342
|
+
await fs.promises.mkdir(path.join(outputDir, "examples"), {
|
|
343
|
+
recursive: true,
|
|
344
|
+
});
|
|
345
|
+
await fs.promises.mkdir(path.join(outputDir, "categories"), {
|
|
346
|
+
recursive: true,
|
|
347
|
+
});
|
|
323
348
|
// Write main API documentation
|
|
324
349
|
await this.writeApiOverview(output);
|
|
325
350
|
// Write individual tool documentation
|
|
@@ -336,28 +361,42 @@ export class DocumentationGenerator {
|
|
|
336
361
|
}
|
|
337
362
|
// Write OpenAPI specification
|
|
338
363
|
if (output.openApiSpec) {
|
|
339
|
-
await fs.promises.writeFile(path.join(outputDir,
|
|
364
|
+
await fs.promises.writeFile(path.join(outputDir, "openapi.json"), JSON.stringify(output.openApiSpec, null, 2));
|
|
340
365
|
}
|
|
341
366
|
// Write summary
|
|
342
|
-
await fs.promises.writeFile(path.join(outputDir,
|
|
367
|
+
await fs.promises.writeFile(path.join(outputDir, "summary.json"), JSON.stringify(output.summary, null, 2));
|
|
343
368
|
console.log(`📁 Documentation written to ${outputDir}/`);
|
|
344
369
|
}
|
|
345
370
|
// Helper methods for specific documentation tasks...
|
|
346
371
|
extractCategoryFromClassName(className) {
|
|
347
|
-
return className.replace(
|
|
372
|
+
return className.replace("Tools", "").toLowerCase();
|
|
348
373
|
}
|
|
349
374
|
initializeWordPressMapping() {
|
|
350
375
|
// Map MCP tools to WordPress REST API endpoints
|
|
351
|
-
this.wordpressEndpoints.set(
|
|
352
|
-
this.wordpressEndpoints.set(
|
|
353
|
-
this.wordpressEndpoints.set(
|
|
354
|
-
this.wordpressEndpoints.set(
|
|
355
|
-
this.wordpressEndpoints.set(
|
|
376
|
+
this.wordpressEndpoints.set("wp_list_posts", "/wp-json/wp/v2/posts");
|
|
377
|
+
this.wordpressEndpoints.set("wp_get_post", "/wp-json/wp/v2/posts/{id}");
|
|
378
|
+
this.wordpressEndpoints.set("wp_create_post", "/wp-json/wp/v2/posts");
|
|
379
|
+
this.wordpressEndpoints.set("wp_update_post", "/wp-json/wp/v2/posts/{id}");
|
|
380
|
+
this.wordpressEndpoints.set("wp_delete_post", "/wp-json/wp/v2/posts/{id}");
|
|
356
381
|
// Add more mappings...
|
|
357
382
|
}
|
|
358
383
|
initializeToolCategories() {
|
|
359
|
-
this.toolCategories.set(
|
|
360
|
-
|
|
384
|
+
this.toolCategories.set("Posts", [
|
|
385
|
+
"wp_list_posts",
|
|
386
|
+
"wp_get_post",
|
|
387
|
+
"wp_create_post",
|
|
388
|
+
"wp_update_post",
|
|
389
|
+
"wp_delete_post",
|
|
390
|
+
"wp_search_posts",
|
|
391
|
+
]);
|
|
392
|
+
this.toolCategories.set("Pages", [
|
|
393
|
+
"wp_list_pages",
|
|
394
|
+
"wp_get_page",
|
|
395
|
+
"wp_create_page",
|
|
396
|
+
"wp_update_page",
|
|
397
|
+
"wp_delete_page",
|
|
398
|
+
"wp_search_pages",
|
|
399
|
+
]);
|
|
361
400
|
// Add more categories...
|
|
362
401
|
}
|
|
363
402
|
generateDocumentationSummary(tools, categories, types) {
|
|
@@ -366,12 +405,13 @@ export class DocumentationGenerator {
|
|
|
366
405
|
totalCategories: categories.length,
|
|
367
406
|
totalTypes: types.length,
|
|
368
407
|
lastUpdated: new Date().toISOString(),
|
|
369
|
-
version:
|
|
408
|
+
version: "1.2.0",
|
|
370
409
|
coverage: {
|
|
371
|
-
toolsWithExamples: tools.filter(t => t.examples.length > 0).length,
|
|
372
|
-
toolsWithWordPressMapping: tools.filter(t => t.wordpressEndpoint)
|
|
373
|
-
|
|
374
|
-
|
|
410
|
+
toolsWithExamples: tools.filter((t) => t.examples.length > 0).length,
|
|
411
|
+
toolsWithWordPressMapping: tools.filter((t) => t.wordpressEndpoint)
|
|
412
|
+
.length,
|
|
413
|
+
typesDocumented: types.length,
|
|
414
|
+
},
|
|
375
415
|
};
|
|
376
416
|
}
|
|
377
417
|
/**
|
|
@@ -379,145 +419,145 @@ export class DocumentationGenerator {
|
|
|
379
419
|
*/
|
|
380
420
|
getDefaultValue(param) {
|
|
381
421
|
const defaults = {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
422
|
+
per_page: 10,
|
|
423
|
+
page: 1,
|
|
424
|
+
order: "desc",
|
|
425
|
+
orderby: "date",
|
|
426
|
+
status: "publish",
|
|
427
|
+
format: "summary",
|
|
428
|
+
category: "all",
|
|
429
|
+
includeExamples: true,
|
|
430
|
+
includeTrends: true,
|
|
391
431
|
};
|
|
392
432
|
return defaults[param.name];
|
|
393
433
|
}
|
|
394
434
|
getAllowedValues(param) {
|
|
395
435
|
const allowedValues = {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
436
|
+
status: ["publish", "draft", "private", "pending", "future"],
|
|
437
|
+
order: ["asc", "desc"],
|
|
438
|
+
orderby: ["date", "title", "author", "modified"],
|
|
439
|
+
format: ["summary", "detailed", "raw"],
|
|
440
|
+
category: ["overview", "requests", "cache", "system", "tools", "all"],
|
|
441
|
+
timeframe: ["1h", "6h", "12h", "24h", "7d", "30d"],
|
|
442
|
+
priority: ["quick_wins", "medium_term", "long_term", "all"],
|
|
443
|
+
focus: ["speed", "reliability", "efficiency", "scaling"],
|
|
404
444
|
};
|
|
405
445
|
return allowedValues[param.name];
|
|
406
446
|
}
|
|
407
447
|
generateParameterExamples(param) {
|
|
408
448
|
const examples = {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
449
|
+
id: ["123", "456"],
|
|
450
|
+
title: ["My Blog Post", "Hello World"],
|
|
451
|
+
content: ["<p>Post content here</p>", "This is my post content"],
|
|
452
|
+
site: ["site1", "production", "staging"],
|
|
453
|
+
per_page: ["10", "20", "50"],
|
|
454
|
+
search: ["wordpress", "tutorial"],
|
|
455
|
+
author: ["1", "2"],
|
|
456
|
+
email: ["user@example.com", "admin@site.com"],
|
|
457
|
+
username: ["john_doe", "admin"],
|
|
458
|
+
limit: ["10", "20", "50"],
|
|
459
|
+
timeframe: ["24h", "7d", "1h"],
|
|
420
460
|
};
|
|
421
|
-
return examples[param.name] || [
|
|
461
|
+
return examples[param.name] || ["example"];
|
|
422
462
|
}
|
|
423
463
|
supportsMultiSite(toolDef) {
|
|
424
464
|
// All tools support multi-site via the site parameter
|
|
425
|
-
return toolDef.parameters?.some(p => p.name ===
|
|
465
|
+
return toolDef.parameters?.some((p) => p.name === "site") ?? true;
|
|
426
466
|
}
|
|
427
467
|
generateExampleValue(param) {
|
|
428
468
|
const exampleValues = {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
469
|
+
id: 123,
|
|
470
|
+
title: "Example Post Title",
|
|
471
|
+
content: "This is example content for the post.",
|
|
472
|
+
site: "site1",
|
|
473
|
+
per_page: 10,
|
|
474
|
+
page: 1,
|
|
475
|
+
search: "wordpress",
|
|
476
|
+
author: 1,
|
|
477
|
+
email: "user@example.com",
|
|
478
|
+
username: "john_doe",
|
|
479
|
+
status: "publish",
|
|
480
|
+
order: "desc",
|
|
481
|
+
orderby: "date",
|
|
482
|
+
limit: 20,
|
|
483
|
+
timeframe: "24h",
|
|
484
|
+
format: "summary",
|
|
485
|
+
category: "overview",
|
|
446
486
|
};
|
|
447
|
-
return exampleValues[param.name] ||
|
|
487
|
+
return exampleValues[param.name] || "example_value";
|
|
448
488
|
}
|
|
449
489
|
generateExpectedResponse(toolName, category, type) {
|
|
450
|
-
if (toolName.includes(
|
|
490
|
+
if (toolName.includes("list")) {
|
|
451
491
|
return {
|
|
452
492
|
success: true,
|
|
453
493
|
data: [
|
|
454
|
-
{ id: 1, title: `Example ${category} 1`, status:
|
|
455
|
-
{ id: 2, title: `Example ${category} 2`, status:
|
|
494
|
+
{ id: 1, title: `Example ${category} 1`, status: "publish" },
|
|
495
|
+
{ id: 2, title: `Example ${category} 2`, status: "draft" },
|
|
456
496
|
],
|
|
457
497
|
total: 2,
|
|
458
|
-
pages: 1
|
|
498
|
+
pages: 1,
|
|
459
499
|
};
|
|
460
500
|
}
|
|
461
|
-
if (toolName.includes(
|
|
501
|
+
if (toolName.includes("get")) {
|
|
462
502
|
return {
|
|
463
503
|
success: true,
|
|
464
504
|
data: {
|
|
465
505
|
id: 123,
|
|
466
506
|
title: `Example ${category}`,
|
|
467
|
-
content:
|
|
468
|
-
status:
|
|
469
|
-
date:
|
|
470
|
-
}
|
|
507
|
+
content: "Example content",
|
|
508
|
+
status: "publish",
|
|
509
|
+
date: "2024-01-01T00:00:00Z",
|
|
510
|
+
},
|
|
471
511
|
};
|
|
472
512
|
}
|
|
473
|
-
if (toolName.includes(
|
|
513
|
+
if (toolName.includes("create") || toolName.includes("update")) {
|
|
474
514
|
return {
|
|
475
515
|
success: true,
|
|
476
516
|
data: {
|
|
477
517
|
id: 123,
|
|
478
|
-
title:
|
|
479
|
-
status:
|
|
480
|
-
}
|
|
518
|
+
title: "Created/Updated successfully",
|
|
519
|
+
status: "publish",
|
|
520
|
+
},
|
|
481
521
|
};
|
|
482
522
|
}
|
|
483
|
-
if (toolName.includes(
|
|
523
|
+
if (toolName.includes("delete")) {
|
|
484
524
|
return {
|
|
485
525
|
success: true,
|
|
486
526
|
data: {
|
|
487
527
|
deleted: true,
|
|
488
|
-
id: 123
|
|
489
|
-
}
|
|
528
|
+
id: 123,
|
|
529
|
+
},
|
|
490
530
|
};
|
|
491
531
|
}
|
|
492
|
-
if (toolName.includes(
|
|
532
|
+
if (toolName.includes("performance")) {
|
|
493
533
|
return {
|
|
494
534
|
success: true,
|
|
495
535
|
data: {
|
|
496
536
|
overview: {
|
|
497
|
-
overallHealth:
|
|
537
|
+
overallHealth: "Good",
|
|
498
538
|
performanceScore: 85,
|
|
499
|
-
averageResponseTime:
|
|
500
|
-
cacheHitRate:
|
|
501
|
-
}
|
|
502
|
-
}
|
|
539
|
+
averageResponseTime: "245ms",
|
|
540
|
+
cacheHitRate: "87.5%",
|
|
541
|
+
},
|
|
542
|
+
},
|
|
503
543
|
};
|
|
504
544
|
}
|
|
505
545
|
return {
|
|
506
546
|
success: true,
|
|
507
547
|
data: {},
|
|
508
|
-
message: `${toolName} executed successfully
|
|
548
|
+
message: `${toolName} executed successfully`,
|
|
509
549
|
};
|
|
510
550
|
}
|
|
511
551
|
getExampleParameters(toolDef, type) {
|
|
512
552
|
const params = {};
|
|
513
553
|
const parameters = toolDef.parameters || [];
|
|
514
|
-
if (type ===
|
|
554
|
+
if (type === "all") {
|
|
515
555
|
// Include all parameters
|
|
516
556
|
for (const param of parameters) {
|
|
517
557
|
params[param.name] = this.generateExampleValue(param);
|
|
518
558
|
}
|
|
519
559
|
}
|
|
520
|
-
else if (typeof type ===
|
|
560
|
+
else if (typeof type === "number") {
|
|
521
561
|
// Include limited number of parameters
|
|
522
562
|
for (const param of parameters.slice(0, type)) {
|
|
523
563
|
params[param.name] = this.generateExampleValue(param);
|
|
@@ -527,65 +567,66 @@ export class DocumentationGenerator {
|
|
|
527
567
|
}
|
|
528
568
|
getCategoryDescription(categoryName) {
|
|
529
569
|
const descriptions = {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
570
|
+
posts: "Blog post creation, editing, and management tools",
|
|
571
|
+
pages: "Static page creation and management tools",
|
|
572
|
+
media: "File upload, management, and media library tools",
|
|
573
|
+
users: "User account management and authentication tools",
|
|
574
|
+
comments: "Comment moderation and management tools",
|
|
575
|
+
taxonomies: "Category and tag management tools",
|
|
576
|
+
site: "Site settings and configuration tools",
|
|
577
|
+
auth: "Authentication testing and management tools",
|
|
578
|
+
cache: "Performance caching and optimization tools",
|
|
579
|
+
performance: "Performance monitoring and analytics tools",
|
|
540
580
|
};
|
|
541
|
-
return descriptions[categoryName.toLowerCase()] ||
|
|
581
|
+
return (descriptions[categoryName.toLowerCase()] ||
|
|
582
|
+
`${categoryName} management tools`);
|
|
542
583
|
}
|
|
543
584
|
generateUsagePatterns(categoryName, tools) {
|
|
544
585
|
const patterns = {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
586
|
+
posts: [
|
|
587
|
+
"Create and publish blog posts",
|
|
588
|
+
"Bulk edit multiple posts",
|
|
589
|
+
"Search and filter posts by criteria",
|
|
590
|
+
"Schedule posts for future publication",
|
|
591
|
+
],
|
|
592
|
+
media: [
|
|
593
|
+
"Upload images and files",
|
|
594
|
+
"Organize media library",
|
|
595
|
+
"Generate thumbnails and variants",
|
|
596
|
+
"Bulk media operations",
|
|
550
597
|
],
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
598
|
+
users: [
|
|
599
|
+
"Manage user accounts and roles",
|
|
600
|
+
"User authentication and permissions",
|
|
601
|
+
"Bulk user operations",
|
|
602
|
+
"User profile management",
|
|
556
603
|
],
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
604
|
+
performance: [
|
|
605
|
+
"Monitor real-time performance metrics",
|
|
606
|
+
"Analyze historical performance trends",
|
|
607
|
+
"Generate optimization recommendations",
|
|
608
|
+
"Export performance reports",
|
|
562
609
|
],
|
|
563
|
-
'performance': [
|
|
564
|
-
'Monitor real-time performance metrics',
|
|
565
|
-
'Analyze historical performance trends',
|
|
566
|
-
'Generate optimization recommendations',
|
|
567
|
-
'Export performance reports'
|
|
568
|
-
]
|
|
569
610
|
};
|
|
570
|
-
return patterns[categoryName.toLowerCase()] || [
|
|
611
|
+
return (patterns[categoryName.toLowerCase()] || [
|
|
571
612
|
`Manage ${categoryName.toLowerCase()} efficiently`,
|
|
572
613
|
`Bulk ${categoryName.toLowerCase()} operations`,
|
|
573
|
-
`Search and filter ${categoryName.toLowerCase()}
|
|
574
|
-
];
|
|
614
|
+
`Search and filter ${categoryName.toLowerCase()}`,
|
|
615
|
+
]);
|
|
575
616
|
}
|
|
576
617
|
generateWordPressPostExample() {
|
|
577
618
|
return {
|
|
578
619
|
id: 123,
|
|
579
|
-
title:
|
|
580
|
-
content:
|
|
581
|
-
status:
|
|
582
|
-
date:
|
|
620
|
+
title: "Welcome to WordPress",
|
|
621
|
+
content: "<p>This is your first post. Edit or delete it to get started!</p>",
|
|
622
|
+
status: "publish",
|
|
623
|
+
date: "2024-01-01T00:00:00Z",
|
|
583
624
|
author: 1,
|
|
584
625
|
categories: [1],
|
|
585
626
|
tags: [1, 2],
|
|
586
627
|
featured_media: 0,
|
|
587
|
-
excerpt:
|
|
588
|
-
slug:
|
|
628
|
+
excerpt: "A sample WordPress post",
|
|
629
|
+
slug: "welcome-to-wordpress",
|
|
589
630
|
};
|
|
590
631
|
}
|
|
591
632
|
generateParameterSchema(parameters) {
|
|
@@ -594,7 +635,7 @@ export class DocumentationGenerator {
|
|
|
594
635
|
for (const param of parameters) {
|
|
595
636
|
properties[param.name] = {
|
|
596
637
|
type: param.type,
|
|
597
|
-
description: param.description
|
|
638
|
+
description: param.description,
|
|
598
639
|
};
|
|
599
640
|
if (param.allowedValues) {
|
|
600
641
|
properties[param.name].enum = param.allowedValues;
|
|
@@ -607,9 +648,9 @@ export class DocumentationGenerator {
|
|
|
607
648
|
}
|
|
608
649
|
}
|
|
609
650
|
return {
|
|
610
|
-
type:
|
|
651
|
+
type: "object",
|
|
611
652
|
properties,
|
|
612
|
-
required: required.length > 0 ? required : undefined
|
|
653
|
+
required: required.length > 0 ? required : undefined,
|
|
613
654
|
};
|
|
614
655
|
}
|
|
615
656
|
convertTypeToJsonSchema(type) {
|
|
@@ -618,7 +659,7 @@ export class DocumentationGenerator {
|
|
|
618
659
|
for (const prop of type.properties) {
|
|
619
660
|
properties[prop.name] = {
|
|
620
661
|
type: prop.type,
|
|
621
|
-
description: prop.description
|
|
662
|
+
description: prop.description,
|
|
622
663
|
};
|
|
623
664
|
if (prop.format) {
|
|
624
665
|
properties[prop.name].format = prop.format;
|
|
@@ -628,79 +669,79 @@ export class DocumentationGenerator {
|
|
|
628
669
|
}
|
|
629
670
|
}
|
|
630
671
|
return {
|
|
631
|
-
type:
|
|
672
|
+
type: "object",
|
|
632
673
|
description: type.description,
|
|
633
674
|
properties,
|
|
634
|
-
required: required.length > 0 ? required : undefined
|
|
675
|
+
required: required.length > 0 ? required : undefined,
|
|
635
676
|
};
|
|
636
677
|
}
|
|
637
678
|
inferReturnType(toolName, category) {
|
|
638
|
-
if (toolName.includes(
|
|
679
|
+
if (toolName.includes("list"))
|
|
639
680
|
return `${category}[]`;
|
|
640
|
-
if (toolName.includes(
|
|
681
|
+
if (toolName.includes("get"))
|
|
641
682
|
return category;
|
|
642
|
-
if (toolName.includes(
|
|
683
|
+
if (toolName.includes("create"))
|
|
643
684
|
return category;
|
|
644
|
-
if (toolName.includes(
|
|
685
|
+
if (toolName.includes("update"))
|
|
645
686
|
return category;
|
|
646
|
-
if (toolName.includes(
|
|
647
|
-
return
|
|
648
|
-
if (toolName.includes(
|
|
687
|
+
if (toolName.includes("delete"))
|
|
688
|
+
return "DeleteResult";
|
|
689
|
+
if (toolName.includes("search"))
|
|
649
690
|
return `${category}[]`;
|
|
650
|
-
if (toolName.includes(
|
|
651
|
-
return
|
|
652
|
-
if (toolName.includes(
|
|
653
|
-
return
|
|
654
|
-
return
|
|
691
|
+
if (toolName.includes("performance"))
|
|
692
|
+
return "PerformanceMetrics";
|
|
693
|
+
if (toolName.includes("cache"))
|
|
694
|
+
return "CacheStats";
|
|
695
|
+
return "object";
|
|
655
696
|
}
|
|
656
697
|
generateErrorDocumentation(toolName) {
|
|
657
698
|
return [
|
|
658
699
|
{
|
|
659
|
-
code:
|
|
660
|
-
message:
|
|
661
|
-
description:
|
|
662
|
-
resolution:
|
|
700
|
+
code: "AUTHENTICATION_FAILED",
|
|
701
|
+
message: "Authentication failed",
|
|
702
|
+
description: "Invalid credentials or insufficient permissions",
|
|
703
|
+
resolution: "Check your authentication credentials and user permissions",
|
|
663
704
|
},
|
|
664
705
|
{
|
|
665
|
-
code:
|
|
666
|
-
message:
|
|
667
|
-
description:
|
|
668
|
-
resolution:
|
|
706
|
+
code: "VALIDATION_ERROR",
|
|
707
|
+
message: "Parameter validation failed",
|
|
708
|
+
description: "One or more required parameters are missing or invalid",
|
|
709
|
+
resolution: "Review the required parameters and their formats",
|
|
669
710
|
},
|
|
670
711
|
{
|
|
671
|
-
code:
|
|
672
|
-
message:
|
|
673
|
-
description:
|
|
674
|
-
resolution:
|
|
712
|
+
code: "NOT_FOUND",
|
|
713
|
+
message: "Resource not found",
|
|
714
|
+
description: "The requested resource does not exist",
|
|
715
|
+
resolution: "Verify the resource ID and ensure it exists",
|
|
675
716
|
},
|
|
676
717
|
{
|
|
677
|
-
code:
|
|
678
|
-
message:
|
|
679
|
-
description:
|
|
680
|
-
resolution:
|
|
681
|
-
}
|
|
718
|
+
code: "PERMISSION_DENIED",
|
|
719
|
+
message: "Insufficient permissions",
|
|
720
|
+
description: "The user does not have permission to perform this action",
|
|
721
|
+
resolution: "Contact an administrator to grant the necessary permissions",
|
|
722
|
+
},
|
|
682
723
|
];
|
|
683
724
|
}
|
|
684
725
|
findRelatedTools(toolName, category) {
|
|
685
726
|
// Find tools in the same category
|
|
686
727
|
const categoryTools = this.toolCategories.get(category) || [];
|
|
687
|
-
return categoryTools.filter(tool => tool !== toolName).slice(0, 3);
|
|
728
|
+
return categoryTools.filter((tool) => tool !== toolName).slice(0, 3);
|
|
688
729
|
}
|
|
689
730
|
getRequiredPermissions(toolName) {
|
|
690
731
|
const permissions = {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
732
|
+
wp_create_post: ["publish_posts", "edit_posts"],
|
|
733
|
+
wp_update_post: ["edit_posts"],
|
|
734
|
+
wp_delete_post: ["delete_posts"],
|
|
735
|
+
wp_create_page: ["publish_pages", "edit_pages"],
|
|
736
|
+
wp_update_page: ["edit_pages"],
|
|
737
|
+
wp_delete_page: ["delete_pages"],
|
|
738
|
+
wp_upload_media: ["upload_files"],
|
|
739
|
+
wp_delete_media: ["delete_files"],
|
|
740
|
+
wp_create_user: ["create_users"],
|
|
741
|
+
wp_update_user: ["edit_users"],
|
|
742
|
+
wp_delete_user: ["delete_users"],
|
|
743
|
+
wp_moderate_comment: ["moderate_comments"],
|
|
744
|
+
wp_get_site_settings: ["manage_options"],
|
|
704
745
|
};
|
|
705
746
|
return permissions[toolName];
|
|
706
747
|
}
|
|
@@ -708,28 +749,28 @@ export class DocumentationGenerator {
|
|
|
708
749
|
* File writing implementations
|
|
709
750
|
*/
|
|
710
751
|
async writeApiOverview(output) {
|
|
711
|
-
const { MarkdownFormatter } = await import(
|
|
752
|
+
const { MarkdownFormatter } = await import("./MarkdownFormatter.js");
|
|
712
753
|
const formatter = new MarkdownFormatter();
|
|
713
754
|
const content = formatter.generateApiOverview(output);
|
|
714
|
-
await fs.promises.writeFile(path.join(this.config.outputDir,
|
|
755
|
+
await fs.promises.writeFile(path.join(this.config.outputDir, "README.md"), content);
|
|
715
756
|
}
|
|
716
757
|
async writeToolDocumentation(tool) {
|
|
717
|
-
const { MarkdownFormatter } = await import(
|
|
758
|
+
const { MarkdownFormatter } = await import("./MarkdownFormatter.js");
|
|
718
759
|
const formatter = new MarkdownFormatter();
|
|
719
760
|
const content = formatter.generateToolDocumentation(tool);
|
|
720
|
-
await fs.promises.writeFile(path.join(this.config.outputDir,
|
|
761
|
+
await fs.promises.writeFile(path.join(this.config.outputDir, "tools", `${tool.name}.md`), content);
|
|
721
762
|
}
|
|
722
763
|
async writeCategoryDocumentation(category) {
|
|
723
|
-
const { MarkdownFormatter } = await import(
|
|
764
|
+
const { MarkdownFormatter } = await import("./MarkdownFormatter.js");
|
|
724
765
|
const formatter = new MarkdownFormatter();
|
|
725
766
|
const content = formatter.generateCategoryDocumentation(category);
|
|
726
|
-
await fs.promises.writeFile(path.join(this.config.outputDir,
|
|
767
|
+
await fs.promises.writeFile(path.join(this.config.outputDir, "categories", `${category.name.toLowerCase()}.md`), content);
|
|
727
768
|
}
|
|
728
769
|
async writeTypeDocumentation(type) {
|
|
729
|
-
const { MarkdownFormatter } = await import(
|
|
770
|
+
const { MarkdownFormatter } = await import("./MarkdownFormatter.js");
|
|
730
771
|
const formatter = new MarkdownFormatter();
|
|
731
772
|
const content = formatter.generateTypeDocumentation(type);
|
|
732
|
-
await fs.promises.writeFile(path.join(this.config.outputDir,
|
|
773
|
+
await fs.promises.writeFile(path.join(this.config.outputDir, "types", `${type.name}.md`), content);
|
|
733
774
|
}
|
|
734
775
|
}
|
|
735
776
|
//# sourceMappingURL=DocumentationGenerator.js.map
|