mcp-wordpress 2.4.2 → 2.5.1

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 (653) hide show
  1. package/README.md +124 -54
  2. package/bin/status.js +1 -1
  3. package/dist/cache/CacheInvalidation.d.ts +3 -1
  4. package/dist/cache/CacheInvalidation.d.ts.map +1 -1
  5. package/dist/cache/CacheInvalidation.js +10 -4
  6. package/dist/cache/CacheInvalidation.js.map +1 -1
  7. package/dist/cache/CacheManager.d.ts +3 -2
  8. package/dist/cache/CacheManager.d.ts.map +1 -1
  9. package/dist/cache/CacheManager.js +11 -3
  10. package/dist/cache/CacheManager.js.map +1 -1
  11. package/dist/cache/HttpCacheWrapper.d.ts +7 -6
  12. package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
  13. package/dist/cache/HttpCacheWrapper.js +8 -5
  14. package/dist/cache/HttpCacheWrapper.js.map +1 -1
  15. package/dist/cache/index.d.ts +3 -3
  16. package/dist/cache/index.d.ts.map +1 -1
  17. package/dist/cache/index.js +1 -1
  18. package/dist/cache/index.js.map +1 -1
  19. package/dist/client/CachedWordPressClient.d.ts +23 -9
  20. package/dist/client/CachedWordPressClient.d.ts.map +1 -1
  21. package/dist/client/CachedWordPressClient.js +4 -1
  22. package/dist/client/CachedWordPressClient.js.map +1 -1
  23. package/dist/client/MockWordPressClient.d.ts +2 -1
  24. package/dist/client/MockWordPressClient.d.ts.map +1 -1
  25. package/dist/client/MockWordPressClient.js +3 -1
  26. package/dist/client/MockWordPressClient.js.map +1 -1
  27. package/dist/client/api.d.ts +17 -13
  28. package/dist/client/api.d.ts.map +1 -1
  29. package/dist/client/api.js +135 -30
  30. package/dist/client/api.js.map +1 -1
  31. package/dist/client/auth.d.ts.map +1 -1
  32. package/dist/client/auth.js +2 -3
  33. package/dist/client/auth.js.map +1 -1
  34. package/dist/client/managers/AuthenticationManager.d.ts +55 -2
  35. package/dist/client/managers/AuthenticationManager.d.ts.map +1 -1
  36. package/dist/client/managers/AuthenticationManager.js +269 -71
  37. package/dist/client/managers/AuthenticationManager.js.map +1 -1
  38. package/dist/client/managers/BaseManager.d.ts +3 -3
  39. package/dist/client/managers/BaseManager.d.ts.map +1 -1
  40. package/dist/client/managers/BaseManager.js +11 -5
  41. package/dist/client/managers/BaseManager.js.map +1 -1
  42. package/dist/client/managers/RequestManager.d.ts +2 -2
  43. package/dist/client/managers/RequestManager.d.ts.map +1 -1
  44. package/dist/client/managers/RequestManager.js +25 -12
  45. package/dist/client/managers/RequestManager.js.map +1 -1
  46. package/dist/config/Config.d.ts +155 -0
  47. package/dist/config/Config.d.ts.map +1 -0
  48. package/dist/config/Config.js +215 -0
  49. package/dist/config/Config.js.map +1 -0
  50. package/dist/config/ConfigurationSchema.d.ts +21 -21
  51. package/dist/config/ConfigurationSchema.d.ts.map +1 -1
  52. package/dist/config/ConfigurationSchema.js +19 -2
  53. package/dist/config/ConfigurationSchema.js.map +1 -1
  54. package/dist/config/ServerConfiguration.d.ts +2 -1
  55. package/dist/config/ServerConfiguration.d.ts.map +1 -1
  56. package/dist/config/ServerConfiguration.js +73 -43
  57. package/dist/config/ServerConfiguration.js.map +1 -1
  58. package/dist/docs/DocumentationGenerator.d.ts +9 -8
  59. package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
  60. package/dist/docs/DocumentationGenerator.js +10 -7
  61. package/dist/docs/DocumentationGenerator.js.map +1 -1
  62. package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
  63. package/dist/docs/MarkdownFormatter.js +3 -2
  64. package/dist/docs/MarkdownFormatter.js.map +1 -1
  65. package/dist/dxt-entry.js +15 -14
  66. package/dist/dxt-entry.js.map +1 -1
  67. package/dist/index.d.ts +3 -1
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +37 -21
  70. package/dist/index.js.map +1 -1
  71. package/dist/performance/MetricsCollector.d.ts +13 -7
  72. package/dist/performance/MetricsCollector.d.ts.map +1 -1
  73. package/dist/performance/MetricsCollector.js +69 -27
  74. package/dist/performance/MetricsCollector.js.map +1 -1
  75. package/dist/performance/PerformanceAnalytics.d.ts +8 -2
  76. package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
  77. package/dist/performance/PerformanceAnalytics.js +17 -47
  78. package/dist/performance/PerformanceAnalytics.js.map +1 -1
  79. package/dist/performance/PerformanceMonitor.d.ts +2 -1
  80. package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
  81. package/dist/performance/PerformanceMonitor.js +12 -13
  82. package/dist/performance/PerformanceMonitor.js.map +1 -1
  83. package/dist/performance/index.d.ts +2 -2
  84. package/dist/performance/index.d.ts.map +1 -1
  85. package/dist/security/AISecurityScanner.d.ts +1 -0
  86. package/dist/security/AISecurityScanner.d.ts.map +1 -1
  87. package/dist/security/AISecurityScanner.js +22 -12
  88. package/dist/security/AISecurityScanner.js.map +1 -1
  89. package/dist/security/AutomatedRemediation.d.ts +4 -3
  90. package/dist/security/AutomatedRemediation.d.ts.map +1 -1
  91. package/dist/security/AutomatedRemediation.js +46 -15
  92. package/dist/security/AutomatedRemediation.js.map +1 -1
  93. package/dist/security/InputValidator.d.ts +13 -9
  94. package/dist/security/InputValidator.d.ts.map +1 -1
  95. package/dist/security/InputValidator.js +4 -2
  96. package/dist/security/InputValidator.js.map +1 -1
  97. package/dist/security/SecurityCIPipeline.d.ts +1 -1
  98. package/dist/security/SecurityCIPipeline.d.ts.map +1 -1
  99. package/dist/security/SecurityCIPipeline.js +38 -29
  100. package/dist/security/SecurityCIPipeline.js.map +1 -1
  101. package/dist/security/SecurityConfig.d.ts +3 -3
  102. package/dist/security/SecurityConfig.d.ts.map +1 -1
  103. package/dist/security/SecurityConfig.js +13 -9
  104. package/dist/security/SecurityConfig.js.map +1 -1
  105. package/dist/security/SecurityConfigManager.d.ts +2 -2
  106. package/dist/security/SecurityConfigManager.d.ts.map +1 -1
  107. package/dist/security/SecurityConfigManager.js +20 -15
  108. package/dist/security/SecurityConfigManager.js.map +1 -1
  109. package/dist/security/SecurityMonitoring.d.ts +2 -2
  110. package/dist/security/SecurityMonitoring.d.ts.map +1 -1
  111. package/dist/security/SecurityMonitoring.js +19 -17
  112. package/dist/security/SecurityMonitoring.js.map +1 -1
  113. package/dist/security/SecurityReviewer.d.ts.map +1 -1
  114. package/dist/security/SecurityReviewer.js +10 -7
  115. package/dist/security/SecurityReviewer.js.map +1 -1
  116. package/dist/security/index.d.ts +24 -23
  117. package/dist/security/index.d.ts.map +1 -1
  118. package/dist/security/index.js +52 -23
  119. package/dist/security/index.js.map +1 -1
  120. package/dist/server/ConnectionTester.d.ts +12 -4
  121. package/dist/server/ConnectionTester.d.ts.map +1 -1
  122. package/dist/server/ConnectionTester.js +96 -22
  123. package/dist/server/ConnectionTester.js.map +1 -1
  124. package/dist/server/ToolRegistry.d.ts +2 -2
  125. package/dist/server/ToolRegistry.d.ts.map +1 -1
  126. package/dist/server/ToolRegistry.js +10 -5
  127. package/dist/server/ToolRegistry.js.map +1 -1
  128. package/dist/src/cache/CacheInvalidation.d.ts +120 -0
  129. package/dist/src/cache/CacheInvalidation.d.ts.map +1 -0
  130. package/dist/src/cache/CacheInvalidation.js +355 -0
  131. package/dist/src/cache/CacheInvalidation.js.map +1 -0
  132. package/dist/src/cache/CacheManager.d.ts +149 -0
  133. package/dist/src/cache/CacheManager.d.ts.map +1 -0
  134. package/dist/src/cache/CacheManager.js +326 -0
  135. package/dist/src/cache/CacheManager.js.map +1 -0
  136. package/dist/src/cache/HttpCacheWrapper.d.ts +122 -0
  137. package/dist/src/cache/HttpCacheWrapper.d.ts.map +1 -0
  138. package/dist/src/cache/HttpCacheWrapper.js +283 -0
  139. package/dist/src/cache/HttpCacheWrapper.js.map +1 -0
  140. package/dist/src/cache/index.d.ts +12 -0
  141. package/dist/src/cache/index.d.ts.map +1 -0
  142. package/dist/src/cache/index.js +9 -0
  143. package/dist/src/cache/index.js.map +1 -0
  144. package/dist/src/client/CachedWordPressClient.d.ts +174 -0
  145. package/dist/src/client/CachedWordPressClient.d.ts.map +1 -0
  146. package/dist/src/client/CachedWordPressClient.js +345 -0
  147. package/dist/src/client/CachedWordPressClient.js.map +1 -0
  148. package/dist/src/client/MockWordPressClient.d.ts +56 -0
  149. package/dist/src/client/MockWordPressClient.d.ts.map +1 -0
  150. package/dist/src/client/MockWordPressClient.js +371 -0
  151. package/dist/src/client/MockWordPressClient.js.map +1 -0
  152. package/dist/src/client/api.d.ts +235 -0
  153. package/dist/src/client/api.d.ts.map +1 -0
  154. package/dist/src/client/api.js +896 -0
  155. package/dist/src/client/api.js.map +1 -0
  156. package/dist/src/client/auth.d.ts +121 -0
  157. package/dist/src/client/auth.d.ts.map +1 -0
  158. package/dist/src/client/auth.js +429 -0
  159. package/dist/src/client/auth.js.map +1 -0
  160. package/dist/src/client/managers/AuthenticationManager.d.ts +92 -0
  161. package/dist/src/client/managers/AuthenticationManager.d.ts.map +1 -0
  162. package/dist/src/client/managers/AuthenticationManager.js +369 -0
  163. package/dist/src/client/managers/AuthenticationManager.js.map +1 -0
  164. package/dist/src/client/managers/BaseManager.d.ts +22 -0
  165. package/dist/src/client/managers/BaseManager.d.ts.map +1 -0
  166. package/dist/src/client/managers/BaseManager.js +53 -0
  167. package/dist/src/client/managers/BaseManager.js.map +1 -0
  168. package/dist/src/client/managers/RequestManager.d.ts +47 -0
  169. package/dist/src/client/managers/RequestManager.d.ts.map +1 -0
  170. package/dist/src/client/managers/RequestManager.js +193 -0
  171. package/dist/src/client/managers/RequestManager.js.map +1 -0
  172. package/dist/src/client/managers/index.d.ts +8 -0
  173. package/dist/src/client/managers/index.d.ts.map +1 -0
  174. package/dist/src/client/managers/index.js +8 -0
  175. package/dist/src/client/managers/index.js.map +1 -0
  176. package/dist/src/config/Config.d.ts +155 -0
  177. package/dist/src/config/Config.d.ts.map +1 -0
  178. package/dist/src/config/Config.js +215 -0
  179. package/dist/src/config/Config.js.map +1 -0
  180. package/dist/src/config/ConfigurationSchema.d.ts +281 -0
  181. package/dist/src/config/ConfigurationSchema.d.ts.map +1 -0
  182. package/dist/src/config/ConfigurationSchema.js +205 -0
  183. package/dist/src/config/ConfigurationSchema.js.map +1 -0
  184. package/dist/src/config/ServerConfiguration.d.ts +47 -0
  185. package/dist/src/config/ServerConfiguration.d.ts.map +1 -0
  186. package/dist/src/config/ServerConfiguration.js +255 -0
  187. package/dist/src/config/ServerConfiguration.js.map +1 -0
  188. package/dist/src/docs/DocumentationGenerator.d.ts +185 -0
  189. package/dist/src/docs/DocumentationGenerator.d.ts.map +1 -0
  190. package/dist/src/docs/DocumentationGenerator.js +777 -0
  191. package/dist/src/docs/DocumentationGenerator.js.map +1 -0
  192. package/dist/src/docs/MarkdownFormatter.d.ts +84 -0
  193. package/dist/src/docs/MarkdownFormatter.d.ts.map +1 -0
  194. package/dist/src/docs/MarkdownFormatter.js +458 -0
  195. package/dist/src/docs/MarkdownFormatter.js.map +1 -0
  196. package/dist/src/docs/index.d.ts +8 -0
  197. package/dist/src/docs/index.d.ts.map +1 -0
  198. package/dist/src/docs/index.js +7 -0
  199. package/dist/src/docs/index.js.map +1 -0
  200. package/dist/src/dxt-entry.d.ts +6 -0
  201. package/dist/src/dxt-entry.d.ts.map +1 -0
  202. package/dist/src/dxt-entry.js +39 -0
  203. package/dist/src/dxt-entry.js.map +1 -0
  204. package/dist/src/index.d.ts +18 -0
  205. package/dist/src/index.d.ts.map +1 -0
  206. package/dist/src/index.js +143 -0
  207. package/dist/src/index.js.map +1 -0
  208. package/dist/src/performance/MetricsCollector.d.ts +145 -0
  209. package/dist/src/performance/MetricsCollector.d.ts.map +1 -0
  210. package/dist/src/performance/MetricsCollector.js +368 -0
  211. package/dist/src/performance/MetricsCollector.js.map +1 -0
  212. package/dist/src/performance/PerformanceAnalytics.d.ts +168 -0
  213. package/dist/src/performance/PerformanceAnalytics.d.ts.map +1 -0
  214. package/dist/src/performance/PerformanceAnalytics.js +570 -0
  215. package/dist/src/performance/PerformanceAnalytics.js.map +1 -0
  216. package/dist/src/performance/PerformanceMonitor.d.ts +203 -0
  217. package/dist/src/performance/PerformanceMonitor.d.ts.map +1 -0
  218. package/dist/src/performance/PerformanceMonitor.js +478 -0
  219. package/dist/src/performance/PerformanceMonitor.js.map +1 -0
  220. package/dist/src/performance/index.d.ts +11 -0
  221. package/dist/src/performance/index.d.ts.map +1 -0
  222. package/dist/src/performance/index.js +8 -0
  223. package/dist/src/performance/index.js.map +1 -0
  224. package/dist/src/security/AISecurityScanner.d.ts +176 -0
  225. package/dist/src/security/AISecurityScanner.d.ts.map +1 -0
  226. package/dist/src/security/AISecurityScanner.js +655 -0
  227. package/dist/src/security/AISecurityScanner.js.map +1 -0
  228. package/dist/src/security/AutomatedRemediation.d.ts +146 -0
  229. package/dist/src/security/AutomatedRemediation.d.ts.map +1 -0
  230. package/dist/src/security/AutomatedRemediation.js +566 -0
  231. package/dist/src/security/AutomatedRemediation.js.map +1 -0
  232. package/dist/src/security/InputValidator.d.ts +219 -0
  233. package/dist/src/security/InputValidator.d.ts.map +1 -0
  234. package/dist/src/security/InputValidator.js +295 -0
  235. package/dist/src/security/InputValidator.js.map +1 -0
  236. package/dist/src/security/SecurityCIPipeline.d.ts +213 -0
  237. package/dist/src/security/SecurityCIPipeline.d.ts.map +1 -0
  238. package/dist/src/security/SecurityCIPipeline.js +693 -0
  239. package/dist/src/security/SecurityCIPipeline.js.map +1 -0
  240. package/dist/src/security/SecurityConfig.d.ts +129 -0
  241. package/dist/src/security/SecurityConfig.d.ts.map +1 -0
  242. package/dist/src/security/SecurityConfig.js +266 -0
  243. package/dist/src/security/SecurityConfig.js.map +1 -0
  244. package/dist/src/security/SecurityConfigManager.d.ts +294 -0
  245. package/dist/src/security/SecurityConfigManager.d.ts.map +1 -0
  246. package/dist/src/security/SecurityConfigManager.js +558 -0
  247. package/dist/src/security/SecurityConfigManager.js.map +1 -0
  248. package/dist/src/security/SecurityMonitoring.d.ts +245 -0
  249. package/dist/src/security/SecurityMonitoring.d.ts.map +1 -0
  250. package/dist/src/security/SecurityMonitoring.js +598 -0
  251. package/dist/src/security/SecurityMonitoring.js.map +1 -0
  252. package/dist/src/security/SecurityReviewer.d.ts +168 -0
  253. package/dist/src/security/SecurityReviewer.d.ts.map +1 -0
  254. package/dist/src/security/SecurityReviewer.js +686 -0
  255. package/dist/src/security/SecurityReviewer.js.map +1 -0
  256. package/dist/src/security/index.d.ts +183 -0
  257. package/dist/src/security/index.d.ts.map +1 -0
  258. package/dist/src/security/index.js +218 -0
  259. package/dist/src/security/index.js.map +1 -0
  260. package/dist/src/server/ConnectionTester.d.ts +32 -0
  261. package/dist/src/server/ConnectionTester.d.ts.map +1 -0
  262. package/dist/src/server/ConnectionTester.js +135 -0
  263. package/dist/src/server/ConnectionTester.js.map +1 -0
  264. package/dist/src/server/ToolRegistry.d.ts +50 -0
  265. package/dist/src/server/ToolRegistry.d.ts.map +1 -0
  266. package/dist/src/server/ToolRegistry.js +219 -0
  267. package/dist/src/server/ToolRegistry.js.map +1 -0
  268. package/dist/src/server.d.ts +7 -0
  269. package/dist/src/server.d.ts.map +1 -0
  270. package/dist/src/server.js +7 -0
  271. package/dist/src/server.js.map +1 -0
  272. package/dist/src/tools/BaseToolManager.d.ts +62 -0
  273. package/dist/src/tools/BaseToolManager.d.ts.map +1 -0
  274. package/dist/src/tools/BaseToolManager.js +195 -0
  275. package/dist/src/tools/BaseToolManager.js.map +1 -0
  276. package/dist/src/tools/auth.d.ts +50 -0
  277. package/dist/src/tools/auth.d.ts.map +1 -0
  278. package/dist/src/tools/auth.js +133 -0
  279. package/dist/src/tools/auth.js.map +1 -0
  280. package/dist/src/tools/cache.d.ts +260 -0
  281. package/dist/src/tools/cache.d.ts.map +1 -0
  282. package/dist/src/tools/cache.js +232 -0
  283. package/dist/src/tools/cache.js.map +1 -0
  284. package/dist/src/tools/comments.d.ts +33 -0
  285. package/dist/src/tools/comments.d.ts.map +1 -0
  286. package/dist/src/tools/comments.js +235 -0
  287. package/dist/src/tools/comments.js.map +1 -0
  288. package/dist/src/tools/index.d.ts +11 -0
  289. package/dist/src/tools/index.d.ts.map +1 -0
  290. package/dist/src/tools/index.js +11 -0
  291. package/dist/src/tools/index.js.map +1 -0
  292. package/dist/src/tools/media.d.ts +70 -0
  293. package/dist/src/tools/media.d.ts.map +1 -0
  294. package/dist/src/tools/media.js +248 -0
  295. package/dist/src/tools/media.js.map +1 -0
  296. package/dist/src/tools/pages.d.ts +32 -0
  297. package/dist/src/tools/pages.d.ts.map +1 -0
  298. package/dist/src/tools/pages.js +215 -0
  299. package/dist/src/tools/pages.js.map +1 -0
  300. package/dist/src/tools/performance.d.ts +73 -0
  301. package/dist/src/tools/performance.d.ts.map +1 -0
  302. package/dist/src/tools/performance.js +922 -0
  303. package/dist/src/tools/performance.js.map +1 -0
  304. package/dist/src/tools/posts/PostHandlers.d.ts +46 -0
  305. package/dist/src/tools/posts/PostHandlers.d.ts.map +1 -0
  306. package/dist/src/tools/posts/PostHandlers.js +400 -0
  307. package/dist/src/tools/posts/PostHandlers.js.map +1 -0
  308. package/dist/src/tools/posts/PostToolDefinitions.d.ts +37 -0
  309. package/dist/src/tools/posts/PostToolDefinitions.d.ts.map +1 -0
  310. package/dist/src/tools/posts/PostToolDefinitions.js +236 -0
  311. package/dist/src/tools/posts/PostToolDefinitions.js.map +1 -0
  312. package/dist/src/tools/posts/index.d.ts +138 -0
  313. package/dist/src/tools/posts/index.d.ts.map +1 -0
  314. package/dist/src/tools/posts/index.js +163 -0
  315. package/dist/src/tools/posts/index.js.map +1 -0
  316. package/dist/src/tools/posts.d.ts +15 -0
  317. package/dist/src/tools/posts.d.ts.map +1 -0
  318. package/dist/src/tools/posts.js +16 -0
  319. package/dist/src/tools/posts.js.map +1 -0
  320. package/dist/src/tools/site.d.ts +32 -0
  321. package/dist/src/tools/site.d.ts.map +1 -0
  322. package/dist/src/tools/site.js +234 -0
  323. package/dist/src/tools/site.js.map +1 -0
  324. package/dist/src/tools/taxonomies.d.ts +36 -0
  325. package/dist/src/tools/taxonomies.d.ts.map +1 -0
  326. package/dist/src/tools/taxonomies.js +286 -0
  327. package/dist/src/tools/taxonomies.js.map +1 -0
  328. package/dist/src/tools/users.d.ts +33 -0
  329. package/dist/src/tools/users.d.ts.map +1 -0
  330. package/dist/src/tools/users.js +308 -0
  331. package/dist/src/tools/users.js.map +1 -0
  332. package/dist/src/types/client.d.ts +223 -0
  333. package/dist/src/types/client.d.ts.map +1 -0
  334. package/dist/src/types/client.js +97 -0
  335. package/dist/src/types/client.js.map +1 -0
  336. package/dist/src/types/enhanced.d.ts +237 -0
  337. package/dist/src/types/enhanced.d.ts.map +1 -0
  338. package/dist/src/types/enhanced.js +49 -0
  339. package/dist/src/types/enhanced.js.map +1 -0
  340. package/dist/src/types/index.d.ts +160 -0
  341. package/dist/src/types/index.d.ts.map +1 -0
  342. package/dist/src/types/index.js +14 -0
  343. package/dist/src/types/index.js.map +1 -0
  344. package/dist/src/types/mcp.d.ts +178 -0
  345. package/dist/src/types/mcp.d.ts.map +1 -0
  346. package/dist/src/types/mcp.js +7 -0
  347. package/dist/src/types/mcp.js.map +1 -0
  348. package/dist/src/types/requests.d.ts +322 -0
  349. package/dist/src/types/requests.d.ts.map +1 -0
  350. package/dist/src/types/requests.js +8 -0
  351. package/dist/src/types/requests.js.map +1 -0
  352. package/dist/src/types/tools.d.ts +506 -0
  353. package/dist/src/types/tools.d.ts.map +1 -0
  354. package/dist/src/types/tools.js +8 -0
  355. package/dist/src/types/tools.js.map +1 -0
  356. package/dist/src/types/wordpress.d.ts +471 -0
  357. package/dist/src/types/wordpress.d.ts.map +1 -0
  358. package/dist/src/types/wordpress.js +14 -0
  359. package/dist/src/types/wordpress.js.map +1 -0
  360. package/dist/src/utils/debug.d.ts +71 -0
  361. package/dist/src/utils/debug.d.ts.map +1 -0
  362. package/dist/src/utils/debug.js +235 -0
  363. package/dist/src/utils/debug.js.map +1 -0
  364. package/dist/src/utils/enhancedError.d.ts +61 -0
  365. package/dist/src/utils/enhancedError.d.ts.map +1 -0
  366. package/dist/src/utils/enhancedError.js +221 -0
  367. package/dist/src/utils/enhancedError.js.map +1 -0
  368. package/dist/src/utils/error.d.ts +17 -0
  369. package/dist/src/utils/error.d.ts.map +1 -0
  370. package/dist/src/utils/error.js +108 -0
  371. package/dist/src/utils/error.js.map +1 -0
  372. package/dist/src/utils/logger.d.ts +106 -0
  373. package/dist/src/utils/logger.d.ts.map +1 -0
  374. package/dist/src/utils/logger.js +280 -0
  375. package/dist/src/utils/logger.js.map +1 -0
  376. package/dist/src/utils/streaming.d.ts +104 -0
  377. package/dist/src/utils/streaming.d.ts.map +1 -0
  378. package/dist/src/utils/streaming.js +331 -0
  379. package/dist/src/utils/streaming.js.map +1 -0
  380. package/dist/src/utils/toolWrapper.d.ts +42 -0
  381. package/dist/src/utils/toolWrapper.d.ts.map +1 -0
  382. package/dist/src/utils/toolWrapper.js +101 -0
  383. package/dist/src/utils/toolWrapper.js.map +1 -0
  384. package/dist/src/utils/validation/core.d.ts +21 -0
  385. package/dist/src/utils/validation/core.d.ts.map +1 -0
  386. package/dist/src/utils/validation/core.js +71 -0
  387. package/dist/src/utils/validation/core.js.map +1 -0
  388. package/dist/src/utils/validation/index.d.ts +25 -0
  389. package/dist/src/utils/validation/index.d.ts.map +1 -0
  390. package/dist/src/utils/validation/index.js +29 -0
  391. package/dist/src/utils/validation/index.js.map +1 -0
  392. package/dist/src/utils/validation/network.d.ts +19 -0
  393. package/dist/src/utils/validation/network.d.ts.map +1 -0
  394. package/dist/src/utils/validation/network.js +93 -0
  395. package/dist/src/utils/validation/network.js.map +1 -0
  396. package/dist/src/utils/validation/rateLimit.d.ts +21 -0
  397. package/dist/src/utils/validation/rateLimit.d.ts.map +1 -0
  398. package/dist/src/utils/validation/rateLimit.js +43 -0
  399. package/dist/src/utils/validation/rateLimit.js.map +1 -0
  400. package/dist/src/utils/validation/security.d.ts +29 -0
  401. package/dist/src/utils/validation/security.d.ts.map +1 -0
  402. package/dist/src/utils/validation/security.js +327 -0
  403. package/dist/src/utils/validation/security.js.map +1 -0
  404. package/dist/src/utils/validation/wordpress.d.ts +31 -0
  405. package/dist/src/utils/validation/wordpress.d.ts.map +1 -0
  406. package/dist/src/utils/validation/wordpress.js +146 -0
  407. package/dist/src/utils/validation/wordpress.js.map +1 -0
  408. package/dist/src/utils/validation.d.ts +15 -0
  409. package/dist/src/utils/validation.d.ts.map +1 -0
  410. package/dist/src/utils/validation.js +27 -0
  411. package/dist/src/utils/validation.js.map +1 -0
  412. package/dist/tests/vitest.setup.d.ts +6 -0
  413. package/dist/tests/vitest.setup.d.ts.map +1 -0
  414. package/dist/tests/vitest.setup.js +39 -0
  415. package/dist/tests/vitest.setup.js.map +1 -0
  416. package/dist/tools/BaseToolManager.d.ts +47 -11
  417. package/dist/tools/BaseToolManager.d.ts.map +1 -1
  418. package/dist/tools/BaseToolManager.js +168 -29
  419. package/dist/tools/BaseToolManager.js.map +1 -1
  420. package/dist/tools/auth.d.ts +16 -10
  421. package/dist/tools/auth.d.ts.map +1 -1
  422. package/dist/tools/auth.js +3 -2
  423. package/dist/tools/auth.js.map +1 -1
  424. package/dist/tools/cache.d.ts +30 -30
  425. package/dist/tools/cache.d.ts.map +1 -1
  426. package/dist/tools/cache.js +1 -6
  427. package/dist/tools/cache.js.map +1 -1
  428. package/dist/tools/comments.d.ts +20 -20
  429. package/dist/tools/comments.d.ts.map +1 -1
  430. package/dist/tools/comments.js +16 -9
  431. package/dist/tools/comments.js.map +1 -1
  432. package/dist/tools/media.d.ts +18 -16
  433. package/dist/tools/media.d.ts.map +1 -1
  434. package/dist/tools/media.js +16 -15
  435. package/dist/tools/media.js.map +1 -1
  436. package/dist/tools/pages.d.ts +19 -17
  437. package/dist/tools/pages.d.ts.map +1 -1
  438. package/dist/tools/pages.js +16 -12
  439. package/dist/tools/pages.js.map +1 -1
  440. package/dist/tools/performance.d.ts +11 -1
  441. package/dist/tools/performance.d.ts.map +1 -1
  442. package/dist/tools/performance.js +67 -34
  443. package/dist/tools/performance.js.map +1 -1
  444. package/dist/tools/posts/PostHandlers.d.ts +46 -0
  445. package/dist/tools/posts/PostHandlers.d.ts.map +1 -0
  446. package/dist/tools/posts/PostHandlers.js +400 -0
  447. package/dist/tools/posts/PostHandlers.js.map +1 -0
  448. package/dist/tools/posts/PostToolDefinitions.d.ts +37 -0
  449. package/dist/tools/posts/PostToolDefinitions.d.ts.map +1 -0
  450. package/dist/tools/posts/PostToolDefinitions.js +236 -0
  451. package/dist/tools/posts/PostToolDefinitions.js.map +1 -0
  452. package/dist/tools/posts/index.d.ts +138 -0
  453. package/dist/tools/posts/index.d.ts.map +1 -0
  454. package/dist/tools/posts/index.js +163 -0
  455. package/dist/tools/posts/index.js.map +1 -0
  456. package/dist/tools/posts.d.ts +10 -246
  457. package/dist/tools/posts.d.ts.map +1 -1
  458. package/dist/tools/posts.js +11 -723
  459. package/dist/tools/posts.js.map +1 -1
  460. package/dist/tools/site.d.ts +19 -18
  461. package/dist/tools/site.d.ts.map +1 -1
  462. package/dist/tools/site.js +14 -10
  463. package/dist/tools/site.js.map +1 -1
  464. package/dist/tools/taxonomies.d.ts +23 -24
  465. package/dist/tools/taxonomies.d.ts.map +1 -1
  466. package/dist/tools/taxonomies.js +24 -18
  467. package/dist/tools/taxonomies.js.map +1 -1
  468. package/dist/tools/users.d.ts +20 -15
  469. package/dist/tools/users.d.ts.map +1 -1
  470. package/dist/tools/users.js +12 -8
  471. package/dist/tools/users.js.map +1 -1
  472. package/dist/types/client.d.ts +48 -41
  473. package/dist/types/client.d.ts.map +1 -1
  474. package/dist/types/client.js +30 -5
  475. package/dist/types/client.js.map +1 -1
  476. package/dist/types/enhanced.d.ts +237 -0
  477. package/dist/types/enhanced.d.ts.map +1 -0
  478. package/dist/types/enhanced.js +49 -0
  479. package/dist/types/enhanced.js.map +1 -0
  480. package/dist/types/index.d.ts +15 -12
  481. package/dist/types/index.d.ts.map +1 -1
  482. package/dist/types/index.js +2 -0
  483. package/dist/types/index.js.map +1 -1
  484. package/dist/types/mcp.d.ts +12 -12
  485. package/dist/types/mcp.d.ts.map +1 -1
  486. package/dist/types/requests.d.ts +322 -0
  487. package/dist/types/requests.d.ts.map +1 -0
  488. package/dist/types/requests.js +8 -0
  489. package/dist/types/requests.js.map +1 -0
  490. package/dist/types/tools.d.ts +506 -0
  491. package/dist/types/tools.d.ts.map +1 -0
  492. package/dist/types/tools.js +8 -0
  493. package/dist/types/tools.js.map +1 -0
  494. package/dist/types/wordpress.d.ts +43 -15
  495. package/dist/types/wordpress.d.ts.map +1 -1
  496. package/dist/types/wordpress.js +8 -1
  497. package/dist/types/wordpress.js.map +1 -1
  498. package/dist/utils/debug.d.ts +19 -11
  499. package/dist/utils/debug.d.ts.map +1 -1
  500. package/dist/utils/debug.js +46 -10
  501. package/dist/utils/debug.js.map +1 -1
  502. package/dist/utils/enhancedError.d.ts +8 -8
  503. package/dist/utils/enhancedError.d.ts.map +1 -1
  504. package/dist/utils/enhancedError.js.map +1 -1
  505. package/dist/utils/error.d.ts +2 -4
  506. package/dist/utils/error.d.ts.map +1 -1
  507. package/dist/utils/error.js +42 -5
  508. package/dist/utils/error.js.map +1 -1
  509. package/dist/utils/logger.d.ts +106 -0
  510. package/dist/utils/logger.d.ts.map +1 -0
  511. package/dist/utils/logger.js +280 -0
  512. package/dist/utils/logger.js.map +1 -0
  513. package/dist/utils/streaming.d.ts +9 -9
  514. package/dist/utils/streaming.d.ts.map +1 -1
  515. package/dist/utils/streaming.js +71 -52
  516. package/dist/utils/streaming.js.map +1 -1
  517. package/dist/utils/toolWrapper.d.ts +9 -7
  518. package/dist/utils/toolWrapper.d.ts.map +1 -1
  519. package/dist/utils/toolWrapper.js.map +1 -1
  520. package/dist/utils/validation/core.d.ts +21 -0
  521. package/dist/utils/validation/core.d.ts.map +1 -0
  522. package/dist/utils/validation/core.js +71 -0
  523. package/dist/utils/validation/core.js.map +1 -0
  524. package/dist/utils/validation/index.d.ts +25 -0
  525. package/dist/utils/validation/index.d.ts.map +1 -0
  526. package/dist/utils/validation/index.js +29 -0
  527. package/dist/utils/validation/index.js.map +1 -0
  528. package/dist/utils/validation/network.d.ts +19 -0
  529. package/dist/utils/validation/network.d.ts.map +1 -0
  530. package/dist/utils/validation/network.js +93 -0
  531. package/dist/utils/validation/network.js.map +1 -0
  532. package/dist/utils/validation/rateLimit.d.ts +21 -0
  533. package/dist/utils/validation/rateLimit.d.ts.map +1 -0
  534. package/dist/utils/validation/rateLimit.js +43 -0
  535. package/dist/utils/validation/rateLimit.js.map +1 -0
  536. package/dist/utils/validation/security.d.ts +29 -0
  537. package/dist/utils/validation/security.d.ts.map +1 -0
  538. package/dist/utils/validation/security.js +327 -0
  539. package/dist/utils/validation/security.js.map +1 -0
  540. package/dist/utils/validation/wordpress.d.ts +31 -0
  541. package/dist/utils/validation/wordpress.d.ts.map +1 -0
  542. package/dist/utils/validation/wordpress.js +146 -0
  543. package/dist/utils/validation/wordpress.js.map +1 -0
  544. package/dist/utils/validation.d.ts +13 -82
  545. package/dist/utils/validation.d.ts.map +1 -1
  546. package/dist/utils/validation.js +25 -343
  547. package/dist/utils/validation.js.map +1 -1
  548. package/docs/BADGE_UPDATES.md +132 -0
  549. package/docs/CI_CD_IMPROVEMENTS.md +191 -0
  550. package/docs/INCREMENTAL_COVERAGE.md +183 -0
  551. package/docs/INSTALLATION.md +4 -2
  552. package/docs/TROUBLESHOOTING.md +2 -1
  553. package/docs/api/README.md +3 -1
  554. package/docs/api/openapi.json +5 -1
  555. package/docs/api/summary.json +1 -1
  556. package/docs/api/tools/wp_create_post.md +12 -14
  557. package/docs/developer/TESTING.md +24 -19
  558. package/docs/examples/claude-desktop-config.md +1 -1
  559. package/docs/examples/docker-production.md +100 -93
  560. package/docs/examples/multi-site-setup.md +5 -4
  561. package/docs/examples/single-site-setup.md +3 -4
  562. package/docs/examples/use-case-workflows.md +4 -5
  563. package/docs/integrations/claude-desktop.md +39 -34
  564. package/docs/integrations/cline.md +4 -4
  565. package/docs/integrations/vs-code.md +9 -8
  566. package/docs/user-guides/DXT_INSTALLATION.md +2 -1
  567. package/docs/user-guides/SMITHERY_SETUP.md +10 -10
  568. package/package.json +57 -39
  569. package/src/cache/CacheInvalidation.ts +12 -5
  570. package/src/cache/CacheManager.ts +18 -15
  571. package/src/cache/HttpCacheWrapper.ts +30 -59
  572. package/src/cache/__tests__/HttpCacheWrapper.test.ts +6 -5
  573. package/src/cache/index.ts +3 -14
  574. package/src/client/CachedWordPressClient.ts +32 -30
  575. package/src/client/MockWordPressClient.ts +4 -2
  576. package/src/client/api.ts +186 -64
  577. package/src/client/auth.ts +15 -40
  578. package/src/client/managers/AuthenticationManager.ts +337 -77
  579. package/src/client/managers/BaseManager.ts +18 -30
  580. package/src/client/managers/RequestManager.ts +39 -44
  581. package/src/config/Config.ts +308 -0
  582. package/src/config/ConfigurationSchema.ts +23 -2
  583. package/src/config/ServerConfiguration.ts +73 -49
  584. package/src/docs/DocumentationGenerator.ts +50 -39
  585. package/src/docs/MarkdownFormatter.ts +19 -29
  586. package/src/dxt-entry.cjs +26 -16
  587. package/src/dxt-entry.ts +17 -27
  588. package/src/index.ts +42 -28
  589. package/src/performance/MetricsCollector.ts +108 -86
  590. package/src/performance/PerformanceAnalytics.ts +69 -164
  591. package/src/performance/PerformanceMonitor.ts +32 -47
  592. package/src/performance/index.ts +2 -10
  593. package/src/security/AISecurityScanner.ts +22 -12
  594. package/src/security/AutomatedRemediation.ts +49 -18
  595. package/src/security/InputValidator.ts +9 -6
  596. package/src/security/SecurityCIPipeline.ts +53 -37
  597. package/src/security/SecurityConfig.ts +22 -22
  598. package/src/security/SecurityConfigManager.ts +23 -19
  599. package/src/security/SecurityMonitoring.ts +24 -21
  600. package/src/security/SecurityReviewer.ts +10 -7
  601. package/src/security/index.ts +64 -29
  602. package/src/server/ConnectionTester.ts +120 -31
  603. package/src/server/ToolRegistry.ts +31 -21
  604. package/src/tools/BaseToolManager.ts +286 -33
  605. package/src/tools/auth.ts +20 -8
  606. package/src/tools/cache.ts +5 -15
  607. package/src/tools/comments.ts +34 -48
  608. package/src/tools/media.ts +41 -53
  609. package/src/tools/pages.ts +32 -54
  610. package/src/tools/performance.ts +141 -176
  611. package/src/tools/posts/PostHandlers.ts +474 -0
  612. package/src/tools/posts/PostToolDefinitions.ts +250 -0
  613. package/src/tools/posts/index.ts +192 -0
  614. package/src/tools/posts.ts +24 -780
  615. package/src/tools/site.ts +34 -19
  616. package/src/tools/taxonomies.ts +41 -57
  617. package/src/tools/users.ts +28 -16
  618. package/src/types/client.ts +114 -138
  619. package/src/types/enhanced.ts +318 -0
  620. package/src/types/index.ts +51 -30
  621. package/src/types/mcp.ts +20 -42
  622. package/src/types/requests.ts +378 -0
  623. package/src/types/tools.ts +608 -0
  624. package/src/types/wordpress.ts +56 -34
  625. package/src/utils/debug.ts +77 -59
  626. package/src/utils/enhancedError.ts +8 -8
  627. package/src/utils/error.ts +53 -31
  628. package/src/utils/logger.ts +351 -0
  629. package/src/utils/streaming.ts +86 -68
  630. package/src/utils/toolWrapper.ts +10 -12
  631. package/src/utils/validation/core.ts +108 -0
  632. package/src/utils/validation/index.ts +36 -0
  633. package/src/utils/validation/network.ts +132 -0
  634. package/src/utils/validation/rateLimit.ts +54 -0
  635. package/src/utils/validation/security.ts +361 -0
  636. package/src/utils/validation/wordpress.ts +180 -0
  637. package/src/utils/validation.ts +47 -470
  638. package/dist/cache/__tests__/CacheInvalidation.test.d.ts +0 -5
  639. package/dist/cache/__tests__/CacheInvalidation.test.d.ts.map +0 -1
  640. package/dist/cache/__tests__/CacheInvalidation.test.js +0 -238
  641. package/dist/cache/__tests__/CacheInvalidation.test.js.map +0 -1
  642. package/dist/cache/__tests__/CacheManager.test.d.ts +0 -5
  643. package/dist/cache/__tests__/CacheManager.test.d.ts.map +0 -1
  644. package/dist/cache/__tests__/CacheManager.test.js +0 -233
  645. package/dist/cache/__tests__/CacheManager.test.js.map +0 -1
  646. package/dist/cache/__tests__/CachedWordPressClient.test.d.ts +0 -5
  647. package/dist/cache/__tests__/CachedWordPressClient.test.d.ts.map +0 -1
  648. package/dist/cache/__tests__/CachedWordPressClient.test.js +0 -231
  649. package/dist/cache/__tests__/CachedWordPressClient.test.js.map +0 -1
  650. package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts +0 -5
  651. package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts.map +0 -1
  652. package/dist/cache/__tests__/HttpCacheWrapper.test.js +0 -299
  653. package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +0 -1
