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.
- package/README.md +210 -182
- package/dist/cache/CacheInvalidation.d.ts +3 -3
- package/dist/cache/CacheInvalidation.d.ts.map +1 -1
- package/dist/cache/CacheInvalidation.js +119 -119
- package/dist/cache/CacheInvalidation.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +5 -0
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +26 -16
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
- package/dist/cache/HttpCacheWrapper.js +29 -29
- package/dist/cache/HttpCacheWrapper.js.map +1 -1
- package/dist/cache/__tests__/CacheInvalidation.test.js +96 -94
- package/dist/cache/__tests__/CacheInvalidation.test.js.map +1 -1
- package/dist/cache/__tests__/CacheManager.test.js +113 -113
- package/dist/cache/__tests__/CacheManager.test.js.map +1 -1
- package/dist/cache/__tests__/CachedWordPressClient.test.js +102 -99
- package/dist/cache/__tests__/CachedWordPressClient.test.js.map +1 -1
- package/dist/cache/__tests__/HttpCacheWrapper.test.js +98 -95
- package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +1 -1
- package/dist/cache/index.d.ts +7 -7
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +4 -4
- package/dist/cache/index.js.map +1 -1
- package/dist/client/CachedWordPressClient.d.ts +4 -4
- package/dist/client/CachedWordPressClient.d.ts.map +1 -1
- package/dist/client/CachedWordPressClient.js +55 -51
- package/dist/client/CachedWordPressClient.js.map +1 -1
- package/dist/client/api.d.ts +10 -10
- package/dist/client/api.js +158 -158
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts +2 -2
- package/dist/client/auth.js +72 -72
- package/dist/client/managers/AuthenticationManager.d.ts +2 -2
- package/dist/client/managers/AuthenticationManager.js +46 -46
- package/dist/client/managers/BaseManager.d.ts +1 -1
- package/dist/client/managers/BaseManager.js +9 -9
- package/dist/client/managers/RequestManager.d.ts +5 -3
- package/dist/client/managers/RequestManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.js +39 -19
- package/dist/client/managers/RequestManager.js.map +1 -1
- package/dist/client/managers/index.d.ts +3 -3
- package/dist/client/managers/index.js +3 -3
- package/dist/config/ConfigurationSchema.d.ts +2 -2
- package/dist/config/ConfigurationSchema.d.ts.map +1 -1
- package/dist/config/ConfigurationSchema.js +40 -40
- package/dist/config/ConfigurationSchema.js.map +1 -1
- package/dist/config/ServerConfiguration.d.ts +2 -2
- package/dist/config/ServerConfiguration.js +35 -35
- package/dist/config/ServerConfiguration.js.map +1 -1
- package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
- package/dist/docs/DocumentationGenerator.js +296 -255
- package/dist/docs/DocumentationGenerator.js.map +1 -1
- package/dist/docs/MarkdownFormatter.d.ts +1 -1
- package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
- package/dist/docs/MarkdownFormatter.js +60 -51
- package/dist/docs/MarkdownFormatter.js.map +1 -1
- package/dist/docs/index.d.ts +3 -3
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/mcp-wordpress-1.3.0.tgz +0 -0
- package/dist/performance/MetricsCollector.d.ts +3 -3
- package/dist/performance/MetricsCollector.d.ts.map +1 -1
- package/dist/performance/MetricsCollector.js +33 -27
- package/dist/performance/MetricsCollector.js.map +1 -1
- package/dist/performance/PerformanceAnalytics.d.ts +12 -12
- package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
- package/dist/performance/PerformanceAnalytics.js +200 -154
- package/dist/performance/PerformanceAnalytics.js.map +1 -1
- package/dist/performance/PerformanceMonitor.d.ts +5 -5
- package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
- package/dist/performance/PerformanceMonitor.js +53 -52
- package/dist/performance/PerformanceMonitor.js.map +1 -1
- package/dist/performance/index.d.ts +6 -6
- package/dist/performance/index.d.ts.map +1 -1
- package/dist/performance/index.js +3 -3
- package/dist/security/InputValidator.d.ts +1 -1
- package/dist/security/InputValidator.d.ts.map +1 -1
- package/dist/security/InputValidator.js +111 -88
- package/dist/security/InputValidator.js.map +1 -1
- package/dist/security/SecurityConfig.d.ts +5 -5
- package/dist/security/SecurityConfig.js +92 -92
- package/dist/security/SecurityConfig.js.map +1 -1
- package/dist/server/ConnectionTester.d.ts +1 -1
- package/dist/server/ConnectionTester.d.ts.map +1 -1
- package/dist/server/ConnectionTester.js +4 -4
- package/dist/server/ConnectionTester.js.map +1 -1
- package/dist/server/ToolRegistry.d.ts +2 -2
- package/dist/server/ToolRegistry.d.ts.map +1 -1
- package/dist/server/ToolRegistry.js +35 -32
- package/dist/server/ToolRegistry.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/tools/BaseToolManager.js +5 -5
- package/dist/tools/auth.d.ts +2 -2
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +32 -31
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/cache.d.ts +1 -1
- package/dist/tools/cache.d.ts.map +1 -1
- package/dist/tools/cache.js +71 -71
- package/dist/tools/cache.js.map +1 -1
- package/dist/tools/comments.d.ts +2 -2
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +79 -79
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/index.d.ts +10 -10
- package/dist/tools/index.js +10 -10
- package/dist/tools/media.d.ts +2 -2
- package/dist/tools/media.js +80 -80
- package/dist/tools/pages.d.ts +2 -2
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +75 -75
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/performance.d.ts +1 -1
- package/dist/tools/performance.d.ts.map +1 -1
- package/dist/tools/performance.js +311 -287
- package/dist/tools/performance.js.map +1 -1
- package/dist/tools/posts.d.ts +2 -2
- package/dist/tools/posts.d.ts.map +1 -1
- package/dist/tools/posts.js +94 -94
- package/dist/tools/posts.js.map +1 -1
- package/dist/tools/site.d.ts +2 -2
- package/dist/tools/site.d.ts.map +1 -1
- package/dist/tools/site.js +60 -60
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts +2 -2
- package/dist/tools/taxonomies.js +89 -89
- package/dist/tools/users.d.ts +2 -2
- package/dist/tools/users.js +68 -68
- package/dist/tools/users.js.map +1 -1
- package/dist/types/client.d.ts +13 -13
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client.js +12 -12
- package/dist/types/client.js.map +1 -1
- package/dist/types/index.d.ts +19 -19
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -3
- package/dist/types/mcp.d.ts +7 -7
- package/dist/types/wordpress.d.ts +21 -21
- package/dist/types/wordpress.d.ts.map +1 -1
- package/dist/utils/debug.d.ts +2 -2
- package/dist/utils/debug.js +28 -28
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +13 -13
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts.map +1 -1
- package/dist/utils/toolWrapper.js +5 -5
- package/dist/utils/toolWrapper.js.map +1 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +41 -31
- package/dist/utils/validation.js.map +1 -1
- package/docs/CACHING.md +36 -2
- package/docs/DOCKER.md +24 -18
- package/docs/PERFORMANCE_MONITORING.md +49 -1
- package/docs/SECURITY_TESTING.md +30 -1
- package/docs/api/README.md +9 -1
- package/docs/api/summary.json +1 -1
- package/docs/contract-testing.md +24 -3
- package/docs/developer/GITHUB_ACTIONS_SETUP.md +8 -2
- package/docs/developer/MAINTENANCE.md +29 -3
- package/docs/developer/MIGRATION_GUIDE.md +13 -1
- package/docs/developer/NPM_AUTH_SETUP.md +13 -2
- package/docs/developer/REFACTORING.md +31 -1
- package/docs/releases/COMMUNITY_ANNOUNCEMENT_v1.1.2.md +18 -7
- package/docs/releases/RELEASE_NOTES_v1.1.2.md +31 -5
- package/docs/user-guides/DOCKER_SETUP.md +264 -0
- package/docs/user-guides/DTX_SETUP.md +327 -0
- package/docs/user-guides/NPM_SETUP.md +109 -0
- package/docs/user-guides/NPX_SETUP.md +281 -0
- package/docs/wordpress-rest-api-authentication-troubleshooting.md +13 -2
- package/package.json +27 -8
- package/src/cache/CacheInvalidation.ts +140 -132
- package/src/cache/CacheManager.ts +40 -29
- package/src/cache/HttpCacheWrapper.ts +105 -68
- package/src/cache/__tests__/CacheInvalidation.test.ts +123 -118
- package/src/cache/__tests__/CacheManager.test.ts +156 -152
- package/src/cache/__tests__/CachedWordPressClient.test.ts +131 -116
- package/src/cache/__tests__/HttpCacheWrapper.test.ts +118 -115
- package/src/cache/index.ts +13 -13
- package/src/client/CachedWordPressClient.ts +90 -80
- package/src/client/api.ts +205 -205
- package/src/client/auth.ts +80 -80
- package/src/client/managers/AuthenticationManager.ts +61 -61
- package/src/client/managers/BaseManager.ts +11 -11
- package/src/client/managers/RequestManager.ts +79 -47
- package/src/client/managers/index.ts +3 -3
- package/src/config/ConfigurationSchema.ts +44 -44
- package/src/config/ServerConfiguration.ts +39 -39
- package/src/docs/DocumentationGenerator.ts +402 -295
- package/src/docs/MarkdownFormatter.ts +94 -69
- package/src/docs/index.ts +4 -4
- package/src/index.ts +24 -21
- package/src/performance/MetricsCollector.ts +90 -58
- package/src/performance/PerformanceAnalytics.ts +386 -262
- package/src/performance/PerformanceMonitor.ts +152 -118
- package/src/performance/index.ts +9 -9
- package/src/security/InputValidator.ts +148 -91
- package/src/security/SecurityConfig.ts +94 -94
- package/src/server/ConnectionTester.ts +21 -15
- package/src/server/ToolRegistry.ts +64 -51
- package/src/server.ts +2 -2
- package/src/tools/BaseToolManager.ts +6 -6
- package/src/tools/auth.ts +42 -37
- package/src/tools/cache.ts +85 -81
- package/src/tools/comments.ts +93 -91
- package/src/tools/index.ts +10 -10
- package/src/tools/media.ts +89 -89
- package/src/tools/pages.ts +89 -87
- package/src/tools/performance.ts +443 -352
- package/src/tools/posts.ts +109 -107
- package/src/tools/site.ts +86 -77
- package/src/tools/taxonomies.ts +102 -102
- package/src/tools/users.ts +77 -77
- package/src/types/client.ts +157 -60
- package/src/types/index.ts +49 -27
- package/src/types/mcp.ts +15 -15
- package/src/types/wordpress.ts +57 -29
- package/src/utils/debug.ts +37 -37
- package/src/utils/error.ts +47 -25
- package/src/utils/toolWrapper.ts +12 -8
- package/src/utils/validation.ts +116 -65
- package/dist/client/WordPressClient.d.ts +0 -81
- package/dist/client/WordPressClient.d.ts.map +0 -1
- package/dist/client/WordPressClient.js +0 -354
- package/dist/client/WordPressClient.js.map +0 -1
- package/dist/performance/AnomalyDetector.d.ts +0 -63
- package/dist/performance/AnomalyDetector.d.ts.map +0 -1
- package/dist/performance/AnomalyDetector.js +0 -222
- package/dist/performance/AnomalyDetector.js.map +0 -1
- package/dist/performance/BenchmarkAnalyzer.d.ts +0 -67
- package/dist/performance/BenchmarkAnalyzer.d.ts.map +0 -1
- package/dist/performance/BenchmarkAnalyzer.js +0 -301
- package/dist/performance/BenchmarkAnalyzer.js.map +0 -1
- package/dist/performance/TrendAnalyzer.d.ts +0 -69
- package/dist/performance/TrendAnalyzer.d.ts.map +0 -1
- package/dist/performance/TrendAnalyzer.js +0 -203
- package/dist/performance/TrendAnalyzer.js.map +0 -1
- package/dist/tools/BaseToolClass.d.ts +0 -76
- package/dist/tools/BaseToolClass.d.ts.map +0 -1
- package/dist/tools/BaseToolClass.js +0 -104
- package/dist/tools/BaseToolClass.js.map +0 -1
- package/dist/tools/base.d.ts +0 -37
- package/dist/tools/base.d.ts.map +0 -1
- package/dist/tools/base.js +0 -60
- package/dist/tools/base.js.map +0 -1
- package/docs/user-guides/CLAUDE_DESKTOP_SETUP.md +0 -187
package/src/tools/posts.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { WordPressClient } from
|
|
1
|
+
import { WordPressClient } from "../client/api.js";
|
|
2
2
|
import {
|
|
3
3
|
CreatePostRequest,
|
|
4
4
|
PostQueryParams,
|
|
5
|
-
UpdatePostRequest
|
|
6
|
-
} from
|
|
7
|
-
import { getErrorMessage } from
|
|
5
|
+
UpdatePostRequest,
|
|
6
|
+
} from "../types/wordpress.js";
|
|
7
|
+
import { getErrorMessage } from "../utils/error.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Provides tools for managing posts on a WordPress site.
|
|
@@ -18,175 +18,175 @@ export class PostTools {
|
|
|
18
18
|
public getTools(): any[] {
|
|
19
19
|
return [
|
|
20
20
|
{
|
|
21
|
-
name:
|
|
22
|
-
description:
|
|
21
|
+
name: "wp_list_posts",
|
|
22
|
+
description: "Lists posts from a WordPress site, with filters.",
|
|
23
23
|
parameters: [
|
|
24
24
|
{
|
|
25
|
-
name:
|
|
26
|
-
type:
|
|
27
|
-
description:
|
|
25
|
+
name: "per_page",
|
|
26
|
+
type: "number",
|
|
27
|
+
description: "Number of items to return per page (max 100).",
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
|
-
name:
|
|
31
|
-
type:
|
|
32
|
-
description:
|
|
30
|
+
name: "search",
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "Limit results to those matching a search term.",
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
name:
|
|
36
|
-
type:
|
|
37
|
-
description:
|
|
38
|
-
enum: [
|
|
35
|
+
name: "status",
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "Filter by post status.",
|
|
38
|
+
enum: ["publish", "future", "draft", "pending", "private"],
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
name:
|
|
42
|
-
type:
|
|
43
|
-
items: { type:
|
|
44
|
-
description:
|
|
41
|
+
name: "categories",
|
|
42
|
+
type: "array",
|
|
43
|
+
items: { type: "number" },
|
|
44
|
+
description: "Limit results to posts in specific category IDs.",
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
|
-
name:
|
|
48
|
-
type:
|
|
49
|
-
items: { type:
|
|
50
|
-
description:
|
|
51
|
-
}
|
|
47
|
+
name: "tags",
|
|
48
|
+
type: "array",
|
|
49
|
+
items: { type: "number" },
|
|
50
|
+
description: "Limit results to posts with specific tag IDs.",
|
|
51
|
+
},
|
|
52
52
|
],
|
|
53
|
-
handler: this.handleListPosts.bind(this)
|
|
53
|
+
handler: this.handleListPosts.bind(this),
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
|
-
name:
|
|
57
|
-
description:
|
|
56
|
+
name: "wp_get_post",
|
|
57
|
+
description: "Retrieves a single post by its ID.",
|
|
58
58
|
parameters: [
|
|
59
59
|
{
|
|
60
|
-
name:
|
|
61
|
-
type:
|
|
60
|
+
name: "id",
|
|
61
|
+
type: "number",
|
|
62
62
|
required: true,
|
|
63
|
-
description:
|
|
64
|
-
}
|
|
63
|
+
description: "The unique identifier for the post.",
|
|
64
|
+
},
|
|
65
65
|
],
|
|
66
|
-
handler: this.handleGetPost.bind(this)
|
|
66
|
+
handler: this.handleGetPost.bind(this),
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
|
-
name:
|
|
70
|
-
description:
|
|
69
|
+
name: "wp_create_post",
|
|
70
|
+
description: "Creates a new post.",
|
|
71
71
|
parameters: [
|
|
72
72
|
{
|
|
73
|
-
name:
|
|
74
|
-
type:
|
|
73
|
+
name: "title",
|
|
74
|
+
type: "string",
|
|
75
75
|
required: true,
|
|
76
|
-
description:
|
|
76
|
+
description: "The title for the post.",
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
|
-
name:
|
|
80
|
-
type:
|
|
81
|
-
description:
|
|
79
|
+
name: "content",
|
|
80
|
+
type: "string",
|
|
81
|
+
description: "The content for the post, in HTML format.",
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
|
-
name:
|
|
85
|
-
type:
|
|
86
|
-
description:
|
|
87
|
-
enum: [
|
|
84
|
+
name: "status",
|
|
85
|
+
type: "string",
|
|
86
|
+
description: "The publishing status for the post.",
|
|
87
|
+
enum: ["publish", "draft", "pending", "private"],
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
|
-
name:
|
|
91
|
-
type:
|
|
92
|
-
description:
|
|
90
|
+
name: "excerpt",
|
|
91
|
+
type: "string",
|
|
92
|
+
description: "The excerpt for the post.",
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
|
-
name:
|
|
96
|
-
type:
|
|
97
|
-
items: { type:
|
|
98
|
-
description:
|
|
95
|
+
name: "categories",
|
|
96
|
+
type: "array",
|
|
97
|
+
items: { type: "number" },
|
|
98
|
+
description: "An array of category IDs to assign to the post.",
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
|
-
name:
|
|
102
|
-
type:
|
|
103
|
-
items: { type:
|
|
104
|
-
description:
|
|
105
|
-
}
|
|
101
|
+
name: "tags",
|
|
102
|
+
type: "array",
|
|
103
|
+
items: { type: "number" },
|
|
104
|
+
description: "An array of tag IDs to assign to the post.",
|
|
105
|
+
},
|
|
106
106
|
],
|
|
107
|
-
handler: this.handleCreatePost.bind(this)
|
|
107
|
+
handler: this.handleCreatePost.bind(this),
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
|
-
name:
|
|
111
|
-
description:
|
|
110
|
+
name: "wp_update_post",
|
|
111
|
+
description: "Updates an existing post.",
|
|
112
112
|
parameters: [
|
|
113
113
|
{
|
|
114
|
-
name:
|
|
115
|
-
type:
|
|
114
|
+
name: "id",
|
|
115
|
+
type: "number",
|
|
116
116
|
required: true,
|
|
117
|
-
description:
|
|
117
|
+
description: "The ID of the post to update.",
|
|
118
118
|
},
|
|
119
119
|
{
|
|
120
|
-
name:
|
|
121
|
-
type:
|
|
122
|
-
description:
|
|
120
|
+
name: "title",
|
|
121
|
+
type: "string",
|
|
122
|
+
description: "The new title for the post.",
|
|
123
123
|
},
|
|
124
124
|
{
|
|
125
|
-
name:
|
|
126
|
-
type:
|
|
127
|
-
description:
|
|
125
|
+
name: "content",
|
|
126
|
+
type: "string",
|
|
127
|
+
description: "The new content for the post, in HTML format.",
|
|
128
128
|
},
|
|
129
129
|
{
|
|
130
|
-
name:
|
|
131
|
-
type:
|
|
132
|
-
description:
|
|
133
|
-
enum: [
|
|
134
|
-
}
|
|
130
|
+
name: "status",
|
|
131
|
+
type: "string",
|
|
132
|
+
description: "The new status for the post.",
|
|
133
|
+
enum: ["publish", "draft", "pending", "private"],
|
|
134
|
+
},
|
|
135
135
|
],
|
|
136
|
-
handler: this.handleUpdatePost.bind(this)
|
|
136
|
+
handler: this.handleUpdatePost.bind(this),
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
|
-
name:
|
|
140
|
-
description:
|
|
139
|
+
name: "wp_delete_post",
|
|
140
|
+
description: "Deletes a post.",
|
|
141
141
|
parameters: [
|
|
142
142
|
{
|
|
143
|
-
name:
|
|
144
|
-
type:
|
|
143
|
+
name: "id",
|
|
144
|
+
type: "number",
|
|
145
145
|
required: true,
|
|
146
|
-
description:
|
|
146
|
+
description: "The ID of the post to delete.",
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
|
-
name:
|
|
150
|
-
type:
|
|
149
|
+
name: "force",
|
|
150
|
+
type: "boolean",
|
|
151
151
|
description:
|
|
152
|
-
|
|
153
|
-
}
|
|
152
|
+
"If true, permanently delete. If false, move to trash. Defaults to false.",
|
|
153
|
+
},
|
|
154
154
|
],
|
|
155
|
-
handler: this.handleDeletePost.bind(this)
|
|
155
|
+
handler: this.handleDeletePost.bind(this),
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
|
-
name:
|
|
159
|
-
description:
|
|
158
|
+
name: "wp_get_post_revisions",
|
|
159
|
+
description: "Retrieves revisions for a specific post.",
|
|
160
160
|
parameters: [
|
|
161
161
|
{
|
|
162
|
-
name:
|
|
163
|
-
type:
|
|
162
|
+
name: "id",
|
|
163
|
+
type: "number",
|
|
164
164
|
required: true,
|
|
165
|
-
description:
|
|
166
|
-
}
|
|
165
|
+
description: "The ID of the post to get revisions for.",
|
|
166
|
+
},
|
|
167
167
|
],
|
|
168
|
-
handler: this.handleGetPostRevisions.bind(this)
|
|
169
|
-
}
|
|
168
|
+
handler: this.handleGetPostRevisions.bind(this),
|
|
169
|
+
},
|
|
170
170
|
];
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
public async handleListPosts(
|
|
174
174
|
client: WordPressClient,
|
|
175
|
-
params: PostQueryParams
|
|
175
|
+
params: PostQueryParams,
|
|
176
176
|
): Promise<any> {
|
|
177
177
|
try {
|
|
178
178
|
const posts = await client.getPosts(params);
|
|
179
179
|
if (posts.length === 0) {
|
|
180
|
-
return
|
|
180
|
+
return "No posts found matching the criteria.";
|
|
181
181
|
}
|
|
182
182
|
const content =
|
|
183
183
|
`Found ${posts.length} posts:\n\n` +
|
|
184
184
|
posts
|
|
185
185
|
.map(
|
|
186
186
|
(p) =>
|
|
187
|
-
`- ID ${p.id}: **${p.title.rendered}** (${p.status})\n Link: ${p.link}
|
|
187
|
+
`- ID ${p.id}: **${p.title.rendered}** (${p.status})\n Link: ${p.link}`,
|
|
188
188
|
)
|
|
189
|
-
.join(
|
|
189
|
+
.join("\n");
|
|
190
190
|
return content;
|
|
191
191
|
} catch (error) {
|
|
192
192
|
throw new Error(`Failed to list posts: ${getErrorMessage(error)}`);
|
|
@@ -195,7 +195,7 @@ export class PostTools {
|
|
|
195
195
|
|
|
196
196
|
public async handleGetPost(
|
|
197
197
|
client: WordPressClient,
|
|
198
|
-
params: { id: number }
|
|
198
|
+
params: { id: number },
|
|
199
199
|
): Promise<any> {
|
|
200
200
|
try {
|
|
201
201
|
const post = await client.getPost(params.id);
|
|
@@ -213,7 +213,7 @@ export class PostTools {
|
|
|
213
213
|
|
|
214
214
|
public async handleCreatePost(
|
|
215
215
|
client: WordPressClient,
|
|
216
|
-
params: CreatePostRequest
|
|
216
|
+
params: CreatePostRequest,
|
|
217
217
|
): Promise<any> {
|
|
218
218
|
try {
|
|
219
219
|
const post = await client.createPost(params);
|
|
@@ -225,7 +225,7 @@ export class PostTools {
|
|
|
225
225
|
|
|
226
226
|
public async handleUpdatePost(
|
|
227
227
|
client: WordPressClient,
|
|
228
|
-
params: UpdatePostRequest & { id: number }
|
|
228
|
+
params: UpdatePostRequest & { id: number },
|
|
229
229
|
): Promise<any> {
|
|
230
230
|
try {
|
|
231
231
|
const post = await client.updatePost(params);
|
|
@@ -237,11 +237,11 @@ export class PostTools {
|
|
|
237
237
|
|
|
238
238
|
public async handleDeletePost(
|
|
239
239
|
client: WordPressClient,
|
|
240
|
-
params: { id: number; force?: boolean }
|
|
240
|
+
params: { id: number; force?: boolean },
|
|
241
241
|
): Promise<any> {
|
|
242
242
|
try {
|
|
243
243
|
await client.deletePost(params.id, params.force);
|
|
244
|
-
const action = params.force ?
|
|
244
|
+
const action = params.force ? "permanently deleted" : "moved to trash";
|
|
245
245
|
return `✅ Post ${params.id} has been ${action}.`;
|
|
246
246
|
} catch (error) {
|
|
247
247
|
throw new Error(`Failed to delete post: ${getErrorMessage(error)}`);
|
|
@@ -250,7 +250,7 @@ export class PostTools {
|
|
|
250
250
|
|
|
251
251
|
public async handleGetPostRevisions(
|
|
252
252
|
client: WordPressClient,
|
|
253
|
-
params: { id: number }
|
|
253
|
+
params: { id: number },
|
|
254
254
|
): Promise<any> {
|
|
255
255
|
try {
|
|
256
256
|
const revisions = await client.getPostRevisions(params.id);
|
|
@@ -263,13 +263,15 @@ export class PostTools {
|
|
|
263
263
|
.map(
|
|
264
264
|
(r) =>
|
|
265
265
|
`- Revision by user ID ${r.author} at ${new Date(
|
|
266
|
-
r.modified
|
|
267
|
-
).toLocaleString()}
|
|
266
|
+
r.modified,
|
|
267
|
+
).toLocaleString()}`,
|
|
268
268
|
)
|
|
269
|
-
.join(
|
|
269
|
+
.join("\n");
|
|
270
270
|
return content;
|
|
271
271
|
} catch (error) {
|
|
272
|
-
throw new Error(
|
|
272
|
+
throw new Error(
|
|
273
|
+
`Failed to get post revisions: ${getErrorMessage(error)}`,
|
|
274
|
+
);
|
|
273
275
|
}
|
|
274
276
|
}
|
|
275
277
|
}
|
package/src/tools/site.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { WordPressClient } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
} from '../types/wordpress.js';
|
|
5
|
-
import { getErrorMessage } from '../utils/error.js';
|
|
1
|
+
import { WordPressClient } from "../client/api.js";
|
|
2
|
+
import { WordPressApplicationPassword } from "../types/wordpress.js";
|
|
3
|
+
import { getErrorMessage } from "../utils/error.js";
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Provides tools for managing general site settings and operations on a WordPress site.
|
|
@@ -16,111 +14,111 @@ export class SiteTools {
|
|
|
16
14
|
public getTools(): any[] {
|
|
17
15
|
return [
|
|
18
16
|
{
|
|
19
|
-
name:
|
|
20
|
-
description:
|
|
17
|
+
name: "wp_get_site_settings",
|
|
18
|
+
description: "Retrieves the general settings for a WordPress site.",
|
|
21
19
|
parameters: [],
|
|
22
|
-
handler: this.handleGetSiteSettings.bind(this)
|
|
20
|
+
handler: this.handleGetSiteSettings.bind(this),
|
|
23
21
|
},
|
|
24
22
|
{
|
|
25
|
-
name:
|
|
23
|
+
name: "wp_update_site_settings",
|
|
26
24
|
description:
|
|
27
|
-
|
|
25
|
+
"Updates one or more general settings for a WordPress site.",
|
|
28
26
|
parameters: [
|
|
29
27
|
{
|
|
30
|
-
name:
|
|
31
|
-
type:
|
|
32
|
-
description:
|
|
28
|
+
name: "title",
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "The title of the site.",
|
|
33
31
|
},
|
|
34
32
|
{
|
|
35
|
-
name:
|
|
36
|
-
type:
|
|
37
|
-
description:
|
|
33
|
+
name: "description",
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "The tagline or description of the site.",
|
|
38
36
|
},
|
|
39
37
|
{
|
|
40
|
-
name:
|
|
41
|
-
type:
|
|
38
|
+
name: "timezone",
|
|
39
|
+
type: "string",
|
|
42
40
|
description:
|
|
43
|
-
|
|
44
|
-
}
|
|
41
|
+
"A city in the same timezone, e.g., 'America/New_York'.",
|
|
42
|
+
},
|
|
45
43
|
],
|
|
46
|
-
handler: this.handleUpdateSiteSettings.bind(this)
|
|
44
|
+
handler: this.handleUpdateSiteSettings.bind(this),
|
|
47
45
|
},
|
|
48
46
|
{
|
|
49
|
-
name:
|
|
50
|
-
description:
|
|
47
|
+
name: "wp_search_site",
|
|
48
|
+
description: "Performs a site-wide search for content.",
|
|
51
49
|
parameters: [
|
|
52
50
|
{
|
|
53
|
-
name:
|
|
54
|
-
type:
|
|
51
|
+
name: "term",
|
|
52
|
+
type: "string",
|
|
55
53
|
required: true,
|
|
56
|
-
description:
|
|
54
|
+
description: "The search term to look for.",
|
|
57
55
|
},
|
|
58
56
|
{
|
|
59
|
-
name:
|
|
60
|
-
type:
|
|
61
|
-
description:
|
|
62
|
-
enum: [
|
|
63
|
-
}
|
|
57
|
+
name: "type",
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "The type of content to search.",
|
|
60
|
+
enum: ["posts", "pages", "media"],
|
|
61
|
+
},
|
|
64
62
|
],
|
|
65
|
-
handler: this.handleSearchSite.bind(this)
|
|
63
|
+
handler: this.handleSearchSite.bind(this),
|
|
66
64
|
},
|
|
67
65
|
{
|
|
68
|
-
name:
|
|
69
|
-
description:
|
|
66
|
+
name: "wp_get_application_passwords",
|
|
67
|
+
description: "Lists application passwords for a specific user.",
|
|
70
68
|
parameters: [
|
|
71
69
|
{
|
|
72
|
-
name:
|
|
73
|
-
type:
|
|
70
|
+
name: "user_id",
|
|
71
|
+
type: "number",
|
|
74
72
|
required: true,
|
|
75
|
-
description:
|
|
76
|
-
}
|
|
73
|
+
description: "The ID of the user to get application passwords for.",
|
|
74
|
+
},
|
|
77
75
|
],
|
|
78
|
-
handler: this.handleGetApplicationPasswords.bind(this)
|
|
76
|
+
handler: this.handleGetApplicationPasswords.bind(this),
|
|
79
77
|
},
|
|
80
78
|
{
|
|
81
|
-
name:
|
|
82
|
-
description:
|
|
79
|
+
name: "wp_create_application_password",
|
|
80
|
+
description: "Creates a new application password for a user.",
|
|
83
81
|
parameters: [
|
|
84
82
|
{
|
|
85
|
-
name:
|
|
86
|
-
type:
|
|
83
|
+
name: "user_id",
|
|
84
|
+
type: "number",
|
|
87
85
|
required: true,
|
|
88
|
-
description:
|
|
86
|
+
description: "The ID of the user to create the password for.",
|
|
89
87
|
},
|
|
90
88
|
{
|
|
91
|
-
name:
|
|
92
|
-
type:
|
|
89
|
+
name: "app_name",
|
|
90
|
+
type: "string",
|
|
93
91
|
required: true,
|
|
94
|
-
description:
|
|
95
|
-
}
|
|
92
|
+
description: "The name of the application this password is for.",
|
|
93
|
+
},
|
|
96
94
|
],
|
|
97
|
-
handler: this.handleCreateApplicationPassword.bind(this)
|
|
95
|
+
handler: this.handleCreateApplicationPassword.bind(this),
|
|
98
96
|
},
|
|
99
97
|
{
|
|
100
|
-
name:
|
|
101
|
-
description:
|
|
98
|
+
name: "wp_delete_application_password",
|
|
99
|
+
description: "Revokes an existing application password.",
|
|
102
100
|
parameters: [
|
|
103
101
|
{
|
|
104
|
-
name:
|
|
105
|
-
type:
|
|
102
|
+
name: "user_id",
|
|
103
|
+
type: "number",
|
|
106
104
|
required: true,
|
|
107
|
-
description:
|
|
105
|
+
description: "The ID of the user who owns the password.",
|
|
108
106
|
},
|
|
109
107
|
{
|
|
110
|
-
name:
|
|
111
|
-
type:
|
|
108
|
+
name: "uuid",
|
|
109
|
+
type: "string",
|
|
112
110
|
required: true,
|
|
113
|
-
description:
|
|
114
|
-
}
|
|
111
|
+
description: "The UUID of the application password to revoke.",
|
|
112
|
+
},
|
|
115
113
|
],
|
|
116
|
-
handler: this.handleDeleteApplicationPassword.bind(this)
|
|
117
|
-
}
|
|
114
|
+
handler: this.handleDeleteApplicationPassword.bind(this),
|
|
115
|
+
},
|
|
118
116
|
];
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
public async handleGetSiteSettings(
|
|
122
120
|
client: WordPressClient,
|
|
123
|
-
params: any
|
|
121
|
+
params: any,
|
|
124
122
|
): Promise<any> {
|
|
125
123
|
try {
|
|
126
124
|
const settings = await client.getSiteSettings();
|
|
@@ -138,22 +136,27 @@ export class SiteTools {
|
|
|
138
136
|
|
|
139
137
|
public async handleUpdateSiteSettings(
|
|
140
138
|
client: WordPressClient,
|
|
141
|
-
params: any
|
|
139
|
+
params: any,
|
|
142
140
|
): Promise<any> {
|
|
143
141
|
try {
|
|
144
142
|
const updatedSettings = await client.updateSiteSettings(params);
|
|
145
143
|
return `✅ Site settings updated successfully. New title: ${updatedSettings.title}`;
|
|
146
144
|
} catch (error) {
|
|
147
|
-
throw new Error(
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Failed to update site settings: ${getErrorMessage(error)}`,
|
|
147
|
+
);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
public async handleSearchSite(
|
|
152
152
|
client: WordPressClient,
|
|
153
|
-
params: { term: string; type?:
|
|
153
|
+
params: { term: string; type?: "posts" | "pages" | "media" },
|
|
154
154
|
): Promise<any> {
|
|
155
155
|
try {
|
|
156
|
-
const results = await client.search(
|
|
156
|
+
const results = await client.search(
|
|
157
|
+
params.term,
|
|
158
|
+
params.type ? [params.type] : undefined,
|
|
159
|
+
);
|
|
157
160
|
if (results.length === 0) {
|
|
158
161
|
return `No results found for "${params.term}".`;
|
|
159
162
|
}
|
|
@@ -161,7 +164,7 @@ export class SiteTools {
|
|
|
161
164
|
`Found ${results.length} results for "${params.term}":\n\n` +
|
|
162
165
|
results
|
|
163
166
|
.map((r) => `- [${r.type}] **${r.title}**\n Link: ${r.url}`)
|
|
164
|
-
.join(
|
|
167
|
+
.join("\n");
|
|
165
168
|
return content;
|
|
166
169
|
} catch (error) {
|
|
167
170
|
throw new Error(`Failed to perform search: ${getErrorMessage(error)}`);
|
|
@@ -170,7 +173,7 @@ export class SiteTools {
|
|
|
170
173
|
|
|
171
174
|
public async handleGetApplicationPasswords(
|
|
172
175
|
client: WordPressClient,
|
|
173
|
-
params: { user_id: number }
|
|
176
|
+
params: { user_id: number },
|
|
174
177
|
): Promise<any> {
|
|
175
178
|
try {
|
|
176
179
|
const passwords = await client.getApplicationPasswords(params.user_id);
|
|
@@ -182,44 +185,50 @@ export class SiteTools {
|
|
|
182
185
|
passwords
|
|
183
186
|
.map(
|
|
184
187
|
(p: WordPressApplicationPassword) =>
|
|
185
|
-
`- **${p.name}** (UUID: ${p.uuid})\n Created: ${new Date(p.created).toLocaleDateString()}
|
|
188
|
+
`- **${p.name}** (UUID: ${p.uuid})\n Created: ${new Date(p.created).toLocaleDateString()}`,
|
|
186
189
|
)
|
|
187
|
-
.join(
|
|
190
|
+
.join("\n");
|
|
188
191
|
return content;
|
|
189
192
|
} catch (error) {
|
|
190
|
-
throw new Error(
|
|
193
|
+
throw new Error(
|
|
194
|
+
`Failed to get application passwords: ${getErrorMessage(error)}`,
|
|
195
|
+
);
|
|
191
196
|
}
|
|
192
197
|
}
|
|
193
198
|
|
|
194
199
|
public async handleCreateApplicationPassword(
|
|
195
200
|
client: WordPressClient,
|
|
196
|
-
params: { user_id: number; app_name: string }
|
|
201
|
+
params: { user_id: number; app_name: string },
|
|
197
202
|
): Promise<any> {
|
|
198
203
|
try {
|
|
199
204
|
const result = await client.createApplicationPassword(
|
|
200
205
|
params.user_id,
|
|
201
|
-
params.app_name
|
|
206
|
+
params.app_name,
|
|
202
207
|
);
|
|
203
208
|
const content =
|
|
204
|
-
|
|
209
|
+
"✅ **Application password created successfully!**\n\n" +
|
|
205
210
|
`**Name:** ${result.name}\n` +
|
|
206
211
|
`**Password:** \`${result.password}\`\n\n` +
|
|
207
|
-
|
|
212
|
+
"**IMPORTANT:** This password is shown only once. Please save it securely.";
|
|
208
213
|
return content;
|
|
209
214
|
} catch (error) {
|
|
210
|
-
throw new Error(
|
|
215
|
+
throw new Error(
|
|
216
|
+
`Failed to create application password: ${getErrorMessage(error)}`,
|
|
217
|
+
);
|
|
211
218
|
}
|
|
212
219
|
}
|
|
213
220
|
|
|
214
221
|
public async handleDeleteApplicationPassword(
|
|
215
222
|
client: WordPressClient,
|
|
216
|
-
params: { user_id: number; uuid: string }
|
|
223
|
+
params: { user_id: number; uuid: string },
|
|
217
224
|
): Promise<any> {
|
|
218
225
|
try {
|
|
219
226
|
await client.deleteApplicationPassword(params.user_id, params.uuid);
|
|
220
227
|
return `✅ Application password with UUID ${params.uuid} has been revoked.`;
|
|
221
228
|
} catch (error) {
|
|
222
|
-
throw new Error(
|
|
229
|
+
throw new Error(
|
|
230
|
+
`Failed to delete application password: ${getErrorMessage(error)}`,
|
|
231
|
+
);
|
|
223
232
|
}
|
|
224
233
|
}
|
|
225
234
|
}
|