mcp-wordpress 2.4.2 → 2.5.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 +114 -48
- package/dist/ajv-patch.js +34 -0
- package/dist/cache/CacheInvalidation.d.ts +3 -1
- package/dist/cache/CacheInvalidation.d.ts.map +1 -1
- package/dist/cache/CacheInvalidation.js +10 -4
- package/dist/cache/CacheInvalidation.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +3 -2
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +11 -3
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts +7 -6
- package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
- package/dist/cache/HttpCacheWrapper.js +8 -5
- package/dist/cache/HttpCacheWrapper.js.map +1 -1
- package/dist/cache/__tests__/HttpCacheWrapper.test.js +6 -5
- package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +1 -1
- package/dist/cache/index.d.ts +3 -3
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cache/index.js.map +1 -1
- package/dist/client/CachedWordPressClient.d.ts +23 -9
- package/dist/client/CachedWordPressClient.d.ts.map +1 -1
- package/dist/client/CachedWordPressClient.js +4 -1
- package/dist/client/CachedWordPressClient.js.map +1 -1
- package/dist/client/MockWordPressClient.d.ts +2 -1
- package/dist/client/MockWordPressClient.d.ts.map +1 -1
- package/dist/client/MockWordPressClient.js +3 -1
- package/dist/client/MockWordPressClient.js.map +1 -1
- package/dist/client/api.d.ts +17 -13
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +135 -30
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js +2 -3
- package/dist/client/auth.js.map +1 -1
- package/dist/client/managers/AuthenticationManager.d.ts +55 -2
- package/dist/client/managers/AuthenticationManager.d.ts.map +1 -1
- package/dist/client/managers/AuthenticationManager.js +269 -71
- package/dist/client/managers/AuthenticationManager.js.map +1 -1
- package/dist/client/managers/BaseManager.d.ts +3 -3
- package/dist/client/managers/BaseManager.d.ts.map +1 -1
- package/dist/client/managers/BaseManager.js +11 -5
- package/dist/client/managers/BaseManager.js.map +1 -1
- package/dist/client/managers/RequestManager.d.ts +2 -2
- package/dist/client/managers/RequestManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.js +25 -12
- package/dist/client/managers/RequestManager.js.map +1 -1
- package/dist/config/Config.d.ts +155 -0
- package/dist/config/Config.d.ts.map +1 -0
- package/dist/config/Config.js +215 -0
- package/dist/config/Config.js.map +1 -0
- package/dist/config/ConfigurationSchema.d.ts +21 -21
- package/dist/config/ConfigurationSchema.d.ts.map +1 -1
- package/dist/config/ConfigurationSchema.js +19 -2
- package/dist/config/ConfigurationSchema.js.map +1 -1
- package/dist/config/ServerConfiguration.d.ts +2 -1
- package/dist/config/ServerConfiguration.d.ts.map +1 -1
- package/dist/config/ServerConfiguration.js +50 -41
- package/dist/config/ServerConfiguration.js.map +1 -1
- package/dist/docs/DocumentationGenerator.d.ts +9 -8
- package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
- package/dist/docs/DocumentationGenerator.js +10 -7
- package/dist/docs/DocumentationGenerator.js.map +1 -1
- package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
- package/dist/docs/MarkdownFormatter.js +3 -2
- package/dist/docs/MarkdownFormatter.js.map +1 -1
- package/dist/dxt-entry.cjs +81 -0
- package/dist/dxt-entry.js +15 -14
- package/dist/dxt-entry.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -21
- package/dist/index.js.map +1 -1
- package/dist/performance/MetricsCollector.d.ts +13 -7
- package/dist/performance/MetricsCollector.d.ts.map +1 -1
- package/dist/performance/MetricsCollector.js +69 -27
- package/dist/performance/MetricsCollector.js.map +1 -1
- package/dist/performance/PerformanceAnalytics.d.ts +8 -2
- package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
- package/dist/performance/PerformanceAnalytics.js +17 -47
- package/dist/performance/PerformanceAnalytics.js.map +1 -1
- package/dist/performance/PerformanceMonitor.d.ts +2 -1
- package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
- package/dist/performance/PerformanceMonitor.js +12 -13
- package/dist/performance/PerformanceMonitor.js.map +1 -1
- package/dist/performance/index.d.ts +2 -2
- package/dist/performance/index.d.ts.map +1 -1
- package/dist/security/AISecurityScanner.d.ts +1 -0
- package/dist/security/AISecurityScanner.d.ts.map +1 -1
- package/dist/security/AISecurityScanner.js +22 -12
- package/dist/security/AISecurityScanner.js.map +1 -1
- package/dist/security/AutomatedRemediation.d.ts +4 -3
- package/dist/security/AutomatedRemediation.d.ts.map +1 -1
- package/dist/security/AutomatedRemediation.js +46 -15
- package/dist/security/AutomatedRemediation.js.map +1 -1
- package/dist/security/InputValidator.d.ts +13 -9
- package/dist/security/InputValidator.d.ts.map +1 -1
- package/dist/security/InputValidator.js +4 -2
- package/dist/security/InputValidator.js.map +1 -1
- package/dist/security/SecurityCIPipeline.d.ts +1 -1
- package/dist/security/SecurityCIPipeline.d.ts.map +1 -1
- package/dist/security/SecurityCIPipeline.js +38 -29
- package/dist/security/SecurityCIPipeline.js.map +1 -1
- package/dist/security/SecurityConfig.d.ts +3 -3
- package/dist/security/SecurityConfig.d.ts.map +1 -1
- package/dist/security/SecurityConfig.js +13 -9
- package/dist/security/SecurityConfig.js.map +1 -1
- package/dist/security/SecurityConfigManager.d.ts +2 -2
- package/dist/security/SecurityConfigManager.d.ts.map +1 -1
- package/dist/security/SecurityConfigManager.js +20 -15
- package/dist/security/SecurityConfigManager.js.map +1 -1
- package/dist/security/SecurityMonitoring.d.ts +2 -2
- package/dist/security/SecurityMonitoring.d.ts.map +1 -1
- package/dist/security/SecurityMonitoring.js +19 -17
- package/dist/security/SecurityMonitoring.js.map +1 -1
- package/dist/security/SecurityReviewer.d.ts.map +1 -1
- package/dist/security/SecurityReviewer.js +10 -7
- package/dist/security/SecurityReviewer.js.map +1 -1
- package/dist/security/index.d.ts +24 -23
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +52 -23
- package/dist/security/index.js.map +1 -1
- package/dist/server/ConnectionTester.d.ts +12 -4
- package/dist/server/ConnectionTester.d.ts.map +1 -1
- package/dist/server/ConnectionTester.js +96 -22
- 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 +10 -5
- package/dist/server/ToolRegistry.js.map +1 -1
- package/dist/tools/BaseToolManager.d.ts +47 -11
- package/dist/tools/BaseToolManager.d.ts.map +1 -1
- package/dist/tools/BaseToolManager.js +168 -29
- package/dist/tools/BaseToolManager.js.map +1 -1
- package/dist/tools/auth.d.ts +16 -10
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +3 -2
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/cache.d.ts +30 -30
- package/dist/tools/cache.d.ts.map +1 -1
- package/dist/tools/cache.js +1 -6
- package/dist/tools/cache.js.map +1 -1
- package/dist/tools/comments.d.ts +20 -20
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +16 -9
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/media.d.ts +18 -16
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js +16 -15
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/pages.d.ts +19 -17
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +16 -12
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/performance.d.ts +11 -1
- package/dist/tools/performance.d.ts.map +1 -1
- package/dist/tools/performance.js +67 -34
- package/dist/tools/performance.js.map +1 -1
- package/dist/tools/posts/PostHandlers.d.ts +46 -0
- package/dist/tools/posts/PostHandlers.d.ts.map +1 -0
- package/dist/tools/posts/PostHandlers.js +400 -0
- package/dist/tools/posts/PostHandlers.js.map +1 -0
- package/dist/tools/posts/PostToolDefinitions.d.ts +37 -0
- package/dist/tools/posts/PostToolDefinitions.d.ts.map +1 -0
- package/dist/tools/posts/PostToolDefinitions.js +236 -0
- package/dist/tools/posts/PostToolDefinitions.js.map +1 -0
- package/dist/tools/posts/index.d.ts +138 -0
- package/dist/tools/posts/index.d.ts.map +1 -0
- package/dist/tools/posts/index.js +163 -0
- package/dist/tools/posts/index.js.map +1 -0
- package/dist/tools/posts.d.ts +10 -246
- package/dist/tools/posts.d.ts.map +1 -1
- package/dist/tools/posts.js +11 -723
- package/dist/tools/posts.js.map +1 -1
- package/dist/tools/site.d.ts +19 -18
- package/dist/tools/site.d.ts.map +1 -1
- package/dist/tools/site.js +14 -10
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts +23 -24
- package/dist/tools/taxonomies.d.ts.map +1 -1
- package/dist/tools/taxonomies.js +24 -18
- package/dist/tools/taxonomies.js.map +1 -1
- package/dist/tools/users.d.ts +20 -15
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js +12 -8
- package/dist/tools/users.js.map +1 -1
- package/dist/types/client.d.ts +48 -41
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client.js +30 -5
- package/dist/types/client.js.map +1 -1
- package/dist/types/enhanced.d.ts +237 -0
- package/dist/types/enhanced.d.ts.map +1 -0
- package/dist/types/enhanced.js +49 -0
- package/dist/types/enhanced.js.map +1 -0
- package/dist/types/index.d.ts +15 -12
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/mcp.d.ts +12 -12
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/types/requests.d.ts +322 -0
- package/dist/types/requests.d.ts.map +1 -0
- package/dist/types/requests.js +8 -0
- package/dist/types/requests.js.map +1 -0
- package/dist/types/tools.d.ts +506 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +8 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/types/wordpress.d.ts +43 -15
- package/dist/types/wordpress.d.ts.map +1 -1
- package/dist/types/wordpress.js +8 -1
- package/dist/types/wordpress.js.map +1 -1
- package/dist/utils/debug.d.ts +19 -11
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +46 -10
- package/dist/utils/debug.js.map +1 -1
- package/dist/utils/enhancedError.d.ts +8 -8
- package/dist/utils/enhancedError.d.ts.map +1 -1
- package/dist/utils/enhancedError.js.map +1 -1
- package/dist/utils/error.d.ts +2 -4
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +42 -5
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/logger.d.ts +106 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +280 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/streaming.d.ts +9 -9
- package/dist/utils/streaming.d.ts.map +1 -1
- package/dist/utils/streaming.js +71 -52
- package/dist/utils/streaming.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts +9 -7
- package/dist/utils/toolWrapper.d.ts.map +1 -1
- package/dist/utils/toolWrapper.js.map +1 -1
- package/dist/utils/validation/core.d.ts +21 -0
- package/dist/utils/validation/core.d.ts.map +1 -0
- package/dist/utils/validation/core.js +71 -0
- package/dist/utils/validation/core.js.map +1 -0
- package/dist/utils/validation/index.d.ts +25 -0
- package/dist/utils/validation/index.d.ts.map +1 -0
- package/dist/utils/validation/index.js +29 -0
- package/dist/utils/validation/index.js.map +1 -0
- package/dist/utils/validation/network.d.ts +19 -0
- package/dist/utils/validation/network.d.ts.map +1 -0
- package/dist/utils/validation/network.js +93 -0
- package/dist/utils/validation/network.js.map +1 -0
- package/dist/utils/validation/rateLimit.d.ts +21 -0
- package/dist/utils/validation/rateLimit.d.ts.map +1 -0
- package/dist/utils/validation/rateLimit.js +43 -0
- package/dist/utils/validation/rateLimit.js.map +1 -0
- package/dist/utils/validation/security.d.ts +29 -0
- package/dist/utils/validation/security.d.ts.map +1 -0
- package/dist/utils/validation/security.js +327 -0
- package/dist/utils/validation/security.js.map +1 -0
- package/dist/utils/validation/wordpress.d.ts +31 -0
- package/dist/utils/validation/wordpress.d.ts.map +1 -0
- package/dist/utils/validation/wordpress.js +146 -0
- package/dist/utils/validation/wordpress.js.map +1 -0
- package/dist/utils/validation.d.ts +13 -82
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +25 -343
- package/dist/utils/validation.js.map +1 -1
- package/docs/BADGE_UPDATES.md +132 -0
- package/docs/CI_CD_IMPROVEMENTS.md +191 -0
- package/docs/INCREMENTAL_COVERAGE.md +183 -0
- package/docs/api/README.md +3 -1
- package/docs/api/openapi.json +5 -1
- package/docs/api/summary.json +1 -1
- package/docs/api/tools/wp_create_post.md +12 -14
- package/docs/examples/claude-desktop-config.md +1 -1
- package/docs/examples/docker-production.md +100 -93
- package/docs/examples/multi-site-setup.md +5 -4
- package/docs/examples/single-site-setup.md +3 -4
- package/docs/examples/use-case-workflows.md +4 -5
- package/docs/integrations/claude-desktop.md +31 -31
- package/docs/integrations/cline.md +4 -4
- package/docs/integrations/vs-code.md +9 -8
- package/docs/user-guides/SMITHERY_SETUP.md +10 -10
- package/package.json +44 -25
- package/src/cache/CacheInvalidation.ts +12 -5
- package/src/cache/CacheManager.ts +18 -15
- package/src/cache/HttpCacheWrapper.ts +30 -59
- package/src/cache/__tests__/HttpCacheWrapper.test.ts +6 -5
- package/src/cache/index.ts +3 -14
- package/src/client/CachedWordPressClient.ts +32 -30
- package/src/client/MockWordPressClient.ts +4 -2
- package/src/client/api.ts +186 -64
- package/src/client/auth.ts +15 -40
- package/src/client/managers/AuthenticationManager.ts +337 -77
- package/src/client/managers/BaseManager.ts +18 -30
- package/src/client/managers/RequestManager.ts +39 -44
- package/src/config/Config.ts +308 -0
- package/src/config/ConfigurationSchema.ts +23 -2
- package/src/config/ServerConfiguration.ts +51 -47
- package/src/docs/DocumentationGenerator.ts +50 -39
- package/src/docs/MarkdownFormatter.ts +19 -29
- package/src/dxt-entry.cjs +26 -16
- package/src/dxt-entry.ts +17 -27
- package/src/index.ts +42 -28
- package/src/performance/MetricsCollector.ts +108 -86
- package/src/performance/PerformanceAnalytics.ts +69 -164
- package/src/performance/PerformanceMonitor.ts +32 -47
- package/src/performance/index.ts +2 -10
- package/src/security/AISecurityScanner.ts +22 -12
- package/src/security/AutomatedRemediation.ts +49 -18
- package/src/security/InputValidator.ts +9 -6
- package/src/security/SecurityCIPipeline.ts +53 -37
- package/src/security/SecurityConfig.ts +22 -22
- package/src/security/SecurityConfigManager.ts +23 -19
- package/src/security/SecurityMonitoring.ts +24 -21
- package/src/security/SecurityReviewer.ts +10 -7
- package/src/security/index.ts +64 -29
- package/src/server/ConnectionTester.ts +120 -31
- package/src/server/ToolRegistry.ts +31 -21
- package/src/tools/BaseToolManager.ts +286 -33
- package/src/tools/auth.ts +20 -8
- package/src/tools/cache.ts +5 -15
- package/src/tools/comments.ts +34 -48
- package/src/tools/media.ts +41 -53
- package/src/tools/pages.ts +32 -54
- package/src/tools/performance.ts +141 -176
- package/src/tools/posts/PostHandlers.ts +474 -0
- package/src/tools/posts/PostToolDefinitions.ts +250 -0
- package/src/tools/posts/index.ts +192 -0
- package/src/tools/posts.ts +24 -780
- package/src/tools/site.ts +34 -19
- package/src/tools/taxonomies.ts +41 -57
- package/src/tools/users.ts +28 -16
- package/src/types/client.ts +114 -138
- package/src/types/enhanced.ts +318 -0
- package/src/types/index.ts +51 -30
- package/src/types/mcp.ts +20 -42
- package/src/types/requests.ts +378 -0
- package/src/types/tools.ts +608 -0
- package/src/types/wordpress.ts +56 -34
- package/src/utils/debug.ts +77 -59
- package/src/utils/enhancedError.ts +8 -8
- package/src/utils/error.ts +53 -31
- package/src/utils/logger.ts +351 -0
- package/src/utils/streaming.ts +86 -68
- package/src/utils/toolWrapper.ts +10 -12
- package/src/utils/validation/core.ts +108 -0
- package/src/utils/validation/index.ts +36 -0
- package/src/utils/validation/network.ts +132 -0
- package/src/utils/validation/rateLimit.ts +54 -0
- package/src/utils/validation/security.ts +361 -0
- package/src/utils/validation/wordpress.ts +180 -0
- package/src/utils/validation.ts +47 -470
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress Posts Tool Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines all MCP tool schemas for WordPress post management.
|
|
5
|
+
* This module separates tool definitions from their implementations
|
|
6
|
+
* for better maintainability and testing.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Tool definition for listing WordPress posts
|
|
10
|
+
*/
|
|
11
|
+
export const listPostsTool = {
|
|
12
|
+
name: "wp_list_posts",
|
|
13
|
+
description: "Lists posts from a WordPress site with comprehensive filtering options. Supports search, status filtering, and category/tag filtering with enhanced metadata display.\n\n" +
|
|
14
|
+
"**Usage Examples:**\n" +
|
|
15
|
+
"• Basic listing: `wp_list_posts`\n" +
|
|
16
|
+
'• Search posts: `wp_list_posts --search="AI trends"`\n' +
|
|
17
|
+
'• Filter by status: `wp_list_posts --status="draft"`\n' +
|
|
18
|
+
"• Category filtering: `wp_list_posts --categories=[1,2,3]`\n" +
|
|
19
|
+
"• Paginated results: `wp_list_posts --per_page=20 --page=2`\n" +
|
|
20
|
+
'• Combined filters: `wp_list_posts --search="WordPress" --status="publish" --per_page=10`',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
per_page: {
|
|
25
|
+
type: "number",
|
|
26
|
+
description: "Number of items to return per page (max 100).",
|
|
27
|
+
},
|
|
28
|
+
search: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "Limit results to those matching a search term.",
|
|
31
|
+
},
|
|
32
|
+
status: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Filter by post status.",
|
|
35
|
+
enum: ["publish", "future", "draft", "pending", "private"],
|
|
36
|
+
},
|
|
37
|
+
categories: {
|
|
38
|
+
type: "array",
|
|
39
|
+
items: { type: "number" },
|
|
40
|
+
description: "Limit results to posts in specific category IDs.",
|
|
41
|
+
},
|
|
42
|
+
tags: {
|
|
43
|
+
type: "array",
|
|
44
|
+
items: { type: "number" },
|
|
45
|
+
description: "Limit results to posts with specific tag IDs.",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Tool definition for retrieving a single WordPress post
|
|
52
|
+
*/
|
|
53
|
+
export const getPostTool = {
|
|
54
|
+
name: "wp_get_post",
|
|
55
|
+
description: "Retrieves detailed information about a single post including metadata, content statistics, and management links.",
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: "object",
|
|
58
|
+
properties: {
|
|
59
|
+
id: {
|
|
60
|
+
type: "number",
|
|
61
|
+
description: "The unique identifier for the post.",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: ["id"],
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Tool definition for creating a new WordPress post
|
|
69
|
+
*/
|
|
70
|
+
export const createPostTool = {
|
|
71
|
+
name: "wp_create_post",
|
|
72
|
+
description: "Creates a new WordPress post with comprehensive validation and detailed success feedback including management links.\n\n" +
|
|
73
|
+
"**Usage Examples:**\n" +
|
|
74
|
+
'• Simple post: `wp_create_post --title="My New Post" --content="<p>Hello World!</p>"`\n' +
|
|
75
|
+
'• Draft post: `wp_create_post --title="Draft Post" --status="draft"`\n' +
|
|
76
|
+
'• Categorized post: `wp_create_post --title="Tech News" --categories=[1,5] --tags=[10,20]`\n' +
|
|
77
|
+
'• Post with featured image: `wp_create_post --title="My Post" --content="<p>Content</p>" --featured_media=42`\n' +
|
|
78
|
+
'• Remove featured image: `wp_create_post --title="My Post" --featured_media=0`\n' +
|
|
79
|
+
'• Scheduled post: `wp_create_post --title="Future Post" --status="future" --date="2024-12-25T10:00:00"`\n' +
|
|
80
|
+
'• Complete post: `wp_create_post --title="Complete Post" --content="<p>Content</p>" --excerpt="Summary" --status="publish"`',
|
|
81
|
+
inputSchema: {
|
|
82
|
+
type: "object",
|
|
83
|
+
properties: {
|
|
84
|
+
title: {
|
|
85
|
+
type: "string",
|
|
86
|
+
description: "The title for the post.",
|
|
87
|
+
},
|
|
88
|
+
content: {
|
|
89
|
+
type: "string",
|
|
90
|
+
description: "The content for the post, in HTML format.",
|
|
91
|
+
},
|
|
92
|
+
status: {
|
|
93
|
+
type: "string",
|
|
94
|
+
description: "The publishing status for the post.",
|
|
95
|
+
enum: ["publish", "draft", "pending", "private"],
|
|
96
|
+
},
|
|
97
|
+
excerpt: {
|
|
98
|
+
type: "string",
|
|
99
|
+
description: "The excerpt for the post.",
|
|
100
|
+
},
|
|
101
|
+
categories: {
|
|
102
|
+
type: "array",
|
|
103
|
+
items: { type: "number" },
|
|
104
|
+
description: "An array of category IDs to assign to the post.",
|
|
105
|
+
},
|
|
106
|
+
tags: {
|
|
107
|
+
type: "array",
|
|
108
|
+
items: { type: "number" },
|
|
109
|
+
description: "An array of tag IDs to assign to the post.",
|
|
110
|
+
},
|
|
111
|
+
featured_media: {
|
|
112
|
+
type: "number",
|
|
113
|
+
description: "The ID of the featured media (image). Use 0 to remove featured media.",
|
|
114
|
+
},
|
|
115
|
+
date: {
|
|
116
|
+
type: "string",
|
|
117
|
+
description: "The date the post was published, in the site's timezone (ISO 8601 format).",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
required: ["title"],
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Tool definition for updating an existing WordPress post
|
|
125
|
+
*/
|
|
126
|
+
export const updatePostTool = {
|
|
127
|
+
name: "wp_update_post",
|
|
128
|
+
description: "Updates an existing WordPress post with comprehensive validation and change tracking. All parameters except ID are optional - only provided fields will be updated.\n\n" +
|
|
129
|
+
"**Usage Examples:**\n" +
|
|
130
|
+
'• Update title: `wp_update_post --id=123 --title="New Title"`\n' +
|
|
131
|
+
'• Update content: `wp_update_post --id=123 --content="<p>Updated content</p>"`\n' +
|
|
132
|
+
'• Change status: `wp_update_post --id=123 --status="publish"`\n' +
|
|
133
|
+
"• Update categories: `wp_update_post --id=123 --categories=[1,5,10]`\n" +
|
|
134
|
+
"• Set featured image: `wp_update_post --id=123 --featured_media=42`\n" +
|
|
135
|
+
"• Remove featured image: `wp_update_post --id=123 --featured_media=0`\n" +
|
|
136
|
+
'• Multiple updates: `wp_update_post --id=123 --title="New Title" --status="publish" --categories=[1,2]`',
|
|
137
|
+
inputSchema: {
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: {
|
|
140
|
+
id: {
|
|
141
|
+
type: "number",
|
|
142
|
+
description: "The ID of the post to update.",
|
|
143
|
+
},
|
|
144
|
+
title: {
|
|
145
|
+
type: "string",
|
|
146
|
+
description: "The new title for the post.",
|
|
147
|
+
},
|
|
148
|
+
content: {
|
|
149
|
+
type: "string",
|
|
150
|
+
description: "The new content for the post, in HTML format.",
|
|
151
|
+
},
|
|
152
|
+
status: {
|
|
153
|
+
type: "string",
|
|
154
|
+
description: "The new publishing status for the post.",
|
|
155
|
+
enum: ["publish", "draft", "pending", "private"],
|
|
156
|
+
},
|
|
157
|
+
excerpt: {
|
|
158
|
+
type: "string",
|
|
159
|
+
description: "The new excerpt for the post.",
|
|
160
|
+
},
|
|
161
|
+
categories: {
|
|
162
|
+
type: "array",
|
|
163
|
+
items: { type: "number" },
|
|
164
|
+
description: "An array of category IDs to assign to the post.",
|
|
165
|
+
},
|
|
166
|
+
tags: {
|
|
167
|
+
type: "array",
|
|
168
|
+
items: { type: "number" },
|
|
169
|
+
description: "An array of tag IDs to assign to the post.",
|
|
170
|
+
},
|
|
171
|
+
featured_media: {
|
|
172
|
+
type: "number",
|
|
173
|
+
description: "The ID of the featured media (image). Use 0 to remove featured media.",
|
|
174
|
+
},
|
|
175
|
+
date: {
|
|
176
|
+
type: "string",
|
|
177
|
+
description: "The date the post was published, in the site's timezone (ISO 8601 format).",
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
required: ["id"],
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Tool definition for deleting a WordPress post
|
|
185
|
+
*/
|
|
186
|
+
export const deletePostTool = {
|
|
187
|
+
name: "wp_delete_post",
|
|
188
|
+
description: "Deletes a WordPress post with options for trash or permanent deletion. Includes safety confirmations and detailed feedback on the deletion action.\n\n" +
|
|
189
|
+
"**Usage Examples:**\n" +
|
|
190
|
+
"• Trash a post: `wp_delete_post --id=123` (moves to trash)\n" +
|
|
191
|
+
"• Permanent deletion: `wp_delete_post --id=123 --force=true`\n" +
|
|
192
|
+
"• Bulk operations: Use multiple calls with different IDs",
|
|
193
|
+
inputSchema: {
|
|
194
|
+
type: "object",
|
|
195
|
+
properties: {
|
|
196
|
+
id: {
|
|
197
|
+
type: "number",
|
|
198
|
+
description: "The ID of the post to delete.",
|
|
199
|
+
},
|
|
200
|
+
force: {
|
|
201
|
+
type: "boolean",
|
|
202
|
+
description: "Whether to bypass trash and force deletion (default: false, moves to trash).",
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
required: ["id"],
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Tool definition for retrieving post revisions
|
|
210
|
+
*/
|
|
211
|
+
export const getPostRevisionsTool = {
|
|
212
|
+
name: "wp_get_post_revisions",
|
|
213
|
+
description: "Retrieves the revision history for a specific post, including details about changes, dates, and authors for content management and auditing purposes.",
|
|
214
|
+
inputSchema: {
|
|
215
|
+
type: "object",
|
|
216
|
+
properties: {
|
|
217
|
+
id: {
|
|
218
|
+
type: "number",
|
|
219
|
+
description: "The ID of the post to get revisions for.",
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
required: ["id"],
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Collection of all post tool definitions
|
|
227
|
+
*/
|
|
228
|
+
export const postToolDefinitions = [
|
|
229
|
+
listPostsTool,
|
|
230
|
+
getPostTool,
|
|
231
|
+
createPostTool,
|
|
232
|
+
updatePostTool,
|
|
233
|
+
deletePostTool,
|
|
234
|
+
getPostRevisionsTool,
|
|
235
|
+
];
|
|
236
|
+
//# sourceMappingURL=PostToolDefinitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostToolDefinitions.js","sourceRoot":"","sources":["../../../src/tools/posts/PostToolDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,2KAA2K;QAC3K,uBAAuB;QACvB,oCAAoC;QACpC,wDAAwD;QACxD,wDAAwD;QACxD,8DAA8D;QAC9D,+DAA+D;QAC/D,2FAA2F;IAC7F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+CAA+C;aAC7D;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gDAAgD;aAC9D;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wBAAwB;gBACrC,IAAI,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;aAC3D;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,kDAAkD;aAChE;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,+CAA+C;aAC7D;SACF;KACF;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,WA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WAAW,EAAE,4EAA4E;aAC1F;SACF;QACD,QAAQ,EAAE,CAAC,IAAI,CAAC;KACjB;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAY;IACrC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,wJAAwJ;QACxJ,uBAAuB;QACvB,8DAA8D;QAC9D,gEAAgE;QAChE,0DAA0D;IAC5D,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,EAAE,EAAE;gBACF,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+BAA+B;aAC7C;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8EAA8E;aAC5F;SACF;QACD,QAAQ,EAAE,CAAC,IAAI,CAAC;KACjB;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAY;IAC3C,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EACT,uJAAuJ;IACzJ,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,EAAE,EAAE;gBACF,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0CAA0C;aACxD;SACF;QACD,QAAQ,EAAE,CAAC,IAAI,CAAC;KACjB;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa;IACb,WAAW;IACX,cAAc;IACd,cAAc;IACd,cAAc;IACd,oBAAoB;CACrB,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress Posts Tools - Refactored Module
|
|
3
|
+
*
|
|
4
|
+
* This module provides comprehensive WordPress post management functionality
|
|
5
|
+
* through a clean, modular architecture. It combines tool definitions with
|
|
6
|
+
* their corresponding handlers for complete post management capabilities.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - List posts with advanced filtering and search
|
|
10
|
+
* - Get individual posts with detailed metadata
|
|
11
|
+
* - Create new posts with validation and feedback
|
|
12
|
+
* - Update existing posts with change tracking
|
|
13
|
+
* - Delete posts with trash/permanent options
|
|
14
|
+
* - Retrieve post revision history
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { PostTools } from './tools/posts';
|
|
19
|
+
*
|
|
20
|
+
* const postTools = new PostTools();
|
|
21
|
+
* const tools = postTools.getTools();
|
|
22
|
+
*
|
|
23
|
+
* // Use with MCP server
|
|
24
|
+
* server.setRequestHandler(ListToolsRequestSchema, () => ({
|
|
25
|
+
* tools: [...tools, ...otherTools]
|
|
26
|
+
* }));
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { WordPressClient } from "../../client/api.js";
|
|
30
|
+
import { CreatePostRequest, PostQueryParams, UpdatePostRequest, WordPressPost } from "../../types/wordpress.js";
|
|
31
|
+
/**
|
|
32
|
+
* Main PostTools class that provides WordPress post management functionality.
|
|
33
|
+
*
|
|
34
|
+
* This class serves as the interface between the MCP framework and WordPress
|
|
35
|
+
* post operations. It combines tool definitions with their corresponding handlers
|
|
36
|
+
* to provide a complete post management solution.
|
|
37
|
+
*
|
|
38
|
+
* The class is designed with a modular architecture:
|
|
39
|
+
* - Tool definitions are separate from implementations
|
|
40
|
+
* - Handlers are extracted into focused functions
|
|
41
|
+
* - Business logic is isolated from framework concerns
|
|
42
|
+
*
|
|
43
|
+
* @since 2.0.0 (Refactored from monolithic implementation)
|
|
44
|
+
*/
|
|
45
|
+
export declare class PostTools {
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves all post management tool definitions for MCP registration.
|
|
48
|
+
*
|
|
49
|
+
* Returns an array of tool definitions that include:
|
|
50
|
+
* - wp_list_posts: Advanced post listing with filtering
|
|
51
|
+
* - wp_get_post: Detailed individual post retrieval
|
|
52
|
+
* - wp_create_post: New post creation with validation
|
|
53
|
+
* - wp_update_post: Post updating with change tracking
|
|
54
|
+
* - wp_delete_post: Post deletion with trash/permanent options
|
|
55
|
+
* - wp_get_post_revisions: Post revision history
|
|
56
|
+
*
|
|
57
|
+
* Each tool includes comprehensive parameter validation, detailed documentation,
|
|
58
|
+
* and usage examples for optimal developer experience.
|
|
59
|
+
*
|
|
60
|
+
* @returns Tool definitions ready for MCP server registration
|
|
61
|
+
*/
|
|
62
|
+
getTools(): unknown[];
|
|
63
|
+
/**
|
|
64
|
+
* Maps tool names to their corresponding handler methods.
|
|
65
|
+
*
|
|
66
|
+
* This method provides the binding between tool definitions and their
|
|
67
|
+
* implementations, ensuring proper context and error handling.
|
|
68
|
+
*
|
|
69
|
+
* @param toolName - The name of the tool to get a handler for
|
|
70
|
+
* @returns The bound handler method for the specified tool
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
73
|
+
private getHandlerForTool;
|
|
74
|
+
/**
|
|
75
|
+
* Lists WordPress posts with advanced filtering capabilities.
|
|
76
|
+
*
|
|
77
|
+
* @param client - WordPress client instance
|
|
78
|
+
* @param params - Query parameters for filtering posts
|
|
79
|
+
* @returns Formatted list of posts or error message
|
|
80
|
+
*/
|
|
81
|
+
handleListPosts(client: WordPressClient, params: PostQueryParams): Promise<WordPressPost[] | string>;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves a single WordPress post with detailed information.
|
|
84
|
+
*
|
|
85
|
+
* @param client - WordPress client instance
|
|
86
|
+
* @param params - Parameters including post ID
|
|
87
|
+
* @returns Detailed post information or error message
|
|
88
|
+
*/
|
|
89
|
+
handleGetPost(client: WordPressClient, params: {
|
|
90
|
+
id: number;
|
|
91
|
+
}): Promise<WordPressPost | string>;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a new WordPress post with validation and feedback.
|
|
94
|
+
*
|
|
95
|
+
* @param client - WordPress client instance
|
|
96
|
+
* @param params - Post creation parameters
|
|
97
|
+
* @returns Created post information or error message
|
|
98
|
+
*/
|
|
99
|
+
handleCreatePost(client: WordPressClient, params: CreatePostRequest): Promise<WordPressPost | string>;
|
|
100
|
+
/**
|
|
101
|
+
* Updates an existing WordPress post with change tracking.
|
|
102
|
+
*
|
|
103
|
+
* @param client - WordPress client instance
|
|
104
|
+
* @param params - Post update parameters including ID
|
|
105
|
+
* @returns Updated post information or error message
|
|
106
|
+
*/
|
|
107
|
+
handleUpdatePost(client: WordPressClient, params: UpdatePostRequest & {
|
|
108
|
+
id: number;
|
|
109
|
+
}): Promise<WordPressPost | string>;
|
|
110
|
+
/**
|
|
111
|
+
* Deletes a WordPress post with options for trash or permanent deletion.
|
|
112
|
+
*
|
|
113
|
+
* @param client - WordPress client instance
|
|
114
|
+
* @param params - Deletion parameters including ID and force option
|
|
115
|
+
* @returns Deletion result or error message
|
|
116
|
+
*/
|
|
117
|
+
handleDeletePost(client: WordPressClient, params: {
|
|
118
|
+
id: number;
|
|
119
|
+
force?: boolean;
|
|
120
|
+
}): Promise<{
|
|
121
|
+
deleted: boolean;
|
|
122
|
+
previous?: WordPressPost;
|
|
123
|
+
} | string>;
|
|
124
|
+
/**
|
|
125
|
+
* Retrieves revision history for a WordPress post.
|
|
126
|
+
*
|
|
127
|
+
* @param client - WordPress client instance
|
|
128
|
+
* @param params - Parameters including post ID
|
|
129
|
+
* @returns Post revisions or error message
|
|
130
|
+
*/
|
|
131
|
+
handleGetPostRevisions(client: WordPressClient, params: {
|
|
132
|
+
id: number;
|
|
133
|
+
}): Promise<WordPressPost[] | string>;
|
|
134
|
+
}
|
|
135
|
+
export { postToolDefinitions } from "./PostToolDefinitions.js";
|
|
136
|
+
export * from "./PostHandlers.js";
|
|
137
|
+
export default PostTools;
|
|
138
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/posts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,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AAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,cAAc,mBAAmB,CAAC;AAGlC,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress Posts Tools - Refactored Module
|
|
3
|
+
*
|
|
4
|
+
* This module provides comprehensive WordPress post management functionality
|
|
5
|
+
* through a clean, modular architecture. It combines tool definitions with
|
|
6
|
+
* their corresponding handlers for complete post management capabilities.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - List posts with advanced filtering and search
|
|
10
|
+
* - Get individual posts with detailed metadata
|
|
11
|
+
* - Create new posts with validation and feedback
|
|
12
|
+
* - Update existing posts with change tracking
|
|
13
|
+
* - Delete posts with trash/permanent options
|
|
14
|
+
* - Retrieve post revision history
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { PostTools } from './tools/posts';
|
|
19
|
+
*
|
|
20
|
+
* const postTools = new PostTools();
|
|
21
|
+
* const tools = postTools.getTools();
|
|
22
|
+
*
|
|
23
|
+
* // Use with MCP server
|
|
24
|
+
* server.setRequestHandler(ListToolsRequestSchema, () => ({
|
|
25
|
+
* tools: [...tools, ...otherTools]
|
|
26
|
+
* }));
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { postToolDefinitions } from "./PostToolDefinitions.js";
|
|
30
|
+
import { handleListPosts, handleGetPost, handleCreatePost, handleUpdatePost, handleDeletePost, handleGetPostRevisions, } from "./PostHandlers.js";
|
|
31
|
+
/**
|
|
32
|
+
* Main PostTools class that provides WordPress post management functionality.
|
|
33
|
+
*
|
|
34
|
+
* This class serves as the interface between the MCP framework and WordPress
|
|
35
|
+
* post operations. It combines tool definitions with their corresponding handlers
|
|
36
|
+
* to provide a complete post management solution.
|
|
37
|
+
*
|
|
38
|
+
* The class is designed with a modular architecture:
|
|
39
|
+
* - Tool definitions are separate from implementations
|
|
40
|
+
* - Handlers are extracted into focused functions
|
|
41
|
+
* - Business logic is isolated from framework concerns
|
|
42
|
+
*
|
|
43
|
+
* @since 2.0.0 (Refactored from monolithic implementation)
|
|
44
|
+
*/
|
|
45
|
+
export class PostTools {
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves all post management tool definitions for MCP registration.
|
|
48
|
+
*
|
|
49
|
+
* Returns an array of tool definitions that include:
|
|
50
|
+
* - wp_list_posts: Advanced post listing with filtering
|
|
51
|
+
* - wp_get_post: Detailed individual post retrieval
|
|
52
|
+
* - wp_create_post: New post creation with validation
|
|
53
|
+
* - wp_update_post: Post updating with change tracking
|
|
54
|
+
* - wp_delete_post: Post deletion with trash/permanent options
|
|
55
|
+
* - wp_get_post_revisions: Post revision history
|
|
56
|
+
*
|
|
57
|
+
* Each tool includes comprehensive parameter validation, detailed documentation,
|
|
58
|
+
* and usage examples for optimal developer experience.
|
|
59
|
+
*
|
|
60
|
+
* @returns Tool definitions ready for MCP server registration
|
|
61
|
+
*/
|
|
62
|
+
getTools() {
|
|
63
|
+
return postToolDefinitions.map((toolDef) => ({
|
|
64
|
+
...toolDef,
|
|
65
|
+
handler: this.getHandlerForTool(toolDef.name),
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Maps tool names to their corresponding handler methods.
|
|
70
|
+
*
|
|
71
|
+
* This method provides the binding between tool definitions and their
|
|
72
|
+
* implementations, ensuring proper context and error handling.
|
|
73
|
+
*
|
|
74
|
+
* @param toolName - The name of the tool to get a handler for
|
|
75
|
+
* @returns The bound handler method for the specified tool
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
getHandlerForTool(toolName) {
|
|
79
|
+
switch (toolName) {
|
|
80
|
+
case "wp_list_posts":
|
|
81
|
+
return this.handleListPosts.bind(this);
|
|
82
|
+
case "wp_get_post":
|
|
83
|
+
return this.handleGetPost.bind(this);
|
|
84
|
+
case "wp_create_post":
|
|
85
|
+
return this.handleCreatePost.bind(this);
|
|
86
|
+
case "wp_update_post":
|
|
87
|
+
return this.handleUpdatePost.bind(this);
|
|
88
|
+
case "wp_delete_post":
|
|
89
|
+
return this.handleDeletePost.bind(this);
|
|
90
|
+
case "wp_get_post_revisions":
|
|
91
|
+
return this.handleGetPostRevisions.bind(this);
|
|
92
|
+
default:
|
|
93
|
+
throw new Error(`Unknown tool: ${toolName}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Handler Methods - Delegated to Extracted Functions
|
|
97
|
+
/**
|
|
98
|
+
* Lists WordPress posts with advanced filtering capabilities.
|
|
99
|
+
*
|
|
100
|
+
* @param client - WordPress client instance
|
|
101
|
+
* @param params - Query parameters for filtering posts
|
|
102
|
+
* @returns Formatted list of posts or error message
|
|
103
|
+
*/
|
|
104
|
+
async handleListPosts(client, params) {
|
|
105
|
+
return handleListPosts(client, params);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Retrieves a single WordPress post with detailed information.
|
|
109
|
+
*
|
|
110
|
+
* @param client - WordPress client instance
|
|
111
|
+
* @param params - Parameters including post ID
|
|
112
|
+
* @returns Detailed post information or error message
|
|
113
|
+
*/
|
|
114
|
+
async handleGetPost(client, params) {
|
|
115
|
+
return handleGetPost(client, params);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Creates a new WordPress post with validation and feedback.
|
|
119
|
+
*
|
|
120
|
+
* @param client - WordPress client instance
|
|
121
|
+
* @param params - Post creation parameters
|
|
122
|
+
* @returns Created post information or error message
|
|
123
|
+
*/
|
|
124
|
+
async handleCreatePost(client, params) {
|
|
125
|
+
return handleCreatePost(client, params);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Updates an existing WordPress post with change tracking.
|
|
129
|
+
*
|
|
130
|
+
* @param client - WordPress client instance
|
|
131
|
+
* @param params - Post update parameters including ID
|
|
132
|
+
* @returns Updated post information or error message
|
|
133
|
+
*/
|
|
134
|
+
async handleUpdatePost(client, params) {
|
|
135
|
+
return handleUpdatePost(client, params);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Deletes a WordPress post with options for trash or permanent deletion.
|
|
139
|
+
*
|
|
140
|
+
* @param client - WordPress client instance
|
|
141
|
+
* @param params - Deletion parameters including ID and force option
|
|
142
|
+
* @returns Deletion result or error message
|
|
143
|
+
*/
|
|
144
|
+
async handleDeletePost(client, params) {
|
|
145
|
+
return handleDeletePost(client, params);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Retrieves revision history for a WordPress post.
|
|
149
|
+
*
|
|
150
|
+
* @param client - WordPress client instance
|
|
151
|
+
* @param params - Parameters including post ID
|
|
152
|
+
* @returns Post revisions or error message
|
|
153
|
+
*/
|
|
154
|
+
async handleGetPostRevisions(client, params) {
|
|
155
|
+
return handleGetPostRevisions(client, params);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// Export everything for easy imports
|
|
159
|
+
export { postToolDefinitions } from "./PostToolDefinitions.js";
|
|
160
|
+
export * from "./PostHandlers.js";
|
|
161
|
+
// Default export for backwards compatibility
|
|
162
|
+
export default PostTools;
|
|
163
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/posts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,SAAS;IACpB;;;;;;;;;;;;;;;OAeG;IACI,QAAQ;QACb,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC3C,GAAG,OAAO;YACV,OA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