mcp-wordpress 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/README.md +210 -182
  2. package/dist/cache/CacheInvalidation.d.ts +3 -3
  3. package/dist/cache/CacheInvalidation.d.ts.map +1 -1
  4. package/dist/cache/CacheInvalidation.js +119 -119
  5. package/dist/cache/CacheInvalidation.js.map +1 -1
  6. package/dist/cache/CacheManager.d.ts +5 -0
  7. package/dist/cache/CacheManager.d.ts.map +1 -1
  8. package/dist/cache/CacheManager.js +26 -16
  9. package/dist/cache/CacheManager.js.map +1 -1
  10. package/dist/cache/HttpCacheWrapper.d.ts +1 -1
  11. package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
  12. package/dist/cache/HttpCacheWrapper.js +29 -29
  13. package/dist/cache/HttpCacheWrapper.js.map +1 -1
  14. package/dist/cache/__tests__/CacheInvalidation.test.js +96 -94
  15. package/dist/cache/__tests__/CacheInvalidation.test.js.map +1 -1
  16. package/dist/cache/__tests__/CacheManager.test.js +113 -113
  17. package/dist/cache/__tests__/CacheManager.test.js.map +1 -1
  18. package/dist/cache/__tests__/CachedWordPressClient.test.js +102 -99
  19. package/dist/cache/__tests__/CachedWordPressClient.test.js.map +1 -1
  20. package/dist/cache/__tests__/HttpCacheWrapper.test.js +98 -95
  21. package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +1 -1
  22. package/dist/cache/index.d.ts +7 -7
  23. package/dist/cache/index.d.ts.map +1 -1
  24. package/dist/cache/index.js +4 -4
  25. package/dist/cache/index.js.map +1 -1
  26. package/dist/client/CachedWordPressClient.d.ts +4 -4
  27. package/dist/client/CachedWordPressClient.d.ts.map +1 -1
  28. package/dist/client/CachedWordPressClient.js +55 -51
  29. package/dist/client/CachedWordPressClient.js.map +1 -1
  30. package/dist/client/api.d.ts +10 -10
  31. package/dist/client/api.js +158 -158
  32. package/dist/client/api.js.map +1 -1
  33. package/dist/client/auth.d.ts +2 -2
  34. package/dist/client/auth.js +72 -72
  35. package/dist/client/managers/AuthenticationManager.d.ts +2 -2
  36. package/dist/client/managers/AuthenticationManager.js +46 -46
  37. package/dist/client/managers/BaseManager.d.ts +1 -1
  38. package/dist/client/managers/BaseManager.js +9 -9
  39. package/dist/client/managers/RequestManager.d.ts +5 -3
  40. package/dist/client/managers/RequestManager.d.ts.map +1 -1
  41. package/dist/client/managers/RequestManager.js +39 -19
  42. package/dist/client/managers/RequestManager.js.map +1 -1
  43. package/dist/client/managers/index.d.ts +3 -3
  44. package/dist/client/managers/index.js +3 -3
  45. package/dist/config/ConfigurationSchema.d.ts +2 -2
  46. package/dist/config/ConfigurationSchema.d.ts.map +1 -1
  47. package/dist/config/ConfigurationSchema.js +40 -40
  48. package/dist/config/ConfigurationSchema.js.map +1 -1
  49. package/dist/config/ServerConfiguration.d.ts +2 -2
  50. package/dist/config/ServerConfiguration.js +35 -35
  51. package/dist/config/ServerConfiguration.js.map +1 -1
  52. package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
  53. package/dist/docs/DocumentationGenerator.js +296 -255
  54. package/dist/docs/DocumentationGenerator.js.map +1 -1
  55. package/dist/docs/MarkdownFormatter.d.ts +1 -1
  56. package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
  57. package/dist/docs/MarkdownFormatter.js +60 -51
  58. package/dist/docs/MarkdownFormatter.js.map +1 -1
  59. package/dist/docs/index.d.ts +3 -3
  60. package/dist/docs/index.d.ts.map +1 -1
  61. package/dist/docs/index.js +2 -2
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +16 -16
  64. package/dist/index.js.map +1 -1
  65. package/dist/mcp-wordpress-1.3.0.tgz +0 -0
  66. package/dist/performance/MetricsCollector.d.ts +3 -3
  67. package/dist/performance/MetricsCollector.d.ts.map +1 -1
  68. package/dist/performance/MetricsCollector.js +33 -27
  69. package/dist/performance/MetricsCollector.js.map +1 -1
  70. package/dist/performance/PerformanceAnalytics.d.ts +12 -12
  71. package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
  72. package/dist/performance/PerformanceAnalytics.js +200 -154
  73. package/dist/performance/PerformanceAnalytics.js.map +1 -1
  74. package/dist/performance/PerformanceMonitor.d.ts +5 -5
  75. package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
  76. package/dist/performance/PerformanceMonitor.js +53 -52
  77. package/dist/performance/PerformanceMonitor.js.map +1 -1
  78. package/dist/performance/index.d.ts +6 -6
  79. package/dist/performance/index.d.ts.map +1 -1
  80. package/dist/performance/index.js +3 -3
  81. package/dist/security/InputValidator.d.ts +1 -1
  82. package/dist/security/InputValidator.d.ts.map +1 -1
  83. package/dist/security/InputValidator.js +111 -88
  84. package/dist/security/InputValidator.js.map +1 -1
  85. package/dist/security/SecurityConfig.d.ts +5 -5
  86. package/dist/security/SecurityConfig.js +92 -92
  87. package/dist/security/SecurityConfig.js.map +1 -1
  88. package/dist/server/ConnectionTester.d.ts +1 -1
  89. package/dist/server/ConnectionTester.d.ts.map +1 -1
  90. package/dist/server/ConnectionTester.js +4 -4
  91. package/dist/server/ConnectionTester.js.map +1 -1
  92. package/dist/server/ToolRegistry.d.ts +2 -2
  93. package/dist/server/ToolRegistry.d.ts.map +1 -1
  94. package/dist/server/ToolRegistry.js +35 -32
  95. package/dist/server/ToolRegistry.js.map +1 -1
  96. package/dist/server.d.ts +2 -2
  97. package/dist/server.js +2 -2
  98. package/dist/tools/BaseToolManager.js +5 -5
  99. package/dist/tools/auth.d.ts +2 -2
  100. package/dist/tools/auth.d.ts.map +1 -1
  101. package/dist/tools/auth.js +32 -31
  102. package/dist/tools/auth.js.map +1 -1
  103. package/dist/tools/cache.d.ts +1 -1
  104. package/dist/tools/cache.d.ts.map +1 -1
  105. package/dist/tools/cache.js +71 -71
  106. package/dist/tools/cache.js.map +1 -1
  107. package/dist/tools/comments.d.ts +2 -2
  108. package/dist/tools/comments.d.ts.map +1 -1
  109. package/dist/tools/comments.js +79 -79
  110. package/dist/tools/comments.js.map +1 -1
  111. package/dist/tools/index.d.ts +10 -10
  112. package/dist/tools/index.js +10 -10
  113. package/dist/tools/media.d.ts +2 -2
  114. package/dist/tools/media.js +80 -80
  115. package/dist/tools/pages.d.ts +2 -2
  116. package/dist/tools/pages.d.ts.map +1 -1
  117. package/dist/tools/pages.js +75 -75
  118. package/dist/tools/pages.js.map +1 -1
  119. package/dist/tools/performance.d.ts +1 -1
  120. package/dist/tools/performance.d.ts.map +1 -1
  121. package/dist/tools/performance.js +311 -287
  122. package/dist/tools/performance.js.map +1 -1
  123. package/dist/tools/posts.d.ts +2 -2
  124. package/dist/tools/posts.d.ts.map +1 -1
  125. package/dist/tools/posts.js +94 -94
  126. package/dist/tools/posts.js.map +1 -1
  127. package/dist/tools/site.d.ts +2 -2
  128. package/dist/tools/site.d.ts.map +1 -1
  129. package/dist/tools/site.js +60 -60
  130. package/dist/tools/site.js.map +1 -1
  131. package/dist/tools/taxonomies.d.ts +2 -2
  132. package/dist/tools/taxonomies.js +89 -89
  133. package/dist/tools/users.d.ts +2 -2
  134. package/dist/tools/users.js +68 -68
  135. package/dist/tools/users.js.map +1 -1
  136. package/dist/types/client.d.ts +13 -13
  137. package/dist/types/client.d.ts.map +1 -1
  138. package/dist/types/client.js +12 -12
  139. package/dist/types/client.js.map +1 -1
  140. package/dist/types/index.d.ts +19 -19
  141. package/dist/types/index.d.ts.map +1 -1
  142. package/dist/types/index.js +3 -3
  143. package/dist/types/mcp.d.ts +7 -7
  144. package/dist/types/wordpress.d.ts +21 -21
  145. package/dist/types/wordpress.d.ts.map +1 -1
  146. package/dist/utils/debug.d.ts +2 -2
  147. package/dist/utils/debug.js +28 -28
  148. package/dist/utils/error.d.ts.map +1 -1
  149. package/dist/utils/error.js +13 -13
  150. package/dist/utils/error.js.map +1 -1
  151. package/dist/utils/toolWrapper.d.ts.map +1 -1
  152. package/dist/utils/toolWrapper.js +5 -5
  153. package/dist/utils/toolWrapper.js.map +1 -1
  154. package/dist/utils/validation.d.ts.map +1 -1
  155. package/dist/utils/validation.js +41 -31
  156. package/dist/utils/validation.js.map +1 -1
  157. package/docs/CACHING.md +36 -2
  158. package/docs/DOCKER.md +24 -18
  159. package/docs/PERFORMANCE_MONITORING.md +49 -1
  160. package/docs/SECURITY_TESTING.md +30 -1
  161. package/docs/api/README.md +9 -1
  162. package/docs/api/summary.json +1 -1
  163. package/docs/contract-testing.md +24 -3
  164. package/docs/developer/GITHUB_ACTIONS_SETUP.md +8 -2
  165. package/docs/developer/MAINTENANCE.md +29 -3
  166. package/docs/developer/MIGRATION_GUIDE.md +13 -1
  167. package/docs/developer/NPM_AUTH_SETUP.md +13 -2
  168. package/docs/developer/REFACTORING.md +31 -1
  169. package/docs/releases/COMMUNITY_ANNOUNCEMENT_v1.1.2.md +18 -7
  170. package/docs/releases/RELEASE_NOTES_v1.1.2.md +31 -5
  171. package/docs/user-guides/DOCKER_SETUP.md +264 -0
  172. package/docs/user-guides/DTX_SETUP.md +327 -0
  173. package/docs/user-guides/NPM_SETUP.md +109 -0
  174. package/docs/user-guides/NPX_SETUP.md +281 -0
  175. package/docs/wordpress-rest-api-authentication-troubleshooting.md +13 -2
  176. package/package.json +27 -8
  177. package/src/cache/CacheInvalidation.ts +140 -132
  178. package/src/cache/CacheManager.ts +40 -29
  179. package/src/cache/HttpCacheWrapper.ts +105 -68
  180. package/src/cache/__tests__/CacheInvalidation.test.ts +123 -118
  181. package/src/cache/__tests__/CacheManager.test.ts +156 -152
  182. package/src/cache/__tests__/CachedWordPressClient.test.ts +131 -116
  183. package/src/cache/__tests__/HttpCacheWrapper.test.ts +118 -115
  184. package/src/cache/index.ts +13 -13
  185. package/src/client/CachedWordPressClient.ts +90 -80
  186. package/src/client/api.ts +205 -205
  187. package/src/client/auth.ts +80 -80
  188. package/src/client/managers/AuthenticationManager.ts +61 -61
  189. package/src/client/managers/BaseManager.ts +11 -11
  190. package/src/client/managers/RequestManager.ts +79 -47
  191. package/src/client/managers/index.ts +3 -3
  192. package/src/config/ConfigurationSchema.ts +44 -44
  193. package/src/config/ServerConfiguration.ts +39 -39
  194. package/src/docs/DocumentationGenerator.ts +402 -295
  195. package/src/docs/MarkdownFormatter.ts +94 -69
  196. package/src/docs/index.ts +4 -4
  197. package/src/index.ts +24 -21
  198. package/src/performance/MetricsCollector.ts +90 -58
  199. package/src/performance/PerformanceAnalytics.ts +386 -262
  200. package/src/performance/PerformanceMonitor.ts +152 -118
  201. package/src/performance/index.ts +9 -9
  202. package/src/security/InputValidator.ts +148 -91
  203. package/src/security/SecurityConfig.ts +94 -94
  204. package/src/server/ConnectionTester.ts +21 -15
  205. package/src/server/ToolRegistry.ts +64 -51
  206. package/src/server.ts +2 -2
  207. package/src/tools/BaseToolManager.ts +6 -6
  208. package/src/tools/auth.ts +42 -37
  209. package/src/tools/cache.ts +85 -81
  210. package/src/tools/comments.ts +93 -91
  211. package/src/tools/index.ts +10 -10
  212. package/src/tools/media.ts +89 -89
  213. package/src/tools/pages.ts +89 -87
  214. package/src/tools/performance.ts +443 -352
  215. package/src/tools/posts.ts +109 -107
  216. package/src/tools/site.ts +86 -77
  217. package/src/tools/taxonomies.ts +102 -102
  218. package/src/tools/users.ts +77 -77
  219. package/src/types/client.ts +157 -60
  220. package/src/types/index.ts +49 -27
  221. package/src/types/mcp.ts +15 -15
  222. package/src/types/wordpress.ts +57 -29
  223. package/src/utils/debug.ts +37 -37
  224. package/src/utils/error.ts +47 -25
  225. package/src/utils/toolWrapper.ts +12 -8
  226. package/src/utils/validation.ts +116 -65
  227. package/dist/client/WordPressClient.d.ts +0 -81
  228. package/dist/client/WordPressClient.d.ts.map +0 -1
  229. package/dist/client/WordPressClient.js +0 -354
  230. package/dist/client/WordPressClient.js.map +0 -1
  231. package/dist/performance/AnomalyDetector.d.ts +0 -63
  232. package/dist/performance/AnomalyDetector.d.ts.map +0 -1
  233. package/dist/performance/AnomalyDetector.js +0 -222
  234. package/dist/performance/AnomalyDetector.js.map +0 -1
  235. package/dist/performance/BenchmarkAnalyzer.d.ts +0 -67
  236. package/dist/performance/BenchmarkAnalyzer.d.ts.map +0 -1
  237. package/dist/performance/BenchmarkAnalyzer.js +0 -301
  238. package/dist/performance/BenchmarkAnalyzer.js.map +0 -1
  239. package/dist/performance/TrendAnalyzer.d.ts +0 -69
  240. package/dist/performance/TrendAnalyzer.d.ts.map +0 -1
  241. package/dist/performance/TrendAnalyzer.js +0 -203
  242. package/dist/performance/TrendAnalyzer.js.map +0 -1
  243. package/dist/tools/BaseToolClass.d.ts +0 -76
  244. package/dist/tools/BaseToolClass.d.ts.map +0 -1
  245. package/dist/tools/BaseToolClass.js +0 -104
  246. package/dist/tools/BaseToolClass.js.map +0 -1
  247. package/dist/tools/base.d.ts +0 -37
  248. package/dist/tools/base.d.ts.map +0 -1
  249. package/dist/tools/base.js +0 -60
  250. package/dist/tools/base.js.map +0 -1
  251. package/docs/user-guides/CLAUDE_DESKTOP_SETUP.md +0 -187
