mcp-wordpress 1.1.7 → 1.2.2

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 (255) hide show
  1. package/README.md +388 -66
  2. package/dist/cache/CacheInvalidation.d.ts +118 -0
  3. package/dist/cache/CacheInvalidation.d.ts.map +1 -0
  4. package/dist/cache/CacheInvalidation.js +349 -0
  5. package/dist/cache/CacheInvalidation.js.map +1 -0
  6. package/dist/cache/CacheManager.d.ts +143 -0
  7. package/dist/cache/CacheManager.d.ts.map +1 -0
  8. package/dist/cache/CacheManager.js +308 -0
  9. package/dist/cache/CacheManager.js.map +1 -0
  10. package/dist/cache/HttpCacheWrapper.d.ts +121 -0
  11. package/dist/cache/HttpCacheWrapper.d.ts.map +1 -0
  12. package/dist/cache/HttpCacheWrapper.js +280 -0
  13. package/dist/cache/HttpCacheWrapper.js.map +1 -0
  14. package/dist/cache/__tests__/CacheInvalidation.test.d.ts +5 -0
  15. package/dist/cache/__tests__/CacheInvalidation.test.d.ts.map +1 -0
  16. package/dist/cache/__tests__/CacheInvalidation.test.js +236 -0
  17. package/dist/cache/__tests__/CacheInvalidation.test.js.map +1 -0
  18. package/dist/cache/__tests__/CacheManager.test.d.ts +5 -0
  19. package/dist/cache/__tests__/CacheManager.test.d.ts.map +1 -0
  20. package/dist/cache/__tests__/CacheManager.test.js +233 -0
  21. package/dist/cache/__tests__/CacheManager.test.js.map +1 -0
  22. package/dist/cache/__tests__/CachedWordPressClient.test.d.ts +5 -0
  23. package/dist/cache/__tests__/CachedWordPressClient.test.d.ts.map +1 -0
  24. package/dist/cache/__tests__/CachedWordPressClient.test.js +228 -0
  25. package/dist/cache/__tests__/CachedWordPressClient.test.js.map +1 -0
  26. package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts +5 -0
  27. package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts.map +1 -0
  28. package/dist/cache/__tests__/HttpCacheWrapper.test.js +296 -0
  29. package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +1 -0
  30. package/dist/cache/index.d.ts +12 -0
  31. package/dist/cache/index.d.ts.map +1 -0
  32. package/dist/cache/index.js +9 -0
  33. package/dist/cache/index.js.map +1 -0
  34. package/dist/client/CachedWordPressClient.d.ts +160 -0
  35. package/dist/client/CachedWordPressClient.d.ts.map +1 -0
  36. package/dist/client/CachedWordPressClient.js +338 -0
  37. package/dist/client/CachedWordPressClient.js.map +1 -0
  38. package/dist/client/WordPressClient.d.ts +81 -0
  39. package/dist/client/WordPressClient.d.ts.map +1 -0
  40. package/dist/client/WordPressClient.js +354 -0
  41. package/dist/client/WordPressClient.js.map +1 -0
  42. package/dist/config/ConfigurationSchema.d.ts +281 -0
  43. package/dist/config/ConfigurationSchema.d.ts.map +1 -0
  44. package/dist/config/ConfigurationSchema.js +205 -0
  45. package/dist/config/ConfigurationSchema.js.map +1 -0
  46. package/dist/config/ServerConfiguration.d.ts +38 -0
  47. package/dist/config/ServerConfiguration.d.ts.map +1 -0
  48. package/dist/config/ServerConfiguration.js +158 -0
  49. package/dist/config/ServerConfiguration.js.map +1 -0
  50. package/dist/docs/DocumentationGenerator.d.ts +184 -0
  51. package/dist/docs/DocumentationGenerator.d.ts.map +1 -0
  52. package/dist/docs/DocumentationGenerator.js +735 -0
  53. package/dist/docs/DocumentationGenerator.js.map +1 -0
  54. package/dist/docs/MarkdownFormatter.d.ts +84 -0
  55. package/dist/docs/MarkdownFormatter.d.ts.map +1 -0
  56. package/dist/docs/MarkdownFormatter.js +448 -0
  57. package/dist/docs/MarkdownFormatter.js.map +1 -0
  58. package/dist/docs/index.d.ts +8 -0
  59. package/dist/docs/index.d.ts.map +1 -0
  60. package/dist/docs/index.js +7 -0
  61. package/dist/docs/index.js.map +1 -0
  62. package/dist/index.d.ts +1 -4
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +12 -212
  65. package/dist/index.js.map +1 -1
  66. package/dist/performance/AnomalyDetector.d.ts +63 -0
  67. package/dist/performance/AnomalyDetector.d.ts.map +1 -0
  68. package/dist/performance/AnomalyDetector.js +222 -0
  69. package/dist/performance/AnomalyDetector.js.map +1 -0
  70. package/dist/performance/BenchmarkAnalyzer.d.ts +67 -0
  71. package/dist/performance/BenchmarkAnalyzer.d.ts.map +1 -0
  72. package/dist/performance/BenchmarkAnalyzer.js +301 -0
  73. package/dist/performance/BenchmarkAnalyzer.js.map +1 -0
  74. package/dist/performance/MetricsCollector.d.ts +139 -0
  75. package/dist/performance/MetricsCollector.d.ts.map +1 -0
  76. package/dist/performance/MetricsCollector.js +320 -0
  77. package/dist/performance/MetricsCollector.js.map +1 -0
  78. package/dist/performance/PerformanceAnalytics.d.ts +162 -0
  79. package/dist/performance/PerformanceAnalytics.d.ts.map +1 -0
  80. package/dist/performance/PerformanceAnalytics.js +554 -0
  81. package/dist/performance/PerformanceAnalytics.js.map +1 -0
  82. package/dist/performance/PerformanceMonitor.d.ts +202 -0
  83. package/dist/performance/PerformanceMonitor.d.ts.map +1 -0
  84. package/dist/performance/PerformanceMonitor.js +478 -0
  85. package/dist/performance/PerformanceMonitor.js.map +1 -0
  86. package/dist/performance/TrendAnalyzer.d.ts +69 -0
  87. package/dist/performance/TrendAnalyzer.d.ts.map +1 -0
  88. package/dist/performance/TrendAnalyzer.js +203 -0
  89. package/dist/performance/TrendAnalyzer.js.map +1 -0
  90. package/dist/performance/index.d.ts +11 -0
  91. package/dist/performance/index.d.ts.map +1 -0
  92. package/dist/performance/index.js +8 -0
  93. package/dist/performance/index.js.map +1 -0
  94. package/dist/security/InputValidator.d.ts +215 -0
  95. package/dist/security/InputValidator.d.ts.map +1 -0
  96. package/dist/security/InputValidator.js +278 -0
  97. package/dist/security/InputValidator.js.map +1 -0
  98. package/dist/security/SecurityConfig.d.ts +129 -0
  99. package/dist/security/SecurityConfig.d.ts.map +1 -0
  100. package/dist/security/SecurityConfig.js +262 -0
  101. package/dist/security/SecurityConfig.js.map +1 -0
  102. package/dist/server/ConnectionTester.d.ts +24 -0
  103. package/dist/server/ConnectionTester.d.ts.map +1 -0
  104. package/dist/server/ConnectionTester.js +61 -0
  105. package/dist/server/ConnectionTester.js.map +1 -0
  106. package/dist/server/ToolRegistry.d.ts +46 -0
  107. package/dist/server/ToolRegistry.d.ts.map +1 -0
  108. package/dist/server/ToolRegistry.js +148 -0
  109. package/dist/server/ToolRegistry.js.map +1 -0
  110. package/dist/tools/BaseToolClass.d.ts +76 -0
  111. package/dist/tools/BaseToolClass.d.ts.map +1 -0
  112. package/dist/tools/BaseToolClass.js +104 -0
  113. package/dist/tools/BaseToolClass.js.map +1 -0
  114. package/dist/tools/BaseToolManager.d.ts +26 -0
  115. package/dist/tools/BaseToolManager.d.ts.map +1 -0
  116. package/dist/tools/BaseToolManager.js +56 -0
  117. package/dist/tools/BaseToolManager.js.map +1 -0
  118. package/dist/tools/base.d.ts +37 -0
  119. package/dist/tools/base.d.ts.map +1 -0
  120. package/dist/tools/base.js +60 -0
  121. package/dist/tools/base.js.map +1 -0
  122. package/dist/tools/cache.d.ts +260 -0
  123. package/dist/tools/cache.d.ts.map +1 -0
  124. package/dist/tools/cache.js +237 -0
  125. package/dist/tools/cache.js.map +1 -0
  126. package/dist/tools/index.d.ts +2 -0
  127. package/dist/tools/index.d.ts.map +1 -1
  128. package/dist/tools/index.js +2 -0
  129. package/dist/tools/index.js.map +1 -1
  130. package/dist/tools/performance.d.ts +63 -0
  131. package/dist/tools/performance.d.ts.map +1 -0
  132. package/dist/tools/performance.js +865 -0
  133. package/dist/tools/performance.js.map +1 -0
  134. package/dist/types/client.d.ts +1 -0
  135. package/dist/types/client.d.ts.map +1 -1
  136. package/dist/types/client.js.map +1 -1
  137. package/dist/utils/toolWrapper.d.ts +4 -0
  138. package/dist/utils/toolWrapper.d.ts.map +1 -1
  139. package/dist/utils/toolWrapper.js +11 -0
  140. package/dist/utils/toolWrapper.js.map +1 -1
  141. package/dist/utils/validation.d.ts +68 -0
  142. package/dist/utils/validation.d.ts.map +1 -0
  143. package/dist/utils/validation.js +185 -0
  144. package/dist/utils/validation.js.map +1 -0
  145. package/docs/CACHING.md +340 -0
  146. package/docs/DOCKER.md +451 -0
  147. package/docs/PERFORMANCE_MONITORING.md +471 -0
  148. package/docs/SECURITY_TESTING.md +393 -0
  149. package/docs/api/README.md +200 -0
  150. package/docs/api/categories/auth.md +40 -0
  151. package/docs/api/categories/cache.md +41 -0
  152. package/docs/api/categories/comment.md +44 -0
  153. package/docs/api/categories/media.md +43 -0
  154. package/docs/api/categories/page.md +43 -0
  155. package/docs/api/categories/performance.md +44 -0
  156. package/docs/api/categories/post.md +43 -0
  157. package/docs/api/categories/site.md +43 -0
  158. package/docs/api/categories/taxonomy.md +47 -0
  159. package/docs/api/categories/user.md +43 -0
  160. package/docs/api/openapi.json +3305 -0
  161. package/docs/api/summary.json +12 -0
  162. package/docs/api/tools/wp_approve_comment.md +98 -0
  163. package/docs/api/tools/wp_cache_clear.md +120 -0
  164. package/docs/api/tools/wp_cache_info.md +119 -0
  165. package/docs/api/tools/wp_cache_stats.md +119 -0
  166. package/docs/api/tools/wp_cache_warm.md +119 -0
  167. package/docs/api/tools/wp_create_application_password.md +102 -0
  168. package/docs/api/tools/wp_create_category.md +102 -0
  169. package/docs/api/tools/wp_create_comment.md +128 -0
  170. package/docs/api/tools/wp_create_page.md +135 -0
  171. package/docs/api/tools/wp_create_post.md +147 -0
  172. package/docs/api/tools/wp_create_tag.md +101 -0
  173. package/docs/api/tools/wp_create_user.md +135 -0
  174. package/docs/api/tools/wp_delete_application_password.md +101 -0
  175. package/docs/api/tools/wp_delete_category.md +100 -0
  176. package/docs/api/tools/wp_delete_comment.md +101 -0
  177. package/docs/api/tools/wp_delete_media.md +108 -0
  178. package/docs/api/tools/wp_delete_page.md +108 -0
  179. package/docs/api/tools/wp_delete_post.md +117 -0
  180. package/docs/api/tools/wp_delete_tag.md +100 -0
  181. package/docs/api/tools/wp_delete_user.md +108 -0
  182. package/docs/api/tools/wp_get_application_passwords.md +103 -0
  183. package/docs/api/tools/wp_get_auth_status.md +101 -0
  184. package/docs/api/tools/wp_get_category.md +103 -0
  185. package/docs/api/tools/wp_get_comment.md +103 -0
  186. package/docs/api/tools/wp_get_current_user.md +101 -0
  187. package/docs/api/tools/wp_get_media.md +103 -0
  188. package/docs/api/tools/wp_get_page.md +103 -0
  189. package/docs/api/tools/wp_get_page_revisions.md +103 -0
  190. package/docs/api/tools/wp_get_post.md +112 -0
  191. package/docs/api/tools/wp_get_post_revisions.md +103 -0
  192. package/docs/api/tools/wp_get_site_settings.md +108 -0
  193. package/docs/api/tools/wp_get_tag.md +103 -0
  194. package/docs/api/tools/wp_get_user.md +103 -0
  195. package/docs/api/tools/wp_list_categories.md +111 -0
  196. package/docs/api/tools/wp_list_comments.md +111 -0
  197. package/docs/api/tools/wp_list_media.md +145 -0
  198. package/docs/api/tools/wp_list_pages.md +145 -0
  199. package/docs/api/tools/wp_list_posts.md +156 -0
  200. package/docs/api/tools/wp_list_tags.md +110 -0
  201. package/docs/api/tools/wp_list_users.md +111 -0
  202. package/docs/api/tools/wp_performance_alerts.md +162 -0
  203. package/docs/api/tools/wp_performance_benchmark.md +160 -0
  204. package/docs/api/tools/wp_performance_export.md +162 -0
  205. package/docs/api/tools/wp_performance_history.md +161 -0
  206. package/docs/api/tools/wp_performance_optimize.md +162 -0
  207. package/docs/api/tools/wp_performance_stats.md +160 -0
  208. package/docs/api/tools/wp_search_site.md +99 -0
  209. package/docs/api/tools/wp_spam_comment.md +98 -0
  210. package/docs/api/tools/wp_switch_auth_method.md +122 -0
  211. package/docs/api/tools/wp_test_auth.md +96 -0
  212. package/docs/api/tools/wp_update_category.md +102 -0
  213. package/docs/api/tools/wp_update_comment.md +127 -0
  214. package/docs/api/tools/wp_update_media.md +129 -0
  215. package/docs/api/tools/wp_update_page.md +135 -0
  216. package/docs/api/tools/wp_update_post.md +144 -0
  217. package/docs/api/tools/wp_update_site_settings.md +127 -0
  218. package/docs/api/tools/wp_update_tag.md +102 -0
  219. package/docs/api/tools/wp_update_user.md +134 -0
  220. package/docs/api/tools/wp_upload_media.md +131 -0
  221. package/docs/api/types/WordPressPost.md +39 -0
  222. package/docs/contract-testing.md +183 -0
  223. package/docs/developer/NPM_AUTH_SETUP.md +3 -3
  224. package/docs/wordpress-rest-api-authentication-troubleshooting.md +218 -0
  225. package/package.json +84 -64
  226. package/src/cache/CacheInvalidation.ts +421 -0
  227. package/src/cache/CacheManager.ts +391 -0
  228. package/src/cache/HttpCacheWrapper.ts +372 -0
  229. package/src/cache/__tests__/CacheInvalidation.test.ts +299 -0
  230. package/src/cache/__tests__/CacheManager.test.ts +300 -0
  231. package/src/cache/__tests__/CachedWordPressClient.test.ts +304 -0
  232. package/src/cache/__tests__/HttpCacheWrapper.test.ts +359 -0
  233. package/src/cache/index.ts +26 -0
  234. package/src/client/CachedWordPressClient.ts +442 -0
  235. package/src/config/ConfigurationSchema.ts +246 -0
  236. package/src/config/ServerConfiguration.ts +215 -0
  237. package/src/docs/DocumentationGenerator.ts +952 -0
  238. package/src/docs/MarkdownFormatter.ts +494 -0
  239. package/src/docs/index.ts +21 -0
  240. package/src/index.ts +14 -274
  241. package/src/performance/MetricsCollector.ts +447 -0
  242. package/src/performance/PerformanceAnalytics.ts +762 -0
  243. package/src/performance/PerformanceMonitor.ts +649 -0
  244. package/src/performance/index.ts +28 -0
  245. package/src/security/InputValidator.ts +319 -0
  246. package/src/security/SecurityConfig.ts +301 -0
  247. package/src/server/ConnectionTester.ts +74 -0
  248. package/src/server/ToolRegistry.ts +194 -0
  249. package/src/tools/BaseToolManager.ts +66 -0
  250. package/src/tools/cache.ts +259 -0
  251. package/src/tools/index.ts +2 -0
  252. package/src/tools/performance.ts +948 -0
  253. package/src/types/client.ts +1 -0
  254. package/src/utils/toolWrapper.ts +11 -0
  255. package/src/utils/validation.ts +259 -0
