mcp-wordpress 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +149 -789
  2. package/dist/mcp-wordpress-1.4.0.tgz +0 -0
  3. package/docs/DOCKER.md +8 -1
  4. package/docs/api/README.md +82 -75
  5. package/docs/api/categories/auth.md +2 -0
  6. package/docs/api/categories/cache.md +2 -0
  7. package/docs/api/categories/comment.md +2 -0
  8. package/docs/api/categories/media.md +2 -0
  9. package/docs/api/categories/page.md +2 -0
  10. package/docs/api/categories/performance.md +2 -0
  11. package/docs/api/categories/post.md +2 -0
  12. package/docs/api/categories/site.md +2 -0
  13. package/docs/api/categories/taxonomy.md +2 -0
  14. package/docs/api/categories/user.md +2 -0
  15. package/docs/api/tools/wp_approve_comment.md +3 -11
  16. package/docs/api/tools/wp_cache_clear.md +5 -14
  17. package/docs/api/tools/wp_cache_info.md +5 -14
  18. package/docs/api/tools/wp_cache_stats.md +5 -14
  19. package/docs/api/tools/wp_cache_warm.md +5 -14
  20. package/docs/api/tools/wp_create_application_password.md +3 -11
  21. package/docs/api/tools/wp_create_category.md +3 -11
  22. package/docs/api/tools/wp_create_comment.md +5 -14
  23. package/docs/api/tools/wp_create_page.md +5 -13
  24. package/docs/api/tools/wp_create_post.md +6 -12
  25. package/docs/api/tools/wp_create_tag.md +3 -11
  26. package/docs/api/tools/wp_create_user.md +5 -13
  27. package/docs/api/tools/wp_delete_application_password.md +3 -11
  28. package/docs/api/tools/wp_delete_category.md +3 -11
  29. package/docs/api/tools/wp_delete_comment.md +3 -11
  30. package/docs/api/tools/wp_delete_media.md +3 -10
  31. package/docs/api/tools/wp_delete_page.md +3 -10
  32. package/docs/api/tools/wp_delete_post.md +4 -9
  33. package/docs/api/tools/wp_delete_tag.md +3 -11
  34. package/docs/api/tools/wp_delete_user.md +3 -10
  35. package/docs/api/tools/wp_get_application_passwords.md +3 -11
  36. package/docs/api/tools/wp_get_auth_status.md +3 -11
  37. package/docs/api/tools/wp_get_category.md +3 -11
  38. package/docs/api/tools/wp_get_comment.md +3 -11
  39. package/docs/api/tools/wp_get_current_user.md +3 -11
  40. package/docs/api/tools/wp_get_media.md +3 -11
  41. package/docs/api/tools/wp_get_page.md +3 -11
  42. package/docs/api/tools/wp_get_page_revisions.md +3 -11
  43. package/docs/api/tools/wp_get_post.md +4 -10
  44. package/docs/api/tools/wp_get_post_revisions.md +3 -11
  45. package/docs/api/tools/wp_get_site_settings.md +3 -10
  46. package/docs/api/tools/wp_get_tag.md +3 -11
  47. package/docs/api/tools/wp_get_user.md +3 -11
  48. package/docs/api/tools/wp_list_categories.md +3 -11
  49. package/docs/api/tools/wp_list_comments.md +3 -11
  50. package/docs/api/tools/wp_list_media.md +5 -14
  51. package/docs/api/tools/wp_list_pages.md +5 -14
  52. package/docs/api/tools/wp_list_posts.md +6 -13
  53. package/docs/api/tools/wp_list_tags.md +3 -11
  54. package/docs/api/tools/wp_list_users.md +3 -11
  55. package/docs/api/tools/wp_performance_alerts.md +7 -17
  56. package/docs/api/tools/wp_performance_benchmark.md +7 -17
  57. package/docs/api/tools/wp_performance_export.md +7 -17
  58. package/docs/api/tools/wp_performance_history.md +7 -17
  59. package/docs/api/tools/wp_performance_optimize.md +7 -17
  60. package/docs/api/tools/wp_performance_stats.md +7 -17
  61. package/docs/api/tools/wp_search_site.md +3 -11
  62. package/docs/api/tools/wp_spam_comment.md +3 -11
  63. package/docs/api/tools/wp_switch_auth_method.md +5 -14
  64. package/docs/api/tools/wp_test_auth.md +3 -11
  65. package/docs/api/tools/wp_update_category.md +3 -11
  66. package/docs/api/tools/wp_update_comment.md +5 -14
  67. package/docs/api/tools/wp_update_media.md +5 -14
  68. package/docs/api/tools/wp_update_page.md +5 -13
  69. package/docs/api/tools/wp_update_post.md +6 -12
  70. package/docs/api/tools/wp_update_site_settings.md +5 -14
  71. package/docs/api/tools/wp_update_tag.md +3 -11
  72. package/docs/api/tools/wp_update_user.md +5 -13
  73. package/docs/api/tools/wp_upload_media.md +5 -13
  74. package/docs/api/types/WordPressPost.md +0 -2
  75. package/docs/developer/API_REFERENCE.md +628 -0
  76. package/docs/developer/ARCHITECTURE.md +374 -0
  77. package/docs/developer/BUILD_SYSTEM.md +465 -0
  78. package/docs/developer/CONTRIBUTING.md +463 -0
  79. package/docs/developer/DEVELOPMENT_SETUP.md +463 -0
  80. package/docs/developer/GITHUB_ACTIONS_SETUP.md +2 -1
  81. package/docs/developer/MAINTENANCE.md +5 -5
  82. package/docs/developer/MIGRATION_GUIDE.md +7 -5
  83. package/docs/developer/NPM_AUTH_SETUP.md +4 -4
  84. package/docs/developer/README.md +219 -0
  85. package/docs/developer/REFACTORING.md +15 -10
  86. package/docs/developer/RELEASE_PROCESS.md +523 -0
  87. package/docs/developer/TESTING.md +730 -0
  88. package/docs/releases/COMMUNITY_ANNOUNCEMENT_v1.1.2.md +9 -3
  89. package/docs/releases/RELEASE_NOTES_v1.1.2.md +4 -4
  90. package/docs/user-guides/DOCKER_NPM_DTX_SETUP.md +217 -0
  91. package/docs/user-guides/DOCKER_SETUP.md +3 -3
  92. package/docs/user-guides/DTX_SETUP.md +5 -5
  93. package/docs/user-guides/NPX_SETUP.md +2 -2
  94. package/package.json +2 -2
  95. package/dist/mcp-wordpress-1.3.0.tgz +0 -0