@@ -1,10 +1,10 @@
1
- import { WordPressClient } from '../client/api.js';
1
+ import { WordPressClient } from "../client/api.js";
2
2
  import {
3
3
  CommentQueryParams,
4
4
  CreateCommentRequest,
5
- UpdateCommentRequest
6
- } from '../types/wordpress.js';
7
- import { getErrorMessage } from '../utils/error.js';
5
+ UpdateCommentRequest,
6
+ } from "../types/wordpress.js";
7
+ import { getErrorMessage } from "../utils/error.js";
8
8
 
9
9
  /**
10
10
  * Provides tools for managing comments on a WordPress site.
@@ -18,155 +18,155 @@ export class CommentTools {
18
18
  public getTools(): any[] {
19
19
  return [
20
20
  {
21
- name: 'wp_list_comments',
22
- description: 'Lists comments from a WordPress site, with filters.',
21
+ name: "wp_list_comments",
22
+ description: "Lists comments from a WordPress site, with filters.",
23
23
  parameters: [
24
24
  {
25
- name: 'post',
26
- type: 'number',
25
+ name: "post",
26
+ type: "number",
27
27
  description:
28
- 'Limit results to comments assigned to a specific post ID.'
28
+ "Limit results to comments assigned to a specific post ID.",
29
29
  },
30
30
  {
31
- name: 'status',
32
- type: 'string',
33
- description: 'Filter by comment status.',
34
- enum: ['hold', 'approve', 'spam', 'trash']
35
- }
31
+ name: "status",
32
+ type: "string",
33
+ description: "Filter by comment status.",
34
+ enum: ["hold", "approve", "spam", "trash"],
35
+ },
36
36
  ],
37
- handler: this.handleListComments.bind(this)
37
+ handler: this.handleListComments.bind(this),
38
38
  },
39
39
  {
40
- name: 'wp_get_comment',
41
- description: 'Retrieves a single comment by its ID.',
40
+ name: "wp_get_comment",
41
+ description: "Retrieves a single comment by its ID.",
42
42
  parameters: [
43
43
  {
44
- name: 'id',
45
- type: 'number',
44
+ name: "id",
45
+ type: "number",
46
46
  required: true,
47
- description: 'The unique identifier for the comment.'
48
- }
47
+ description: "The unique identifier for the comment.",
48
+ },
49
49
  ],
50
- handler: this.handleGetComment.bind(this)
50
+ handler: this.handleGetComment.bind(this),
51
51
  },
52
52
  {
53
- name: 'wp_create_comment',
54
- description: 'Creates a new comment on a post.',
53
+ name: "wp_create_comment",
54
+ description: "Creates a new comment on a post.",
55
55
  parameters: [
56
56
  {
57
- name: 'post',
58
- type: 'number',
57
+ name: "post",
58
+ type: "number",
59
59
  required: true,
60
- description: 'The ID of the post to comment on.'
60
+ description: "The ID of the post to comment on.",
61
61
  },
62
62
  {
63
- name: 'content',
64
- type: 'string',
63
+ name: "content",
64
+ type: "string",
65
65
  required: true,
66
- description: 'The content of the comment.'
66
+ description: "The content of the comment.",
67
67
  },
68
68
  {
69
- name: 'author_name',
70
- type: 'string',
71
- description: 'The name of the comment author.'
69
+ name: "author_name",
70
+ type: "string",
71
+ description: "The name of the comment author.",
72
72
  },
73
73
  {
74
- name: 'author_email',
75
- type: 'string',
76
- description: 'The email of the comment author.'
77
- }
74
+ name: "author_email",
75
+ type: "string",
76
+ description: "The email of the comment author.",
77
+ },
78
78
  ],
79
- handler: this.handleCreateComment.bind(this)
79
+ handler: this.handleCreateComment.bind(this),
80
80
  },
81
81
  {
82
- name: 'wp_update_comment',
83
- description: 'Updates an existing comment.',
82
+ name: "wp_update_comment",
83
+ description: "Updates an existing comment.",
84
84
  parameters: [
85
85
  {
86
- name: 'id',
87
- type: 'number',
86
+ name: "id",
87
+ type: "number",
88
88
  required: true,
89
- description: 'The ID of the comment to update.'
89
+ description: "The ID of the comment to update.",
90
90
  },
91
91
  {
92
- name: 'content',
93
- type: 'string',
94
- description: 'The updated content for the comment.'
92
+ name: "content",
93
+ type: "string",
94
+ description: "The updated content for the comment.",
95
95
  },
96
96
  {
97
- name: 'status',
98
- type: 'string',
99
- description: 'The new status for the comment.',
100
- enum: ['hold', 'approve', 'spam', 'trash']
101
- }
97
+ name: "status",
98
+ type: "string",
99
+ description: "The new status for the comment.",
100
+ enum: ["hold", "approve", "spam", "trash"],
101
+ },
102
102
  ],
103
- handler: this.handleUpdateComment.bind(this)
103
+ handler: this.handleUpdateComment.bind(this),
104
104
  },
105
105
  {
106
- name: 'wp_delete_comment',
107
- description: 'Deletes a comment.',
106
+ name: "wp_delete_comment",
107
+ description: "Deletes a comment.",
108
108
  parameters: [
109
109
  {
110
- name: 'id',
111
- type: 'number',
110
+ name: "id",
111
+ type: "number",
112
112
  required: true,
113
- description: 'The ID of the comment to delete.'
113
+ description: "The ID of the comment to delete.",
114
114
  },
115
115
  {
116
- name: 'force',
117
- type: 'boolean',
116
+ name: "force",
117
+ type: "boolean",
118
118
  description:
119
- 'If true, the comment will be permanently deleted. Defaults to false (moved to trash).'
120
- }
119
+ "If true, the comment will be permanently deleted. Defaults to false (moved to trash).",
120
+ },
121
121
  ],
122
- handler: this.handleDeleteComment.bind(this)
122
+ handler: this.handleDeleteComment.bind(this),
123
123
  },
124
124
  {
125
- name: 'wp_approve_comment',
126
- description: 'Approves a pending comment.',
125
+ name: "wp_approve_comment",
126
+ description: "Approves a pending comment.",
127
127
  parameters: [
128
128
  {
129
- name: 'id',
130
- type: 'number',
129
+ name: "id",
130
+ type: "number",
131
131
  required: true,
132
- description: 'The ID of the comment to approve.'
133
- }
132
+ description: "The ID of the comment to approve.",
133
+ },
134
134
  ],
135
- handler: this.handleApproveComment.bind(this)
135
+ handler: this.handleApproveComment.bind(this),
136
136
  },
137
137
  {
138
- name: 'wp_spam_comment',
139
- description: 'Marks a comment as spam.',
138
+ name: "wp_spam_comment",
139
+ description: "Marks a comment as spam.",
140
140
  parameters: [
141
141
  {
142
- name: 'id',
143
- type: 'number',
142
+ name: "id",
143
+ type: "number",
144
144
  required: true,
145
- description: 'The ID of the comment to mark as spam.'
146
- }
145
+ description: "The ID of the comment to mark as spam.",
146
+ },
147
147
  ],
148
- handler: this.handleSpamComment.bind(this)
149
- }
148
+ handler: this.handleSpamComment.bind(this),
149
+ },
150
150
  ];
151
151
  }
152
152
 
153
153
  public async handleListComments(
154
154
  client: WordPressClient,
155
- params: CommentQueryParams
155
+ params: CommentQueryParams,
156
156
  ): Promise<any> {
157
157
  try {
158
158
  const comments = await client.getComments(params);
159
159
  if (comments.length === 0) {
160
- return 'No comments found matching the criteria.';
160
+ return "No comments found matching the criteria.";
161
161
  }
162
162
  const content =
163
163
  `Found ${comments.length} comments:\n\n` +
164
164
  comments
165
165
  .map(
166
166
  (c) =>
167
- `- ID ${c.id}: By **${c.author_name}** on Post ${c.post} (${c.status})\n > ${c.content.rendered.substring(0, 100)}...`
167
+ `- ID ${c.id}: By **${c.author_name}** on Post ${c.post} (${c.status})\n > ${c.content.rendered.substring(0, 100)}...`,
168
168
  )
169
- .join('\n');
169
+ .join("\n");
170
170
  return content;
171
171
  } catch (error) {
172
172
  throw new Error(`Failed to list comments: ${getErrorMessage(error)}`);
@@ -175,7 +175,7 @@ export class CommentTools {
175
175
 
176
176
  public async handleGetComment(
177
177
  client: WordPressClient,
178
- params: { id: number }
178
+ params: { id: number },
179
179
  ): Promise<any> {
180
180
  try {
181
181
  const comment = await client.getComment(params.id);
@@ -194,7 +194,7 @@ export class CommentTools {
194
194
 
195
195
  public async handleCreateComment(
196
196
  client: WordPressClient,
197
- params: CreateCommentRequest
197
+ params: CreateCommentRequest,
198
198
  ): Promise<any> {
199
199
  try {
200
200
  const comment = await client.createComment(params);
@@ -206,7 +206,7 @@ export class CommentTools {
206
206
 
207
207
  public async handleUpdateComment(
208
208
  client: WordPressClient,
209
- params: UpdateCommentRequest & { id: number }
209
+ params: UpdateCommentRequest & { id: number },
210
210
  ): Promise<any> {
211
211
  try {
212
212
  const comment = await client.updateComment(params);
@@ -218,11 +218,11 @@ export class CommentTools {
218
218
 
219
219
  public async handleDeleteComment(
220
220
  client: WordPressClient,
221
- params: { id: number; force?: boolean }
221
+ params: { id: number; force?: boolean },
222
222
  ): Promise<any> {
223
223
  try {
224
224
  await client.deleteComment(params.id, params.force);
225
- const action = params.force ? 'permanently deleted' : 'moved to trash';
225
+ const action = params.force ? "permanently deleted" : "moved to trash";
226
226
  return `✅ Comment ${params.id} has been ${action}.`;
227
227
  } catch (error) {
228
228
  throw new Error(`Failed to delete comment: ${getErrorMessage(error)}`);
@@ -231,12 +231,12 @@ export class CommentTools {
231
231
 
232
232
  public async handleApproveComment(
233
233
  client: WordPressClient,
234
- params: { id: number }
234
+ params: { id: number },
235
235
  ): Promise<any> {
236
236
  try {
237
237
  const comment = await client.updateComment({
238
238
  id: params.id,
239
- status: 'approved'
239
+ status: "approved",
240
240
  });
241
241
  return `✅ Comment ${comment.id} has been approved.`;
242
242
  } catch (error) {
@@ -246,16 +246,18 @@ export class CommentTools {
246
246
 
247
247
  public async handleSpamComment(
248
248
  client: WordPressClient,
249
- params: { id: number }
249
+ params: { id: number },
250
250
  ): Promise<any> {
251
251
  try {
252
252
  const comment = await client.updateComment({
253
253
  id: params.id,
254
- status: 'spam'
254
+ status: "spam",
255
255
  });
256
256
  return `✅ Comment ${comment.id} has been marked as spam.`;
257
257
  } catch (error) {
258
- throw new Error(`Failed to mark comment as spam: ${getErrorMessage(error)}`);
258
+ throw new Error(
259
+ `Failed to mark comment as spam: ${getErrorMessage(error)}`,
260
+ );
259
261
  }
260
262
  }
261
263
  }
@@ -1,10 +1,10 @@
1
- export { default as AuthTools } from './auth.js';
2
- export { default as CacheTools } from './cache.js';
3
- export { default as CommentTools } from './comments.js';
4
- export { default as MediaTools } from './media.js';
5
- export { default as PageTools } from './pages.js';
6
- export { default as PerformanceTools } from './performance.js';
7
- export { default as PostTools } from './posts.js';
8
- export { default as SiteTools } from './site.js';
9
- export { default as TaxonomyTools } from './taxonomies.js';
10
- export { default as UserTools } from './users.js';
1
+ export { default as AuthTools } from "./auth.js";
2
+ export { default as CacheTools } from "./cache.js";
3
+ export { default as CommentTools } from "./comments.js";
4
+ export { default as MediaTools } from "./media.js";
5
+ export { default as PageTools } from "./pages.js";
6
+ export { default as PerformanceTools } from "./performance.js";
7
+ export { default as PostTools } from "./posts.js";
8
+ export { default as SiteTools } from "./site.js";
9
+ export { default as TaxonomyTools } from "./taxonomies.js";
10
+ export { default as UserTools } from "./users.js";
@@ -1,11 +1,11 @@
1
- import * as fs from 'fs';
2
- import { WordPressClient } from '../client/api.js';
1
+ import * as fs from "fs";
2
+ import { WordPressClient } from "../client/api.js";
3
3
  import {
4
4
  MediaQueryParams,
5
5
  UpdateMediaRequest,
6
- UploadMediaRequest
7
- } from '../types/wordpress.js';
8
- import { getErrorMessage } from '../utils/error.js';
6
+ UploadMediaRequest,
7
+ } from "../types/wordpress.js";
8
+ import { getErrorMessage } from "../utils/error.js";
9
9
 
10
10
  /**
11
11
  * Provides tools for managing media on a WordPress site.
@@ -19,152 +19,152 @@ export class MediaTools {
19
19
  public getTools(): any[] {
20
20
  return [
21
21
  {
22
- name: 'wp_list_media',
23
- description: 'Lists media items from a WordPress site, with filters.',
22
+ name: "wp_list_media",
23
+ description: "Lists media items from a WordPress site, with filters.",
24
24
  parameters: [
25
25
  {
26
- name: 'per_page',
27
- type: 'number',
28
- description: 'Number of items to return per page (max 100).'
26
+ name: "per_page",
27
+ type: "number",
28
+ description: "Number of items to return per page (max 100).",
29
29
  },
30
30
  {
31
- name: 'search',
32
- type: 'string',
33
- description: 'Limit results to those matching a search term.'
31
+ name: "search",
32
+ type: "string",
33
+ description: "Limit results to those matching a search term.",
34
34
  },
35
35
  {
36
- name: 'media_type',
37
- type: 'string',
38
- description: 'Limit results to a specific media type.',
39
- enum: ['image', 'video', 'audio', 'application']
40
- }
36
+ name: "media_type",
37
+ type: "string",
38
+ description: "Limit results to a specific media type.",
39
+ enum: ["image", "video", "audio", "application"],
40
+ },
41
41
  ],
42
- handler: this.handleListMedia.bind(this)
42
+ handler: this.handleListMedia.bind(this),
43
43
  },
44
44
  {
45
- name: 'wp_get_media',
46
- description: 'Retrieves a single media item by its ID.',
45
+ name: "wp_get_media",
46
+ description: "Retrieves a single media item by its ID.",
47
47
  parameters: [
48
48
  {
49
- name: 'id',
50
- type: 'number',
49
+ name: "id",
50
+ type: "number",
51
51
  required: true,
52
- description: 'The unique identifier for the media item.'
53
- }
52
+ description: "The unique identifier for the media item.",
53
+ },
54
54
  ],
55
- handler: this.handleGetMedia.bind(this)
55
+ handler: this.handleGetMedia.bind(this),
56
56
  },
57
57
  {
58
- name: 'wp_upload_media',
59
- description: 'Uploads a file to the WordPress media library.',
58
+ name: "wp_upload_media",
59
+ description: "Uploads a file to the WordPress media library.",
60
60
  parameters: [
61
61
  {
62
- name: 'file_path',
63
- type: 'string',
62
+ name: "file_path",
63
+ type: "string",
64
64
  required: true,
65
- description: 'The local, absolute path to the file to upload.'
65
+ description: "The local, absolute path to the file to upload.",
66
66
  },
67
67
  {
68
- name: 'title',
69
- type: 'string',
70
- description: 'The title for the media item.'
68
+ name: "title",
69
+ type: "string",
70
+ description: "The title for the media item.",
71
71
  },
72
72
  {
73
- name: 'alt_text',
74
- type: 'string',
73
+ name: "alt_text",
74
+ type: "string",
75
75
  description:
76
- 'Alternative text for the media item (for accessibility).'
76
+ "Alternative text for the media item (for accessibility).",
77
77
  },
78
78
  {
79
- name: 'caption',
80
- type: 'string',
81
- description: 'The caption for the media item.'
79
+ name: "caption",
80
+ type: "string",
81
+ description: "The caption for the media item.",
82
82
  },
83
83
  {
84
- name: 'description',
85
- type: 'string',
86
- description: 'The description for the media item.'
84
+ name: "description",
85
+ type: "string",
86
+ description: "The description for the media item.",
87
87
  },
88
88
  {
89
- name: 'post',
90
- type: 'number',
91
- description: 'The ID of a post to attach this media to.'
92
- }
89
+ name: "post",
90
+ type: "number",
91
+ description: "The ID of a post to attach this media to.",
92
+ },
93
93
  ],
94
- handler: this.handleUploadMedia.bind(this)
94
+ handler: this.handleUploadMedia.bind(this),
95
95
  },
96
96
  {
97
- name: 'wp_update_media',
98
- description: 'Updates the metadata of an existing media item.',
97
+ name: "wp_update_media",
98
+ description: "Updates the metadata of an existing media item.",
99
99
  parameters: [
100
100
  {
101
- name: 'id',
102
- type: 'number',
101
+ name: "id",
102
+ type: "number",
103
103
  required: true,
104
- description: 'The ID of the media item to update.'
104
+ description: "The ID of the media item to update.",
105
105
  },
106
106
  {
107
- name: 'title',
108
- type: 'string',
109
- description: 'The new title for the media item.'
107
+ name: "title",
108
+ type: "string",
109
+ description: "The new title for the media item.",
110
110
  },
111
111
  {
112
- name: 'alt_text',
113
- type: 'string',
114
- description: 'The new alternative text.'
112
+ name: "alt_text",
113
+ type: "string",
114
+ description: "The new alternative text.",
115
115
  },
116
116
  {
117
- name: 'caption',
118
- type: 'string',
119
- description: 'The new caption.'
117
+ name: "caption",
118
+ type: "string",
119
+ description: "The new caption.",
120
120
  },
121
121
  {
122
- name: 'description',
123
- type: 'string',
124
- description: 'The new description.'
125
- }
122
+ name: "description",
123
+ type: "string",
124
+ description: "The new description.",
125
+ },
126
126
  ],
127
- handler: this.handleUpdateMedia.bind(this)
127
+ handler: this.handleUpdateMedia.bind(this),
128
128
  },
129
129
  {
130
- name: 'wp_delete_media',
131
- description: 'Deletes a media item.',
130
+ name: "wp_delete_media",
131
+ description: "Deletes a media item.",
132
132
  parameters: [
133
133
  {
134
- name: 'id',
135
- type: 'number',
134
+ name: "id",
135
+ type: "number",
136
136
  required: true,
137
- description: 'The ID of the media item to delete.'
137
+ description: "The ID of the media item to delete.",
138
138
  },
139
139
  {
140
- name: 'force',
141
- type: 'boolean',
140
+ name: "force",
141
+ type: "boolean",
142
142
  description:
143
- 'If true, permanently delete. If false, move to trash. Defaults to false.'
144
- }
143
+ "If true, permanently delete. If false, move to trash. Defaults to false.",
144
+ },
145
145
  ],
146
- handler: this.handleDeleteMedia.bind(this)
147
- }
146
+ handler: this.handleDeleteMedia.bind(this),
147
+ },
148
148
  ];
149
149
  }
150
150
 
151
151
  public async handleListMedia(
152
152
  client: WordPressClient,
153
- params: MediaQueryParams
153
+ params: MediaQueryParams,
154
154
  ): Promise<any> {
155
155
  try {
156
156
  const media = await client.getMedia(params);
157
157
  if (media.length === 0) {
158
- return 'No media items found matching the criteria.';
158
+ return "No media items found matching the criteria.";
159
159
  }
160
160
  const content =
161
161
  `Found ${media.length} media items:\n\n` +
162
162
  media
163
163
  .map(
164
164
  (m) =>
165
- `- ID ${m.id}: **${m.title.rendered}** (${m.mime_type})\n Link: ${m.source_url}`
165
+ `- ID ${m.id}: **${m.title.rendered}** (${m.mime_type})\n Link: ${m.source_url}`,
166
166
  )
167
- .join('\n');
167
+ .join("\n");
168
168
  return content;
169
169
  } catch (error) {
170
170
  throw new Error(`Failed to list media: ${getErrorMessage(error)}`);
@@ -173,7 +173,7 @@ export class MediaTools {
173
173
 
174
174
  public async handleGetMedia(
175
175
  client: WordPressClient,
176
- params: { id: number }
176
+ params: { id: number },
177
177
  ): Promise<any> {
178
178
  try {
179
179
  const media = await client.getMediaItem(params.id);
@@ -183,10 +183,10 @@ export class MediaTools {
183
183
  `- **URL:** ${media.source_url}\n` +
184
184
  `- **Type:** ${media.media_type} (${media.mime_type})\n` +
185
185
  `- **Date:** ${new Date(media.date).toLocaleString()}\n` +
186
- (media.alt_text ? `- **Alt Text:** ${media.alt_text}\n` : '') +
186
+ (media.alt_text ? `- **Alt Text:** ${media.alt_text}\n` : "") +
187
187
  (media.caption.rendered
188
188
  ? `- **Caption:** ${media.caption.rendered}\n`
189
- : '');
189
+ : "");
190
190
  return content;
191
191
  } catch (error) {
192
192
  throw new Error(`Failed to get media item: ${getErrorMessage(error)}`);
@@ -195,7 +195,7 @@ export class MediaTools {
195
195
 
196
196
  public async handleUploadMedia(
197
197
  client: WordPressClient,
198
- params: UploadMediaRequest & { file_path: string }
198
+ params: UploadMediaRequest & { file_path: string },
199
199
  ): Promise<any> {
200
200
  try {
201
201
  if (!fs.existsSync(params.file_path)) {
@@ -211,7 +211,7 @@ export class MediaTools {
211
211
 
212
212
  public async handleUpdateMedia(
213
213
  client: WordPressClient,
214
- params: UpdateMediaRequest & { id: number }
214
+ params: UpdateMediaRequest & { id: number },
215
215
  ): Promise<any> {
216
216
  try {
217
217
  const media = await client.updateMedia(params);
@@ -223,11 +223,11 @@ export class MediaTools {
223
223
 
224
224
  public async handleDeleteMedia(
225
225
  client: WordPressClient,
226
- params: { id: number; force?: boolean }
226
+ params: { id: number; force?: boolean },
227
227
  ): Promise<any> {
228
228
  try {
229
229
  await client.deleteMedia(params.id, params.force);
230
- const action = params.force ? 'permanently deleted' : 'moved to trash';
230
+ const action = params.force ? "permanently deleted" : "moved to trash";
231
231
  return `✅ Media item ${params.id} has been ${action}.`;
232
232
  } catch (error) {
233
233
  throw new Error(`Failed to delete media: ${getErrorMessage(error)}`);