@wplaunchify/ml-mcp-server 1.0.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/LICENSE +22 -0
- package/README.md +220 -0
- package/build/cli.d.ts +2 -0
- package/build/cli.js +52 -0
- package/build/server.d.ts +2 -0
- package/build/server.js +97 -0
- package/build/tools/comments.d.ts +212 -0
- package/build/tools/comments.js +181 -0
- package/build/tools/fluent-affiliate.d.ts +2 -0
- package/build/tools/fluent-affiliate.js +3 -0
- package/build/tools/fluent-cart.d.ts +706 -0
- package/build/tools/fluent-cart.js +642 -0
- package/build/tools/fluent-community-BACKUP.d.ts +364 -0
- package/build/tools/fluent-community-BACKUP.js +883 -0
- package/build/tools/fluent-community-MINIMAL.d.ts +69 -0
- package/build/tools/fluent-community-MINIMAL.js +92 -0
- package/build/tools/fluent-community-design.d.ts +3 -0
- package/build/tools/fluent-community-design.js +150 -0
- package/build/tools/fluent-community-layout.d.ts +119 -0
- package/build/tools/fluent-community-layout.js +88 -0
- package/build/tools/fluent-community.d.ts +364 -0
- package/build/tools/fluent-community.js +528 -0
- package/build/tools/fluent-crm.d.ts +3 -0
- package/build/tools/fluent-crm.js +392 -0
- package/build/tools/index.d.ts +2205 -0
- package/build/tools/index.js +54 -0
- package/build/tools/media.d.ts +135 -0
- package/build/tools/media.js +168 -0
- package/build/tools/ml-canvas.d.ts +91 -0
- package/build/tools/ml-canvas.js +109 -0
- package/build/tools/ml-image-editor.d.ts +230 -0
- package/build/tools/ml-image-editor.js +270 -0
- package/build/tools/ml-media-hub.d.ts +575 -0
- package/build/tools/ml-media-hub.js +714 -0
- package/build/tools/plugin-repository.d.ts +62 -0
- package/build/tools/plugin-repository.js +149 -0
- package/build/tools/plugins.d.ts +129 -0
- package/build/tools/plugins.js +148 -0
- package/build/tools/unified-content.d.ts +313 -0
- package/build/tools/unified-content.js +615 -0
- package/build/tools/unified-taxonomies.d.ts +229 -0
- package/build/tools/unified-taxonomies.js +479 -0
- package/build/tools/users.d.ts +227 -0
- package/build/tools/users.js +182 -0
- package/build/types/wordpress-types.d.ts +151 -0
- package/build/types/wordpress-types.js +2 -0
- package/build/wordpress.d.ts +26 -0
- package/build/wordpress.js +223 -0
- package/package.json +67 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { unifiedContentTools, unifiedContentHandlers } from './unified-content.js';
|
|
2
|
+
import { unifiedTaxonomyTools, unifiedTaxonomyHandlers } from './unified-taxonomies.js';
|
|
3
|
+
import { pluginTools, pluginHandlers } from './plugins.js';
|
|
4
|
+
import { mediaTools, mediaHandlers } from './media.js';
|
|
5
|
+
import { userTools, userHandlers } from './users.js';
|
|
6
|
+
import { pluginRepositoryTools, pluginRepositoryHandlers } from './plugin-repository.js';
|
|
7
|
+
import { commentTools, commentHandlers } from './comments.js';
|
|
8
|
+
import { fluentCommunityTools, fluentCommunityHandlers } from './fluent-community.js';
|
|
9
|
+
import { fluentCommunityDesignTools, fluentCommunityDesignHandlers } from './fluent-community-design.js';
|
|
10
|
+
import { fluentCommunityLayoutTools, fluentCommunityLayoutHandlers } from './fluent-community-layout.js';
|
|
11
|
+
import { fluentCartTools, fluentCartHandlers } from './fluent-cart.js';
|
|
12
|
+
import { fluentCRMTools, fluentCRMHandlers } from './fluent-crm.js';
|
|
13
|
+
import { mlCanvasTools, mlCanvasHandlers } from './ml-canvas.js';
|
|
14
|
+
import { mlImageEditorTools, mlImageEditorHandlers } from './ml-image-editor.js';
|
|
15
|
+
import { fluentAffiliateTools, fluentAffiliateHandlers } from './fluent-affiliate.js';
|
|
16
|
+
import { mlMediaHubTools, mlMediaHubHandlers } from './ml-media-hub.js';
|
|
17
|
+
// Combine all tools - WordPress + FluentCommunity + FluentCRM + FluentCart + ML Plugins = 145 tools
|
|
18
|
+
export const allTools = [
|
|
19
|
+
...unifiedContentTools, // 8 tools (unified content management)
|
|
20
|
+
...unifiedTaxonomyTools, // 8 tools (unified taxonomy management)
|
|
21
|
+
...pluginTools, // 5 tools (WordPress plugin management)
|
|
22
|
+
...mediaTools, // 4 tools (WordPress media library)
|
|
23
|
+
...userTools, // 5 tools (WordPress user management)
|
|
24
|
+
...pluginRepositoryTools, // 2 tools (WordPress.org plugin repository)
|
|
25
|
+
...commentTools, // 5 tools (WordPress comments)
|
|
26
|
+
...fluentCommunityTools, // 21 tools (FluentCommunity spaces, posts, members)
|
|
27
|
+
...fluentCommunityDesignTools, // 6 tools (FluentCommunity colors, branding, CSS)
|
|
28
|
+
...fluentCommunityLayoutTools, // 2 tools (FluentCommunity layout control)
|
|
29
|
+
...fluentCRMTools, // 19 tools (FluentCRM contacts, lists, campaigns)
|
|
30
|
+
...fluentCartTools, // 31 tools (FluentCart products, orders, customers)
|
|
31
|
+
...fluentAffiliateTools, // 0 tools (FluentAffiliate - coming soon)
|
|
32
|
+
...mlCanvasTools, // 3 tools (ML Canvas Block surgical HTML editing)
|
|
33
|
+
...mlImageEditorTools, // 8 tools (ML Image Editor AI generation/editing)
|
|
34
|
+
...mlMediaHubTools // 18 tools (ML Media Hub: basic + advanced search/filters)
|
|
35
|
+
];
|
|
36
|
+
// Combine all handlers
|
|
37
|
+
export const toolHandlers = {
|
|
38
|
+
...unifiedContentHandlers,
|
|
39
|
+
...unifiedTaxonomyHandlers,
|
|
40
|
+
...pluginHandlers,
|
|
41
|
+
...mediaHandlers,
|
|
42
|
+
...userHandlers,
|
|
43
|
+
...pluginRepositoryHandlers,
|
|
44
|
+
...commentHandlers,
|
|
45
|
+
...fluentCommunityHandlers,
|
|
46
|
+
...fluentCommunityDesignHandlers,
|
|
47
|
+
...fluentCommunityLayoutHandlers,
|
|
48
|
+
...fluentCRMHandlers,
|
|
49
|
+
...fluentCartHandlers,
|
|
50
|
+
...fluentAffiliateHandlers,
|
|
51
|
+
...mlCanvasHandlers,
|
|
52
|
+
...mlImageEditorHandlers,
|
|
53
|
+
...mlMediaHubHandlers
|
|
54
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
declare const listMediaSchema: z.ZodObject<{
|
|
4
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
per_page: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
search: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strict", z.ZodTypeAny, {
|
|
8
|
+
page?: number | undefined;
|
|
9
|
+
per_page?: number | undefined;
|
|
10
|
+
search?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
page?: number | undefined;
|
|
13
|
+
per_page?: number | undefined;
|
|
14
|
+
search?: string | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
declare const createMediaSchema: z.ZodObject<{
|
|
17
|
+
title: z.ZodString;
|
|
18
|
+
alt_text: z.ZodOptional<z.ZodString>;
|
|
19
|
+
caption: z.ZodOptional<z.ZodString>;
|
|
20
|
+
description: z.ZodOptional<z.ZodString>;
|
|
21
|
+
source_url: z.ZodString;
|
|
22
|
+
}, "strict", z.ZodTypeAny, {
|
|
23
|
+
title: string;
|
|
24
|
+
source_url: string;
|
|
25
|
+
description?: string | undefined;
|
|
26
|
+
alt_text?: string | undefined;
|
|
27
|
+
caption?: string | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
title: string;
|
|
30
|
+
source_url: string;
|
|
31
|
+
description?: string | undefined;
|
|
32
|
+
alt_text?: string | undefined;
|
|
33
|
+
caption?: string | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
declare const editMediaSchema: z.ZodObject<{
|
|
36
|
+
id: z.ZodNumber;
|
|
37
|
+
title: z.ZodOptional<z.ZodString>;
|
|
38
|
+
alt_text: z.ZodOptional<z.ZodString>;
|
|
39
|
+
caption: z.ZodOptional<z.ZodString>;
|
|
40
|
+
description: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, "strict", z.ZodTypeAny, {
|
|
42
|
+
id: number;
|
|
43
|
+
title?: string | undefined;
|
|
44
|
+
description?: string | undefined;
|
|
45
|
+
alt_text?: string | undefined;
|
|
46
|
+
caption?: string | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
id: number;
|
|
49
|
+
title?: string | undefined;
|
|
50
|
+
description?: string | undefined;
|
|
51
|
+
alt_text?: string | undefined;
|
|
52
|
+
caption?: string | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
declare const deleteMediaSchema: z.ZodObject<{
|
|
55
|
+
id: z.ZodNumber;
|
|
56
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
}, "strict", z.ZodTypeAny, {
|
|
58
|
+
id: number;
|
|
59
|
+
force?: boolean | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
id: number;
|
|
62
|
+
force?: boolean | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const mediaTools: Tool[];
|
|
65
|
+
export declare const mediaHandlers: {
|
|
66
|
+
list_media: (params: z.infer<typeof listMediaSchema>) => Promise<{
|
|
67
|
+
toolResult: {
|
|
68
|
+
content: {
|
|
69
|
+
type: string;
|
|
70
|
+
text: string;
|
|
71
|
+
}[];
|
|
72
|
+
isError?: undefined;
|
|
73
|
+
};
|
|
74
|
+
} | {
|
|
75
|
+
toolResult: {
|
|
76
|
+
isError: boolean;
|
|
77
|
+
content: {
|
|
78
|
+
type: string;
|
|
79
|
+
text: string;
|
|
80
|
+
}[];
|
|
81
|
+
};
|
|
82
|
+
}>;
|
|
83
|
+
create_media: (params: z.infer<typeof createMediaSchema>) => Promise<{
|
|
84
|
+
toolResult: {
|
|
85
|
+
content: {
|
|
86
|
+
type: string;
|
|
87
|
+
text: string;
|
|
88
|
+
}[];
|
|
89
|
+
isError?: undefined;
|
|
90
|
+
};
|
|
91
|
+
} | {
|
|
92
|
+
toolResult: {
|
|
93
|
+
isError: boolean;
|
|
94
|
+
content: {
|
|
95
|
+
type: string;
|
|
96
|
+
text: string;
|
|
97
|
+
}[];
|
|
98
|
+
};
|
|
99
|
+
}>;
|
|
100
|
+
edit_media: (params: z.infer<typeof editMediaSchema>) => Promise<{
|
|
101
|
+
toolResult: {
|
|
102
|
+
content: {
|
|
103
|
+
type: string;
|
|
104
|
+
text: string;
|
|
105
|
+
}[];
|
|
106
|
+
isError?: undefined;
|
|
107
|
+
};
|
|
108
|
+
} | {
|
|
109
|
+
toolResult: {
|
|
110
|
+
isError: boolean;
|
|
111
|
+
content: {
|
|
112
|
+
type: string;
|
|
113
|
+
text: string;
|
|
114
|
+
}[];
|
|
115
|
+
};
|
|
116
|
+
}>;
|
|
117
|
+
delete_media: (params: z.infer<typeof deleteMediaSchema>) => Promise<{
|
|
118
|
+
toolResult: {
|
|
119
|
+
content: {
|
|
120
|
+
type: string;
|
|
121
|
+
text: string;
|
|
122
|
+
}[];
|
|
123
|
+
isError?: undefined;
|
|
124
|
+
};
|
|
125
|
+
} | {
|
|
126
|
+
toolResult: {
|
|
127
|
+
isError: boolean;
|
|
128
|
+
content: {
|
|
129
|
+
type: string;
|
|
130
|
+
text: string;
|
|
131
|
+
}[];
|
|
132
|
+
};
|
|
133
|
+
}>;
|
|
134
|
+
};
|
|
135
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { makeWordPressRequest } from '../wordpress.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
// Schema for listing media items
|
|
4
|
+
const listMediaSchema = z.object({
|
|
5
|
+
page: z.number().optional().describe("Page number"),
|
|
6
|
+
per_page: z.number().min(1).max(100).optional().describe("Items per page"),
|
|
7
|
+
search: z.string().optional().describe("Search term for media")
|
|
8
|
+
}).strict();
|
|
9
|
+
// Schema for creating a new media item
|
|
10
|
+
const createMediaSchema = z.object({
|
|
11
|
+
title: z.string().describe("Media title"),
|
|
12
|
+
alt_text: z.string().optional().describe("Alternate text for the media"),
|
|
13
|
+
caption: z.string().optional().describe("Caption of the media"),
|
|
14
|
+
description: z.string().optional().describe("Description of the media"),
|
|
15
|
+
source_url: z.string().describe("Source URL of the media file")
|
|
16
|
+
}).strict();
|
|
17
|
+
// Schema for editing an existing media item
|
|
18
|
+
const editMediaSchema = z.object({
|
|
19
|
+
id: z.number().describe("Media ID to edit"),
|
|
20
|
+
title: z.string().optional().describe("Media title"),
|
|
21
|
+
alt_text: z.string().optional().describe("Alternate text for the media"),
|
|
22
|
+
caption: z.string().optional().describe("Caption of the media"),
|
|
23
|
+
description: z.string().optional().describe("Description of the media")
|
|
24
|
+
}).strict();
|
|
25
|
+
// Schema for deleting a media item
|
|
26
|
+
const deleteMediaSchema = z.object({
|
|
27
|
+
id: z.number().describe("Media ID to delete"),
|
|
28
|
+
force: z.boolean().optional().describe("Force deletion bypassing trash")
|
|
29
|
+
}).strict();
|
|
30
|
+
// Define the tool set for media operations
|
|
31
|
+
export const mediaTools = [
|
|
32
|
+
{
|
|
33
|
+
name: "list_media",
|
|
34
|
+
description: "Lists media items with filtering and pagination options",
|
|
35
|
+
inputSchema: { type: "object", properties: listMediaSchema.shape }
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "create_media",
|
|
39
|
+
description: "Creates a new media item",
|
|
40
|
+
inputSchema: { type: "object", properties: createMediaSchema.shape }
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "edit_media",
|
|
44
|
+
description: "Updates an existing media item",
|
|
45
|
+
inputSchema: { type: "object", properties: editMediaSchema.shape }
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "delete_media",
|
|
49
|
+
description: "Deletes a media item",
|
|
50
|
+
inputSchema: { type: "object", properties: deleteMediaSchema.shape }
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
// Define handlers for each media operation
|
|
54
|
+
export const mediaHandlers = {
|
|
55
|
+
list_media: async (params) => {
|
|
56
|
+
try {
|
|
57
|
+
const response = await makeWordPressRequest("GET", "wp/v2/media", params);
|
|
58
|
+
return {
|
|
59
|
+
toolResult: {
|
|
60
|
+
content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
const errorMessage = error.response?.data?.message || error.message;
|
|
66
|
+
return {
|
|
67
|
+
toolResult: {
|
|
68
|
+
isError: true,
|
|
69
|
+
content: [{ type: "text", text: `Error listing media: ${errorMessage}` }]
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
create_media: async (params) => {
|
|
75
|
+
try {
|
|
76
|
+
if (params.source_url && params.source_url.startsWith('http')) {
|
|
77
|
+
// Download the media file from the URL and upload as multipart form-data
|
|
78
|
+
const axios = (await import('axios')).default;
|
|
79
|
+
const FormData = (await import('form-data')).default;
|
|
80
|
+
const fileRes = await axios.get(params.source_url, { responseType: 'arraybuffer' });
|
|
81
|
+
// Derive a filename from the title or fallback
|
|
82
|
+
const filename = params.title ? `${params.title.replace(/\s+/g, '_')}.jpg` : 'upload.jpg';
|
|
83
|
+
const form = new FormData();
|
|
84
|
+
form.append('file', Buffer.from(fileRes.data), {
|
|
85
|
+
filename: filename,
|
|
86
|
+
contentType: fileRes.headers['content-type'] || 'application/octet-stream'
|
|
87
|
+
});
|
|
88
|
+
// Append additional fields if provided
|
|
89
|
+
if (params.title)
|
|
90
|
+
form.append('title', params.title);
|
|
91
|
+
if (params.alt_text)
|
|
92
|
+
form.append('alt_text', params.alt_text);
|
|
93
|
+
if (params.caption)
|
|
94
|
+
form.append('caption', params.caption);
|
|
95
|
+
if (params.description)
|
|
96
|
+
form.append('description', params.description);
|
|
97
|
+
// Use the enhanced makeWordPressRequest function with FormData support
|
|
98
|
+
const response = await makeWordPressRequest('POST', 'wp/v2/media', form, {
|
|
99
|
+
isFormData: true,
|
|
100
|
+
headers: form.getHeaders(),
|
|
101
|
+
rawResponse: true
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
toolResult: {
|
|
105
|
+
content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }]
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
const response = await makeWordPressRequest("POST", "wp/v2/media", params);
|
|
111
|
+
return {
|
|
112
|
+
toolResult: {
|
|
113
|
+
content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
const errorMessage = error.response?.data?.message || error.message;
|
|
120
|
+
return {
|
|
121
|
+
toolResult: {
|
|
122
|
+
isError: true,
|
|
123
|
+
content: [{ type: "text", text: `Error creating media: ${errorMessage}` }]
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
edit_media: async (params) => {
|
|
129
|
+
try {
|
|
130
|
+
const { id, ...updateData } = params;
|
|
131
|
+
const response = await makeWordPressRequest("POST", `wp/v2/media/${id}`, updateData);
|
|
132
|
+
return {
|
|
133
|
+
toolResult: {
|
|
134
|
+
content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
const errorMessage = error.response?.data?.message || error.message;
|
|
140
|
+
return {
|
|
141
|
+
toolResult: {
|
|
142
|
+
isError: true,
|
|
143
|
+
content: [{ type: "text", text: `Error editing media: ${errorMessage}` }]
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
delete_media: async (params) => {
|
|
149
|
+
try {
|
|
150
|
+
const { id, ...deleteData } = params;
|
|
151
|
+
const response = await makeWordPressRequest("DELETE", `wp/v2/media/${id}`, deleteData);
|
|
152
|
+
return {
|
|
153
|
+
toolResult: {
|
|
154
|
+
content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
const errorMessage = error.response?.data?.message || error.message;
|
|
160
|
+
return {
|
|
161
|
+
toolResult: {
|
|
162
|
+
isError: true,
|
|
163
|
+
content: [{ type: "text", text: `Error deleting media: ${errorMessage}` }]
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const mlCanvasTools: ({
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
title: z.ZodString;
|
|
9
|
+
html: z.ZodOptional<z.ZodString>;
|
|
10
|
+
css: z.ZodOptional<z.ZodString>;
|
|
11
|
+
hideHeader: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
hideFooter: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
canvasMode: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
hideTitle: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
status: z.ZodOptional<z.ZodEnum<["draft", "publish"]>>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object";
|
|
23
|
+
properties: {
|
|
24
|
+
page_id: z.ZodNumber;
|
|
25
|
+
find_html: z.ZodOptional<z.ZodString>;
|
|
26
|
+
replace_html: z.ZodOptional<z.ZodString>;
|
|
27
|
+
find_css: z.ZodOptional<z.ZodString>;
|
|
28
|
+
replace_css: z.ZodOptional<z.ZodString>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: "object";
|
|
36
|
+
properties: {};
|
|
37
|
+
};
|
|
38
|
+
})[];
|
|
39
|
+
export declare const mlCanvasHandlers: {
|
|
40
|
+
mlcanvas_create_page: (args: any) => Promise<{
|
|
41
|
+
toolResult: {
|
|
42
|
+
content: {
|
|
43
|
+
type: string;
|
|
44
|
+
text: string;
|
|
45
|
+
}[];
|
|
46
|
+
isError?: undefined;
|
|
47
|
+
};
|
|
48
|
+
} | {
|
|
49
|
+
toolResult: {
|
|
50
|
+
isError: boolean;
|
|
51
|
+
content: {
|
|
52
|
+
type: string;
|
|
53
|
+
text: string;
|
|
54
|
+
}[];
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
mlcanvas_edit_page: (args: any) => Promise<{
|
|
58
|
+
toolResult: {
|
|
59
|
+
content: {
|
|
60
|
+
type: string;
|
|
61
|
+
text: string;
|
|
62
|
+
}[];
|
|
63
|
+
isError?: undefined;
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
toolResult: {
|
|
67
|
+
isError: boolean;
|
|
68
|
+
content: {
|
|
69
|
+
type: string;
|
|
70
|
+
text: string;
|
|
71
|
+
}[];
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
mlcanvas_get_docs: (args: any) => Promise<{
|
|
75
|
+
toolResult: {
|
|
76
|
+
content: {
|
|
77
|
+
type: string;
|
|
78
|
+
text: string;
|
|
79
|
+
}[];
|
|
80
|
+
isError?: undefined;
|
|
81
|
+
};
|
|
82
|
+
} | {
|
|
83
|
+
toolResult: {
|
|
84
|
+
isError: boolean;
|
|
85
|
+
content: {
|
|
86
|
+
type: string;
|
|
87
|
+
text: string;
|
|
88
|
+
}[];
|
|
89
|
+
};
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { makeWordPressRequest } from '../wordpress.js';
|
|
3
|
+
// ML Canvas Block Tools - Custom HTML/CSS Page Creation & Surgical Editing
|
|
4
|
+
export const mlCanvasTools = [
|
|
5
|
+
{
|
|
6
|
+
name: 'mlcanvas_create_page',
|
|
7
|
+
description: 'Create a custom HTML/CSS page using ML Canvas Block. Perfect for landing pages, full-width designs, and custom layouts. No block recovery needed!',
|
|
8
|
+
inputSchema: { type: 'object', properties: z.object({
|
|
9
|
+
title: z.string().describe('Page title (required)'),
|
|
10
|
+
html: z.string().optional().describe('Custom HTML content'),
|
|
11
|
+
css: z.string().optional().describe('Custom CSS styles'),
|
|
12
|
+
hideHeader: z.boolean().optional().describe('Hide site header'),
|
|
13
|
+
hideFooter: z.boolean().optional().describe('Hide site footer'),
|
|
14
|
+
canvasMode: z.boolean().optional().describe('Full-width canvas mode (100% width, zero padding)'),
|
|
15
|
+
hideTitle: z.boolean().optional().describe('Hide page title/hero section'),
|
|
16
|
+
status: z.enum(['draft', 'publish']).optional().describe('Page status (default: draft)'),
|
|
17
|
+
}).shape },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'mlcanvas_edit_page',
|
|
21
|
+
description: 'Surgical editing for ML Canvas pages - find/replace specific HTML/CSS snippets without rewriting entire page. Works on ANY post type with ML Canvas block.',
|
|
22
|
+
inputSchema: { type: 'object', properties: z.object({
|
|
23
|
+
page_id: z.number().describe('Page/Post ID to edit (required)'),
|
|
24
|
+
find_html: z.string().optional().describe('HTML string to find and replace'),
|
|
25
|
+
replace_html: z.string().optional().describe('New HTML to replace with'),
|
|
26
|
+
find_css: z.string().optional().describe('CSS string to find and replace'),
|
|
27
|
+
replace_css: z.string().optional().describe('New CSS to replace with'),
|
|
28
|
+
}).shape },
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'mlcanvas_get_docs',
|
|
32
|
+
description: 'Get ML Canvas Block API documentation',
|
|
33
|
+
inputSchema: { type: 'object', properties: {} },
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
export const mlCanvasHandlers = {
|
|
37
|
+
mlcanvas_create_page: async (args) => {
|
|
38
|
+
try {
|
|
39
|
+
const response = await makeWordPressRequest('POST', 'fc-manager/v1/canvas/create-page', args);
|
|
40
|
+
return {
|
|
41
|
+
toolResult: {
|
|
42
|
+
content: [{
|
|
43
|
+
type: 'text',
|
|
44
|
+
text: JSON.stringify(response, null, 2)
|
|
45
|
+
}]
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
toolResult: {
|
|
52
|
+
isError: true,
|
|
53
|
+
content: [{
|
|
54
|
+
type: 'text',
|
|
55
|
+
text: `Error creating canvas page: ${error.message}`
|
|
56
|
+
}]
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
mlcanvas_edit_page: async (args) => {
|
|
62
|
+
try {
|
|
63
|
+
const response = await makeWordPressRequest('POST', 'fc-manager/v1/canvas/edit-page', args);
|
|
64
|
+
return {
|
|
65
|
+
toolResult: {
|
|
66
|
+
content: [{
|
|
67
|
+
type: 'text',
|
|
68
|
+
text: JSON.stringify(response, null, 2)
|
|
69
|
+
}]
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return {
|
|
75
|
+
toolResult: {
|
|
76
|
+
isError: true,
|
|
77
|
+
content: [{
|
|
78
|
+
type: 'text',
|
|
79
|
+
text: `Error editing canvas page: ${error.message}`
|
|
80
|
+
}]
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
mlcanvas_get_docs: async (args) => {
|
|
86
|
+
try {
|
|
87
|
+
const response = await makeWordPressRequest('GET', 'fc-manager/v1/canvas/api-docs');
|
|
88
|
+
return {
|
|
89
|
+
toolResult: {
|
|
90
|
+
content: [{
|
|
91
|
+
type: 'text',
|
|
92
|
+
text: JSON.stringify(response, null, 2)
|
|
93
|
+
}]
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return {
|
|
99
|
+
toolResult: {
|
|
100
|
+
isError: true,
|
|
101
|
+
content: [{
|
|
102
|
+
type: 'text',
|
|
103
|
+
text: `Error getting canvas docs: ${error.message}`
|
|
104
|
+
}]
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
};
|