@@ -0,0 +1,374 @@
1
+ # Architecture Guide
2
+
3
+ This guide explains the system architecture and design patterns used in the MCP WordPress Server.
4
+
5
+ ## 🏗️ Overall Architecture
6
+
7
+ The MCP WordPress Server follows a modular, layered architecture designed for scalability, maintainability, and extensibility.
8
+
9
+ ```text
10
+ ┌─────────────────────────────────────────────────────────────┐
11
+ │ MCP Server Layer │
12
+ ├─────────────────────────────────────────────────────────────┤
13
+ │ Tool Registry │
14
+ ├─────────────────────────────────────────────────────────────┤
15
+ │ Posts │ Pages │ Media │ Users │ Comments │ Taxonomies │... │
16
+ ├─────────────────────────────────────────────────────────────┤
17
+ │ WordPress Client Layer │
18
+ ├─────────────────────────────────────────────────────────────┤
19
+ │ Auth Manager │ Request Manager │ Cache Manager │ Metrics │
20
+ ├─────────────────────────────────────────────────────────────┤
21
+ │ WordPress REST API │
22
+ └─────────────────────────────────────────────────────────────┘
23
+ ```
24
+
25
+ ## 🎯 Design Principles
26
+
27
+ ### 1. Composition Over Inheritance
28
+
29
+ - **Manager Pattern**: Client functionality split into focused managers
30
+ - **Dependency Injection**: Tools receive client instances for testability
31
+ - **Single Responsibility**: Each class has one clear purpose
32
+
33
+ ### 2. Type Safety First
34
+
35
+ - **100% TypeScript**: Complete type coverage for all APIs
36
+ - **Strict Mode**: Enabled for maximum type safety
37
+ - **Zod Validation**: Runtime validation matching compile-time types
38
+
39
+ ### 3. Modular Architecture
40
+
41
+ - **Pluggable Tools**: Easy to add new WordPress management tools
42
+ - **Manager System**: Focused, replaceable components
43
+ - **Clean Interfaces**: Well-defined boundaries between layers
44
+
45
+ ### 4. Performance by Design
46
+
47
+ - **Intelligent Caching**: Multi-layer caching with invalidation
48
+ - **Request Optimization**: Batching and deduplication
49
+ - **Resource Management**: Memory and connection pooling
50
+
51
+ ## 🔧 Core Components
52
+
53
+ ### MCP Server (`src/index.ts`)
54
+
55
+ **Purpose**: Main entry point implementing the Model Context Protocol
56
+
57
+ **Key Features**:
58
+
59
+ - Tool registration and discovery
60
+ - Request routing and handling
61
+ - Multi-site configuration support
62
+ - Error handling and logging
63
+
64
+ **Architecture Pattern**: Facade + Factory
65
+
66
+ ```typescript
67
+ class MCPWordPressServer {
68
+ private toolRegistry: ToolRegistry;
69
+ private clients: Map<string, WordPressClient>;
70
+
71
+ constructor(config: Config) {
72
+ this.toolRegistry = new ToolRegistry();
73
+ this.clients = this.initializeClients(config);
74
+ }
75
+ }
76
+ ```
77
+
78
+ ### WordPress Client (`src/client/WordPressClient.ts`)
79
+
80
+ **Purpose**: Primary interface to WordPress REST API
81
+
82
+ **Architecture Pattern**: Composition + Manager Pattern
83
+
84
+ ```typescript
85
+ class WordPressClient {
86
+ private authManager: AuthenticationManager;
87
+ private requestManager: RequestManager;
88
+ private cacheManager: CacheManager;
89
+
90
+ constructor(config: ClientConfig) {
91
+ this.authManager = new AuthenticationManager(config);
92
+ this.requestManager = new RequestManager(config);
93
+ this.cacheManager = new CacheManager(config);
94
+ }
95
+ }
96
+ ```
97
+
98
+ **Manager Responsibilities**:
99
+
100
+ - **AuthenticationManager**: Handle all authentication methods
101
+ - **RequestManager**: HTTP operations, retries, rate limiting
102
+ - **CacheManager**: Intelligent caching with invalidation
103
+
104
+ ### Tool System (`src/tools/`)
105
+
106
+ **Purpose**: WordPress management functionality exposed as MCP tools
107
+
108
+ **Architecture Pattern**: Class-based Tools with Dependency Injection
109
+
110
+ ```typescript
111
+ export class PostTools {
112
+ constructor(private client: WordPressClient) {}
113
+
114
+ async createPost(params: CreatePostParams): Promise<PostResult> {
115
+ return toolWrapper(this.client, 'create_post', params, async () => {
116
+ const validatedParams = createPostSchema.parse(params);
117
+ return await this.client.posts.create(validatedParams);
118
+ });
119
+ }
120
+ }
121
+ ```
122
+
123
+ **Tool Categories**:
124
+
125
+ - **Content Tools**: Posts, Pages, Media (18 tools)
126
+ - **User Management**: Users, Comments (13 tools)
127
+ - **Site Management**: Taxonomies, Settings, Auth (23 tools)
128
+ - **Performance**: Cache, Monitoring (10 tools)
129
+
130
+ ### Performance System (`src/performance/`)
131
+
132
+ **Purpose**: Real-time performance monitoring and optimization
133
+
134
+ **Architecture Pattern**: Observer + Strategy Pattern
135
+
136
+ ```typescript
137
+ class PerformanceMonitor {
138
+ private collectors: MetricsCollector[];
139
+ private analytics: PerformanceAnalytics;
140
+
141
+ collect(metric: Metric): void {
142
+ this.collectors.forEach(collector => collector.collect(metric));
143
+ this.analytics.analyze(metric);
144
+ }
145
+ }
146
+ ```
147
+
148
+ **Components**:
149
+
150
+ - **MetricsCollector**: Gather performance data
151
+ - **PerformanceAnalytics**: Analyze trends and patterns
152
+ - **AlertSystem**: Notify on performance degradation
153
+
154
+ ### Cache System (`src/cache/`)
155
+
156
+ **Purpose**: Intelligent multi-layer caching for performance
157
+
158
+ **Architecture Pattern**: Decorator + Strategy Pattern
159
+
160
+ ```typescript
161
+ class CacheManager {
162
+ private strategies: Map<string, CacheStrategy>;
163
+
164
+ async get<T>(key: string): Promise<T | null> {
165
+ const strategy = this.strategies.get(this.getStrategyKey(key));
166
+ return await strategy.get(key);
167
+ }
168
+ }
169
+ ```
170
+
171
+ **Cache Layers**:
172
+
173
+ - **Memory Cache**: Fast in-memory storage
174
+ - **Site-Specific Cache**: Isolated cache per WordPress site
175
+ - **Invalidation Logic**: Smart cache invalidation on updates
176
+
177
+ ## 🔒 Security Architecture
178
+
179
+ ### Input Validation Pipeline
180
+
181
+ ```text
182
+ User Input → Zod Schema → Sanitization → WordPress API
183
+ ↓ ↓ ↓
184
+ Type Safety SQL Injection XSS Protection
185
+ Prevention
186
+ ```
187
+
188
+ ### Authentication Flow
189
+
190
+ ```text
191
+ Client Request → Auth Manager → WordPress API
192
+ ↓ ↓
193
+ Token Validation Permission Check
194
+ ```
195
+
196
+ **Security Layers**:
197
+
198
+ 1. **Input Validation**: Comprehensive Zod schemas
199
+ 2. **Authentication**: Multiple secure methods
200
+ 3. **Authorization**: WordPress permission system
201
+ 4. **Transport Security**: HTTPS enforcement
202
+ 5. **Rate Limiting**: API abuse prevention
203
+
204
+ ## 🚀 Request Flow
205
+
206
+ ### Standard Tool Execution
207
+
208
+ ```text
209
+ MCP Request → Tool Registry → Tool Class → Client Manager → WordPress API
210
+ ↓ ↓ ↓ ↓
211
+ Validation Parameter Authentication HTTP Request
212
+ Processing
213
+ ```
214
+
215
+ ### Cached Request Flow
216
+
217
+ ```text
218
+ MCP Request → Cache Check → [Cache Hit] → Cached Response
219
+ ↓ ↓
220
+ Cache Miss WordPress API → Cache Store → Response
221
+ ```
222
+
223
+ ## 📊 Data Flow
224
+
225
+ ### Configuration Loading
226
+
227
+ ```text
228
+ Environment Variables → Config Validation → Client Initialization
229
+ Multi-Site Config ↗ ↓
230
+ Tool Registration
231
+ ```
232
+
233
+ ### Error Handling
234
+
235
+ ```text
236
+ Error Occurrence → Error Classification → User-Friendly Message
237
+ ↓ ↓
238
+ Logging System MCP Response
239
+ ```
240
+
241
+ ## 🧪 Testing Architecture
242
+
243
+ ### Test Strategy
244
+
245
+ **Unit Tests**: Individual component testing
246
+
247
+ - Mock external dependencies
248
+ - Test business logic in isolation
249
+ - Focus on edge cases and error conditions
250
+
251
+ **Integration Tests**: Multi-component testing
252
+
253
+ - Real WordPress API connections
254
+ - End-to-end tool functionality
255
+ - Authentication method validation
256
+
257
+ **Contract Tests**: API compatibility testing
258
+
259
+ - WordPress REST API changes
260
+ - MCP protocol compliance
261
+ - Backward compatibility verification
262
+
263
+ ### Test Structure
264
+
265
+ ```text
266
+ tests/
267
+ ├── unit/ # Component isolation tests
268
+ ├── integration/ # Multi-component tests
269
+ ├── security/ # Security validation tests
270
+ ├── performance/ # Performance regression tests
271
+ └── property/ # Property-based tests
272
+ ```
273
+
274
+ ## 🔄 Build & Deployment
275
+
276
+ ### Build Pipeline
277
+
278
+ ```text
279
+ TypeScript Source → Compilation → Bundling → Distribution
280
+ ↓ ↓ ↓
281
+ Type Check Optimization NPM Package
282
+ Docker Image
283
+ ```
284
+
285
+ ### Release Process
286
+
287
+ ```text
288
+ Commit → CI/CD Pipeline → Tests → Security Scan → Publishing
289
+ ↓ ↓ ↓ ↓
290
+ Conventional All Pass Vulnerability NPM + Docker
291
+ Commits Free + GitHub
292
+ ```
293
+
294
+ ## 📈 Performance Optimizations
295
+
296
+ ### Caching Strategy
297
+
298
+ **Multi-Layer Caching**:
299
+
300
+ - **L1 Cache**: In-memory (fastest)
301
+ - **L2 Cache**: Site-specific (isolated)
302
+ - **L3 Cache**: Persistent (cross-session)
303
+
304
+ **Cache Invalidation**:
305
+
306
+ - **Time-based**: TTL expiration
307
+ - **Event-based**: Content update invalidation
308
+ - **Manual**: Administrative cache clearing
309
+
310
+ ### Request Optimization
311
+
312
+ **Batching**: Group related requests
313
+ **Deduplication**: Eliminate duplicate requests
314
+ **Connection Pooling**: Reuse HTTP connections
315
+ **Compression**: Reduce payload size
316
+
317
+ ## 🔮 Extensibility
318
+
319
+ ### Adding New Tools
320
+
321
+ 1. **Create Tool Class**: Follow existing patterns
322
+ 2. **Define Parameters**: Zod schema validation
323
+ 3. **Implement Logic**: Use client managers
324
+ 4. **Add Tests**: Unit and integration tests
325
+ 5. **Register Tool**: Add to tool registry
326
+
327
+ ### Adding New Managers
328
+
329
+ 1. **Extend BaseManager**: Inherit common functionality
330
+ 2. **Implement Interface**: Define manager contract
331
+ 3. **Add to Client**: Compose into main client
332
+ 4. **Test Integration**: Verify with existing tools
333
+
334
+ ### Adding New Authentication
335
+
336
+ 1. **Extend AuthenticationManager**: Add new method
337
+ 2. **Implement Strategy**: Handle auth flow
338
+ 3. **Add Configuration**: Support new config options
339
+ 4. **Test Security**: Validate security properties
340
+
341
+ ## 🔍 Monitoring & Observability
342
+
343
+ ### Metrics Collection
344
+
345
+ **Performance Metrics**:
346
+
347
+ - Request latency and throughput
348
+ - Cache hit rates and efficiency
349
+ - Memory usage and garbage collection
350
+
351
+ **Business Metrics**:
352
+
353
+ - Tool usage patterns
354
+ - Authentication success rates
355
+ - Error rates and types
356
+
357
+ ### Logging Strategy
358
+
359
+ **Structured Logging**: JSON format for parsing
360
+ **Log Levels**: DEBUG, INFO, WARN, ERROR
361
+ **Contextual Information**: Request IDs, user context
362
+ **Security Logging**: Authentication events, suspicious activity
363
+
364
+ ## 📚 Further Reading
365
+
366
+ - **[API Reference](API_REFERENCE.md)** - Complete technical API documentation
367
+ - **[Testing Guide](TESTING.md)** - Test suite and best practices
368
+ - **[Security Guidelines](SECURITY_DEVELOPMENT.md)** - Security best practices
369
+ - **[Performance Guide](PERFORMANCE_DEVELOPMENT.md)** - Performance optimization
370
+
371
+ ---
372
+
373
+ **Understanding the architecture?** This foundation enables the system's reliability, performance,
374
+ and extensibility. Each component is designed to be testable, maintainable, and scalable.