multisite-cms-mcp 1.6.0 → 1.6.1
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-items.d.ts","sourceRoot":"","sources":["../../src/tools/cms-items.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"cms-items.d.ts","sourceRoot":"","sources":["../../src/tools/cms-items.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqFH;;GAEG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,MAAM,CAAC,CAuDlB;AAkBD;;GAEG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6ClB;AA4CD;;GAEG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6ClB;AAoBD;;GAEG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GAAG,OAAO,CAAC,MAAM,CAAC,CAwElB;AAkBD;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;CACxB,GAAG,OAAO,CAAC,MAAM,CAAC,CAwElB"}
|
package/dist/tools/cms-items.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* CMS Item Management Tools
|
|
4
4
|
*
|
|
5
|
-
* CRUD operations for managing items in CMS collections via the
|
|
5
|
+
* CRUD operations for managing items in CMS collections via the dashboard API.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.createCmsItem = createCmsItem;
|
|
@@ -30,6 +30,24 @@ async function prepareRequest(projectId) {
|
|
|
30
30
|
}
|
|
31
31
|
return { success: true, tenantId: resolved.tenantId };
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Helper to get collection ID from slug
|
|
35
|
+
* Dashboard API uses collection IDs, not slugs
|
|
36
|
+
*/
|
|
37
|
+
async function getCollectionId(tenantId, collectionSlug) {
|
|
38
|
+
const response = await (0, api_client_1.apiRequest)('/api/collections', { tenantId });
|
|
39
|
+
if ((0, api_client_1.isApiError)(response)) {
|
|
40
|
+
return { error: `Failed to fetch collections: ${response.error}` };
|
|
41
|
+
}
|
|
42
|
+
const collection = response.data.find(c => c.slug === collectionSlug);
|
|
43
|
+
if (!collection) {
|
|
44
|
+
const available = response.data.map(c => `- ${c.slug} (${c.name})`).join('\n');
|
|
45
|
+
return {
|
|
46
|
+
error: `Collection "${collectionSlug}" not found.\n\nAvailable collections:\n${available || 'None'}`
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return { collectionId: collection.id };
|
|
50
|
+
}
|
|
33
51
|
/**
|
|
34
52
|
* Create a new item in a CMS collection
|
|
35
53
|
*/
|
|
@@ -37,7 +55,13 @@ async function createCmsItem(params) {
|
|
|
37
55
|
const prep = await prepareRequest(params.projectId);
|
|
38
56
|
if (!prep.success)
|
|
39
57
|
return prep.message;
|
|
40
|
-
|
|
58
|
+
// Get collection ID from slug
|
|
59
|
+
const collectionResult = await getCollectionId(prep.tenantId, params.collectionSlug);
|
|
60
|
+
if ('error' in collectionResult) {
|
|
61
|
+
return `# Error\n\n${collectionResult.error}`;
|
|
62
|
+
}
|
|
63
|
+
const response = await (0, api_client_1.apiRequest)(`/api/collections/${collectionResult.collectionId}/items`, {
|
|
64
|
+
tenantId: prep.tenantId,
|
|
41
65
|
method: 'POST',
|
|
42
66
|
body: {
|
|
43
67
|
name: params.name,
|
|
@@ -52,7 +76,8 @@ async function createCmsItem(params) {
|
|
|
52
76
|
if (!authResult.authenticated)
|
|
53
77
|
return authResult.message;
|
|
54
78
|
// Retry
|
|
55
|
-
const retry = await (0, api_client_1.
|
|
79
|
+
const retry = await (0, api_client_1.apiRequest)(`/api/collections/${collectionResult.collectionId}/items`, {
|
|
80
|
+
tenantId: prep.tenantId,
|
|
56
81
|
method: 'POST',
|
|
57
82
|
body: {
|
|
58
83
|
name: params.name,
|
|
@@ -92,6 +117,11 @@ async function listCmsItems(params) {
|
|
|
92
117
|
const prep = await prepareRequest(params.projectId);
|
|
93
118
|
if (!prep.success)
|
|
94
119
|
return prep.message;
|
|
120
|
+
// Get collection ID from slug
|
|
121
|
+
const collectionResult = await getCollectionId(prep.tenantId, params.collectionSlug);
|
|
122
|
+
if ('error' in collectionResult) {
|
|
123
|
+
return `# Error\n\n${collectionResult.error}`;
|
|
124
|
+
}
|
|
95
125
|
// Build query params
|
|
96
126
|
const queryParams = new URLSearchParams();
|
|
97
127
|
if (params.limit)
|
|
@@ -101,14 +131,14 @@ async function listCmsItems(params) {
|
|
|
101
131
|
if (params.order)
|
|
102
132
|
queryParams.set('order', params.order);
|
|
103
133
|
const queryString = queryParams.toString();
|
|
104
|
-
const endpoint = `/collections/${
|
|
105
|
-
const response = await (0, api_client_1.
|
|
134
|
+
const endpoint = `/api/collections/${collectionResult.collectionId}/items${queryString ? '?' + queryString : ''}`;
|
|
135
|
+
const response = await (0, api_client_1.apiRequest)(endpoint, { tenantId: prep.tenantId, method: 'GET' });
|
|
106
136
|
if ((0, api_client_1.isApiError)(response)) {
|
|
107
137
|
if ((0, api_client_1.needsAuthError)(response)) {
|
|
108
138
|
const authResult = await (0, device_flow_1.ensureAuthenticated)();
|
|
109
139
|
if (!authResult.authenticated)
|
|
110
140
|
return authResult.message;
|
|
111
|
-
const retry = await (0, api_client_1.
|
|
141
|
+
const retry = await (0, api_client_1.apiRequest)(endpoint, { tenantId: prep.tenantId, method: 'GET' });
|
|
112
142
|
if ((0, api_client_1.isApiError)(retry)) {
|
|
113
143
|
return `# Error Listing Items\n\n${retry.error}\n\n**Status:** ${retry.statusCode}`;
|
|
114
144
|
}
|
|
@@ -161,21 +191,35 @@ async function getCmsItem(params) {
|
|
|
161
191
|
const prep = await prepareRequest(params.projectId);
|
|
162
192
|
if (!prep.success)
|
|
163
193
|
return prep.message;
|
|
164
|
-
|
|
194
|
+
// Get collection ID from slug
|
|
195
|
+
const collectionResult = await getCollectionId(prep.tenantId, params.collectionSlug);
|
|
196
|
+
if ('error' in collectionResult) {
|
|
197
|
+
return `# Error\n\n${collectionResult.error}`;
|
|
198
|
+
}
|
|
199
|
+
// List items and find by slug (dashboard API uses item IDs, not slugs)
|
|
200
|
+
const response = await (0, api_client_1.apiRequest)(`/api/collections/${collectionResult.collectionId}/items`, { tenantId: prep.tenantId, method: 'GET' });
|
|
165
201
|
if ((0, api_client_1.isApiError)(response)) {
|
|
166
202
|
if ((0, api_client_1.needsAuthError)(response)) {
|
|
167
203
|
const authResult = await (0, device_flow_1.ensureAuthenticated)();
|
|
168
204
|
if (!authResult.authenticated)
|
|
169
205
|
return authResult.message;
|
|
170
|
-
const retry = await (0, api_client_1.
|
|
206
|
+
const retry = await (0, api_client_1.apiRequest)(`/api/collections/${collectionResult.collectionId}/items`, { tenantId: prep.tenantId, method: 'GET' });
|
|
171
207
|
if ((0, api_client_1.isApiError)(retry)) {
|
|
172
208
|
return `# Error Fetching Item\n\n${retry.error}\n\n**Status:** ${retry.statusCode}`;
|
|
173
209
|
}
|
|
174
|
-
|
|
210
|
+
const item = retry.data.find(i => i.slug === params.itemSlug);
|
|
211
|
+
if (!item) {
|
|
212
|
+
return `# Item Not Found\n\nNo item with slug "${params.itemSlug}" in collection "${params.collectionSlug}".`;
|
|
213
|
+
}
|
|
214
|
+
return formatSingleItem(item, params.collectionSlug);
|
|
175
215
|
}
|
|
176
216
|
return `# Error Fetching Item\n\n${response.error}\n\n**Status:** ${response.statusCode}`;
|
|
177
217
|
}
|
|
178
|
-
|
|
218
|
+
const item = response.data.find(i => i.slug === params.itemSlug);
|
|
219
|
+
if (!item) {
|
|
220
|
+
return `# Item Not Found\n\nNo item with slug "${params.itemSlug}" in collection "${params.collectionSlug}".`;
|
|
221
|
+
}
|
|
222
|
+
return formatSingleItem(item, params.collectionSlug);
|
|
179
223
|
}
|
|
180
224
|
function formatSingleItem(item, collectionSlug) {
|
|
181
225
|
return `# ${item.name}
|
|
@@ -201,6 +245,20 @@ async function updateCmsItem(params) {
|
|
|
201
245
|
const prep = await prepareRequest(params.projectId);
|
|
202
246
|
if (!prep.success)
|
|
203
247
|
return prep.message;
|
|
248
|
+
// Get collection ID from slug
|
|
249
|
+
const collectionResult = await getCollectionId(prep.tenantId, params.collectionSlug);
|
|
250
|
+
if ('error' in collectionResult) {
|
|
251
|
+
return `# Error\n\n${collectionResult.error}`;
|
|
252
|
+
}
|
|
253
|
+
// Find item ID by slug
|
|
254
|
+
const itemsResponse = await (0, api_client_1.apiRequest)(`/api/collections/${collectionResult.collectionId}/items`, { tenantId: prep.tenantId, method: 'GET' });
|
|
255
|
+
if ((0, api_client_1.isApiError)(itemsResponse)) {
|
|
256
|
+
return `# Error Finding Item\n\n${itemsResponse.error}\n\n**Status:** ${itemsResponse.statusCode}`;
|
|
257
|
+
}
|
|
258
|
+
const existingItem = itemsResponse.data.find(i => i.slug === params.itemSlug);
|
|
259
|
+
if (!existingItem) {
|
|
260
|
+
return `# Item Not Found\n\nNo item with slug "${params.itemSlug}" in collection "${params.collectionSlug}".`;
|
|
261
|
+
}
|
|
204
262
|
// Build the update body with only provided fields
|
|
205
263
|
const updateBody = {};
|
|
206
264
|
if (params.name !== undefined)
|
|
@@ -215,7 +273,8 @@ async function updateCmsItem(params) {
|
|
|
215
273
|
You must provide at least one of: \`name\`, \`data\`, or \`publishedAt\` to update.
|
|
216
274
|
`;
|
|
217
275
|
}
|
|
218
|
-
const response = await (0, api_client_1.
|
|
276
|
+
const response = await (0, api_client_1.apiRequest)(`/api/collections/${collectionResult.collectionId}/items/${existingItem.id}`, {
|
|
277
|
+
tenantId: prep.tenantId,
|
|
219
278
|
method: 'PUT',
|
|
220
279
|
body: updateBody,
|
|
221
280
|
});
|
|
@@ -224,7 +283,8 @@ You must provide at least one of: \`name\`, \`data\`, or \`publishedAt\` to upda
|
|
|
224
283
|
const authResult = await (0, device_flow_1.ensureAuthenticated)();
|
|
225
284
|
if (!authResult.authenticated)
|
|
226
285
|
return authResult.message;
|
|
227
|
-
const retry = await (0, api_client_1.
|
|
286
|
+
const retry = await (0, api_client_1.apiRequest)(`/api/collections/${collectionResult.collectionId}/items/${existingItem.id}`, {
|
|
287
|
+
tenantId: prep.tenantId,
|
|
228
288
|
method: 'PUT',
|
|
229
289
|
body: updateBody,
|
|
230
290
|
});
|
|
@@ -274,13 +334,27 @@ To delete the item "${params.itemSlug}" from collection "${params.collectionSlug
|
|
|
274
334
|
const prep = await prepareRequest(params.projectId);
|
|
275
335
|
if (!prep.success)
|
|
276
336
|
return prep.message;
|
|
277
|
-
|
|
337
|
+
// Get collection ID from slug
|
|
338
|
+
const collectionResult = await getCollectionId(prep.tenantId, params.collectionSlug);
|
|
339
|
+
if ('error' in collectionResult) {
|
|
340
|
+
return `# Error\n\n${collectionResult.error}`;
|
|
341
|
+
}
|
|
342
|
+
// Find item ID by slug
|
|
343
|
+
const itemsResponse = await (0, api_client_1.apiRequest)(`/api/collections/${collectionResult.collectionId}/items`, { tenantId: prep.tenantId, method: 'GET' });
|
|
344
|
+
if ((0, api_client_1.isApiError)(itemsResponse)) {
|
|
345
|
+
return `# Error Finding Item\n\n${itemsResponse.error}\n\n**Status:** ${itemsResponse.statusCode}`;
|
|
346
|
+
}
|
|
347
|
+
const existingItem = itemsResponse.data.find(i => i.slug === params.itemSlug);
|
|
348
|
+
if (!existingItem) {
|
|
349
|
+
return `# Item Not Found\n\nNo item with slug "${params.itemSlug}" in collection "${params.collectionSlug}".`;
|
|
350
|
+
}
|
|
351
|
+
const response = await (0, api_client_1.apiRequest)(`/api/collections/${collectionResult.collectionId}/items/${existingItem.id}`, { tenantId: prep.tenantId, method: 'DELETE' });
|
|
278
352
|
if ((0, api_client_1.isApiError)(response)) {
|
|
279
353
|
if ((0, api_client_1.needsAuthError)(response)) {
|
|
280
354
|
const authResult = await (0, device_flow_1.ensureAuthenticated)();
|
|
281
355
|
if (!authResult.authenticated)
|
|
282
356
|
return authResult.message;
|
|
283
|
-
const retry = await (0, api_client_1.
|
|
357
|
+
const retry = await (0, api_client_1.apiRequest)(`/api/collections/${collectionResult.collectionId}/items/${existingItem.id}`, { tenantId: prep.tenantId, method: 'DELETE' });
|
|
284
358
|
if ((0, api_client_1.isApiError)(retry)) {
|
|
285
359
|
return `# Error Deleting Item\n\n${retry.error}\n\n**Status:** ${retry.statusCode}`;
|
|
286
360
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "multisite-cms-mcp",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "MCP server for Fast Mode CMS. Convert websites, validate packages, and deploy directly to Fast Mode. Includes authentication, project creation, schema sync, and one-click deployment.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|