mcp-wordpress 2.6.3 → 2.7.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 +1 -1
- package/dist/cache/CacheInvalidation.d.ts +25 -6
- package/dist/cache/CacheInvalidation.d.ts.map +1 -1
- package/dist/cache/CacheInvalidation.js +168 -16
- package/dist/cache/CacheInvalidation.js.map +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
- package/dist/cache/HttpCacheWrapper.js +3 -4
- package/dist/cache/HttpCacheWrapper.js.map +1 -1
- package/dist/cache/SEOCacheManager.d.ts +150 -0
- package/dist/cache/SEOCacheManager.d.ts.map +1 -0
- package/dist/cache/SEOCacheManager.js +275 -0
- package/dist/cache/SEOCacheManager.js.map +1 -0
- package/dist/client/SEOWordPressClient.d.ts +164 -0
- package/dist/client/SEOWordPressClient.d.ts.map +1 -0
- package/dist/client/SEOWordPressClient.js +674 -0
- package/dist/client/SEOWordPressClient.js.map +1 -0
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +50 -20
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.js +19 -19
- package/dist/client/auth.js.map +1 -1
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +14 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/managers/AuthManager.d.ts +39 -0
- package/dist/client/managers/AuthManager.d.ts.map +1 -0
- package/dist/client/managers/AuthManager.js +142 -0
- package/dist/client/managers/AuthManager.js.map +1 -0
- package/dist/client/managers/AuthenticationManager.d.ts.map +1 -1
- package/dist/client/managers/AuthenticationManager.js +10 -9
- package/dist/client/managers/AuthenticationManager.js.map +1 -1
- package/dist/client/managers/BaseManager.d.ts.map +1 -1
- package/dist/client/managers/BaseManager.js +12 -0
- package/dist/client/managers/BaseManager.js.map +1 -1
- package/dist/client/managers/ComposedAuthenticationManager.d.ts +94 -0
- package/dist/client/managers/ComposedAuthenticationManager.d.ts.map +1 -0
- package/dist/client/managers/ComposedAuthenticationManager.js +340 -0
- package/dist/client/managers/ComposedAuthenticationManager.js.map +1 -0
- package/dist/client/managers/ComposedManagerFactory.d.ts +104 -0
- package/dist/client/managers/ComposedManagerFactory.d.ts.map +1 -0
- package/dist/client/managers/ComposedManagerFactory.js +180 -0
- package/dist/client/managers/ComposedManagerFactory.js.map +1 -0
- package/dist/client/managers/ComposedRequestManager.d.ts +82 -0
- package/dist/client/managers/ComposedRequestManager.d.ts.map +1 -0
- package/dist/client/managers/ComposedRequestManager.js +260 -0
- package/dist/client/managers/ComposedRequestManager.js.map +1 -0
- package/dist/client/managers/JWTAuthImplementation.d.ts +86 -0
- package/dist/client/managers/JWTAuthImplementation.d.ts.map +1 -0
- package/dist/client/managers/JWTAuthImplementation.js +240 -0
- package/dist/client/managers/JWTAuthImplementation.js.map +1 -0
- package/dist/client/managers/ManagersIndex.d.ts +6 -0
- package/dist/client/managers/ManagersIndex.d.ts.map +1 -0
- package/dist/client/managers/ManagersIndex.js +6 -0
- package/dist/client/managers/ManagersIndex.js.map +1 -0
- package/dist/client/managers/RequestManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.js +5 -3
- package/dist/client/managers/RequestManager.js.map +1 -1
- package/dist/client/managers/composed/MigrationAdapter.d.ts +80 -0
- package/dist/client/managers/composed/MigrationAdapter.d.ts.map +1 -0
- package/dist/client/managers/composed/MigrationAdapter.js +214 -0
- package/dist/client/managers/composed/MigrationAdapter.js.map +1 -0
- package/dist/client/managers/composed/index.d.ts +23 -0
- package/dist/client/managers/composed/index.d.ts.map +1 -0
- package/dist/client/managers/composed/index.js +26 -0
- package/dist/client/managers/composed/index.js.map +1 -0
- package/dist/client/managers/implementations/ConfigurationProviderImpl.d.ts +27 -0
- package/dist/client/managers/implementations/ConfigurationProviderImpl.d.ts.map +1 -0
- package/dist/client/managers/implementations/ConfigurationProviderImpl.js +41 -0
- package/dist/client/managers/implementations/ConfigurationProviderImpl.js.map +1 -0
- package/dist/client/managers/implementations/ErrorHandlerImpl.d.ts +31 -0
- package/dist/client/managers/implementations/ErrorHandlerImpl.d.ts.map +1 -0
- package/dist/client/managers/implementations/ErrorHandlerImpl.js +73 -0
- package/dist/client/managers/implementations/ErrorHandlerImpl.js.map +1 -0
- package/dist/client/managers/implementations/ParameterValidatorImpl.d.ts +47 -0
- package/dist/client/managers/implementations/ParameterValidatorImpl.d.ts.map +1 -0
- package/dist/client/managers/implementations/ParameterValidatorImpl.js +141 -0
- package/dist/client/managers/implementations/ParameterValidatorImpl.js.map +1 -0
- package/dist/client/managers/interfaces/ManagerInterfaces.d.ts +147 -0
- package/dist/client/managers/interfaces/ManagerInterfaces.d.ts.map +1 -0
- package/dist/client/managers/interfaces/ManagerInterfaces.js +6 -0
- package/dist/client/managers/interfaces/ManagerInterfaces.js.map +1 -0
- package/dist/config/Config.d.ts +30 -0
- package/dist/config/Config.d.ts.map +1 -1
- package/dist/config/Config.js +30 -0
- package/dist/config/Config.js.map +1 -1
- package/dist/config/ConfigurationSchema.d.ts +75 -198
- package/dist/config/ConfigurationSchema.d.ts.map +1 -1
- package/dist/config/ConfigurationSchema.js +17 -17
- package/dist/config/ConfigurationSchema.js.map +1 -1
- package/dist/config/ServerConfiguration.d.ts +2 -2
- package/dist/config/ServerConfiguration.d.ts.map +1 -1
- package/dist/config/ServerConfiguration.js +15 -13
- package/dist/config/ServerConfiguration.js.map +1 -1
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +11 -0
- package/dist/config/index.js.map +1 -0
- package/dist/docs/DocumentationGenerator.js +2 -2
- package/dist/docs/DocumentationGenerator.js.map +1 -1
- package/dist/dxt-entry.js +3 -3
- package/dist/dxt-entry.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -37
- package/dist/index.js.map +1 -1
- package/dist/performance/MetricsCollector.d.ts.map +1 -1
- package/dist/performance/MetricsCollector.js +5 -4
- package/dist/performance/MetricsCollector.js.map +1 -1
- package/dist/security/AISecurityScanner.js +7 -7
- package/dist/security/AISecurityScanner.js.map +1 -1
- package/dist/security/AutomatedRemediation.d.ts.map +1 -1
- package/dist/security/AutomatedRemediation.js +11 -11
- package/dist/security/AutomatedRemediation.js.map +1 -1
- package/dist/security/InputValidator.d.ts +50 -126
- package/dist/security/InputValidator.d.ts.map +1 -1
- package/dist/security/InputValidator.js +9 -9
- package/dist/security/InputValidator.js.map +1 -1
- package/dist/security/SecurityCIPipeline.d.ts +47 -5
- package/dist/security/SecurityCIPipeline.d.ts.map +1 -1
- package/dist/security/SecurityCIPipeline.js +390 -49
- package/dist/security/SecurityCIPipeline.js.map +1 -1
- package/dist/security/SecurityConfigManager.js +10 -10
- package/dist/security/SecurityConfigManager.js.map +1 -1
- package/dist/security/SecurityMonitoring.js +4 -4
- package/dist/security/SecurityMonitoring.js.map +1 -1
- package/dist/security/SecurityReviewer.d.ts.map +1 -1
- package/dist/security/SecurityReviewer.js +13 -6
- package/dist/security/SecurityReviewer.js.map +1 -1
- package/dist/security/index.js +3 -3
- package/dist/security/index.js.map +1 -1
- package/dist/server/ConnectionTester.js +5 -5
- 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 +7 -6
- package/dist/server/ToolRegistry.js.map +1 -1
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +9 -0
- package/dist/server/index.js.map +1 -0
- package/dist/tools/BaseToolManager.d.ts.map +1 -1
- package/dist/tools/BaseToolManager.js +11 -11
- package/dist/tools/BaseToolManager.js.map +1 -1
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +7 -7
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +14 -14
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js +14 -11
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +12 -12
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/performance.d.ts.map +1 -1
- package/dist/tools/performance.js +13 -11
- package/dist/tools/performance.js.map +1 -1
- package/dist/tools/posts/PostHandlers.d.ts.map +1 -1
- package/dist/tools/posts/PostHandlers.js +16 -16
- package/dist/tools/posts/PostHandlers.js.map +1 -1
- package/dist/tools/posts/PostToolDefinitions.d.ts.map +1 -1
- package/dist/tools/posts/index.d.ts.map +1 -1
- package/dist/tools/seo/BulkOperations.d.ts +113 -0
- package/dist/tools/seo/BulkOperations.d.ts.map +1 -0
- package/dist/tools/seo/BulkOperations.js +398 -0
- package/dist/tools/seo/BulkOperations.js.map +1 -0
- package/dist/tools/seo/SEOHandlers.d.ts +55 -0
- package/dist/tools/seo/SEOHandlers.d.ts.map +1 -0
- package/dist/tools/seo/SEOHandlers.js +255 -0
- package/dist/tools/seo/SEOHandlers.js.map +1 -0
- package/dist/tools/seo/SEOToolDefinitions.d.ts +59 -0
- package/dist/tools/seo/SEOToolDefinitions.d.ts.map +1 -0
- package/dist/tools/seo/SEOToolDefinitions.js +385 -0
- package/dist/tools/seo/SEOToolDefinitions.js.map +1 -0
- package/dist/tools/seo/SEOTools.d.ts +203 -0
- package/dist/tools/seo/SEOTools.d.ts.map +1 -0
- package/dist/tools/seo/SEOTools.js +708 -0
- package/dist/tools/seo/SEOTools.js.map +1 -0
- package/dist/tools/seo/analyzers/ContentAnalyzer.d.ts +94 -0
- package/dist/tools/seo/analyzers/ContentAnalyzer.d.ts.map +1 -0
- package/dist/tools/seo/analyzers/ContentAnalyzer.js +402 -0
- package/dist/tools/seo/analyzers/ContentAnalyzer.js.map +1 -0
- package/dist/tools/seo/auditors/SiteAuditor.d.ts +121 -0
- package/dist/tools/seo/auditors/SiteAuditor.d.ts.map +1 -0
- package/dist/tools/seo/auditors/SiteAuditor.js +600 -0
- package/dist/tools/seo/auditors/SiteAuditor.js.map +1 -0
- package/dist/tools/seo/generators/MetaGenerator.d.ts +128 -0
- package/dist/tools/seo/generators/MetaGenerator.d.ts.map +1 -0
- package/dist/tools/seo/generators/MetaGenerator.js +547 -0
- package/dist/tools/seo/generators/MetaGenerator.js.map +1 -0
- package/dist/tools/seo/generators/SchemaGenerator.d.ts +204 -0
- package/dist/tools/seo/generators/SchemaGenerator.d.ts.map +1 -0
- package/dist/tools/seo/generators/SchemaGenerator.js +670 -0
- package/dist/tools/seo/generators/SchemaGenerator.js.map +1 -0
- package/dist/tools/seo/index.d.ts +17 -0
- package/dist/tools/seo/index.d.ts.map +1 -0
- package/dist/tools/seo/index.js +18 -0
- package/dist/tools/seo/index.js.map +1 -0
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.d.ts +186 -0
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.d.ts.map +1 -0
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.js +683 -0
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.js.map +1 -0
- package/dist/tools/site.d.ts.map +1 -1
- package/dist/tools/site.js +12 -12
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts.map +1 -1
- package/dist/tools/taxonomies.js +20 -20
- package/dist/tools/taxonomies.js.map +1 -1
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js +12 -12
- package/dist/tools/users.js.map +1 -1
- package/dist/types/client.d.ts +8 -6
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client.js.map +1 -1
- package/dist/types/seo.d.ts +473 -0
- package/dist/types/seo.d.ts.map +1 -0
- package/dist/types/seo.js +94 -0
- package/dist/types/seo.js.map +1 -0
- package/dist/utils/enhancedError.js +1 -1
- package/dist/utils/enhancedError.js.map +1 -1
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +0 -1
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.js +3 -3
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts +2 -2
- package/dist/utils/toolWrapper.js +8 -8
- package/dist/utils/toolWrapper.js.map +1 -1
- package/dist/utils/validation/core.d.ts.map +1 -1
- package/dist/utils/validation/core.js.map +1 -1
- package/dist/utils/validation/index.d.ts.map +1 -1
- package/dist/utils/validation/index.js.map +1 -1
- package/dist/utils/validation/network.js +3 -3
- package/dist/utils/validation/network.js.map +1 -1
- package/dist/utils/validation/rateLimit.js.map +1 -1
- package/dist/utils/validation/security.js.map +1 -1
- package/dist/utils/validation/wordpress.js.map +1 -1
- package/dist/utils/version.d.ts +144 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +318 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +24 -58
- package/src/cache/CacheInvalidation.ts +183 -20
- package/src/cache/HttpCacheWrapper.ts +8 -5
- package/src/cache/SEOCacheManager.ts +330 -0
- package/src/cache/__tests__/CacheInvalidation.test.ts +6 -11
- package/src/cache/__tests__/CachedWordPressClient.test.ts +37 -62
- package/src/client/SEOWordPressClient.ts +876 -0
- package/src/client/api.ts +50 -21
- package/src/client/auth.ts +19 -19
- package/src/client/index.ts +16 -0
- package/src/client/managers/AuthManager.ts +175 -0
- package/src/client/managers/AuthenticationManager.ts +16 -14
- package/src/client/managers/BaseManager.ts +24 -5
- package/src/client/managers/ComposedAuthenticationManager.ts +409 -0
- package/src/client/managers/ComposedManagerFactory.ts +231 -0
- package/src/client/managers/ComposedRequestManager.ts +336 -0
- package/src/client/managers/JWTAuthImplementation.ts +326 -0
- package/src/client/managers/ManagersIndex.ts +6 -0
- package/src/client/managers/RequestManager.ts +9 -7
- package/src/client/managers/composed/MigrationAdapter.ts +263 -0
- package/src/client/managers/composed/index.ts +47 -0
- package/src/client/managers/implementations/ConfigurationProviderImpl.ts +52 -0
- package/src/client/managers/implementations/ErrorHandlerImpl.ts +102 -0
- package/src/client/managers/implementations/ParameterValidatorImpl.ts +221 -0
- package/src/client/managers/interfaces/ManagerInterfaces.ts +171 -0
- package/src/config/Config.ts +63 -0
- package/src/config/ConfigurationSchema.ts +17 -17
- package/src/config/ServerConfiguration.ts +18 -16
- package/src/config/index.ts +13 -0
- package/src/docs/DocumentationGenerator.ts +2 -2
- package/src/dxt-entry.ts +3 -3
- package/src/index.ts +43 -43
- package/src/performance/MetricsCollector.ts +15 -11
- package/src/security/AISecurityScanner.ts +7 -7
- package/src/security/AutomatedRemediation.ts +13 -11
- package/src/security/InputValidator.ts +10 -9
- package/src/security/SecurityCIPipeline.ts +494 -56
- package/src/security/SecurityConfigManager.ts +10 -10
- package/src/security/SecurityMonitoring.ts +5 -5
- package/src/security/SecurityReviewer.ts +13 -6
- package/src/security/index.ts +3 -3
- package/src/server/ConnectionTester.ts +5 -5
- package/src/server/ToolRegistry.ts +9 -8
- package/src/server/index.ts +10 -0
- package/src/tools/BaseToolManager.ts +55 -83
- package/src/tools/auth.ts +21 -12
- package/src/tools/comments.ts +23 -19
- package/src/tools/index.ts +1 -0
- package/src/tools/media.ts +23 -20
- package/src/tools/pages.ts +20 -13
- package/src/tools/performance.ts +101 -32
- package/src/tools/posts/PostHandlers.ts +23 -23
- package/src/tools/posts/PostToolDefinitions.ts +1 -1
- package/src/tools/posts/index.ts +2 -2
- package/src/tools/seo/BulkOperations.ts +557 -0
- package/src/tools/seo/SEOHandlers.ts +296 -0
- package/src/tools/seo/SEOToolDefinitions.ts +402 -0
- package/src/tools/seo/SEOTools.ts +871 -0
- package/src/tools/seo/analyzers/ContentAnalyzer.ts +493 -0
- package/src/tools/seo/auditors/SiteAuditor.ts +787 -0
- package/src/tools/seo/generators/MetaGenerator.ts +694 -0
- package/src/tools/seo/generators/SchemaGenerator.ts +955 -0
- package/src/tools/seo/index.ts +47 -0
- package/src/tools/seo/optimizers/InternalLinkingSuggester.ts +934 -0
- package/src/tools/site.ts +27 -26
- package/src/tools/taxonomies.ts +29 -25
- package/src/tools/users.ts +20 -13
- package/src/types/client.ts +8 -6
- package/src/types/seo.ts +546 -0
- package/src/utils/enhancedError.ts +1 -1
- package/src/utils/error.ts +1 -2
- package/src/utils/index.ts +23 -0
- package/src/utils/logger.ts +3 -3
- package/src/utils/toolWrapper.ts +10 -10
- package/src/utils/validation/core.ts +2 -2
- package/src/utils/validation/index.ts +2 -2
- package/src/utils/validation/network.ts +5 -5
- package/src/utils/validation/rateLimit.ts +1 -1
- package/src/utils/validation/security.ts +1 -1
- package/src/utils/validation/wordpress.ts +1 -1
- package/src/utils/version.ts +402 -0
- package/src/dxt-entry.cjs +0 -68
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manager Interface Definitions
|
|
3
|
+
* Defines contracts for manager behaviors to enable composition over inheritance
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { WordPressClientConfig } from "@/types/client.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Core configuration management interface
|
|
10
|
+
*/
|
|
11
|
+
export interface ConfigurationProvider {
|
|
12
|
+
readonly config: WordPressClientConfig;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get configuration value by path
|
|
16
|
+
*/
|
|
17
|
+
getConfigValue<T>(path: string, defaultValue?: T): T | undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Error handling interface for managers
|
|
22
|
+
*/
|
|
23
|
+
export interface ErrorHandler {
|
|
24
|
+
/**
|
|
25
|
+
* Handle and transform errors with context
|
|
26
|
+
*/
|
|
27
|
+
handleError(error: unknown, operation: string): never;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Log successful operations
|
|
31
|
+
*/
|
|
32
|
+
logSuccess(operation: string, details?: unknown): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Parameter validation interface
|
|
37
|
+
*/
|
|
38
|
+
export interface ParameterValidator {
|
|
39
|
+
/**
|
|
40
|
+
* Validate required parameters are present
|
|
41
|
+
*/
|
|
42
|
+
validateRequired(params: Record<string, unknown>, requiredFields: string[]): void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Validate parameter types and formats
|
|
46
|
+
*/
|
|
47
|
+
validateParameters<T>(params: unknown, schema?: unknown): T;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Validate string parameters
|
|
51
|
+
*/
|
|
52
|
+
validateString(value: unknown, fieldName: string, options?: {
|
|
53
|
+
required?: boolean;
|
|
54
|
+
minLength?: number;
|
|
55
|
+
maxLength?: number;
|
|
56
|
+
pattern?: RegExp;
|
|
57
|
+
}): string;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Validate WordPress ID parameters
|
|
61
|
+
*/
|
|
62
|
+
validateWordPressId(value: unknown, fieldName?: string): number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Base manager contract combining common behaviors
|
|
67
|
+
*/
|
|
68
|
+
export interface BaseManagerContract extends ConfigurationProvider, ErrorHandler, ParameterValidator {}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Request management interface
|
|
72
|
+
*/
|
|
73
|
+
export interface RequestHandler {
|
|
74
|
+
/**
|
|
75
|
+
* Execute HTTP request with full request lifecycle management
|
|
76
|
+
*/
|
|
77
|
+
request<T>(method: string, endpoint: string, data?: unknown, options?: unknown): Promise<T>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get request statistics
|
|
81
|
+
*/
|
|
82
|
+
getStats(): unknown;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Reset statistics
|
|
86
|
+
*/
|
|
87
|
+
resetStats(): void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Authentication management interface
|
|
92
|
+
*/
|
|
93
|
+
export interface AuthenticationProvider {
|
|
94
|
+
/**
|
|
95
|
+
* Authenticate with the configured method
|
|
96
|
+
*/
|
|
97
|
+
authenticate(): Promise<boolean>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Check if currently authenticated
|
|
101
|
+
*/
|
|
102
|
+
isAuthenticated(): boolean;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Get authentication headers for requests
|
|
106
|
+
*/
|
|
107
|
+
getAuthHeaders(): Record<string, string>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Handle authentication failure
|
|
111
|
+
*/
|
|
112
|
+
handleAuthFailure(error: unknown): Promise<boolean>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Manager factory interface for dependency injection
|
|
117
|
+
*/
|
|
118
|
+
export interface ManagerFactory {
|
|
119
|
+
/**
|
|
120
|
+
* Create configuration provider
|
|
121
|
+
*/
|
|
122
|
+
createConfigurationProvider(config: WordPressClientConfig): ConfigurationProvider;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Create error handler
|
|
126
|
+
*/
|
|
127
|
+
createErrorHandler(config: WordPressClientConfig): ErrorHandler;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Create parameter validator
|
|
131
|
+
*/
|
|
132
|
+
createParameterValidator(): ParameterValidator;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Create request handler
|
|
136
|
+
*/
|
|
137
|
+
createRequestHandler(config: WordPressClientConfig, authProvider: AuthenticationProvider): RequestHandler;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Create authentication provider
|
|
141
|
+
*/
|
|
142
|
+
createAuthenticationProvider(config: WordPressClientConfig): AuthenticationProvider;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Configuration for manager composition
|
|
147
|
+
*/
|
|
148
|
+
export interface ManagerCompositionConfig {
|
|
149
|
+
/** WordPress client configuration */
|
|
150
|
+
clientConfig: WordPressClientConfig;
|
|
151
|
+
|
|
152
|
+
/** Optional custom implementations */
|
|
153
|
+
customErrorHandler?: ErrorHandler;
|
|
154
|
+
customValidator?: ParameterValidator;
|
|
155
|
+
customAuthProvider?: AuthenticationProvider;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Composed manager that uses composition instead of inheritance
|
|
160
|
+
*/
|
|
161
|
+
export interface ComposedManager extends BaseManagerContract, RequestHandler, AuthenticationProvider {
|
|
162
|
+
/**
|
|
163
|
+
* Initialize the composed manager
|
|
164
|
+
*/
|
|
165
|
+
initialize(): Promise<void>;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Cleanup resources
|
|
169
|
+
*/
|
|
170
|
+
dispose(): void;
|
|
171
|
+
}
|
package/src/config/Config.ts
CHANGED
|
@@ -74,6 +74,38 @@ export interface AppConfig {
|
|
|
74
74
|
readonly isTravis: boolean;
|
|
75
75
|
readonly isCircleCI: boolean;
|
|
76
76
|
};
|
|
77
|
+
|
|
78
|
+
// SEO Configuration
|
|
79
|
+
readonly seo: {
|
|
80
|
+
readonly enabled: boolean;
|
|
81
|
+
readonly providers: {
|
|
82
|
+
readonly searchConsole: boolean;
|
|
83
|
+
readonly dataForSEO: boolean;
|
|
84
|
+
readonly ahrefs: boolean;
|
|
85
|
+
};
|
|
86
|
+
readonly limits: {
|
|
87
|
+
readonly bulkOperationSize: number;
|
|
88
|
+
readonly rateLimitPerMinute: number;
|
|
89
|
+
readonly maxConcurrentAnalysis: number;
|
|
90
|
+
};
|
|
91
|
+
readonly cache: {
|
|
92
|
+
readonly analysisTTL: number;
|
|
93
|
+
readonly schemaTTL: number;
|
|
94
|
+
readonly auditTTL: number;
|
|
95
|
+
readonly keywordsTTL: number;
|
|
96
|
+
};
|
|
97
|
+
readonly metadata: {
|
|
98
|
+
readonly titleMaxLength: number;
|
|
99
|
+
readonly descriptionMaxLength: number;
|
|
100
|
+
readonly descriptionMinLength: number;
|
|
101
|
+
};
|
|
102
|
+
readonly analysis: {
|
|
103
|
+
readonly minWordCount: number;
|
|
104
|
+
readonly targetKeywordDensity: number;
|
|
105
|
+
readonly maxKeywordDensity: number;
|
|
106
|
+
readonly minReadabilityScore: number;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
77
109
|
}
|
|
78
110
|
|
|
79
111
|
/**
|
|
@@ -174,6 +206,37 @@ export class Config {
|
|
|
174
206
|
isTravis: process.env.TRAVIS === "true",
|
|
175
207
|
isCircleCI: process.env.CIRCLECI === "true",
|
|
176
208
|
},
|
|
209
|
+
|
|
210
|
+
seo: {
|
|
211
|
+
enabled: process.env.SEO_ENABLED !== "false",
|
|
212
|
+
providers: {
|
|
213
|
+
searchConsole: process.env.SEO_PROVIDER_SEARCH_CONSOLE === "true",
|
|
214
|
+
dataForSEO: process.env.SEO_PROVIDER_DATAFORSEO === "true",
|
|
215
|
+
ahrefs: process.env.SEO_PROVIDER_AHREFS === "true",
|
|
216
|
+
},
|
|
217
|
+
limits: {
|
|
218
|
+
bulkOperationSize: parseInt(process.env.SEO_BULK_OPERATION_SIZE || "10", 10),
|
|
219
|
+
rateLimitPerMinute: parseInt(process.env.SEO_RATE_LIMIT_PER_MINUTE || "30", 10),
|
|
220
|
+
maxConcurrentAnalysis: parseInt(process.env.SEO_MAX_CONCURRENT_ANALYSIS || "5", 10),
|
|
221
|
+
},
|
|
222
|
+
cache: {
|
|
223
|
+
analysisTTL: parseInt(process.env.SEO_CACHE_ANALYSIS_TTL || "21600", 10), // 6 hours
|
|
224
|
+
schemaTTL: parseInt(process.env.SEO_CACHE_SCHEMA_TTL || "86400", 10), // 24 hours
|
|
225
|
+
auditTTL: parseInt(process.env.SEO_CACHE_AUDIT_TTL || "3600", 10), // 1 hour
|
|
226
|
+
keywordsTTL: parseInt(process.env.SEO_CACHE_KEYWORDS_TTL || "604800", 10), // 7 days
|
|
227
|
+
},
|
|
228
|
+
metadata: {
|
|
229
|
+
titleMaxLength: parseInt(process.env.SEO_TITLE_MAX_LENGTH || "60", 10),
|
|
230
|
+
descriptionMaxLength: parseInt(process.env.SEO_DESCRIPTION_MAX_LENGTH || "160", 10),
|
|
231
|
+
descriptionMinLength: parseInt(process.env.SEO_DESCRIPTION_MIN_LENGTH || "155", 10),
|
|
232
|
+
},
|
|
233
|
+
analysis: {
|
|
234
|
+
minWordCount: parseInt(process.env.SEO_MIN_WORD_COUNT || "300", 10),
|
|
235
|
+
targetKeywordDensity: parseFloat(process.env.SEO_TARGET_KEYWORD_DENSITY || "2.5"),
|
|
236
|
+
maxKeywordDensity: parseFloat(process.env.SEO_MAX_KEYWORD_DENSITY || "3.5"),
|
|
237
|
+
minReadabilityScore: parseFloat(process.env.SEO_MIN_READABILITY_SCORE || "60"),
|
|
238
|
+
},
|
|
239
|
+
},
|
|
177
240
|
};
|
|
178
241
|
}
|
|
179
242
|
|
|
@@ -142,12 +142,12 @@ export class ConfigurationValidator {
|
|
|
142
142
|
static validateMultiSiteConfig(config: unknown): MultiSiteConfigType {
|
|
143
143
|
try {
|
|
144
144
|
return MultiSiteConfigSchema.parse(config);
|
|
145
|
-
} catch (
|
|
146
|
-
if (
|
|
147
|
-
const messages =
|
|
145
|
+
} catch (_error) {
|
|
146
|
+
if (_error instanceof z.ZodError) {
|
|
147
|
+
const messages = _error.issues.map((err: z.ZodIssue) => `${err.path.join(".")}: ${err.message}`).join("; ");
|
|
148
148
|
throw new Error(`Multi-site configuration validation failed: ${messages}`);
|
|
149
149
|
}
|
|
150
|
-
throw
|
|
150
|
+
throw _error;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -157,12 +157,12 @@ export class ConfigurationValidator {
|
|
|
157
157
|
static validateEnvironmentConfig(env: Record<string, string | undefined>): EnvironmentConfigType {
|
|
158
158
|
try {
|
|
159
159
|
return EnvironmentConfigSchema.parse(env);
|
|
160
|
-
} catch (
|
|
161
|
-
if (
|
|
162
|
-
const messages =
|
|
160
|
+
} catch (_error) {
|
|
161
|
+
if (_error instanceof z.ZodError) {
|
|
162
|
+
const messages = _error.issues.map((err: z.ZodIssue) => `${err.path.join(".")}: ${err.message}`).join("; ");
|
|
163
163
|
throw new Error(`Environment configuration validation failed: ${messages}`);
|
|
164
164
|
}
|
|
165
|
-
throw
|
|
165
|
+
throw _error;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -172,12 +172,12 @@ export class ConfigurationValidator {
|
|
|
172
172
|
static validateMcpConfig(config: unknown): McpConfigType {
|
|
173
173
|
try {
|
|
174
174
|
return McpConfigSchema.parse(config);
|
|
175
|
-
} catch (
|
|
176
|
-
if (
|
|
177
|
-
const messages =
|
|
175
|
+
} catch (_error) {
|
|
176
|
+
if (_error instanceof z.ZodError) {
|
|
177
|
+
const messages = _error.issues.map((err: z.ZodIssue) => `${err.path.join(".")}: ${err.message}`).join("; ");
|
|
178
178
|
throw new Error(`MCP configuration validation failed: ${messages}`);
|
|
179
179
|
}
|
|
180
|
-
throw
|
|
180
|
+
throw _error;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
@@ -187,12 +187,12 @@ export class ConfigurationValidator {
|
|
|
187
187
|
static validateSiteConfig(config: unknown): SiteType {
|
|
188
188
|
try {
|
|
189
189
|
return SiteSchema.parse(config);
|
|
190
|
-
} catch (
|
|
191
|
-
if (
|
|
192
|
-
const messages =
|
|
190
|
+
} catch (_error) {
|
|
191
|
+
if (_error instanceof z.ZodError) {
|
|
192
|
+
const messages = _error.issues.map((err: z.ZodIssue) => `${err.path.join(".")}: ${err.message}`).join("; ");
|
|
193
193
|
throw new Error(`Site configuration validation failed: ${messages}`);
|
|
194
194
|
}
|
|
195
|
-
throw
|
|
195
|
+
throw _error;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
@@ -220,7 +220,7 @@ export class ConfigurationValidator {
|
|
|
220
220
|
if (result.success) {
|
|
221
221
|
return [];
|
|
222
222
|
}
|
|
223
|
-
return result.error.
|
|
223
|
+
return result.error.issues.map((err: z.ZodIssue) => `${err.path.join(".")}: ${err.message}`);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import dotenv from "dotenv";
|
|
2
|
-
import
|
|
2
|
+
import { promises as fsPromises } from "fs";
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { WordPressClient } from "../client/api.js";
|
|
@@ -46,10 +46,10 @@ export class ServerConfiguration {
|
|
|
46
46
|
console.log = () => {};
|
|
47
47
|
// eslint-disable-next-line no-console
|
|
48
48
|
console.error = () => {};
|
|
49
|
-
dotenv.config({
|
|
49
|
+
dotenv.config({
|
|
50
50
|
path: this.envPath,
|
|
51
51
|
debug: false,
|
|
52
|
-
override: false
|
|
52
|
+
override: false,
|
|
53
53
|
});
|
|
54
54
|
} finally {
|
|
55
55
|
// eslint-disable-next-line no-console
|
|
@@ -63,7 +63,7 @@ export class ServerConfiguration {
|
|
|
63
63
|
this.logger.debug("ServerConfiguration initialized", {
|
|
64
64
|
rootDir: this.rootDir,
|
|
65
65
|
envPath: this.envPath,
|
|
66
|
-
|
|
66
|
+
// Note: envFileExists check moved to async initialization
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -82,18 +82,20 @@ export class ServerConfiguration {
|
|
|
82
82
|
* Load WordPress client configurations
|
|
83
83
|
* Returns a Map of site ID to WordPressClient instances
|
|
84
84
|
*/
|
|
85
|
-
public loadClientConfigurations(mcpConfig?: McpConfigType): {
|
|
85
|
+
public async loadClientConfigurations(mcpConfig?: McpConfigType): Promise<{
|
|
86
86
|
clients: Map<string, WordPressClient>;
|
|
87
87
|
configs: SiteConfig[];
|
|
88
|
-
} {
|
|
88
|
+
}> {
|
|
89
89
|
const configPath = path.resolve(this.rootDir, "mcp-wordpress.config.json");
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
try {
|
|
92
|
+
await fsPromises.access(configPath);
|
|
92
93
|
if (ConfigHelpers.shouldLogInfo()) {
|
|
93
94
|
this.logger.info("Found multi-site configuration file", { configPath });
|
|
94
95
|
}
|
|
95
|
-
return this.loadMultiSiteConfig(configPath);
|
|
96
|
-
}
|
|
96
|
+
return await this.loadMultiSiteConfig(configPath);
|
|
97
|
+
} catch (_error) {
|
|
98
|
+
// Config file doesn't exist or is not accessible
|
|
97
99
|
if (ConfigHelpers.shouldLogInfo()) {
|
|
98
100
|
this.logger.info("Multi-site config not found, using environment variables for single-site mode", {
|
|
99
101
|
configPath,
|
|
@@ -106,12 +108,12 @@ export class ServerConfiguration {
|
|
|
106
108
|
/**
|
|
107
109
|
* Load multi-site configuration from JSON file
|
|
108
110
|
*/
|
|
109
|
-
private loadMultiSiteConfig(configPath: string): {
|
|
111
|
+
private async loadMultiSiteConfig(configPath: string): Promise<{
|
|
110
112
|
clients: Map<string, WordPressClient>;
|
|
111
113
|
configs: SiteConfig[];
|
|
112
|
-
} {
|
|
114
|
+
}> {
|
|
113
115
|
try {
|
|
114
|
-
const configFile =
|
|
116
|
+
const configFile = await fsPromises.readFile(configPath, "utf-8");
|
|
115
117
|
const rawConfig = JSON.parse(configFile);
|
|
116
118
|
|
|
117
119
|
// Validate configuration using Zod schema
|
|
@@ -147,10 +149,10 @@ export class ServerConfiguration {
|
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
return { clients, configs: validConfigs };
|
|
150
|
-
} catch (
|
|
152
|
+
} catch (_error) {
|
|
151
153
|
this.logger.fatal("Failed to load multi-site configuration", {
|
|
152
154
|
configPath,
|
|
153
|
-
|
|
155
|
+
_error: getErrorMessage(_error),
|
|
154
156
|
});
|
|
155
157
|
process.exit(1);
|
|
156
158
|
}
|
|
@@ -287,9 +289,9 @@ export class ServerConfiguration {
|
|
|
287
289
|
}
|
|
288
290
|
|
|
289
291
|
return { clients, configs: [siteConfig] };
|
|
290
|
-
} catch (
|
|
292
|
+
} catch (_error) {
|
|
291
293
|
this.logger.error("Configuration validation failed for single-site mode", {
|
|
292
|
-
|
|
294
|
+
_error: getErrorMessage(_error),
|
|
293
295
|
suggestion: "Please check your environment variables or MCP configuration",
|
|
294
296
|
});
|
|
295
297
|
return { clients: new Map(), configs: [] };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Barrel Export
|
|
3
|
+
* Centralized exports for all configuration management
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Main Configuration System
|
|
7
|
+
export { Config, ConfigHelpers, config } from './Config.js';
|
|
8
|
+
|
|
9
|
+
// Configuration Schema and Validation
|
|
10
|
+
export * from './ConfigurationSchema.js';
|
|
11
|
+
|
|
12
|
+
// Server Configuration (legacy)
|
|
13
|
+
export * from './ServerConfiguration.js';
|
|
@@ -193,8 +193,8 @@ export class DocumentationGenerator {
|
|
|
193
193
|
const doc = await this.extractToolDocumentation(toolDef as ToolDefinition, category, className);
|
|
194
194
|
toolDocs.push(doc);
|
|
195
195
|
}
|
|
196
|
-
} catch (
|
|
197
|
-
this.logger.warn(`⚠️ Failed to extract documentation for ${className}:`, {
|
|
196
|
+
} catch (_error) {
|
|
197
|
+
this.logger.warn(`⚠️ Failed to extract documentation for ${className}:`, { _error: String(_error) });
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
package/src/dxt-entry.ts
CHANGED
|
@@ -34,9 +34,9 @@ async function startDXTServer() {
|
|
|
34
34
|
|
|
35
35
|
process.on("SIGINT", shutdown);
|
|
36
36
|
process.on("SIGTERM", shutdown);
|
|
37
|
-
} catch (
|
|
38
|
-
logger.fatal(`DXT server failed to start: ${
|
|
39
|
-
logger.fatal(`Stack trace: ${
|
|
37
|
+
} catch (_error) {
|
|
38
|
+
logger.fatal(`DXT server failed to start: ${_error instanceof Error ? _error.message : String(_error)}`);
|
|
39
|
+
logger.fatal(`Stack trace: ${_error instanceof Error ? _error.stack : "No stack trace available"}`);
|
|
40
40
|
process.exit(1);
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,7 @@ import { getErrorMessage } from "./utils/error.js";
|
|
|
9
9
|
import { LoggerFactory } from "./utils/logger.js";
|
|
10
10
|
import { ConfigHelpers } from "./config/Config.js";
|
|
11
11
|
import { McpConfigType } from "./config/ServerConfiguration.js";
|
|
12
|
-
|
|
13
|
-
// --- Constants ---
|
|
14
|
-
const SERVER_VERSION = "1.1.8"; // Technical debt resolution and modular architecture
|
|
12
|
+
import { getVersion, getDisplayVersion } from "./utils/version.js";
|
|
15
13
|
|
|
16
14
|
// --- Main Server Class ---
|
|
17
15
|
class MCPWordPressServer {
|
|
@@ -19,42 +17,20 @@ class MCPWordPressServer {
|
|
|
19
17
|
private wordpressClients: Map<string, WordPressClient> = new Map();
|
|
20
18
|
private initialized: boolean = false;
|
|
21
19
|
private siteConfigs: SiteConfig[] = [];
|
|
22
|
-
private toolRegistry
|
|
20
|
+
private toolRegistry!: ToolRegistry;
|
|
23
21
|
private logger = LoggerFactory.server();
|
|
24
22
|
|
|
25
|
-
constructor(mcpConfig?: McpConfigType) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (this.wordpressClients.size === 0) {
|
|
29
|
-
// In test environments, don't exit the process
|
|
30
|
-
if (ConfigHelpers.isCI() || ConfigHelpers.isTest() || (globalThis as Record<string, unknown>).__EXECUTION_CONTEXT__ === "jest") {
|
|
31
|
-
this.logger.warn("No WordPress sites configured in test environment");
|
|
32
|
-
// Create a dummy client for testing
|
|
33
|
-
this.wordpressClients.set("test", {} as WordPressClient);
|
|
34
|
-
} else {
|
|
35
|
-
this.logger.fatal("No WordPress sites configured. Server cannot start.", {
|
|
36
|
-
expectedEnvVars: [
|
|
37
|
-
"WORDPRESS_SITE_URL",
|
|
38
|
-
"WORDPRESS_USERNAME",
|
|
39
|
-
"WORDPRESS_APP_PASSWORD"
|
|
40
|
-
]
|
|
41
|
-
});
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
23
|
+
constructor(private mcpConfig?: McpConfigType) {
|
|
24
|
+
// Server initialization will happen in run() method
|
|
46
25
|
this.server = new McpServer({
|
|
47
26
|
name: "mcp-wordpress",
|
|
48
|
-
version:
|
|
27
|
+
version: getVersion(),
|
|
49
28
|
});
|
|
50
|
-
|
|
51
|
-
this.toolRegistry = new ToolRegistry(this.server, this.wordpressClients);
|
|
52
|
-
this.setupTools();
|
|
53
29
|
}
|
|
54
30
|
|
|
55
|
-
private loadConfiguration(mcpConfig?: McpConfigType) {
|
|
31
|
+
private async loadConfiguration(mcpConfig?: McpConfigType) {
|
|
56
32
|
const serverConfig = ServerConfiguration.getInstance();
|
|
57
|
-
const { clients, configs } = serverConfig.loadClientConfigurations(mcpConfig);
|
|
33
|
+
const { clients, configs } = await serverConfig.loadClientConfigurations(mcpConfig);
|
|
58
34
|
|
|
59
35
|
this.wordpressClients = clients;
|
|
60
36
|
this.siteConfigs = configs;
|
|
@@ -68,24 +44,48 @@ class MCPWordPressServer {
|
|
|
68
44
|
// Use optimized connection testing with timeouts and concurrency control
|
|
69
45
|
await ConnectionTester.testClientConnections(this.wordpressClients, {
|
|
70
46
|
timeout: ConfigHelpers.getTimeout("test"),
|
|
71
|
-
maxConcurrent: ConfigHelpers.isCI() ? 2 : 3 // Reduce concurrency in CI
|
|
47
|
+
maxConcurrent: ConfigHelpers.isCI() ? 2 : 3, // Reduce concurrency in CI
|
|
72
48
|
});
|
|
73
49
|
this.initialized = true;
|
|
74
50
|
}
|
|
75
51
|
|
|
76
52
|
async run() {
|
|
53
|
+
// Load configuration asynchronously
|
|
54
|
+
await this.loadConfiguration(this.mcpConfig);
|
|
55
|
+
|
|
56
|
+
if (this.wordpressClients.size === 0) {
|
|
57
|
+
// In test environments, don't exit the process
|
|
58
|
+
if (
|
|
59
|
+
ConfigHelpers.isCI() ||
|
|
60
|
+
ConfigHelpers.isTest() ||
|
|
61
|
+
(globalThis as Record<string, unknown>).__EXECUTION_CONTEXT__ === "jest"
|
|
62
|
+
) {
|
|
63
|
+
this.logger.warn("No WordPress sites configured in test environment");
|
|
64
|
+
// Create a dummy client for testing
|
|
65
|
+
this.wordpressClients.set("test", {} as WordPressClient);
|
|
66
|
+
} else {
|
|
67
|
+
this.logger.fatal("No WordPress sites configured. Server cannot start.", {
|
|
68
|
+
expectedEnvVars: ["WORDPRESS_SITE_URL", "WORDPRESS_USERNAME", "WORDPRESS_APP_PASSWORD"],
|
|
69
|
+
});
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.toolRegistry = new ToolRegistry(this.server, this.wordpressClients);
|
|
75
|
+
this.setupTools();
|
|
76
|
+
|
|
77
77
|
// Skip connection testing in DXT environment to prevent timeouts
|
|
78
78
|
const isDXTMode = ConfigHelpers.isDXT() || process.argv[0]?.includes("dxt-entry");
|
|
79
79
|
|
|
80
80
|
if (!this.initialized && !isDXTMode) {
|
|
81
81
|
this.logger.info("Testing connections to configured WordPress sites...", {
|
|
82
|
-
siteCount: this.wordpressClients.size
|
|
82
|
+
siteCount: this.wordpressClients.size,
|
|
83
83
|
});
|
|
84
84
|
try {
|
|
85
85
|
await this.testClientConnections();
|
|
86
|
-
} catch (
|
|
86
|
+
} catch (_error) {
|
|
87
87
|
this.logger.warn("Connection test failed - continuing with server startup", {
|
|
88
|
-
|
|
88
|
+
_error: getErrorMessage(_error),
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
} else if (isDXTMode) {
|
|
@@ -94,8 +94,8 @@ class MCPWordPressServer {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
this.logger.info("Starting MCP WordPress Server...", {
|
|
97
|
-
version:
|
|
98
|
-
sites: this.wordpressClients.size
|
|
97
|
+
version: getDisplayVersion(),
|
|
98
|
+
sites: this.wordpressClients.size,
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
// Connect to stdio transport with timeout
|
|
@@ -112,14 +112,14 @@ class MCPWordPressServer {
|
|
|
112
112
|
clearTimeout(connectionTimeout);
|
|
113
113
|
|
|
114
114
|
this.logger.info("Server started and connected successfully", {
|
|
115
|
-
sites: this.wordpressClients.size
|
|
115
|
+
sites: this.wordpressClients.size,
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
// Keep the process alive
|
|
119
119
|
process.stdin.resume();
|
|
120
|
-
} catch (
|
|
120
|
+
} catch (_error) {
|
|
121
121
|
clearTimeout(connectionTimeout);
|
|
122
|
-
throw
|
|
122
|
+
throw _error;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -133,7 +133,7 @@ class MCPWordPressServer {
|
|
|
133
133
|
// --- Main Execution ---
|
|
134
134
|
async function main() {
|
|
135
135
|
const mainLogger = LoggerFactory.server();
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
try {
|
|
138
138
|
const mcpServer = new MCPWordPressServer();
|
|
139
139
|
await mcpServer.run();
|
|
@@ -145,8 +145,8 @@ async function main() {
|
|
|
145
145
|
|
|
146
146
|
process.on("SIGINT", shutdown);
|
|
147
147
|
process.on("SIGTERM", shutdown);
|
|
148
|
-
} catch (
|
|
149
|
-
mainLogger.fatal("Failed to start server", {
|
|
148
|
+
} catch (_error) {
|
|
149
|
+
mainLogger.fatal("Failed to start server", { _error: getErrorMessage(_error) });
|
|
150
150
|
process.exit(1);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -178,6 +178,7 @@ export class MetricsCollector {
|
|
|
178
178
|
averageResponseTime: 0,
|
|
179
179
|
rateLimitHits: 0,
|
|
180
180
|
authFailures: 0,
|
|
181
|
+
errors: 0,
|
|
181
182
|
};
|
|
182
183
|
|
|
183
184
|
const responseTimes: number[] = [];
|
|
@@ -252,13 +253,16 @@ export class MetricsCollector {
|
|
|
252
253
|
worstPerforming: string;
|
|
253
254
|
} {
|
|
254
255
|
const sites = Array.from(this.clientInstances.keys());
|
|
255
|
-
const comparison: Record<
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
256
|
+
const comparison: Record<
|
|
257
|
+
string,
|
|
258
|
+
{
|
|
259
|
+
responseTime: number;
|
|
260
|
+
cacheHitRate: number;
|
|
261
|
+
errorRate: number;
|
|
262
|
+
requestCount: number;
|
|
263
|
+
ranking: number;
|
|
264
|
+
}
|
|
265
|
+
> = {};
|
|
262
266
|
const rankings: Array<{ site: string; score: number }> = [];
|
|
263
267
|
|
|
264
268
|
for (const siteId of sites) {
|
|
@@ -401,9 +405,9 @@ export class MetricsCollector {
|
|
|
401
405
|
this.updateCacheMetrics();
|
|
402
406
|
this.updateClientMetrics();
|
|
403
407
|
this.logger.debug("Real-time metrics updated");
|
|
404
|
-
} catch (
|
|
408
|
+
} catch (_error) {
|
|
405
409
|
this.logger.error("Failed to update real-time metrics", {
|
|
406
|
-
|
|
410
|
+
_error: _error instanceof Error ? _error.message : String(_error),
|
|
407
411
|
});
|
|
408
412
|
}
|
|
409
413
|
}, interval);
|
|
@@ -480,12 +484,12 @@ export class MetricsCollector {
|
|
|
480
484
|
this.activeRequests.delete(requestId);
|
|
481
485
|
|
|
482
486
|
return result;
|
|
483
|
-
} catch (
|
|
487
|
+
} catch (_error) {
|
|
484
488
|
const responseTime = Date.now() - startTime;
|
|
485
489
|
this.monitor.recordRequest(responseTime, false);
|
|
486
490
|
this.activeRequests.delete(requestId);
|
|
487
491
|
|
|
488
|
-
throw
|
|
492
|
+
throw _error;
|
|
489
493
|
}
|
|
490
494
|
};
|
|
491
495
|
}
|