mcp-wordpress 3.1.11 → 3.1.12

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.
@@ -1,5 +1,6 @@
1
1
  import * as fs from "fs";
2
2
  import { WordPressClient } from "@/client/api.js";
3
+ import type { MCPToolSchema } from "@/types/mcp.js";
3
4
  import { MediaQueryParams, UpdateMediaRequest, UploadMediaRequest } from "@/types/wordpress.js";
4
5
  import { getErrorMessage } from "@/utils/error.js";
5
6
  import { toolParams } from "./params.js";
@@ -55,140 +56,131 @@ export class MediaTools {
55
56
  public getTools(): Array<{
56
57
  name: string;
57
58
  description: string;
58
- parameters?: Array<{
59
- name: string;
60
- type?: string;
61
- description?: string;
62
- required?: boolean;
63
- enum?: string[];
64
- items?: unknown;
65
- }>;
59
+ inputSchema?: MCPToolSchema;
66
60
  handler: (client: WordPressClient, params: Record<string, unknown>) => Promise<unknown>;
67
61
  }> {
68
62
  return [
69
63
  {
70
64
  name: "wp_list_media",
71
65
  description: "Lists media items from a WordPress site, with filters.",
72
- parameters: [
73
- {
74
- name: "per_page",
75
- type: "number",
76
- description: "Number of items to return per page (max 100).",
66
+ inputSchema: {
67
+ type: "object",
68
+ properties: {
69
+ per_page: {
70
+ type: "number",
71
+ description: "Number of items to return per page (max 100).",
72
+ },
73
+ search: {
74
+ type: "string",
75
+ description: "Limit results to those matching a search term.",
76
+ },
77
+ media_type: {
78
+ type: "string",
79
+ description: "Limit results to a specific media type.",
80
+ enum: ["image", "video", "audio", "application"],
81
+ },
77
82
  },
78
- {
79
- name: "search",
80
- type: "string",
81
- description: "Limit results to those matching a search term.",
82
- },
83
- {
84
- name: "media_type",
85
- type: "string",
86
- description: "Limit results to a specific media type.",
87
- enum: ["image", "video", "audio", "application"],
88
- },
89
- ],
83
+ },
90
84
  handler: this.handleListMedia.bind(this),
91
85
  },
92
86
  {
93
87
  name: "wp_get_media",
94
88
  description: "Retrieves a single media item by its ID.",
95
- parameters: [
96
- {
97
- name: "id",
98
- type: "number",
99
- required: true,
100
- description: "The unique identifier for the media item.",
89
+ inputSchema: {
90
+ type: "object",
91
+ properties: {
92
+ id: {
93
+ type: "number",
94
+ description: "The unique identifier for the media item.",
95
+ },
101
96
  },
102
- ],
97
+ required: ["id"],
98
+ },
103
99
  handler: this.handleGetMedia.bind(this),
104
100
  },
105
101
  {
106
102
  name: "wp_upload_media",
107
103
  description: "Uploads a file to the WordPress media library.",
108
- parameters: [
109
- {
110
- name: "file_path",
111
- type: "string",
112
- required: true,
113
- description: "The local, absolute path to the file to upload.",
114
- },
115
- {
116
- name: "title",
117
- type: "string",
118
- description: "The title for the media item.",
119
- },
120
- {
121
- name: "alt_text",
122
- type: "string",
123
- description: "Alternative text for the media item (for accessibility).",
124
- },
125
- {
126
- name: "caption",
127
- type: "string",
128
- description: "The caption for the media item.",
129
- },
130
- {
131
- name: "description",
132
- type: "string",
133
- description: "The description for the media item.",
104
+ inputSchema: {
105
+ type: "object",
106
+ properties: {
107
+ file_path: {
108
+ type: "string",
109
+ description: "The local, absolute path to the file to upload.",
110
+ },
111
+ title: {
112
+ type: "string",
113
+ description: "The title for the media item.",
114
+ },
115
+ alt_text: {
116
+ type: "string",
117
+ description: "Alternative text for the media item (for accessibility).",
118
+ },
119
+ caption: {
120
+ type: "string",
121
+ description: "The caption for the media item.",
122
+ },
123
+ description: {
124
+ type: "string",
125
+ description: "The description for the media item.",
126
+ },
127
+ post: {
128
+ type: "number",
129
+ description: "The ID of a post to attach this media to.",
130
+ },
134
131
  },
135
- {
136
- name: "post",
137
- type: "number",
138
- description: "The ID of a post to attach this media to.",
139
- },
140
- ],
132
+ required: ["file_path"],
133
+ },
141
134
  handler: this.handleUploadMedia.bind(this),
142
135
  },
143
136
  {
144
137
  name: "wp_update_media",
145
138
  description: "Updates the metadata of an existing media item.",
146
- parameters: [
147
- {
148
- name: "id",
149
- type: "number",
150
- required: true,
151
- description: "The ID of the media item to update.",
152
- },
153
- {
154
- name: "title",
155
- type: "string",
156
- description: "The new title for the media item.",
157
- },
158
- {
159
- name: "alt_text",
160
- type: "string",
161
- description: "The new alternative text.",
139
+ inputSchema: {
140
+ type: "object",
141
+ properties: {
142
+ id: {
143
+ type: "number",
144
+ description: "The ID of the media item to update.",
145
+ },
146
+ title: {
147
+ type: "string",
148
+ description: "The new title for the media item.",
149
+ },
150
+ alt_text: {
151
+ type: "string",
152
+ description: "The new alternative text.",
153
+ },
154
+ caption: {
155
+ type: "string",
156
+ description: "The new caption.",
157
+ },
158
+ description: {
159
+ type: "string",
160
+ description: "The new description.",
161
+ },
162
162
  },
163
- {
164
- name: "caption",
165
- type: "string",
166
- description: "The new caption.",
167
- },
168
- {
169
- name: "description",
170
- type: "string",
171
- description: "The new description.",
172
- },
173
- ],
163
+ required: ["id"],
164
+ },
174
165
  handler: this.handleUpdateMedia.bind(this),
175
166
  },
176
167
  {
177
168
  name: "wp_delete_media",
178
169
  description: "Deletes a media item.",
179
- parameters: [
180
- {
181
- name: "id",
182
- type: "number",
183
- required: true,
184
- description: "The ID of the media item to delete.",
185
- },
186
- {
187
- name: "force",
188
- type: "boolean",
189
- description: "If true, permanently delete. If false, move to trash. Defaults to false.",
170
+ inputSchema: {
171
+ type: "object",
172
+ properties: {
173
+ id: {
174
+ type: "number",
175
+ description: "The ID of the media item to delete.",
176
+ },
177
+ force: {
178
+ type: "boolean",
179
+ description: "If true, permanently delete. If false, move to trash. Defaults to false.",
180
+ },
190
181
  },
191
- ],
182
+ required: ["id"],
183
+ },
192
184
  handler: this.handleDeleteMedia.bind(this),
193
185
  },
194
186
  ];
@@ -1,4 +1,5 @@
1
1
  import { WordPressClient } from "@/client/api.js";
2
+ import type { MCPToolSchema } from "@/types/mcp.js";
2
3
  import { CreatePageRequest, PostQueryParams as PageQueryParams, UpdatePageRequest } from "@/types/wordpress.js";
3
4
  import { getErrorMessage } from "@/utils/error.js";
4
5
  import { toolParams } from "./params.js";
@@ -15,140 +16,137 @@ export class PageTools {
15
16
  public getTools(): Array<{
16
17
  name: string;
17
18
  description: string;
18
- parameters?: Array<{
19
- name: string;
20
- type?: string;
21
- description?: string;
22
- required?: boolean;
23
- enum?: string[];
24
- items?: unknown;
25
- }>;
19
+ inputSchema?: MCPToolSchema;
26
20
  handler: (client: WordPressClient, params: Record<string, unknown>) => Promise<unknown>;
27
21
  }> {
28
22
  return [
29
23
  {
30
24
  name: "wp_list_pages",
31
25
  description: "Lists pages from a WordPress site, with filters.",
32
- parameters: [
33
- {
34
- name: "per_page",
35
- type: "number",
36
- description: "Number of items to return per page (max 100).",
26
+ inputSchema: {
27
+ type: "object",
28
+ properties: {
29
+ per_page: {
30
+ type: "number",
31
+ description: "Number of items to return per page (max 100).",
32
+ },
33
+ search: {
34
+ type: "string",
35
+ description: "Limit results to those matching a search term.",
36
+ },
37
+ status: {
38
+ type: "string",
39
+ description: "Filter by page status.",
40
+ enum: ["publish", "future", "draft", "pending", "private"],
41
+ },
37
42
  },
38
- {
39
- name: "search",
40
- type: "string",
41
- description: "Limit results to those matching a search term.",
42
- },
43
- {
44
- name: "status",
45
- type: "string",
46
- description: "Filter by page status.",
47
- enum: ["publish", "future", "draft", "pending", "private"],
48
- },
49
- ],
43
+ required: [],
44
+ },
50
45
  handler: this.handleListPages.bind(this),
51
46
  },
52
47
  {
53
48
  name: "wp_get_page",
54
49
  description: "Retrieves a single page by its ID, optionally including full content for editing.",
55
- parameters: [
56
- {
57
- name: "id",
58
- type: "number",
59
- required: true,
60
- description: "The unique identifier for the page.",
61
- },
62
- {
63
- name: "include_content",
64
- type: "boolean",
65
- description: "If true, includes the full HTML content of the page. Default: false",
50
+ inputSchema: {
51
+ type: "object",
52
+ properties: {
53
+ id: {
54
+ type: "number",
55
+ description: "The unique identifier for the page.",
56
+ },
57
+ include_content: {
58
+ type: "boolean",
59
+ description: "If true, includes the full HTML content of the page. Default: false",
60
+ },
66
61
  },
67
- ],
62
+ required: ["id"],
63
+ },
68
64
  handler: this.handleGetPage.bind(this),
69
65
  },
70
66
  {
71
67
  name: "wp_create_page",
72
68
  description: "Creates a new page.",
73
- parameters: [
74
- {
75
- name: "title",
76
- type: "string",
77
- required: true,
78
- description: "The title for the page.",
79
- },
80
- {
81
- name: "content",
82
- type: "string",
83
- description: "The content for the page, in HTML format.",
84
- },
85
- {
86
- name: "status",
87
- type: "string",
88
- description: "The publishing status for the page.",
89
- enum: ["publish", "draft", "pending", "private"],
69
+ inputSchema: {
70
+ type: "object",
71
+ properties: {
72
+ title: {
73
+ type: "string",
74
+ description: "The title for the page.",
75
+ },
76
+ content: {
77
+ type: "string",
78
+ description: "The content for the page, in HTML format.",
79
+ },
80
+ status: {
81
+ type: "string",
82
+ description: "The publishing status for the page.",
83
+ enum: ["publish", "draft", "pending", "private"],
84
+ },
90
85
  },
91
- ],
86
+ required: ["title"],
87
+ },
92
88
  handler: this.handleCreatePage.bind(this),
93
89
  },
94
90
  {
95
91
  name: "wp_update_page",
96
92
  description: "Updates an existing page.",
97
- parameters: [
98
- {
99
- name: "id",
100
- type: "number",
101
- required: true,
102
- description: "The ID of the page to update.",
93
+ inputSchema: {
94
+ type: "object",
95
+ properties: {
96
+ id: {
97
+ type: "number",
98
+ description: "The ID of the page to update.",
99
+ },
100
+ title: {
101
+ type: "string",
102
+ description: "The new title for the page.",
103
+ },
104
+ content: {
105
+ type: "string",
106
+ description: "The new content for the page, in HTML format.",
107
+ },
108
+ status: {
109
+ type: "string",
110
+ description: "The new status for the page.",
111
+ enum: ["publish", "draft", "pending", "private"],
112
+ },
103
113
  },
104
- {
105
- name: "title",
106
- type: "string",
107
- description: "The new title for the page.",
108
- },
109
- {
110
- name: "content",
111
- type: "string",
112
- description: "The new content for the page, in HTML format.",
113
- },
114
- {
115
- name: "status",
116
- type: "string",
117
- description: "The new status for the page.",
118
- enum: ["publish", "draft", "pending", "private"],
119
- },
120
- ],
114
+ required: ["id"],
115
+ },
121
116
  handler: this.handleUpdatePage.bind(this),
122
117
  },
123
118
  {
124
119
  name: "wp_delete_page",
125
120
  description: "Deletes a page.",
126
- parameters: [
127
- {
128
- name: "id",
129
- type: "number",
130
- required: true,
131
- description: "The ID of the page to delete.",
132
- },
133
- {
134
- name: "force",
135
- type: "boolean",
136
- description: "If true, permanently delete. If false, move to trash. Defaults to false.",
121
+ inputSchema: {
122
+ type: "object",
123
+ properties: {
124
+ id: {
125
+ type: "number",
126
+ description: "The ID of the page to delete.",
127
+ },
128
+ force: {
129
+ type: "boolean",
130
+ description: "If true, permanently delete. If false, move to trash. Defaults to false.",
131
+ },
137
132
  },
138
- ],
133
+ required: ["id"],
134
+ },
139
135
  handler: this.handleDeletePage.bind(this),
140
136
  },
141
137
  {
142
138
  name: "wp_get_page_revisions",
143
139
  description: "Retrieves revisions for a specific page.",
144
- parameters: [
145
- {
146
- name: "id",
147
- type: "number",
148
- required: true,
149
- description: "The ID of the page to get revisions for.",
140
+ inputSchema: {
141
+ type: "object",
142
+ properties: {
143
+ id: {
144
+ type: "number",
145
+ description: "The ID of the page to get revisions for.",
146
+ },
150
147
  },
151
- ],
148
+ required: ["id"],
149
+ },
152
150
  handler: this.handleGetPageRevisions.bind(this),
153
151
  },
154
152
  ];