@@ -1,783 +1,27 @@
1
- import { WordPressClient } from "../client/api.js";
2
- import { CreatePostRequest, PostQueryParams, UpdatePostRequest } from "../types/wordpress.js";
3
- import { getErrorMessage } from "../utils/error.js";
4
- import { ErrorHandlers, EnhancedError } from "../utils/enhancedError.js";
5
- import { validateId, validatePaginationParams, validatePostParams } from "../utils/validation.js";
6
- import { WordPressDataStreamer, StreamingUtils, StreamingResult } from "../utils/streaming.js";
7
-
8
1
  /**
9
- * Provides comprehensive tools for managing WordPress posts.
10
- *
11
- * This class encapsulates tool definitions and their corresponding handlers for:
12
- * - Listing posts with advanced filtering and search capabilities
13
- * - Creating new posts with full metadata support
14
- * - Updating existing posts with validation
15
- * - Deleting posts with trash/permanent options
16
- * - Retrieving individual posts with detailed information
17
- * - Managing post revisions and history
18
- *
19
- * @example
20
- * ```typescript
21
- * const postTools = new PostTools();
22
- * const tools = postTools.getTools();
23
- *
24
- * // Use with a WordPress client
25
- * const client = new WordPressClient(config);
26
- * const result = await postTools.handleListPosts(client, { per_page: 10 });
27
- * ```
28
- *
29
- * @since 1.0.0
30
- * @author MCP WordPress Team
2
+ * WordPress Posts Tools - Legacy Import Module
3
+ *
4
+ * This file maintains backward compatibility while the codebase transitions
5
+ * to the new modular structure. The actual implementation has been refactored
6
+ * into focused modules under ./posts/ directory.
7
+ *
8
+ * @deprecated Use direct imports from ./posts/ modules instead
9
+ * @see ./posts/index.ts for the new modular implementation
31
10
  */
