mcp-wordpress 1.1.2 → 1.1.6
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 +8 -8
- package/bin/mcp-wordpress.js +1 -1
- package/dist/client/api.d.ts +10 -10
- package/dist/client/api.js +157 -157
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts +2 -2
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js +72 -72
- package/dist/client/auth.js.map +1 -1
- package/dist/client/managers/AuthenticationManager.d.ts +2 -2
- package/dist/client/managers/AuthenticationManager.d.ts.map +1 -1
- package/dist/client/managers/AuthenticationManager.js +50 -46
- package/dist/client/managers/AuthenticationManager.js.map +1 -1
- package/dist/client/managers/BaseManager.d.ts +1 -1
- package/dist/client/managers/BaseManager.d.ts.map +1 -1
- package/dist/client/managers/BaseManager.js +9 -9
- package/dist/client/managers/BaseManager.js.map +1 -1
- package/dist/client/managers/RequestManager.d.ts +2 -2
- package/dist/client/managers/RequestManager.js +15 -15
- package/dist/client/managers/index.d.ts +3 -3
- package/dist/client/managers/index.js +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -61
- package/dist/index.js.map +1 -1
- package/dist/tools/auth.d.ts +2 -2
- package/dist/tools/auth.js +31 -31
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/comments.d.ts +2 -2
- package/dist/tools/comments.js +79 -79
- package/dist/tools/media.d.ts +2 -2
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js +80 -80
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/pages.d.ts +2 -2
- package/dist/tools/pages.js +75 -75
- package/dist/tools/posts.d.ts +2 -2
- package/dist/tools/posts.js +94 -94
- package/dist/tools/site.d.ts +2 -2
- 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/mcp.d.ts +1 -1
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +10 -6
- package/dist/utils/debug.js.map +1 -1
- package/dist/utils/toolWrapper.js +3 -3
- package/docs/developer/GITHUB_ACTIONS_SETUP.md +208 -0
- package/docs/developer/MAINTENANCE.md +307 -0
- package/docs/developer/MIGRATION_GUIDE.md +172 -0
- package/docs/developer/NPM_AUTH_SETUP.md +142 -0
- package/docs/developer/REFACTORING.md +196 -0
- package/docs/releases/COMMUNITY_ANNOUNCEMENT_v1.1.2.md +126 -0
- package/docs/releases/RELEASE_NOTES_v1.1.2.md +173 -0
- package/docs/user-guides/CLAUDE_DESKTOP_SETUP.md +187 -0
- package/package.json +4 -3
- package/src/client/api.ts +229 -229
- package/src/client/auth.ts +135 -136
- package/src/client/managers/AuthenticationManager.ts +148 -105
- package/src/client/managers/BaseManager.ts +15 -12
- package/src/client/managers/RequestManager.ts +17 -17
- package/src/client/managers/index.ts +3 -3
- package/src/index.ts +141 -114
- package/src/server.ts +1 -1
- package/src/tools/auth.ts +36 -36
- package/src/tools/comments.ts +90 -90
- package/src/tools/media.ts +89 -91
- package/src/tools/pages.ts +86 -86
- package/src/tools/posts.ts +106 -106
- package/src/tools/site.ts +71 -71
- package/src/tools/taxonomies.ts +102 -102
- package/src/tools/users.ts +77 -77
- package/src/types/client.ts +1 -1
- package/src/types/index.ts +1 -1
- package/src/types/mcp.ts +36 -16
- package/src/types/wordpress.ts +1 -1
- package/src/utils/debug.ts +63 -39
- package/src/utils/error.ts +1 -1
- package/src/utils/toolWrapper.ts +4 -4
- 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/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/src/tools/site.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { WordPressClient } from
|
|
1
|
+
import { WordPressClient } from '../client/api.js';
|
|
2
2
|
import {
|
|
3
|
-
WordPressApplicationPassword
|
|
4
|
-
} from
|
|
5
|
-
import { getErrorMessage } from
|
|
3
|
+
WordPressApplicationPassword
|
|
4
|
+
} from '../types/wordpress.js';
|
|
5
|
+
import { getErrorMessage } from '../utils/error.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Provides tools for managing general site settings and operations on a WordPress site.
|
|
@@ -16,111 +16,111 @@ export class SiteTools {
|
|
|
16
16
|
public getTools(): any[] {
|
|
17
17
|
return [
|
|
18
18
|
{
|
|
19
|
-
name:
|
|
20
|
-
description:
|
|
19
|
+
name: 'wp_get_site_settings',
|
|
20
|
+
description: 'Retrieves the general settings for a WordPress site.',
|
|
21
21
|
parameters: [],
|
|
22
|
-
handler: this.handleGetSiteSettings.bind(this)
|
|
22
|
+
handler: this.handleGetSiteSettings.bind(this)
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
name:
|
|
25
|
+
name: 'wp_update_site_settings',
|
|
26
26
|
description:
|
|
27
|
-
|
|
27
|
+
'Updates one or more general settings for a WordPress site.',
|
|
28
28
|
parameters: [
|
|
29
29
|
{
|
|
30
|
-
name:
|
|
31
|
-
type:
|
|
32
|
-
description:
|
|
30
|
+
name: 'title',
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'The title of the site.'
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
name:
|
|
36
|
-
type:
|
|
37
|
-
description:
|
|
35
|
+
name: 'description',
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'The tagline or description of the site.'
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
|
-
name:
|
|
41
|
-
type:
|
|
40
|
+
name: 'timezone',
|
|
41
|
+
type: 'string',
|
|
42
42
|
description:
|
|
43
|
-
|
|
44
|
-
}
|
|
43
|
+
'A city in the same timezone, e.g., \'America/New_York\'.'
|
|
44
|
+
}
|
|
45
45
|
],
|
|
46
|
-
handler: this.handleUpdateSiteSettings.bind(this)
|
|
46
|
+
handler: this.handleUpdateSiteSettings.bind(this)
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
-
name:
|
|
50
|
-
description:
|
|
49
|
+
name: 'wp_search_site',
|
|
50
|
+
description: 'Performs a site-wide search for content.',
|
|
51
51
|
parameters: [
|
|
52
52
|
{
|
|
53
|
-
name:
|
|
54
|
-
type:
|
|
53
|
+
name: 'term',
|
|
54
|
+
type: 'string',
|
|
55
55
|
required: true,
|
|
56
|
-
description:
|
|
56
|
+
description: 'The search term to look for.'
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
name:
|
|
60
|
-
type:
|
|
61
|
-
description:
|
|
62
|
-
enum: [
|
|
63
|
-
}
|
|
59
|
+
name: 'type',
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'The type of content to search.',
|
|
62
|
+
enum: ['posts', 'pages', 'media']
|
|
63
|
+
}
|
|
64
64
|
],
|
|
65
|
-
handler: this.handleSearchSite.bind(this)
|
|
65
|
+
handler: this.handleSearchSite.bind(this)
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
|
-
name:
|
|
69
|
-
description:
|
|
68
|
+
name: 'wp_get_application_passwords',
|
|
69
|
+
description: 'Lists application passwords for a specific user.',
|
|
70
70
|
parameters: [
|
|
71
71
|
{
|
|
72
|
-
name:
|
|
73
|
-
type:
|
|
72
|
+
name: 'user_id',
|
|
73
|
+
type: 'number',
|
|
74
74
|
required: true,
|
|
75
|
-
description:
|
|
76
|
-
}
|
|
75
|
+
description: 'The ID of the user to get application passwords for.'
|
|
76
|
+
}
|
|
77
77
|
],
|
|
78
|
-
handler: this.handleGetApplicationPasswords.bind(this)
|
|
78
|
+
handler: this.handleGetApplicationPasswords.bind(this)
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
|
-
name:
|
|
82
|
-
description:
|
|
81
|
+
name: 'wp_create_application_password',
|
|
82
|
+
description: 'Creates a new application password for a user.',
|
|
83
83
|
parameters: [
|
|
84
84
|
{
|
|
85
|
-
name:
|
|
86
|
-
type:
|
|
85
|
+
name: 'user_id',
|
|
86
|
+
type: 'number',
|
|
87
87
|
required: true,
|
|
88
|
-
description:
|
|
88
|
+
description: 'The ID of the user to create the password for.'
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
|
-
name:
|
|
92
|
-
type:
|
|
91
|
+
name: 'app_name',
|
|
92
|
+
type: 'string',
|
|
93
93
|
required: true,
|
|
94
|
-
description:
|
|
95
|
-
}
|
|
94
|
+
description: 'The name of the application this password is for.'
|
|
95
|
+
}
|
|
96
96
|
],
|
|
97
|
-
handler: this.handleCreateApplicationPassword.bind(this)
|
|
97
|
+
handler: this.handleCreateApplicationPassword.bind(this)
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
|
-
name:
|
|
101
|
-
description:
|
|
100
|
+
name: 'wp_delete_application_password',
|
|
101
|
+
description: 'Revokes an existing application password.',
|
|
102
102
|
parameters: [
|
|
103
103
|
{
|
|
104
|
-
name:
|
|
105
|
-
type:
|
|
104
|
+
name: 'user_id',
|
|
105
|
+
type: 'number',
|
|
106
106
|
required: true,
|
|
107
|
-
description:
|
|
107
|
+
description: 'The ID of the user who owns the password.'
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
|
-
name:
|
|
111
|
-
type:
|
|
110
|
+
name: 'uuid',
|
|
111
|
+
type: 'string',
|
|
112
112
|
required: true,
|
|
113
|
-
description:
|
|
114
|
-
}
|
|
113
|
+
description: 'The UUID of the application password to revoke.'
|
|
114
|
+
}
|
|
115
115
|
],
|
|
116
|
-
handler: this.handleDeleteApplicationPassword.bind(this)
|
|
117
|
-
}
|
|
116
|
+
handler: this.handleDeleteApplicationPassword.bind(this)
|
|
117
|
+
}
|
|
118
118
|
];
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
public async handleGetSiteSettings(
|
|
122
122
|
client: WordPressClient,
|
|
123
|
-
params: any
|
|
123
|
+
params: any
|
|
124
124
|
): Promise<any> {
|
|
125
125
|
try {
|
|
126
126
|
const settings = await client.getSiteSettings();
|
|
@@ -138,7 +138,7 @@ export class SiteTools {
|
|
|
138
138
|
|
|
139
139
|
public async handleUpdateSiteSettings(
|
|
140
140
|
client: WordPressClient,
|
|
141
|
-
params: any
|
|
141
|
+
params: any
|
|
142
142
|
): Promise<any> {
|
|
143
143
|
try {
|
|
144
144
|
const updatedSettings = await client.updateSiteSettings(params);
|
|
@@ -150,7 +150,7 @@ export class SiteTools {
|
|
|
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
156
|
const results = await client.search(params.term, params.type ? [params.type] : undefined);
|
|
@@ -161,7 +161,7 @@ export class SiteTools {
|
|
|
161
161
|
`Found ${results.length} results for "${params.term}":\n\n` +
|
|
162
162
|
results
|
|
163
163
|
.map((r) => `- [${r.type}] **${r.title}**\n Link: ${r.url}`)
|
|
164
|
-
.join(
|
|
164
|
+
.join('\n');
|
|
165
165
|
return content;
|
|
166
166
|
} catch (error) {
|
|
167
167
|
throw new Error(`Failed to perform search: ${getErrorMessage(error)}`);
|
|
@@ -170,7 +170,7 @@ export class SiteTools {
|
|
|
170
170
|
|
|
171
171
|
public async handleGetApplicationPasswords(
|
|
172
172
|
client: WordPressClient,
|
|
173
|
-
params: { user_id: number }
|
|
173
|
+
params: { user_id: number }
|
|
174
174
|
): Promise<any> {
|
|
175
175
|
try {
|
|
176
176
|
const passwords = await client.getApplicationPasswords(params.user_id);
|
|
@@ -182,9 +182,9 @@ export class SiteTools {
|
|
|
182
182
|
passwords
|
|
183
183
|
.map(
|
|
184
184
|
(p: WordPressApplicationPassword) =>
|
|
185
|
-
`- **${p.name}** (UUID: ${p.uuid})\n Created: ${new Date(p.created).toLocaleDateString()}
|
|
185
|
+
`- **${p.name}** (UUID: ${p.uuid})\n Created: ${new Date(p.created).toLocaleDateString()}`
|
|
186
186
|
)
|
|
187
|
-
.join(
|
|
187
|
+
.join('\n');
|
|
188
188
|
return content;
|
|
189
189
|
} catch (error) {
|
|
190
190
|
throw new Error(`Failed to get application passwords: ${getErrorMessage(error)}`);
|
|
@@ -193,18 +193,18 @@ export class SiteTools {
|
|
|
193
193
|
|
|
194
194
|
public async handleCreateApplicationPassword(
|
|
195
195
|
client: WordPressClient,
|
|
196
|
-
params: { user_id: number; app_name: string }
|
|
196
|
+
params: { user_id: number; app_name: string }
|
|
197
197
|
): Promise<any> {
|
|
198
198
|
try {
|
|
199
199
|
const result = await client.createApplicationPassword(
|
|
200
200
|
params.user_id,
|
|
201
|
-
params.app_name
|
|
201
|
+
params.app_name
|
|
202
202
|
);
|
|
203
203
|
const content =
|
|
204
|
-
|
|
204
|
+
'✅ **Application password created successfully!**\n\n' +
|
|
205
205
|
`**Name:** ${result.name}\n` +
|
|
206
206
|
`**Password:** \`${result.password}\`\n\n` +
|
|
207
|
-
|
|
207
|
+
'**IMPORTANT:** This password is shown only once. Please save it securely.';
|
|
208
208
|
return content;
|
|
209
209
|
} catch (error) {
|
|
210
210
|
throw new Error(`Failed to create application password: ${getErrorMessage(error)}`);
|
|
@@ -213,7 +213,7 @@ export class SiteTools {
|
|
|
213
213
|
|
|
214
214
|
public async handleDeleteApplicationPassword(
|
|
215
215
|
client: WordPressClient,
|
|
216
|
-
params: { user_id: number; uuid: string }
|
|
216
|
+
params: { user_id: number; uuid: string }
|
|
217
217
|
): Promise<any> {
|
|
218
218
|
try {
|
|
219
219
|
await client.deleteApplicationPassword(params.user_id, params.uuid);
|
package/src/tools/taxonomies.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { WordPressClient } from
|
|
1
|
+
import { WordPressClient } from '../client/api.js';
|
|
2
2
|
import {
|
|
3
3
|
CreateCategoryRequest,
|
|
4
4
|
CreateTagRequest,
|
|
5
5
|
UpdateCategoryRequest,
|
|
6
|
-
UpdateTagRequest
|
|
7
|
-
} from
|
|
8
|
-
import { getErrorMessage } from
|
|
6
|
+
UpdateTagRequest
|
|
7
|
+
} from '../types/wordpress.js';
|
|
8
|
+
import { getErrorMessage } from '../utils/error.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Provides tools for managing taxonomies (categories and tags) on a WordPress site.
|
|
@@ -20,171 +20,171 @@ export class TaxonomyTools {
|
|
|
20
20
|
return [
|
|
21
21
|
// Categories
|
|
22
22
|
{
|
|
23
|
-
name:
|
|
24
|
-
description:
|
|
23
|
+
name: 'wp_list_categories',
|
|
24
|
+
description: 'Lists categories from a WordPress site.',
|
|
25
25
|
parameters: [
|
|
26
26
|
{
|
|
27
|
-
name:
|
|
28
|
-
type:
|
|
29
|
-
description:
|
|
27
|
+
name: 'search',
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'Limit results to those matching a search term.'
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
name:
|
|
33
|
-
type:
|
|
34
|
-
description:
|
|
35
|
-
}
|
|
32
|
+
name: 'hide_empty',
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
description: 'Whether to hide categories with no posts.'
|
|
35
|
+
}
|
|
36
36
|
],
|
|
37
|
-
handler: this.handleListCategories.bind(this)
|
|
37
|
+
handler: this.handleListCategories.bind(this)
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
|
-
name:
|
|
41
|
-
description:
|
|
40
|
+
name: 'wp_get_category',
|
|
41
|
+
description: 'Retrieves a single category by its ID.',
|
|
42
42
|
parameters: [
|
|
43
43
|
{
|
|
44
|
-
name:
|
|
45
|
-
type:
|
|
44
|
+
name: 'id',
|
|
45
|
+
type: 'number',
|
|
46
46
|
required: true,
|
|
47
|
-
description:
|
|
48
|
-
}
|
|
47
|
+
description: 'The unique identifier for the category.'
|
|
48
|
+
}
|
|
49
49
|
],
|
|
50
|
-
handler: this.handleGetCategory.bind(this)
|
|
50
|
+
handler: this.handleGetCategory.bind(this)
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
|
-
name:
|
|
54
|
-
description:
|
|
53
|
+
name: 'wp_create_category',
|
|
54
|
+
description: 'Creates a new category.',
|
|
55
55
|
parameters: [
|
|
56
56
|
{
|
|
57
|
-
name:
|
|
58
|
-
type:
|
|
57
|
+
name: 'name',
|
|
58
|
+
type: 'string',
|
|
59
59
|
required: true,
|
|
60
|
-
description:
|
|
60
|
+
description: 'The name of the category.'
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
|
-
name:
|
|
64
|
-
type:
|
|
65
|
-
description:
|
|
66
|
-
}
|
|
63
|
+
name: 'description',
|
|
64
|
+
type: 'string',
|
|
65
|
+
description: 'The description for the category.'
|
|
66
|
+
}
|
|
67
67
|
],
|
|
68
|
-
handler: this.handleCreateCategory.bind(this)
|
|
68
|
+
handler: this.handleCreateCategory.bind(this)
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
|
-
name:
|
|
72
|
-
description:
|
|
71
|
+
name: 'wp_update_category',
|
|
72
|
+
description: 'Updates an existing category.',
|
|
73
73
|
parameters: [
|
|
74
74
|
{
|
|
75
|
-
name:
|
|
76
|
-
type:
|
|
75
|
+
name: 'id',
|
|
76
|
+
type: 'number',
|
|
77
77
|
required: true,
|
|
78
|
-
description:
|
|
78
|
+
description: 'The ID of the category to update.'
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
|
-
name:
|
|
82
|
-
type:
|
|
83
|
-
description:
|
|
84
|
-
}
|
|
81
|
+
name: 'name',
|
|
82
|
+
type: 'string',
|
|
83
|
+
description: 'The new name for the category.'
|
|
84
|
+
}
|
|
85
85
|
],
|
|
86
|
-
handler: this.handleUpdateCategory.bind(this)
|
|
86
|
+
handler: this.handleUpdateCategory.bind(this)
|
|
87
87
|
},
|
|
88
88
|
{
|
|
89
|
-
name:
|
|
90
|
-
description:
|
|
89
|
+
name: 'wp_delete_category',
|
|
90
|
+
description: 'Deletes a category.',
|
|
91
91
|
parameters: [
|
|
92
92
|
{
|
|
93
|
-
name:
|
|
94
|
-
type:
|
|
93
|
+
name: 'id',
|
|
94
|
+
type: 'number',
|
|
95
95
|
required: true,
|
|
96
|
-
description:
|
|
97
|
-
}
|
|
96
|
+
description: 'The ID of the category to delete.'
|
|
97
|
+
}
|
|
98
98
|
],
|
|
99
|
-
handler: this.handleDeleteCategory.bind(this)
|
|
99
|
+
handler: this.handleDeleteCategory.bind(this)
|
|
100
100
|
},
|
|
101
101
|
// Tags
|
|
102
102
|
{
|
|
103
|
-
name:
|
|
104
|
-
description:
|
|
103
|
+
name: 'wp_list_tags',
|
|
104
|
+
description: 'Lists tags from a WordPress site.',
|
|
105
105
|
parameters: [
|
|
106
106
|
{
|
|
107
|
-
name:
|
|
108
|
-
type:
|
|
109
|
-
description:
|
|
110
|
-
}
|
|
107
|
+
name: 'search',
|
|
108
|
+
type: 'string',
|
|
109
|
+
description: 'Limit results to those matching a search term.'
|
|
110
|
+
}
|
|
111
111
|
],
|
|
112
|
-
handler: this.handleListTags.bind(this)
|
|
112
|
+
handler: this.handleListTags.bind(this)
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
|
-
name:
|
|
116
|
-
description:
|
|
115
|
+
name: 'wp_get_tag',
|
|
116
|
+
description: 'Retrieves a single tag by its ID.',
|
|
117
117
|
parameters: [
|
|
118
118
|
{
|
|
119
|
-
name:
|
|
120
|
-
type:
|
|
119
|
+
name: 'id',
|
|
120
|
+
type: 'number',
|
|
121
121
|
required: true,
|
|
122
|
-
description:
|
|
123
|
-
}
|
|
122
|
+
description: 'The unique identifier for the tag.'
|
|
123
|
+
}
|
|
124
124
|
],
|
|
125
|
-
handler: this.handleGetTag.bind(this)
|
|
125
|
+
handler: this.handleGetTag.bind(this)
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
|
-
name:
|
|
129
|
-
description:
|
|
128
|
+
name: 'wp_create_tag',
|
|
129
|
+
description: 'Creates a new tag.',
|
|
130
130
|
parameters: [
|
|
131
131
|
{
|
|
132
|
-
name:
|
|
133
|
-
type:
|
|
132
|
+
name: 'name',
|
|
133
|
+
type: 'string',
|
|
134
134
|
required: true,
|
|
135
|
-
description:
|
|
136
|
-
}
|
|
135
|
+
description: 'The name of the tag.'
|
|
136
|
+
}
|
|
137
137
|
],
|
|
138
|
-
handler: this.handleCreateTag.bind(this)
|
|
138
|
+
handler: this.handleCreateTag.bind(this)
|
|
139
139
|
},
|
|
140
140
|
{
|
|
141
|
-
name:
|
|
142
|
-
description:
|
|
141
|
+
name: 'wp_update_tag',
|
|
142
|
+
description: 'Updates an existing tag.',
|
|
143
143
|
parameters: [
|
|
144
144
|
{
|
|
145
|
-
name:
|
|
146
|
-
type:
|
|
145
|
+
name: 'id',
|
|
146
|
+
type: 'number',
|
|
147
147
|
required: true,
|
|
148
|
-
description:
|
|
148
|
+
description: 'The ID of the tag to update.'
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
|
-
name:
|
|
152
|
-
type:
|
|
153
|
-
description:
|
|
154
|
-
}
|
|
151
|
+
name: 'name',
|
|
152
|
+
type: 'string',
|
|
153
|
+
description: 'The new name for the tag.'
|
|
154
|
+
}
|
|
155
155
|
],
|
|
156
|
-
handler: this.handleUpdateTag.bind(this)
|
|
156
|
+
handler: this.handleUpdateTag.bind(this)
|
|
157
157
|
},
|
|
158
158
|
{
|
|
159
|
-
name:
|
|
160
|
-
description:
|
|
159
|
+
name: 'wp_delete_tag',
|
|
160
|
+
description: 'Deletes a tag.',
|
|
161
161
|
parameters: [
|
|
162
162
|
{
|
|
163
|
-
name:
|
|
164
|
-
type:
|
|
163
|
+
name: 'id',
|
|
164
|
+
type: 'number',
|
|
165
165
|
required: true,
|
|
166
|
-
description:
|
|
167
|
-
}
|
|
166
|
+
description: 'The ID of the tag to delete.'
|
|
167
|
+
}
|
|
168
168
|
],
|
|
169
|
-
handler: this.handleDeleteTag.bind(this)
|
|
170
|
-
}
|
|
169
|
+
handler: this.handleDeleteTag.bind(this)
|
|
170
|
+
}
|
|
171
171
|
];
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
public async handleListCategories(
|
|
175
175
|
client: WordPressClient,
|
|
176
|
-
params: any
|
|
176
|
+
params: any
|
|
177
177
|
): Promise<any> {
|
|
178
178
|
try {
|
|
179
179
|
const categories = await client.getCategories(params);
|
|
180
180
|
if (categories.length === 0) {
|
|
181
|
-
return
|
|
181
|
+
return 'No categories found.';
|
|
182
182
|
}
|
|
183
183
|
const content =
|
|
184
184
|
`Found ${categories.length} categories:\n\n` +
|
|
185
185
|
categories
|
|
186
186
|
.map((c) => `- ID ${c.id}: **${c.name}** (Posts: ${c.count})`)
|
|
187
|
-
.join(
|
|
187
|
+
.join('\n');
|
|
188
188
|
return content;
|
|
189
189
|
} catch (error) {
|
|
190
190
|
throw new Error(`Failed to list categories: ${getErrorMessage(error)}`);
|
|
@@ -193,7 +193,7 @@ export class TaxonomyTools {
|
|
|
193
193
|
|
|
194
194
|
public async handleGetCategory(
|
|
195
195
|
client: WordPressClient,
|
|
196
|
-
params: { id: number }
|
|
196
|
+
params: { id: number }
|
|
197
197
|
): Promise<any> {
|
|
198
198
|
try {
|
|
199
199
|
const category = await client.getCategory(params.id);
|
|
@@ -201,7 +201,7 @@ export class TaxonomyTools {
|
|
|
201
201
|
`**Category Details (ID: ${category.id})**\n\n` +
|
|
202
202
|
`- **Name:** ${category.name}\n` +
|
|
203
203
|
`- **Slug:** ${category.slug}\n` +
|
|
204
|
-
`- **Description:** ${category.description ||
|
|
204
|
+
`- **Description:** ${category.description || 'None'}\n` +
|
|
205
205
|
`- **Post Count:** ${category.count}`;
|
|
206
206
|
return content;
|
|
207
207
|
} catch (error) {
|
|
@@ -211,7 +211,7 @@ export class TaxonomyTools {
|
|
|
211
211
|
|
|
212
212
|
public async handleCreateCategory(
|
|
213
213
|
client: WordPressClient,
|
|
214
|
-
params: CreateCategoryRequest
|
|
214
|
+
params: CreateCategoryRequest
|
|
215
215
|
): Promise<any> {
|
|
216
216
|
try {
|
|
217
217
|
const category = await client.createCategory(params);
|
|
@@ -223,7 +223,7 @@ export class TaxonomyTools {
|
|
|
223
223
|
|
|
224
224
|
public async handleUpdateCategory(
|
|
225
225
|
client: WordPressClient,
|
|
226
|
-
params: UpdateCategoryRequest & { id: number }
|
|
226
|
+
params: UpdateCategoryRequest & { id: number }
|
|
227
227
|
): Promise<any> {
|
|
228
228
|
try {
|
|
229
229
|
const category = await client.updateCategory(params);
|
|
@@ -235,7 +235,7 @@ export class TaxonomyTools {
|
|
|
235
235
|
|
|
236
236
|
public async handleDeleteCategory(
|
|
237
237
|
client: WordPressClient,
|
|
238
|
-
params: { id: number }
|
|
238
|
+
params: { id: number }
|
|
239
239
|
): Promise<any> {
|
|
240
240
|
try {
|
|
241
241
|
await client.deleteCategory(params.id);
|
|
@@ -247,18 +247,18 @@ export class TaxonomyTools {
|
|
|
247
247
|
|
|
248
248
|
public async handleListTags(
|
|
249
249
|
client: WordPressClient,
|
|
250
|
-
params: any
|
|
250
|
+
params: any
|
|
251
251
|
): Promise<any> {
|
|
252
252
|
try {
|
|
253
253
|
const tags = await client.getTags(params);
|
|
254
254
|
if (tags.length === 0) {
|
|
255
|
-
return
|
|
255
|
+
return 'No tags found.';
|
|
256
256
|
}
|
|
257
257
|
const content =
|
|
258
258
|
`Found ${tags.length} tags:\n\n` +
|
|
259
259
|
tags
|
|
260
260
|
.map((t) => `- ID ${t.id}: **${t.name}** (Posts: ${t.count})`)
|
|
261
|
-
.join(
|
|
261
|
+
.join('\n');
|
|
262
262
|
return content;
|
|
263
263
|
} catch (error) {
|
|
264
264
|
throw new Error(`Failed to list tags: ${getErrorMessage(error)}`);
|
|
@@ -267,7 +267,7 @@ export class TaxonomyTools {
|
|
|
267
267
|
|
|
268
268
|
public async handleGetTag(
|
|
269
269
|
client: WordPressClient,
|
|
270
|
-
params: { id: number }
|
|
270
|
+
params: { id: number }
|
|
271
271
|
): Promise<any> {
|
|
272
272
|
try {
|
|
273
273
|
const tag = await client.getTag(params.id);
|
|
@@ -284,7 +284,7 @@ export class TaxonomyTools {
|
|
|
284
284
|
|
|
285
285
|
public async handleCreateTag(
|
|
286
286
|
client: WordPressClient,
|
|
287
|
-
params: CreateTagRequest
|
|
287
|
+
params: CreateTagRequest
|
|
288
288
|
): Promise<any> {
|
|
289
289
|
try {
|
|
290
290
|
const tag = await client.createTag(params);
|
|
@@ -296,7 +296,7 @@ export class TaxonomyTools {
|
|
|
296
296
|
|
|
297
297
|
public async handleUpdateTag(
|
|
298
298
|
client: WordPressClient,
|
|
299
|
-
params: UpdateTagRequest & { id: number }
|
|
299
|
+
params: UpdateTagRequest & { id: number }
|
|
300
300
|
): Promise<any> {
|
|
301
301
|
try {
|
|
302
302
|
const tag = await client.updateTag(params);
|
|
@@ -308,7 +308,7 @@ export class TaxonomyTools {
|
|
|
308
308
|
|
|
309
309
|
public async handleDeleteTag(
|
|
310
310
|
client: WordPressClient,
|
|
311
|
-
params: { id: number }
|
|
311
|
+
params: { id: number }
|
|
312
312
|
): Promise<any> {
|
|
313
313
|
try {
|
|
314
314
|
await client.deleteTag(params.id);
|