@workover/mcp 0.20.0 → 0.21.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 +2 -0
- package/index.mjs +62 -1
- package/lib.mjs +79 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,8 @@ production sign-in names the environment instead.
|
|
|
36
36
|
- `workover_upload_image(docId, path, alt)` — put a local image into a document's media
|
|
37
37
|
- `workover_list_images(docId, tabId?)` — the images in a document: file name, alt text and src
|
|
38
38
|
- `workover_set_image(docId, src, filename?, alt?)` — set an image's file name (its WordPress media name) and/or alt text, as the editor's Edit image dialog does. Needs `workover login --write`
|
|
39
|
+
- `workover_list_media(projectId, search?, filter?, source?, cursor?)` — the project's Media library: every image its documents use and every WordPress attachment, with usage, alt text and problems (no alt, oversized, broken, outdated)
|
|
40
|
+
- `workover_replace_media(projectId, assetId, replacementAssetId)` — raise one reviewed fix that swaps an image for another in every document that uses it. Needs `workover login --write`
|
|
39
41
|
- `workover_doc_status(docId, status?)` — read a document's Workover status and the statuses its workflow offers (with whether you may move it to each, and why not), or set it through the browser's rules: role, workflow gates, approvals. Needs `workover login --write`, plus `--publish` to or from Published. Does not publish to WordPress
|
|
40
42
|
- `workover_propose_edit(docId, markdown, note, tabId?, reasoning?)` — propose a revised version (rendered as suggestions; never applied or published automatically)
|
|
41
43
|
- `workover_suggestion_status(docId)` — the open suggestion: whether the editor has shown it, has not yet, or could not (and why)
|
package/index.mjs
CHANGED
|
@@ -244,6 +244,67 @@ const TOOLS = [
|
|
|
244
244
|
required: ['docId', 'src'],
|
|
245
245
|
},
|
|
246
246
|
},
|
|
247
|
+
{
|
|
248
|
+
name: 'workover_list_media',
|
|
249
|
+
description:
|
|
250
|
+
"List a project's Media library: every image its documents use and, for a WordPress project, every attachment in the site's media library. Each line gives the asset id, file name, where it comes from (Workover or WordPress #id), how many documents use it, its alt text and any problem (no alt text, oversized, broken, outdated screenshot). Use it to find images to fix, and to find the asset ids workover_replace_media takes.",
|
|
251
|
+
inputSchema: {
|
|
252
|
+
type: 'object',
|
|
253
|
+
properties: {
|
|
254
|
+
projectId: {
|
|
255
|
+
type: 'number',
|
|
256
|
+
description: 'The project, as printed by workover_list_projects ("#7" → 7).',
|
|
257
|
+
},
|
|
258
|
+
search: { type: 'string', description: 'Match file names, titles, alt text and tags.' },
|
|
259
|
+
filter: {
|
|
260
|
+
type: 'string',
|
|
261
|
+
enum: [
|
|
262
|
+
'all',
|
|
263
|
+
'in_use',
|
|
264
|
+
'unused',
|
|
265
|
+
'attention',
|
|
266
|
+
'missing_alt',
|
|
267
|
+
'oversized',
|
|
268
|
+
'broken',
|
|
269
|
+
'stale',
|
|
270
|
+
'deleted',
|
|
271
|
+
],
|
|
272
|
+
description:
|
|
273
|
+
'"unused" means not found in imported content (WordPress themes and page builders are not visible to Workover). "attention" is any of missing_alt, oversized, broken and stale. Default "all".',
|
|
274
|
+
},
|
|
275
|
+
source: {
|
|
276
|
+
type: 'string',
|
|
277
|
+
enum: ['all', 'workover', 'wordpress'],
|
|
278
|
+
description: 'Only Workover uploads, or only WordPress attachments. Default both.',
|
|
279
|
+
},
|
|
280
|
+
cursor: {
|
|
281
|
+
type: 'number',
|
|
282
|
+
description: 'The cursor a previous page printed, for the next page.',
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
required: ['projectId'],
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: 'workover_replace_media',
|
|
290
|
+
description:
|
|
291
|
+
"Replace an image with another image from the same project's Media library, in every document that uses it (body images, featured and social images, WordPress block and attachment references). It changes nothing directly: it raises ONE fix for a person to review in the project's Health page (Findings), and accepting it is what rewrites the documents. The old image stays in the library. Take both ids from workover_list_media; to replace with a new file, upload it first with workover_upload_image. Requires a token from `workover login --write`.",
|
|
292
|
+
inputSchema: {
|
|
293
|
+
type: 'object',
|
|
294
|
+
properties: {
|
|
295
|
+
projectId: {
|
|
296
|
+
type: 'number',
|
|
297
|
+
description: 'The project, as printed by workover_list_projects ("#7" → 7).',
|
|
298
|
+
},
|
|
299
|
+
assetId: {
|
|
300
|
+
type: 'number',
|
|
301
|
+
description: 'The image to replace, as workover_list_media printed it.',
|
|
302
|
+
},
|
|
303
|
+
replacementAssetId: { type: 'number', description: 'The image to put in its place.' },
|
|
304
|
+
},
|
|
305
|
+
required: ['projectId', 'assetId', 'replacementAssetId'],
|
|
306
|
+
},
|
|
307
|
+
},
|
|
247
308
|
{
|
|
248
309
|
name: 'workover_doc_status',
|
|
249
310
|
description:
|
|
@@ -586,7 +647,7 @@ const telemetry = telemetryEnabled(process.env, { auth });
|
|
|
586
647
|
// Keep in step with package.json. It is what every telemetry event is stamped with, so a stale
|
|
587
648
|
// value here does not break anything — it quietly attributes this release's behaviour to an older
|
|
588
649
|
// one, which is worse, because the numbers still look fine.
|
|
589
|
-
const VERSION = '0.
|
|
650
|
+
const VERSION = '0.21.0';
|
|
590
651
|
|
|
591
652
|
/** This release and the connected client, stamped on a feedback report (see feedback.mjs). */
|
|
592
653
|
function clientInfo() {
|
package/lib.mjs
CHANGED
|
@@ -451,6 +451,61 @@ export const imagesInHtml = (html) => {
|
|
|
451
451
|
return out;
|
|
452
452
|
};
|
|
453
453
|
|
|
454
|
+
/** workover_list_media's filters, as the flags GET /project/:id/media takes. */
|
|
455
|
+
const MEDIA_FLAGS = {
|
|
456
|
+
attention: 'attention',
|
|
457
|
+
missing_alt: 'missingAlt',
|
|
458
|
+
oversized: 'oversized',
|
|
459
|
+
broken: 'broken',
|
|
460
|
+
stale: 'stale',
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
/** The query string for GET /project/:id/media, from workover_list_media's arguments. */
|
|
464
|
+
export function mediaListQuery(args = {}) {
|
|
465
|
+
const q = new URLSearchParams();
|
|
466
|
+
const filter = String(args.filter || 'all');
|
|
467
|
+
if (filter === 'in_use' || filter === 'unused' || filter === 'deleted') q.set('tab', filter);
|
|
468
|
+
if (MEDIA_FLAGS[filter]) q.set(MEDIA_FLAGS[filter], 'true');
|
|
469
|
+
if (args.source === 'workover' || args.source === 'wordpress') q.set('source', args.source);
|
|
470
|
+
const search = typeof args.search === 'string' ? args.search.trim() : '';
|
|
471
|
+
if (search) q.set('search', search);
|
|
472
|
+
const cursor = Number(args.cursor);
|
|
473
|
+
if (Number.isInteger(cursor) && cursor > 0) q.set('cursor', String(cursor));
|
|
474
|
+
q.set('limit', '50');
|
|
475
|
+
return q.toString();
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** workover_list_media's answer: the counts, one block per asset, then the next page. */
|
|
479
|
+
export function formatMediaList(projectId, res) {
|
|
480
|
+
const items = Array.isArray(res?.items) ? res.items : [];
|
|
481
|
+
const c = res?.counts || {};
|
|
482
|
+
const head =
|
|
483
|
+
`Media library of project #${projectId}: ${c.all ?? items.length} images, ` +
|
|
484
|
+
`${c.inUse ?? 0} in use, ${c.unused ?? 0} not found in imported content, ` +
|
|
485
|
+
`${c.attention ?? 0} need attention.`;
|
|
486
|
+
if (!items.length) return `${head}\n\nNothing matches.`;
|
|
487
|
+
const lines = items.map((a) => {
|
|
488
|
+
const problems = [];
|
|
489
|
+
// Alt text is an image's; a PDF in the WordPress library has none to miss.
|
|
490
|
+
if (!a.alt && (a.mime == null || String(a.mime).startsWith('image/')))
|
|
491
|
+
problems.push('no alt text');
|
|
492
|
+
if (a.oversized) problems.push(`oversized (${Math.round((a.bytes || 0) / 1024)} KB)`);
|
|
493
|
+
if (a.brokenAt) problems.push('broken');
|
|
494
|
+
if (a.staleAt) problems.push(`outdated: ${a.staleReason || 'the UI changed'}`);
|
|
495
|
+
if (a.deletedAt) problems.push('deleted');
|
|
496
|
+
const from = a.wpAttachmentId ? `WordPress #${a.wpAttachmentId}` : 'Workover';
|
|
497
|
+
const used = a.useCount
|
|
498
|
+
? `used in ${a.useCount} doc${a.useCount === 1 ? '' : 's'}`
|
|
499
|
+
: 'not found in imported content';
|
|
500
|
+
return (
|
|
501
|
+
`#${a.id} ${a.filename} (${from}, ${used})\n alt: ${a.alt || '(none)'}` +
|
|
502
|
+
(problems.length ? `\n problems: ${problems.join('; ')}` : '')
|
|
503
|
+
);
|
|
504
|
+
});
|
|
505
|
+
const more = res?.nextCursor ? `\n\nMore: pass cursor ${res.nextCursor} for the next page.` : '';
|
|
506
|
+
return `${head}\n\n${lines.join('\n')}${more}`;
|
|
507
|
+
}
|
|
508
|
+
|
|
454
509
|
/** The error shown when a tool is handed something that isn't a numeric id. */
|
|
455
510
|
export const badIdErr = (kind, got) =>
|
|
456
511
|
err(
|
|
@@ -1081,6 +1136,30 @@ export function makeDispatch({ auth, api, apiPost, fetchImpl = fetch, readFile,
|
|
|
1081
1136
|
`Updated: file name "${res?.filename}", alt "${res?.alt || ''}".${inDoc} The file name is what WordPress gets on the next publish.`,
|
|
1082
1137
|
);
|
|
1083
1138
|
}
|
|
1139
|
+
if (name === 'workover_list_media') {
|
|
1140
|
+
const projectId = rowId(args.projectId);
|
|
1141
|
+
if (projectId === null) return badIdErr('project', args.projectId);
|
|
1142
|
+
const res = await api(`/project/${projectId}/media?${mediaListQuery(args)}`);
|
|
1143
|
+
return text(formatMediaList(projectId, res));
|
|
1144
|
+
}
|
|
1145
|
+
if (name === 'workover_replace_media') {
|
|
1146
|
+
const projectId = rowId(args.projectId);
|
|
1147
|
+
if (projectId === null) return badIdErr('project', args.projectId);
|
|
1148
|
+
const assetId = rowId(args.assetId);
|
|
1149
|
+
if (assetId === null) return badIdErr('asset', args.assetId);
|
|
1150
|
+
const replacementAssetId = rowId(args.replacementAssetId);
|
|
1151
|
+
if (replacementAssetId === null) return badIdErr('asset', args.replacementAssetId);
|
|
1152
|
+
if (assetId === replacementAssetId)
|
|
1153
|
+
return err('Choose a different image to replace it with.');
|
|
1154
|
+
const res = await api(`/project/${projectId}/media/${assetId}/replace`, {
|
|
1155
|
+
method: 'POST',
|
|
1156
|
+
headers: { 'content-type': 'application/json' },
|
|
1157
|
+
body: JSON.stringify({ replacementAssetId }),
|
|
1158
|
+
});
|
|
1159
|
+
return text(
|
|
1160
|
+
`Raised a fix to replace image #${assetId} with #${replacementAssetId} in every document that uses it${res?.suggestionId ? ` (fix #${res.suggestionId})` : ''}. Nothing has changed yet: a person reviews it in the project's Health page (Findings), and accepting it rewrites the documents. The old image stays in the library.`,
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1084
1163
|
if (name === 'workover_edit_doc') {
|
|
1085
1164
|
const md = String(args.markdown || '').trim();
|
|
1086
1165
|
// A rename rides on the direct-edit tool: `title` alone renames without touching the body.
|
package/package.json
CHANGED