@@ -0,0 +1,393 @@
1
+ # Security Testing Guide
2
+
3
+ ![Security](https://img.shields.io/badge/security-hardened-brightgreen)
4
+ ![Testing](https://img.shields.io/badge/testing-comprehensive-blue)
5
+ ![Validation](https://img.shields.io/badge/validation-strict-orange)
6
+
7
+ This guide covers the comprehensive security testing and validation framework implemented in the MCP WordPress Server.
8
+
9
+ ## 🔒 Security Framework Overview
10
+
11
+ ### Core Security Components
12
+
13
+ 1. **Input Validation** (`src/security/InputValidator.ts`)
14
+ - Zod-based schema validation
15
+ - XSS protection patterns
16
+ - SQL injection prevention
17
+ - Path traversal protection
18
+
19
+ 2. **Rate Limiting** (`SecurityLimiter` class)
20
+ - Request throttling per user/IP
21
+ - DoS attack prevention
22
+ - Automatic cleanup of expired entries
23
+
24
+ 3. **Input Sanitization** (`InputSanitizer` class)
25
+ - HTML content sanitization
26
+ - Search query cleaning
27
+ - File path normalization
28
+ - Output encoding for safe display
29
+
30
+ 4. **Security Testing** (`tests/security/`)
31
+ - Comprehensive vulnerability tests
32
+ - Penetration testing scenarios
33
+ - Edge case validation
34
+
35
+ ## 🛡️ Validation Schemas
36
+
37
+ ### Core Security Schemas
38
+
39
+ ```typescript
40
+ // Safe string validation (XSS protection)
41
+ SecuritySchemas.safeString
42
+ .max(10000)
43
+ .refine(val => !SCRIPT_PATTERN.test(val))
44
+ .refine(val => !val.includes('javascript:'))
45
+
46
+ // URL validation
47
+ SecuritySchemas.url
48
+ .url()
49
+ .regex(URL_PATTERN)
50
+ .refine(val => !val.includes('javascript:'))
51
+
52
+ // Search query validation (SQL injection protection)
53
+ SecuritySchemas.searchQuery
54
+ .max(500)
55
+ .refine(val => !SQL_INJECTION_PATTERN.test(val))
56
+ .refine(val => !val.includes('--'))
57
+ ```
58
+
59
+ ### Tool-Specific Schemas
60
+
61
+ ```typescript
62
+ // Post creation validation
63
+ ToolSchemas.postData = z.object({
64
+ site: SecuritySchemas.siteId.optional(),
65
+ title: SecuritySchemas.safeString.optional(),
66
+ content: SecuritySchemas.wpContent.optional(),
67
+ status: z.enum(['publish', 'draft', 'private', 'pending']).optional()
68
+ });
69
+
70
+ // User management validation
71
+ ToolSchemas.userData = z.object({
72
+ username: SecuritySchemas.slug,
73
+ email: SecuritySchemas.email,
74
+ password: SecuritySchemas.safeString.optional()
75
+ });
76
+ ```
77
+
78
+ ## 🧪 Security Tests
79
+
80
+ ### 1. XSS Protection Tests
81
+
82
+ ```bash
83
+ npm test tests/security/security-validation.test.js -- --grep "XSS"
84
+ ```
85
+
86
+ **Covered Attack Vectors:**
87
+ - Script tag injection
88
+ - Event handler injection
89
+ - JavaScript URL schemes
90
+ - Data URL schemes
91
+ - HTML entity encoding
92
+
93
+ **Example Test:**
94
+ ```javascript
95
+ test('should reject script tags in safe strings', () => {
96
+ const maliciousInput = 'Hello <script>alert("XSS")</script> World';
97
+ expect(() => SecuritySchemas.safeString.parse(maliciousInput)).toThrow();
98
+ });
99
+ ```
100
+
101
+ ### 2. SQL Injection Protection Tests
102
+
103
+ ```bash
104
+ npm test tests/security/security-validation.test.js -- --grep "SQL"
105
+ ```
106
+
107
+ **Covered Attack Vectors:**
108
+ - Union-based injection
109
+ - Boolean-based blind injection
110
+ - Time-based blind injection
111
+ - Error-based injection
112
+ - Comment-based injection
113
+
114
+ **Example Test:**
115
+ ```javascript
116
+ test('should reject SQL injection patterns', () => {
117
+ const maliciousQueries = [
118
+ "'; DROP TABLE wp_posts; --",
119
+ "1' OR '1'='1",
120
+ "admin'--"
121
+ ];
122
+
123
+ maliciousQueries.forEach(query => {
124
+ expect(() => SecuritySchemas.searchQuery.parse(query)).toThrow();
125
+ });
126
+ });
127
+ ```
128
+
129
+ ### 3. Path Traversal Protection Tests
130
+
131
+ ```bash
132
+ npm test tests/security/security-validation.test.js -- --grep "Path"
133
+ ```
134
+
135
+ **Covered Attack Vectors:**
136
+ - Directory traversal (../)
137
+ - Encoded path traversal
138
+ - Windows path traversal (..\\)
139
+ - Absolute path injection
140
+
141
+ ### 4. Penetration Testing Suite
142
+
143
+ ```bash
144
+ npm test tests/security/penetration-tests.test.js
145
+ ```
146
+
147
+ **Comprehensive Attack Simulation:**
148
+ - Command injection attempts
149
+ - Authentication bypass
150
+ - Header injection
151
+ - Rate limiting bypass
152
+ - Large payload attacks
153
+
154
+ ## 🔧 Implementation Guide
155
+
156
+ ### Adding Security to New Tools
157
+
158
+ 1. **Import Security Framework:**
159
+ ```typescript
160
+ import { validateSecurity, ToolSchemas } from '../security/InputValidator.js';
161
+ ```
162
+
163
+ 2. **Apply Validation Decorator:**
164
+ ```typescript
165
+ export class MyTools {
166
+ @validateSecurity(ToolSchemas.postData)
167
+ async createPost(params: any): Promise<any> {
168
+ // Tool implementation
169
+ }
170
+ }
171
+ ```
172
+
173
+ 3. **Custom Validation Schema:**
174
+ ```typescript
175
+ const customSchema = z.object({
176
+ customField: SecuritySchemas.safeString,
177
+ numericField: SecuritySchemas.wpId
178
+ });
179
+
180
+ @validateSecurity(customSchema)
181
+ async customTool(params: any) {
182
+ // Implementation
183
+ }
184
+ ```
185
+
186
+ ### Manual Input Sanitization
187
+
188
+ ```typescript
189
+ import { InputSanitizer } from '../security/InputValidator.js';
190
+
191
+ // Sanitize HTML content
192
+ const safeHtml = InputSanitizer.sanitizeHtml(userInput);
193
+
194
+ // Sanitize search queries
195
+ const safeQuery = InputSanitizer.sanitizeSearchQuery(searchInput);
196
+
197
+ // Encode output for display
198
+ const safeOutput = InputSanitizer.encodeOutput(userContent);
199
+ ```
200
+
201
+ ### Rate Limiting Integration
202
+
203
+ ```typescript
204
+ import { SecurityLimiter } from '../security/InputValidator.js';
205
+
206
+ async function toolMethod(params: any) {
207
+ const userId = params.userId || 'anonymous';
208
+
209
+ if (!SecurityLimiter.checkRateLimit(userId)) {
210
+ throw new Error('Rate limit exceeded. Please try again later.');
211
+ }
212
+
213
+ // Continue with tool logic
214
+ }
215
+ ```
216
+
217
+ ## 🚨 Security Testing Commands
218
+
219
+ ### Run All Security Tests
220
+ ```bash
221
+ npm run test:security
222
+ ```
223
+
224
+ ### Run Specific Security Test Categories
225
+ ```bash
226
+ # Input validation tests
227
+ npm test tests/security/security-validation.test.js
228
+
229
+ # Penetration testing
230
+ npm test tests/security/penetration-tests.test.js
231
+
232
+ # XSS protection only
233
+ npm test -- --grep "XSS"
234
+
235
+ # SQL injection protection only
236
+ npm test -- --grep "SQL"
237
+ ```
238
+
239
+ ### Security Test Coverage
240
+ ```bash
241
+ npm run test:coverage -- tests/security/
242
+ ```
243
+
244
+ ## 📊 Security Monitoring
245
+
246
+ ### Error Logging
247
+ Security validation errors are automatically logged:
248
+
249
+ ```typescript
250
+ {
251
+ timestamp: "2024-01-01T00:00:00.000Z",
252
+ level: "error",
253
+ method: "wp_create_post",
254
+ error: "Security validation failed",
255
+ details: {
256
+ field: "title",
257
+ violation: "Script tags not allowed"
258
+ }
259
+ }
260
+ ```
261
+
262
+ ### Rate Limiting Monitoring
263
+ ```typescript
264
+ {
265
+ timestamp: "2024-01-01T00:00:00.000Z",
266
+ level: "warning",
267
+ event: "rate_limit_exceeded",
268
+ userId: "user123",
269
+ requestCount: 1001,
270
+ windowMs: 60000
271
+ }
272
+ ```
273
+
274
+ ## 🔍 Security Audit Checklist
275
+
276
+ ### ✅ Input Validation
277
+ - [ ] All user inputs validated with Zod schemas
278
+ - [ ] XSS protection on all text fields
279
+ - [ ] SQL injection protection on search/query fields
280
+ - [ ] Path traversal protection on file operations
281
+ - [ ] Length limits enforced on all inputs
282
+
283
+ ### ✅ Output Encoding
284
+ - [ ] HTML entities encoded in output
285
+ - [ ] JSON responses properly escaped
286
+ - [ ] Error messages sanitized
287
+ - [ ] Log entries do not contain sensitive data
288
+
289
+ ### ✅ Authentication & Authorization
290
+ - [ ] Rate limiting implemented
291
+ - [ ] Secure password handling
292
+ - [ ] Session management (if applicable)
293
+ - [ ] Permission checks on all operations
294
+
295
+ ### ✅ Error Handling
296
+ - [ ] Sensitive information not exposed in errors
297
+ - [ ] Consistent error response format
298
+ - [ ] Proper logging without data leakage
299
+ - [ ] Graceful handling of edge cases
300
+
301
+ ### ✅ File Operations
302
+ - [ ] Upload restrictions enforced
303
+ - [ ] File type validation
304
+ - [ ] Size limits implemented
305
+ - [ ] Path sanitization applied
306
+
307
+ ## 🛠️ Security Tools Integration
308
+
309
+ ### ESLint Security Rules
310
+ ```javascript
311
+ {
312
+ "extends": ["plugin:security/recommended"],
313
+ "rules": {
314
+ "security/detect-sql-injection": "error",
315
+ "security/detect-unsafe-regex": "error",
316
+ "security/detect-buffer-noassert": "error"
317
+ }
318
+ }
319
+ ```
320
+
321
+ ### Automated Security Scanning
322
+ ```bash
323
+ # Add to package.json
324
+ {
325
+ "scripts": {
326
+ "security:audit": "npm audit --production",
327
+ "security:scan": "node scripts/security-check.js",
328
+ "security:fix": "npm audit fix"
329
+ }
330
+ }
331
+ ```
332
+
333
+ ### CI/CD Security Pipeline
334
+ ```yaml
335
+ # GitHub Actions workflow
336
+ - name: Security Audit
337
+ run: |
338
+ npm audit --audit-level moderate
339
+ npm run test:security
340
+ npm run security:scan
341
+ ```
342
+
343
+ ## 📚 Best Practices
344
+
345
+ ### Input Validation Best Practices
346
+ 1. **Validate Early**: Check inputs at the entry point
347
+ 2. **Use Allow Lists**: Define what is allowed, not what is blocked
348
+ 3. **Sanitize and Validate**: Both sanitize and validate inputs
349
+ 4. **Fail Securely**: Default to rejecting invalid input
350
+
351
+ ### Error Handling Best Practices
352
+ 1. **Generic Error Messages**: Don't expose implementation details
353
+ 2. **Log Detailed Errors**: Log full details for debugging (securely)
354
+ 3. **Rate Limit Errors**: Prevent information gathering
355
+ 4. **Sanitize Stack Traces**: Remove sensitive information
356
+
357
+ ### Security Testing Best Practices
358
+ 1. **Test All Input Vectors**: Every parameter that accepts user input
359
+ 2. **Use Real Attack Payloads**: Test with actual malicious inputs
360
+ 3. **Automate Security Tests**: Include in CI/CD pipeline
361
+ 4. **Regular Security Reviews**: Periodic manual code reviews
362
+
363
+ ## 🚀 Continuous Security
364
+
365
+ ### Regular Security Updates
366
+ - Monthly dependency audits
367
+ - Quarterly penetration testing
368
+ - Annual security architecture review
369
+ - Continuous monitoring and alerting
370
+
371
+ ### Security Metrics
372
+ - Number of blocked malicious requests
373
+ - Rate limiting effectiveness
374
+ - Input validation error rates
375
+ - Security test coverage percentage
376
+
377
+ ## 📞 Security Incident Response
378
+
379
+ ### If You Discover a Vulnerability
380
+ 1. **Do Not** create a public issue
381
+ 2. **Do** email security concerns privately
382
+ 3. **Include** steps to reproduce
383
+ 4. **Provide** impact assessment if possible
384
+
385
+ ### Response Timeline
386
+ - **24 hours**: Initial acknowledgment
387
+ - **72 hours**: Preliminary assessment
388
+ - **7 days**: Fix development and testing
389
+ - **14 days**: Patched release and disclosure
390
+
391
+ ---
392
+
393
+ **🔒 Security is a shared responsibility - implement, test, and monitor continuously!**
@@ -0,0 +1,200 @@
1
+ # WordPress MCP Server - API Documentation
2
+
3
+ ![Version](https://img.shields.io/badge/version-1.2.0-blue)
4
+ ![Tools](https://img.shields.io/badge/tools-60+-green)
5
+ ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
6
+ ![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue)
7
+ ![License](https://img.shields.io/badge/license-MIT-blue)
8
+
9
+
10
+ ## Overview
11
+
12
+ The WordPress MCP Server provides **59 tools** across **10 categories** for comprehensive WordPress management through the Model Context Protocol.
13
+
14
+ **Last Updated:** 30.6.2025
15
+ **Version:** 1.2.0
16
+ **Coverage:** 59/59 tools with examples
17
+
18
+ ## Quick Start
19
+
20
+ ### Basic Usage
21
+ ```bash
22
+ # List all posts
23
+ wp_list_posts
24
+
25
+ # Get specific post
26
+ wp_get_post --id=123
27
+
28
+ # Create new post
29
+ wp_create_post --title="My Post" --content="Post content"
30
+ ```
31
+
32
+ ### Multi-Site Usage
33
+ ```bash
34
+ # Target specific site
35
+ wp_list_posts --site=site1
36
+
37
+ # Use with different authentication
38
+ wp_get_site_settings --site=production
39
+ ```
40
+
41
+ ## Tool Categories
42
+
43
+ | Category | Tools | Description |
44
+ |----------|-------|-------------|
45
+ | [comment](./categories/comment.md) | 7 | comment management tools |
46
+ | [cache](./categories/cache.md) | 4 | Performance caching and optimization tools |
47
+ | [site](./categories/site.md) | 6 | Site settings and configuration tools |
48
+ | [taxonomy](./categories/taxonomy.md) | 10 | taxonomy management tools |
49
+ | [page](./categories/page.md) | 6 | page management tools |
50
+ | [post](./categories/post.md) | 6 | post management tools |
51
+ | [user](./categories/user.md) | 6 | user management tools |
52
+ | [media](./categories/media.md) | 5 | File upload, management, and media library tools |
53
+ | [auth](./categories/auth.md) | 3 | Authentication testing and management tools |
54
+ | [performance](./categories/performance.md) | 6 | Performance monitoring and analytics tools |
55
+
56
+ ## Available Tools
57
+
58
+ | Tool | Category | Description |
59
+ |------|----------|-------------|
60
+ | [`wp_approve_comment`](./tools/wp_approve_comment.md) | comment | Approves a pending comment. |
61
+ | [`wp_cache_clear`](./tools/wp_cache_clear.md) | cache | Clear cache for a WordPress site. |
62
+ | [`wp_cache_info`](./tools/wp_cache_info.md) | cache | Get detailed cache configuration and status information. |
63
+ | [`wp_cache_stats`](./tools/wp_cache_stats.md) | cache | Get cache statistics for a WordPress site. |
64
+ | [`wp_cache_warm`](./tools/wp_cache_warm.md) | cache | Pre-warm cache with essential WordPress data. |
65
+ | [`wp_create_application_password`](./tools/wp_create_application_password.md) | site | Creates a new application password for a user. |
66
+ | [`wp_create_category`](./tools/wp_create_category.md) | taxonomy | Creates a new category. |
67
+ | [`wp_create_comment`](./tools/wp_create_comment.md) | comment | Creates a new comment on a post. |
68
+ | [`wp_create_page`](./tools/wp_create_page.md) | page | Creates a new page. |
69
+ | [`wp_create_post`](./tools/wp_create_post.md) | post | Creates a new post. |
70
+ | [`wp_create_tag`](./tools/wp_create_tag.md) | taxonomy | Creates a new tag. |
71
+ | [`wp_create_user`](./tools/wp_create_user.md) | user | Creates a new user. |
72
+ | [`wp_delete_application_password`](./tools/wp_delete_application_password.md) | site | Revokes an existing application password. |
73
+ | [`wp_delete_category`](./tools/wp_delete_category.md) | taxonomy | Deletes a category. |
74
+ | [`wp_delete_comment`](./tools/wp_delete_comment.md) | comment | Deletes a comment. |
75
+ | [`wp_delete_media`](./tools/wp_delete_media.md) | media | Deletes a media item. |
76
+ | [`wp_delete_page`](./tools/wp_delete_page.md) | page | Deletes a page. |
77
+ | [`wp_delete_post`](./tools/wp_delete_post.md) | post | Deletes a post. |
78
+ | [`wp_delete_tag`](./tools/wp_delete_tag.md) | taxonomy | Deletes a tag. |
79
+ | [`wp_delete_user`](./tools/wp_delete_user.md) | user | Deletes a user. |
80
+ | [`wp_get_application_passwords`](./tools/wp_get_application_passwords.md) | site | Lists application passwords for a specific user. |
81
+ | [`wp_get_auth_status`](./tools/wp_get_auth_status.md) | auth | Gets the current authentication status for a configured WordPress site. |
82
+ | [`wp_get_category`](./tools/wp_get_category.md) | taxonomy | Retrieves a single category by its ID. |
83
+ | [`wp_get_comment`](./tools/wp_get_comment.md) | comment | Retrieves a single comment by its ID. |
84
+ | [`wp_get_current_user`](./tools/wp_get_current_user.md) | user | Retrieves the currently authenticated user. |
85
+ | [`wp_get_media`](./tools/wp_get_media.md) | media | Retrieves a single media item by its ID. |
86
+ | [`wp_get_page`](./tools/wp_get_page.md) | page | Retrieves a single page by its ID. |
87
+ | [`wp_get_page_revisions`](./tools/wp_get_page_revisions.md) | page | Retrieves revisions for a specific page. |
88
+ | [`wp_get_post`](./tools/wp_get_post.md) | post | Retrieves a single post by its ID. |
89
+ | [`wp_get_post_revisions`](./tools/wp_get_post_revisions.md) | post | Retrieves revisions for a specific post. |
90
+ | [`wp_get_site_settings`](./tools/wp_get_site_settings.md) | site | Retrieves the general settings for a WordPress site. |
91
+ | [`wp_get_tag`](./tools/wp_get_tag.md) | taxonomy | Retrieves a single tag by its ID. |
92
+ | [`wp_get_user`](./tools/wp_get_user.md) | user | Retrieves a single user by their ID. |
93
+ | [`wp_list_categories`](./tools/wp_list_categories.md) | taxonomy | Lists categories from a WordPress site. |
94
+ | [`wp_list_comments`](./tools/wp_list_comments.md) | comment | Lists comments from a WordPress site, with filters. |
95
+ | [`wp_list_media`](./tools/wp_list_media.md) | media | Lists media items from a WordPress site, with filters. |
96
+ | [`wp_list_pages`](./tools/wp_list_pages.md) | page | Lists pages from a WordPress site, with filters. |
97
+ | [`wp_list_posts`](./tools/wp_list_posts.md) | post | Lists posts from a WordPress site, with filters. |
98
+ | [`wp_list_tags`](./tools/wp_list_tags.md) | taxonomy | Lists tags from a WordPress site. |
99
+ | [`wp_list_users`](./tools/wp_list_users.md) | user | Lists users from a WordPress site, with filters. |
100
+ | [`wp_performance_alerts`](./tools/wp_performance_alerts.md) | performance | Get performance alerts and anomaly detection results |
101
+ | [`wp_performance_benchmark`](./tools/wp_performance_benchmark.md) | performance | Compare current performance against industry benchmarks |
102
+ | [`wp_performance_export`](./tools/wp_performance_export.md) | performance | Export comprehensive performance report |
103
+ | [`wp_performance_history`](./tools/wp_performance_history.md) | performance | Get historical performance data and trends |
104
+ | [`wp_performance_optimize`](./tools/wp_performance_optimize.md) | performance | Get optimization recommendations and insights |
105
+ | [`wp_performance_stats`](./tools/wp_performance_stats.md) | performance | Get real-time performance statistics and metrics |
106
+ | [`wp_search_site`](./tools/wp_search_site.md) | site | Performs a site-wide search for content. |
107
+ | [`wp_spam_comment`](./tools/wp_spam_comment.md) | comment | Marks a comment as spam. |
108
+ | [`wp_switch_auth_method`](./tools/wp_switch_auth_method.md) | auth | Switches the authentication method for a site for the current session. |
109
+ | [`wp_test_auth`](./tools/wp_test_auth.md) | auth | Tests the authentication and connectivity for a configured WordPress site. |
110
+ | [`wp_update_category`](./tools/wp_update_category.md) | taxonomy | Updates an existing category. |
111
+ | [`wp_update_comment`](./tools/wp_update_comment.md) | comment | Updates an existing comment. |
112
+ | [`wp_update_media`](./tools/wp_update_media.md) | media | Updates the metadata of an existing media item. |
113
+ | [`wp_update_page`](./tools/wp_update_page.md) | page | Updates an existing page. |
114
+ | [`wp_update_post`](./tools/wp_update_post.md) | post | Updates an existing post. |
115
+ | [`wp_update_site_settings`](./tools/wp_update_site_settings.md) | site | Updates one or more general settings for a WordPress site. |
116
+ | [`wp_update_tag`](./tools/wp_update_tag.md) | taxonomy | Updates an existing tag. |
117
+ | [`wp_update_user`](./tools/wp_update_user.md) | user | Updates an existing user. |
118
+ | [`wp_upload_media`](./tools/wp_upload_media.md) | media | Uploads a file to the WordPress media library. |
119
+
120
+ ## Authentication
121
+
122
+ All tools support multiple authentication methods:
123
+ - **Application Passwords** (recommended)
124
+ - **JWT Authentication**
125
+ - **Basic Authentication** (development only)
126
+ - **API Key Authentication**
127
+
128
+ ## Error Handling
129
+
130
+ Standard error response format:
131
+ ```json
132
+ {
133
+ "error": "Error type",
134
+ "message": "Human-readable error message",
135
+ "code": "ERROR_CODE",
136
+ "details": {
137
+ "endpoint": "/wp-json/wp/v2/posts",
138
+ "method": "GET"
139
+ }
140
+ }
141
+ ```
142
+
143
+ ## Configuration
144
+
145
+ ### Multi-Site Configuration
146
+ ```json
147
+ {
148
+ "sites": [
149
+ {
150
+ "id": "site1",
151
+ "name": "My WordPress Site",
152
+ "config": {
153
+ "WORDPRESS_SITE_URL": "https://example.com",
154
+ "WORDPRESS_USERNAME": "username",
155
+ "WORDPRESS_APP_PASSWORD": "app_password"
156
+ }
157
+ }
158
+ ]
159
+ }
160
+ ```
161
+
162
+ ## Response Formats
163
+
164
+ All tools return responses in this format:
165
+ ```json
166
+ {
167
+ "success": true,
168
+ "data": {
169
+ // Tool-specific response data
170
+ },
171
+ "metadata": {
172
+ "timestamp": "2024-01-01T00:00:00.000Z",
173
+ "site": "site1",
174
+ "tool": "wp_list_posts"
175
+ }
176
+ }
177
+ ```
178
+
179
+ ## Performance Monitoring
180
+
181
+ The server includes comprehensive performance monitoring:
182
+ - Real-time metrics collection
183
+ - Historical performance analysis
184
+ - Industry benchmark comparisons
185
+ - Automated optimization recommendations
186
+
187
+ See [Performance Monitoring Guide](./performance/README.md) for details.
188
+
189
+ ## Additional Resources
190
+
191
+ - [Tool Reference](./tools/README.md) - Detailed tool documentation
192
+ - [Type Definitions](./types/README.md) - TypeScript type definitions
193
+ - [Examples](./examples/README.md) - Usage examples and workflows
194
+ - [OpenAPI Specification](./openapi.json) - Machine-readable API spec
195
+
196
+ ## Support
197
+
198
+ - **Documentation:** [GitHub Repository](https://github.com/docdyhr/mcp-wordpress)
199
+ - **Issues:** [GitHub Issues](https://github.com/docdyhr/mcp-wordpress/issues)
200
+ - **Discussions:** [GitHub Discussions](https://github.com/docdyhr/mcp-wordpress/discussions)
@@ -0,0 +1,40 @@
1
+ # auth Tools
2
+
3
+ Authentication testing and management tools
4
+
5
+ **Tool Count:** 3
6
+
7
+ ## Available Tools
8
+
9
+ - [`wp_get_auth_status`](./tools/wp_get_auth_status.md)
10
+ - [`wp_switch_auth_method`](./tools/wp_switch_auth_method.md)
11
+ - [`wp_test_auth`](./tools/wp_test_auth.md)
12
+
13
+ ## Common Usage Patterns
14
+
15
+ - Manage auth efficiently
16
+ - Bulk auth operations
17
+ - Search and filter auth
18
+
19
+ ## Examples
20
+
21
+ ### Basic auth Workflow
22
+ ```bash
23
+ # List all auth
24
+ wp_list_auth
25
+
26
+ # Get specific item
27
+ wp_get_aut --id=123
28
+
29
+ # Create new item
30
+ wp_create_aut --title="Example"
31
+ ```
32
+
33
+ ### Multi-Site auth Management
34
+ ```bash
35
+ # Work with specific site
36
+ wp_list_auth --site=production
37
+
38
+ # Bulk operations
39
+ wp_list_auth --site=staging --limit=50
40
+ ```
@@ -0,0 +1,41 @@
1
+ # cache Tools
2
+
3
+ Performance caching and optimization tools
4
+
5
+ **Tool Count:** 4
6
+
7
+ ## Available Tools
8
+
9
+ - [`wp_cache_clear`](./tools/wp_cache_clear.md)
10
+ - [`wp_cache_info`](./tools/wp_cache_info.md)
11
+ - [`wp_cache_stats`](./tools/wp_cache_stats.md)
12
+ - [`wp_cache_warm`](./tools/wp_cache_warm.md)
13
+
14
+ ## Common Usage Patterns
15
+
16
+ - Manage cache efficiently
17
+ - Bulk cache operations
18
+ - Search and filter cache
19
+
20
+ ## Examples
21
+
22
+ ### Basic cache Workflow
23
+ ```bash
24
+ # List all cache
25
+ wp_list_cache
26
+
27
+ # Get specific item
28
+ wp_get_cach --id=123
29
+
30
+ # Create new item
31
+ wp_create_cach --title="Example"
32
+ ```
33
+
34
+ ### Multi-Site cache Management
35
+ ```bash
36
+ # Work with specific site
37
+ wp_list_cache --site=production
38
+
39
+ # Bulk operations
40
+ wp_list_cache --site=staging --limit=50
41
+ ```