32
- export class PostTools {
33
- /**
34
- * Retrieves the complete list of post management tools available for MCP.
35
- *
36
- * Returns an array of tool definitions that can be registered with an MCP server.
37
- * Each tool includes comprehensive parameter validation, error handling, and
38
- * detailed documentation with usage examples.
39
- *
40
- * @returns {Array<MCPTool>} An array of MCPTool definitions for post management
41
- *
42
- * @example
43
- * ```typescript
44
- * const postTools = new PostTools();
45
- * const tools = postTools.getTools();
46
- * console.log(tools.length); // 6 tools: list, get, create, update, delete, revisions
47
- * ```
48
- */
49
- public getTools(): any[] {
50
- return [
51
- {
52
- name: "wp_list_posts",
53
- description:
54
- "Lists posts from a WordPress site with comprehensive filtering options. Supports search, status filtering, and category/tag filtering with enhanced metadata display.\n\n" +
55
- "**Usage Examples:**\n" +
56
- "• Basic listing: `wp_list_posts`\n" +
57
- '• Search posts: `wp_list_posts --search="AI trends"`\n' +
58
- '• Filter by status: `wp_list_posts --status="draft"`\n' +
59
- "• Category filtering: `wp_list_posts --categories=[1,2,3]`\n" +
60
- "• Paginated results: `wp_list_posts --per_page=20 --page=2`\n" +
61
- '• Combined filters: `wp_list_posts --search="WordPress" --status="publish" --per_page=10`',
62
- parameters: [
63
- {
64
- name: "per_page",
65
- type: "number",
66
- description: "Number of items to return per page (max 100).",
67
- },
68
- {
69
- name: "search",
70
- type: "string",
71
- description: "Limit results to those matching a search term.",
72
- },
73
- {
74
- name: "status",
75
- type: "string",
76
- description: "Filter by post status.",
77
- enum: ["publish", "future", "draft", "pending", "private"],
78
- },
79
- {
80
- name: "categories",
81
- type: "array",
82
- items: { type: "number" },
83
- description: "Limit results to posts in specific category IDs.",
84
- },
85
- {
86
- name: "tags",
87
- type: "array",
88
- items: { type: "number" },
89
- description: "Limit results to posts with specific tag IDs.",
90
- },
91
- ],
92
- handler: this.handleListPosts.bind(this),
93
- },
94
- {
95
- name: "wp_get_post",
96
- description:
97
- "Retrieves detailed information about a single post including metadata, content statistics, and management links.",
98
- parameters: [
99
- {
100
- name: "id",
101
- type: "number",
102
- required: true,
103
- description: "The unique identifier for the post.",
104
- },
105
- ],
106
- handler: this.handleGetPost.bind(this),
107
- },
108
- {
109
- name: "wp_create_post",
110
- description:
111
- "Creates a new WordPress post with comprehensive validation and detailed success feedback including management links.\n\n" +
112
- "**Usage Examples:**\n" +
113
- '• Simple post: `wp_create_post --title="My New Post" --content="<p>Hello World!</p>"`\n' +
114
- '• Draft post: `wp_create_post --title="Draft Post" --status="draft"`\n' +
115
- '• Categorized post: `wp_create_post --title="Tech News" --categories=[1,5] --tags=[10,20]`\n' +
116
- '• Scheduled post: `wp_create_post --title="Future Post" --status="future" --date="2024-12-25T10:00:00"`\n' +
117
- '• Complete post: `wp_create_post --title="Complete Post" --content="<p>Content</p>" --excerpt="Summary" --status="publish"`',
118
- parameters: [
119
- {
120
- name: "title",
121
- type: "string",
122
- required: true,
123
- description: "The title for the post.",
124
- },
125
- {
126
- name: "content",
127
- type: "string",
128
- description: "The content for the post, in HTML format.",
129
- },
130
- {
131
- name: "status",
132
- type: "string",
133
- description: "The publishing status for the post.",
134
- enum: ["publish", "draft", "pending", "private"],
135
- },
136
- {
137
- name: "excerpt",
138
- type: "string",
139
- description: "The excerpt for the post.",
140
- },
141
- {
142
- name: "categories",
143
- type: "array",
144
- items: { type: "number" },
145
- description: "An array of category IDs to assign to the post.",
146
- },
147
- {
148
- name: "tags",
149
- type: "array",
150
- items: { type: "number" },
151
- description: "An array of tag IDs to assign to the post.",
152
- },
153
- ],
154
- handler: this.handleCreatePost.bind(this),
155
- },
156
- {
157
- name: "wp_update_post",
158
- description: "Updates an existing WordPress post with validation and detailed confirmation.",
159
- parameters: [
160
- {
161
- name: "id",
162
- type: "number",
163
- required: true,
164
- description: "The ID of the post to update.",
165
- },
166
- {
167
- name: "title",
168
- type: "string",
169
- description: "The new title for the post.",
170
- },
171
- {
172
- name: "content",
173
- type: "string",
174
- description: "The new content for the post, in HTML format.",
175
- },
176
- {
177
- name: "status",
178
- type: "string",
179
- description: "The new status for the post.",
180
- enum: ["publish", "draft", "pending", "private"],
181
- },
182
- ],
183
- handler: this.handleUpdatePost.bind(this),
184
- },
185
- {
186
- name: "wp_delete_post",
187
- description: "Deletes a WordPress post with option for permanent deletion or moving to trash.",
188
- parameters: [
189
- {
190
- name: "id",
191
- type: "number",
192
- required: true,
193
- description: "The ID of the post to delete.",
194
- },
195
- {
196
- name: "force",
197
- type: "boolean",
198
- description: "If true, permanently delete. If false, move to trash. Defaults to false.",
199
- },
200
- ],
201
- handler: this.handleDeletePost.bind(this),
202
- },
203
- {
204
- name: "wp_get_post_revisions",
205
- description: "Retrieves the revision history for a specific post showing author and modification dates.",
206
- parameters: [
207
- {
208
- name: "id",
209
- type: "number",
210
- required: true,
211
- description: "The ID of the post to get revisions for.",
212
- },
213
- ],
214
- handler: this.handleGetPostRevisions.bind(this),
215
- },
216
- ];
217
- }
218
-
219
- /**
220
- * Handles listing posts from a WordPress site with comprehensive filtering options.
221
- *
222
- * This method provides advanced search capabilities, status filtering, pagination,
223
- * and category/tag filtering. Results include enhanced metadata and author information.
224
- * For large result sets (>50 posts), it automatically uses streaming for better performance.
225
- *
226
- * @param {WordPressClient} client - The WordPress client instance for API communication
227
- * @param {PostQueryParams} params - Query parameters for filtering and pagination
228
- * @param {number} [params.per_page=10] - Number of posts to return per page (max 100)
229
- * @param {string} [params.search] - Search term to filter posts by title/content
230
- * @param {string|string[]} [params.status] - Post status filter (publish, draft, etc.)
231
- * @param {number[]} [params.categories] - Array of category IDs to filter by
232
- * @param {number[]} [params.tags] - Array of tag IDs to filter by
233
- * @param {number} [params.page=1] - Page number for pagination
234
- *
235
- * @returns {Promise<string>} Formatted list of posts with metadata and context
236
- *
237
- * @throws {EnhancedError} When validation fails or API request encounters an error
238
- *
239
- * @example
240
- * ```typescript
241
- * // Basic listing
242
- * const result = await handleListPosts(client, {});
243
- *
244
- * // Advanced filtering
245
- * const filtered = await handleListPosts(client, {
246
- * search: "WordPress tips",
247
- * status: "publish",
248
- * categories: [1, 2],
249
- * per_page: 20
250
- * });
251
- * ```
252
- *
253
- * @since 1.0.0
254
- */
255
- public async handleListPosts(client: WordPressClient, params: PostQueryParams): Promise<any> {
256
- try {
257
- // Enhanced input validation and sanitization
258
- const paginationValidated = validatePaginationParams({
259
- page: params.page,
260
- per_page: params.per_page,
261
- offset: params.offset,
262
- });
263
-
264
- const sanitizedParams = {
265
- ...params,
266
- ...paginationValidated,
267
- };
268
-
269
- // Validate and sanitize search term
270
- if (sanitizedParams.search) {
271
- sanitizedParams.search = sanitizedParams.search.trim();
272
- if (sanitizedParams.search.length === 0) {
273
- delete sanitizedParams.search;
274
- }
275
- }
276
-
277
- // Validate category and tag IDs if provided
278
- if (sanitizedParams.categories) {
279
- sanitizedParams.categories = sanitizedParams.categories.map((id) => validateId(id, "category ID"));
280
- }
281
-
282
- if (sanitizedParams.tags) {
283
- sanitizedParams.tags = sanitizedParams.tags.map((id) => validateId(id, "tag ID"));
284
- }
285
-
286
- // Validate status parameter
287
- if (sanitizedParams.status) {
288
- const validStatuses = ["publish", "future", "draft", "pending", "private"];
289
- const statusesToCheck = Array.isArray(sanitizedParams.status)
290
- ? sanitizedParams.status
291
- : [sanitizedParams.status];
292
-
293
- for (const statusToCheck of statusesToCheck) {
294
- if (!validStatuses.includes(statusToCheck)) {
295
- throw ErrorHandlers.validationError("status", statusToCheck, "one of: " + validStatuses.join(", "));
296
- }
297
- }
298
- }
299
-
300
- // Performance optimization: set reasonable defaults
301
- if (!sanitizedParams.per_page) {
302
- sanitizedParams.per_page = 10; // Default to 10 posts for better performance
303
- }
304
-
305
- const posts = await client.getPosts(sanitizedParams);
306
- if (posts.length === 0) {
307
- const searchInfo = sanitizedParams.search ? ` matching "${sanitizedParams.search}"` : "";
308
- const statusInfo = sanitizedParams.status ? ` with status "${sanitizedParams.status}"` : "";
309
- return `No posts found${searchInfo}${statusInfo}. Try adjusting your search criteria or check if posts exist.`;
310
- }
311
-
312
- // Use streaming for large result sets (>50 posts)
313
- if (posts.length > 50) {
314
- const streamResults: StreamingResult<any>[] = [];
315
-
316
- for await (const result of WordPressDataStreamer.streamPosts(posts, {
317
- includeAuthor: true,
318
- includeCategories: true,
319
- includeTags: true,
320
- batchSize: 20,
321
- })) {
322
- streamResults.push(result);
323
- }
324
-
325
- return StreamingUtils.formatStreamingResponse(streamResults, "posts");
326
- }
327
-
328
- // Add comprehensive site context information
329
- const siteUrl = client.getSiteUrl ? client.getSiteUrl() : "Unknown site";
330
- const totalPosts = posts.length;
331
- const statusCounts = posts.reduce(
332
- (acc, p) => {
333
- acc[p.status] = (acc[p.status] || 0) + 1;
334
- return acc;
335
- },
336
- {} as Record<string, number>,
337
- );
338
-
339
- // Enhanced metadata
340
- const metadata = [
341
- `📊 **Posts Summary**: ${totalPosts} total`,
342
- `📝 **Status Breakdown**: ${Object.entries(statusCounts)
343
- .map(([status, count]) => `${status}: ${count}`)
344
- .join(", ")}`,
345
- `🌐 **Source**: ${siteUrl}`,
346
- `📅 **Retrieved**: ${new Date().toLocaleString()}`,
347
- ...(params.search ? [`🔍 **Search Term**: "${params.search}"`] : []),
348
- ...(params.categories ? [`📁 **Categories**: ${params.categories.join(", ")}`] : []),
349
- ...(params.tags ? [`🏷️ **Tags**: ${params.tags.join(", ")}`] : []),
350
- ];
351
-
352
- // Fetch additional metadata for enhanced responses
353
- const authorIds = [...new Set(posts.map((p) => p.author).filter(Boolean))];
354
- const categoryIds = [...new Set(posts.flatMap((p) => p.categories || []))];
355
- const tagIds = [...new Set(posts.flatMap((p) => p.tags || []))];
356
-
357
- // Fetch authors, categories, and tags in parallel for better performance
358
- const [authors, categories, tags] = await Promise.all([
359
- authorIds.length > 0
360
- ? Promise.all(
361
- authorIds.map(async (id) => {
362
- try {
363
- const user = await client.getUser(id);
364
- return { id, name: user.name || user.username || `User ${id}` };
365
- } catch {
366
- return { id, name: `User ${id}` };
367
- }
368
- }),
369
- )
370
- : [],
371
- categoryIds.length > 0
372
- ? Promise.all(
373
- categoryIds.map(async (id) => {
374
- try {
375
- const category = await client.getCategory(id);
376
- return { id, name: category.name || `Category ${id}` };
377
- } catch {
378
- return { id, name: `Category ${id}` };
379
- }
380
- }),
381
- )
382
- : [],
383
- tagIds.length > 0
384
- ? Promise.all(
385
- tagIds.map(async (id) => {
386
- try {
387
- const tag = await client.getTag(id);
388
- return { id, name: tag.name || `Tag ${id}` };
389
- } catch {
390
- return { id, name: `Tag ${id}` };
391
- }
392
- }),
393
- )
394
- : [],
395
- ]);
396
-
397
- // Create lookup maps for performance
398
- const authorMap = new Map(authors.map((a) => [a.id, a.name]));
399
- const categoryMap = new Map(categories.map((c) => [c.id, c.name]));
400
- const tagMap = new Map(tags.map((t) => [t.id, t.name]));
401
-
402
- const content =
403
- metadata.join("\n") +
404
- "\n\n" +
405
- posts
406
- .map((p) => {
407
- const date = new Date(p.date);
408
- const formattedDate = date.toLocaleDateString("en-US", {
409
- year: "numeric",
410
- month: "short",
411
- day: "numeric",
412
- });
413
- const excerpt = p.excerpt?.rendered
414
- ? p.excerpt.rendered.replace(/<[^>]*>/g, "").substring(0, 80) + "..."
415
- : "";
416
-
417
- // Enhanced metadata
418
- const authorName = authorMap.get(p.author) || `User ${p.author}`;
419
- const postCategories = (p.categories || []).map((id) => categoryMap.get(id) || `Category ${id}`);
420
- const postTags = (p.tags || []).map((id) => tagMap.get(id) || `Tag ${id}`);
421
-
422
- let postInfo = `- ID ${p.id}: **${p.title.rendered}** (${p.status})\n`;
423
- postInfo += ` 👤 Author: ${authorName}\n`;
424
- postInfo += ` 📅 Published: ${formattedDate}\n`;
425
- if (postCategories.length > 0) {
426
- postInfo += ` 📁 Categories: ${postCategories.join(", ")}\n`;
427
- }
428
- if (postTags.length > 0) {
429
- postInfo += ` 🏷️ Tags: ${postTags.join(", ")}\n`;
430
- }
431
- if (excerpt) {
432
- postInfo += ` 📝 Excerpt: ${excerpt}\n`;
433
- }
434
- postInfo += ` 🔗 Link: ${p.link}`;
435
-
436
- return postInfo;
437
- })
438
- .join("\n\n");
439
-
440
- // Add pagination guidance for large result sets
441
- let finalContent = content;
442
- if (posts.length >= (sanitizedParams.per_page || 10)) {
443
- finalContent += `\n\n📄 **Pagination Tip**: Use \`per_page\` parameter to control results (max 100). Current: ${sanitizedParams.per_page || 10}`;
444
- }
445
-
446
- return finalContent;
447
- } catch (error) {
448
- throw new Error(`Failed to list posts: ${getErrorMessage(error)}`);
449
- }
450
- }
451
-
452
- /**
453
- * Retrieves a single WordPress post by ID with complete details and metadata.
454
- *
455
- * This method fetches a specific post and returns comprehensive information including
456
- * content, metadata, author details, categories, tags, and publication status.
457
- *
458
- * @param {WordPressClient} client - The WordPress client instance for API communication
459
- * @param {Object} params - Parameters for post retrieval
460
- * @param {number} params.id - The unique ID of the post to retrieve
461
- *
462
- * @returns {Promise<string>} Detailed post information formatted for display
463
- *
464
- * @throws {EnhancedError} When post ID is invalid or post is not found
465
- *
466
- * @example
467
- * ```typescript
468
- * // Get a specific post
469
- * const post = await handleGetPost(client, { id: 123 });
470
- * ```
471
- *
472
- * @since 1.0.0
473
- */
474
- public async handleGetPost(client: WordPressClient, params: { id: number }): Promise<any> {
475
- try {
476
- // Input validation
477
- if (!params.id || typeof params.id !== "number" || params.id <= 0) {
478
- throw ErrorHandlers.validationError("id", params.id, "positive integer");
479
- }
480
-
481
- const post = await client.getPost(params.id);
482
-
483
- // Fetch additional metadata for enhanced response
484
- const [author, categories, tags] = await Promise.all([
485
- post.author
486
- ? (async () => {
487
- try {
488
- const user = await client.getUser(post.author);
489
- return user.name || user.username || `User ${post.author}`;
490
- } catch {
491
- return `User ${post.author}`;
492
- }
493
- })()
494
- : "Unknown",
495
- post.categories && post.categories.length > 0
496
- ? Promise.all(
497
- post.categories.map(async (id) => {
498
- try {
499
- const category = await client.getCategory(id);
500
- return category.name || `Category ${id}`;
501
- } catch {
502
- return `Category ${id}`;
503
- }
504
- }),
505
- )
506
- : [],
507
- post.tags && post.tags.length > 0
508
- ? Promise.all(
509
- post.tags.map(async (id) => {
510
- try {
511
- const tag = await client.getTag(id);
512
- return tag.name || `Tag ${id}`;
513
- } catch {
514
- return `Tag ${id}`;
515
- }
516
- }),
517
- )
518
- : [],
519
- ]);
520
-
521
- // Enhanced post details with comprehensive metadata
522
- const siteUrl = client.getSiteUrl ? client.getSiteUrl() : "Unknown site";
523
- const publishedDate = new Date(post.date);
524
- const modifiedDate = new Date(post.modified);
525
- const excerpt = post.excerpt?.rendered
526
- ? post.excerpt.rendered.replace(/<[^>]*>/g, "").substring(0, 150) + "..."
527
- : "No excerpt available";
528
- const wordCount = post.content?.rendered ? post.content.rendered.replace(/<[^>]*>/g, "").split(/\s+/).length : 0;
529
-
530
- let content = `**📄 Post Details (ID: ${post.id})**\n\n`;
531
- content += `**📋 Basic Information:**\n`;
532
- content += `- **Title:** ${post.title.rendered}\n`;
533
- content += `- **Status:** ${post.status}\n`;
534
- content += `- **Type:** ${post.type}\n`;
535
- content += `- **Author:** ${author}\n`;
536
- content += `- **Slug:** ${post.slug}\n\n`;
537
-
538
- content += `**📅 Dates:**\n`;
539
- content += `- **Published:** ${publishedDate.toLocaleString()}\n`;
540
- content += `- **Modified:** ${modifiedDate.toLocaleString()}\n\n`;
541
-
542
- content += `**📊 Content:**\n`;
543
- content += `- **Word Count:** ~${wordCount} words\n`;
544
- content += `- **Excerpt:** ${excerpt}\n\n`;
545
-
546
- if (categories.length > 0) {
547
- content += `**📁 Categories:** ${categories.join(", ")}\n`;
548
- }
549
- if (tags.length > 0) {
550
- content += `**🏷️ Tags:** ${tags.join(", ")}\n`;
551
- }
552
- if (categories.length > 0 || tags.length > 0) {
553
- content += `\n`;
554
- }
555
-
556
- content += `**🔗 Links:**\n`;
557
- content += `- **Permalink:** ${post.link}\n`;
558
- content += `- **Edit Link:** ${post.link.replace(/\/$/, "")}/wp-admin/post.php?post=${post.id}&action=edit\n\n`;
559
- content += `**🌐 Source:** ${siteUrl}\n`;
560
- content += `**📅 Retrieved:** ${new Date().toLocaleString()}`;
561
-
562
- return content;
563
- } catch (error) {
564
- // Handle specific error cases
565
- const errorMessage = getErrorMessage(error);
566
-
567
- if (errorMessage.includes("Invalid post ID") || errorMessage.includes("not found")) {
568
- throw ErrorHandlers.postNotFound(params.id, error);
569
- }
570
-
571
- if (errorMessage.includes("401") || errorMessage.includes("Unauthorized")) {
572
- throw ErrorHandlers.authenticationFailed(error);
573
- }
574
-
575
- if (errorMessage.includes("403") || errorMessage.includes("Forbidden")) {
576
- throw ErrorHandlers.permissionDenied("get post", error);
577
- }
578
-
579
- if (errorMessage.includes("timeout") || errorMessage.includes("network")) {
580
- throw ErrorHandlers.connectionError(error);
581
- }
582
-
583
- // Generic error with suggestions
584
- throw ErrorHandlers.generic("get post", error);
585
- }
586
- }
587
-
588
- /**
589
- * Creates a new WordPress post with comprehensive validation and metadata support.
590
- *
591
- * This method handles the creation of new posts with full support for content,
592
- * metadata, categories, tags, and publishing options. Includes automatic validation
593
- * and sanitization of all input parameters.
594
- *
595
- * @param {WordPressClient} client - The WordPress client instance for API communication
596
- * @param {CreatePostRequest} params - Post creation parameters
597
- * @param {string} params.title - The post title
598
- * @param {string} params.content - The post content in HTML format
599
- * @param {string} [params.status="draft"] - Post status (publish, draft, pending, private)
600
- * @param {string} [params.excerpt] - Post excerpt/summary
601
- * @param {number[]} [params.categories] - Array of category IDs to assign
602
- * @param {number[]} [params.tags] - Array of tag IDs to assign
603
- *
604
- * @returns {Promise<string>} Success message with the new post ID and details
605
- *
606
- * @throws {EnhancedError} When validation fails or post creation encounters an error
607
- *
608
- * @example
609
- * ```typescript
610
- * // Create a basic post
611
- * const result = await handleCreatePost(client, {
612
- * title: "My New Post",
613
- * content: "<p>This is the post content.</p>",
614
- * status: "publish"
615
- * });
616
- *
617
- * // Create post with categories and tags
618
- * const detailed = await handleCreatePost(client, {
619
- * title: "WordPress Tips",
620
- * content: "<p>Detailed WordPress tips...</p>",
621
- * categories: [1, 2],
622
- * tags: [5, 6],
623
- * excerpt: "Learn essential WordPress tips"
624
- * });
625
- * ```
626
- *
627
- * @since 1.0.0
628
- */
629
- public async handleCreatePost(client: WordPressClient, params: CreatePostRequest): Promise<any> {
630
- try {
631
- // Enhanced input validation using new validation utilities
632
- const validatedParams = validatePostParams(params);
633
-
634
- const post = await client.createPost(validatedParams);
635
- const siteUrl = client.getSiteUrl ? client.getSiteUrl() : "Unknown site";
636
-
637
- return (
638
- `✅ **Post Created Successfully!**\n\n` +
639
- `**📄 Post Details:**\n` +
640
- `- **ID:** ${post.id}\n` +
641
- `- **Title:** ${post.title.rendered}\n` +
642
- `- **Status:** ${post.status}\n` +
643
- `- **Link:** ${post.link}\n` +
644
- `- **Edit Link:** ${post.link.replace(/\/$/, "")}/wp-admin/post.php?post=${post.id}&action=edit\n\n` +
645
- `**🌐 Site:** ${siteUrl}\n` +
646
- `**📅 Created:** ${new Date().toLocaleString()}`
647
- );
648
- } catch (error) {
649
- if (error instanceof EnhancedError) {
650
- throw error;
651
- }
652
- throw new Error(`Failed to create post: ${getErrorMessage(error)}`);
653
- }
654
- }
655
-
656
- /**
657
- * Updates an existing WordPress post with validation and detailed confirmation.
658
- *
659
- * This method allows updating any aspect of a post including title, content, status,
660
- * categories, and tags. Only provided fields are updated, leaving others unchanged.
661
- *
662
- * @param {WordPressClient} client - The WordPress client instance for API communication
663
- * @param {UpdatePostRequest & {id: number}} params - Update parameters
664
- * @param {number} params.id - The ID of the post to update
665
- * @param {string} [params.title] - New post title
666
- * @param {string} [params.content] - New post content in HTML format
667
- * @param {string} [params.status] - New post status (publish, draft, pending, private)
668
- * @param {string} [params.excerpt] - New post excerpt
669
- * @param {number[]} [params.categories] - New category IDs to assign
670
- * @param {number[]} [params.tags] - New tag IDs to assign
671
- *
672
- * @returns {Promise<string>} Success message confirming the update
673
- *
674
- * @throws {EnhancedError} When post ID is invalid or update fails
675
- *
676
- * @example
677
- * ```typescript
678
- * // Update post title and status
679
- * const result = await handleUpdatePost(client, {
680
- * id: 123,
681
- * title: "Updated Post Title",
682
- * status: "publish"
683
- * });
684
- *
685
- * // Update content and categories
686
- * const updated = await handleUpdatePost(client, {
687
- * id: 123,
688
- * content: "<p>New content here...</p>",
689
- * categories: [1, 3, 5]
690
- * });
691
- * ```
692
- *
693
- * @since 1.0.0
694
- */
695
- public async handleUpdatePost(client: WordPressClient, params: UpdatePostRequest & { id: number }): Promise<any> {
696
- try {
697
- const post = await client.updatePost(params);
698
- return `✅ Post ${post.id} updated successfully.`;
699
- } catch (error) {
700
- throw new Error(`Failed to update post: ${getErrorMessage(error)}`);
701
- }
702
- }
703
-
704
- /**
705
- * Deletes a WordPress post with options for trash or permanent deletion.
706
- *
707
- * This method provides safe deletion with trash option (default) or permanent
708
- * deletion when force is specified. Includes confirmation of the deletion action.
709
- *
710
- * @param {WordPressClient} client - The WordPress client instance for API communication
711
- * @param {Object} params - Deletion parameters
712
- * @param {number} params.id - The ID of the post to delete
713
- * @param {boolean} [params.force=false] - Whether to permanently delete (true) or move to trash (false)
714
- *
715
- * @returns {Promise<string>} Confirmation message of the deletion action
716
- *
717
- * @throws {EnhancedError} When post ID is invalid or deletion fails
718
- *
719
- * @example
720
- * ```typescript
721
- * // Move post to trash (safe deletion)
722
- * const result = await handleDeletePost(client, { id: 123 });
723
- *
724
- * // Permanently delete post (cannot be undone)
725
- * const permanent = await handleDeletePost(client, {
726
- * id: 123,
727
- * force: true
728
- * });
729
- * ```
730
- *
731
- * @since 1.0.0
732
- */
733
- public async handleDeletePost(client: WordPressClient, params: { id: number; force?: boolean }): Promise<any> {
734
- try {
735
- await client.deletePost(params.id, params.force);
736
- const action = params.force ? "permanently deleted" : "moved to trash";
737
- return `✅ Post ${params.id} has been ${action}.`;
738
- } catch (error) {
739
- throw new Error(`Failed to delete post: ${getErrorMessage(error)}`);
740
- }
741
- }
742
-
743
- /**
744
- * Retrieves revision history for a specific WordPress post.
745
- *
746
- * This method fetches all available revisions for a post, providing a complete
747
- * history of changes including dates, authors, and modification details.
748
- *
749
- * @param {WordPressClient} client - The WordPress client instance for API communication
750
- * @param {Object} params - Parameters for revision retrieval
751
- * @param {number} params.id - The ID of the post to get revisions for
752
- *
753
- * @returns {Promise<string>} Formatted list of post revisions with details
754
- *
755
- * @throws {EnhancedError} When post ID is invalid or revisions cannot be retrieved
756
- *
757
- * @example
758
- * ```typescript
759
- * // Get all revisions for a post
760
- * const revisions = await handleGetPostRevisions(client, { id: 123 });
761
- * ```
762
- *
763
- * @since 1.0.0
764
- */
765
- public async handleGetPostRevisions(client: WordPressClient, params: { id: number }): Promise<any> {
766
- try {
767
- const revisions = await client.getPostRevisions(params.id);
768
- if (revisions.length === 0) {
769
- return `No revisions found for post ${params.id}.`;
770
- }
771
- const content =
772
- `Found ${revisions.length} revisions for post ${params.id}:\n\n` +
773
- revisions
774
- .map((r) => `- Revision by user ID ${r.author} at ${new Date(r.modified).toLocaleString()}`)
775
- .join("\n");
776
- return content;
777
- } catch (error) {
778
- throw new Error(`Failed to get post revisions: ${getErrorMessage(error)}`);
779
- }
780
- }
781
- }
782
11
 
783
- export default PostTools;
12
+ // Re-export the refactored PostTools class for backward compatibility
13
+ export { PostTools as default, PostTools } from "./posts/index.js";
14
+
15
+ // Re-export types and handlers for advanced usage
16
+ export type { CreatePostRequest, PostQueryParams, UpdatePostRequest, WordPressPost } from "../types/wordpress.js";
17
+
18
+ // Re-export specific components for granular imports
19
+ export { postToolDefinitions } from "./posts/PostToolDefinitions.js";
20
+ export {
21
+ handleListPosts,
22
+ handleGetPost,
23
+ handleCreatePost,
24
+ handleUpdatePost,
25
+ handleDeletePost,
26
+ handleGetPostRevisions,
27
+ } from "./posts/PostHandlers.js";