@workover/mcp 0.8.0 → 0.9.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 +11 -1
- package/index.mjs +50 -2
- package/lib.mjs +128 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,6 +26,8 @@ That's it. Ask Claude Code things like *"read my Workover doc about onboarding a
|
|
|
26
26
|
- `workover_list_projects()` — list your projects
|
|
27
27
|
- `workover_create_doc(projectId, title, markdown, categories?)` — create a document with its content written in, filed under the categories you name (a category that does not exist yet is created)
|
|
28
28
|
- `workover_upload_image(docId, path, alt)` — put a local image into a document's media
|
|
29
|
+
- `workover_list_images(docId, tabId?)` — the images in a document: file name, alt text and src. `docId` can be the document URL
|
|
30
|
+
- `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`
|
|
29
31
|
- `workover_propose_edit(docId, markdown, note, tabId?, reasoning?)` — propose a revised version (rendered as suggestions; never applied or published automatically)
|
|
30
32
|
- `workover_edit_doc(docId, markdown, note, tabId?)` — edit a document directly, no review step. Needs `workover login --write`
|
|
31
33
|
- `workover_style_guide(projectId?)` — the rules this team writes by
|
|
@@ -33,7 +35,7 @@ That's it. Ask Claude Code things like *"read my Workover doc about onboarding a
|
|
|
33
35
|
- `workover_list_tabs(docId)` — a document's tabs
|
|
34
36
|
- `workover_create_tab(docId, title, parentId?)` — add an empty tab. Needs `workover login --write`
|
|
35
37
|
|
|
36
|
-
Everything the MCP server can do, the CLI can do too (`workover doc create|read|propose|write|list|search|tabs|tab-new`, `workover rules list|export|add`). That is deliberate: a newly-registered MCP server is not available in the session that registered it, so an agent that finds mid-task that it needs Workover has no way in until it restarts. A CLI subcommand works immediately.
|
|
38
|
+
Everything the MCP server can do, the CLI can do too (`workover doc create|read|propose|write|list|search|tabs|tab-new|images|image`, `workover rules list|export|add`). That is deliberate: a newly-registered MCP server is not available in the session that registered it, so an agent that finds mid-task that it needs Workover has no way in until it restarts. A CLI subcommand works immediately.
|
|
37
39
|
|
|
38
40
|
## The style guide
|
|
39
41
|
|
|
@@ -66,6 +68,14 @@ tab**, so `workover_read_doc` says which tab it read and what the others are, an
|
|
|
66
68
|
an optional `tabId`. Creating a tab needs `--write`; deleting one, and changing which tab syncs to
|
|
67
69
|
WordPress, stay in the browser.
|
|
68
70
|
|
|
71
|
+
## Images
|
|
72
|
+
|
|
73
|
+
`workover_set_image` changes one image without rewriting the document: the alt text is set on every
|
|
74
|
+
copy of that image, in every tab, directly in the live document (the `<img alt>` that publishing
|
|
75
|
+
reads), and the file name on the image's media record, which WordPress gets on the next publish.
|
|
76
|
+
Whichever of the two is left out is kept. It needs `--write`, like any other direct edit, and the
|
|
77
|
+
document's activity records it as you, via the agent.
|
|
78
|
+
|
|
69
79
|
## Safety
|
|
70
80
|
|
|
71
81
|
The server authenticates with the token from `workover login`. By default it is **read + propose only**: it cannot publish to WordPress, change your account, or apply changes without you. Every edit is a suggestion you accept, and only a person publishes. Revoke access anytime in **Workover → Settings → Developer**.
|
package/index.mjs
CHANGED
|
@@ -181,6 +181,54 @@ const TOOLS = [
|
|
|
181
181
|
required: ['docId', 'path'],
|
|
182
182
|
},
|
|
183
183
|
},
|
|
184
|
+
{
|
|
185
|
+
name: 'workover_list_images',
|
|
186
|
+
description:
|
|
187
|
+
"List the images in a Workover document, in reading order, with each one's file name (the name WordPress gets on publish), its alt text, and its src. Use it before workover_set_image, and to find images with no alt text.",
|
|
188
|
+
inputSchema: {
|
|
189
|
+
type: 'object',
|
|
190
|
+
properties: {
|
|
191
|
+
docId: {
|
|
192
|
+
type: ['number', 'string'],
|
|
193
|
+
description: 'The numeric document id, or the document URL.',
|
|
194
|
+
},
|
|
195
|
+
tabId: {
|
|
196
|
+
type: 'number',
|
|
197
|
+
description:
|
|
198
|
+
'Which tab, for a document with tabs (workover_list_tabs). Omit for the main body.',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
required: ['docId'],
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: 'workover_set_image',
|
|
206
|
+
description:
|
|
207
|
+
"Set an image's file name and/or alt text in a Workover document, as the editor's \"Edit image\" dialog does. The alt text is written onto every copy of the image in the document (what publishing reads); the file name becomes the WordPress media name on the next publish. Whichever you leave out is kept. Write a short, specific kebab-case file name and alt text that says what the image shows. Requires a token from `workover login --write`. Never publishes.",
|
|
208
|
+
inputSchema: {
|
|
209
|
+
type: 'object',
|
|
210
|
+
properties: {
|
|
211
|
+
docId: {
|
|
212
|
+
type: ['number', 'string'],
|
|
213
|
+
description: 'The numeric document id, or the document URL.',
|
|
214
|
+
},
|
|
215
|
+
src: {
|
|
216
|
+
type: 'string',
|
|
217
|
+
description: 'The image src, exactly as workover_list_images printed it.',
|
|
218
|
+
},
|
|
219
|
+
filename: {
|
|
220
|
+
type: 'string',
|
|
221
|
+
description:
|
|
222
|
+
'The new file name, e.g. "lifterlms-groups-admin-list". The extension is kept if you leave it off.',
|
|
223
|
+
},
|
|
224
|
+
alt: {
|
|
225
|
+
type: 'string',
|
|
226
|
+
description: 'The new alt text. An empty string clears it.',
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
required: ['docId', 'src'],
|
|
230
|
+
},
|
|
231
|
+
},
|
|
184
232
|
{
|
|
185
233
|
name: 'workover_edit_doc',
|
|
186
234
|
description:
|
|
@@ -213,7 +261,7 @@ const TOOLS = [
|
|
|
213
261
|
{
|
|
214
262
|
name: 'workover_propose_edit',
|
|
215
263
|
description:
|
|
216
|
-
"Propose a revised version of a Workover document. You do NOT edit the document directly — the change appears as tracked-change SUGGESTIONS that the human reviews and accepts or rejects in Workover, and only they can publish. Read the document first (workover_read_doc), then provide the FULL revised document as markdown.",
|
|
264
|
+
"Propose a revised version of a Workover document. You do NOT edit the document directly — the change appears as tracked-change SUGGESTIONS that the human reviews and accepts or rejects in Workover, and only they can publish. Read the document first (workover_read_doc), then provide the FULL revised document as markdown. Start from the markdown workover_read_doc returned and change only the words you mean to; leave every other line exactly as it was, so the person reviews your edit rather than a reformatting. Tables come back as HTML: edit the text inside the cells and do not convert them to markdown tables. Keep tasks as `- [x]` / `- [ ]` and code in ``` fences. Do not reflow paragraphs, renumber lists or change bullet markers.",
|
|
217
265
|
inputSchema: {
|
|
218
266
|
type: 'object',
|
|
219
267
|
properties: {
|
|
@@ -250,7 +298,7 @@ const telemetry = telemetryEnabled(process.env, { auth });
|
|
|
250
298
|
// Keep in step with package.json. It is what every telemetry event is stamped with, so a stale
|
|
251
299
|
// value here does not break anything — it quietly attributes this release's behaviour to an older
|
|
252
300
|
// one, which is worse, because the numbers still look fine.
|
|
253
|
-
const VERSION = '0.
|
|
301
|
+
const VERSION = '0.9.0';
|
|
254
302
|
|
|
255
303
|
/**
|
|
256
304
|
* What the client is told about this server before it calls anything.
|
package/lib.mjs
CHANGED
|
@@ -129,6 +129,58 @@ export const renderStyleFeedback = (style) => {
|
|
|
129
129
|
return `\n\n${style.summary}`;
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
+
const HANDLE_RE = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A document's row id from a row id OR a document URL / handle, resolved through the api.
|
|
136
|
+
*
|
|
137
|
+
* The image tools take the link as it is, because the person asking for alt text pastes the URL of
|
|
138
|
+
* the document they are looking at. Returns null when neither is there.
|
|
139
|
+
*/
|
|
140
|
+
export const resolveDocId = async (api, value) => {
|
|
141
|
+
const id = rowId(value);
|
|
142
|
+
if (id !== null) return id;
|
|
143
|
+
const m = HANDLE_RE.exec(String(value ?? ''));
|
|
144
|
+
if (!m) return null;
|
|
145
|
+
const doc = await api(`/project/doc/by-handle/${encodeURIComponent(m[1].toLowerCase())}`);
|
|
146
|
+
return doc?.id ?? null;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const decodeAttr = (v) =>
|
|
150
|
+
String(v ?? '')
|
|
151
|
+
.replace(/"/g, '"')
|
|
152
|
+
.replace(/'/g, "'")
|
|
153
|
+
.replace(/</g, '<')
|
|
154
|
+
.replace(/>/g, '>')
|
|
155
|
+
.replace(/&/g, '&');
|
|
156
|
+
|
|
157
|
+
const attrOf = (tag, name) => {
|
|
158
|
+
const m = new RegExp(`\\s${name}\\s*=\\s*("([^"]*)"|'([^']*)')`, 'i').exec(tag);
|
|
159
|
+
return m ? decodeAttr(m[2] ?? m[3]) : null;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The images in a body, in reading order, one per distinct `src` (the CLI's `imagesInHtml`).
|
|
164
|
+
* The src is read off the rendered HTML byte for byte, because it is how the api identifies an image.
|
|
165
|
+
*/
|
|
166
|
+
export const imagesInHtml = (html) => {
|
|
167
|
+
const out = [];
|
|
168
|
+
const bySrc = new Map();
|
|
169
|
+
for (const m of String(html || '').matchAll(/<img\b[^>]*>/gi)) {
|
|
170
|
+
const src = attrOf(m[0], 'src');
|
|
171
|
+
if (!src) continue;
|
|
172
|
+
const seen = bySrc.get(src);
|
|
173
|
+
if (seen) {
|
|
174
|
+
seen.count += 1;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const entry = { index: out.length + 1, src, alt: attrOf(m[0], 'alt') || '', count: 1 };
|
|
178
|
+
bySrc.set(src, entry);
|
|
179
|
+
out.push(entry);
|
|
180
|
+
}
|
|
181
|
+
return out;
|
|
182
|
+
};
|
|
183
|
+
|
|
132
184
|
/** The error shown when a tool is handed something that isn't a numeric id. */
|
|
133
185
|
export const badIdErr = (kind, got) =>
|
|
134
186
|
err(
|
|
@@ -178,7 +230,18 @@ export function makeApi({ auth, fetchImpl = fetch }) {
|
|
|
178
230
|
.catch(() => '');
|
|
179
231
|
throw new Error(detail || 'This token isn’t allowed to do that.');
|
|
180
232
|
}
|
|
181
|
-
if (!res.ok)
|
|
233
|
+
if (!res.ok) {
|
|
234
|
+
// The api's own sentence for a 4xx as well: "No image with that src is in this document"
|
|
235
|
+
// tells an agent what to do next, "Workover API error (404)" does not.
|
|
236
|
+
const detail =
|
|
237
|
+
res.status < 500
|
|
238
|
+
? await res
|
|
239
|
+
.json()
|
|
240
|
+
.then((body) => (typeof body?.message === 'string' ? body.message : ''))
|
|
241
|
+
.catch(() => '')
|
|
242
|
+
: '';
|
|
243
|
+
throw new Error(`Workover API error (${res.status})${detail ? `: ${detail}` : '.'}`);
|
|
244
|
+
}
|
|
182
245
|
return res.json();
|
|
183
246
|
}
|
|
184
247
|
const apiPost = (path, body) =>
|
|
@@ -454,6 +517,70 @@ export function makeDispatch({ auth, api, apiPost, fetchImpl = fetch, readFile }
|
|
|
454
517
|
`Uploaded. Reference it in the document markdown:\n\n`,
|
|
455
518
|
);
|
|
456
519
|
}
|
|
520
|
+
if (name === 'workover_list_images') {
|
|
521
|
+
const docId = await resolveDocId(api, args.docId);
|
|
522
|
+
if (docId === null)
|
|
523
|
+
return err(`"${args.docId ?? ''}" isn't a document id or a document URL.`);
|
|
524
|
+
const tabId = args.tabId == null ? null : rowId(args.tabId);
|
|
525
|
+
if (args.tabId != null && tabId === null) return badIdErr('tab', args.tabId);
|
|
526
|
+
const live = await api(
|
|
527
|
+
`/project/doc/${docId}/content${tabId === null ? '' : `?tabId=${tabId}`}`,
|
|
528
|
+
);
|
|
529
|
+
const images = imagesInHtml(live?.html || '');
|
|
530
|
+
if (!images.length)
|
|
531
|
+
return text(
|
|
532
|
+
`No images in ${live?.tab ? `the "${live.tab.title}" tab of ` : ''}document #${docId}.`,
|
|
533
|
+
);
|
|
534
|
+
for (const img of images) {
|
|
535
|
+
const meta = await api(
|
|
536
|
+
`/project/doc/${docId}/media/meta?src=${encodeURIComponent(img.src)}`,
|
|
537
|
+
);
|
|
538
|
+
img.filename = meta?.filename || '';
|
|
539
|
+
}
|
|
540
|
+
const tabs = Array.isArray(live?.tabs) ? live.tabs : [];
|
|
541
|
+
return text(
|
|
542
|
+
`Images in ${live?.tab ? `the "${live.tab.title}" tab of ` : ''}document #${docId}, in reading order. The file name is what WordPress gets on publish; pass the src to workover_set_image.\n\n` +
|
|
543
|
+
images
|
|
544
|
+
.map(
|
|
545
|
+
(i) =>
|
|
546
|
+
`${i.index}. ${i.filename}${i.count > 1 ? ` (appears ${i.count}×)` : ''}\n alt: ${i.alt || '(none)'}\n src: ${i.src}`,
|
|
547
|
+
)
|
|
548
|
+
.join('\n') +
|
|
549
|
+
(tabs.length
|
|
550
|
+
? `\n\nThis document has ${tabs.length} tabs; pass tabId to list another: ${tabs.map((t) => `#${t.id} ${t.title}`).join(', ')}.`
|
|
551
|
+
: ''),
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
if (name === 'workover_set_image') {
|
|
555
|
+
const docId = await resolveDocId(api, args.docId);
|
|
556
|
+
if (docId === null)
|
|
557
|
+
return err(`"${args.docId ?? ''}" isn't a document id or a document URL.`);
|
|
558
|
+
const src = String(args.src || '');
|
|
559
|
+
if (!src) return err('Provide the image `src`, exactly as workover_list_images printed it.');
|
|
560
|
+
const filename = typeof args.filename === 'string' ? args.filename : undefined;
|
|
561
|
+
const alt = typeof args.alt === 'string' ? args.alt : undefined;
|
|
562
|
+
if (filename === undefined && alt === undefined)
|
|
563
|
+
return err('Provide `filename`, `alt` or both. Whichever is left out is kept.');
|
|
564
|
+
const res = await api(`/project/doc/${docId}/media`, {
|
|
565
|
+
method: 'PATCH',
|
|
566
|
+
headers: { 'content-type': 'application/json' },
|
|
567
|
+
body: JSON.stringify({
|
|
568
|
+
src,
|
|
569
|
+
...(filename !== undefined ? { filename } : {}),
|
|
570
|
+
...(alt !== undefined ? { alt } : {}),
|
|
571
|
+
syncDoc: true,
|
|
572
|
+
}),
|
|
573
|
+
});
|
|
574
|
+
const inDoc =
|
|
575
|
+
alt !== undefined && typeof res?.updatedInDoc === 'number'
|
|
576
|
+
? res.updatedInDoc
|
|
577
|
+
? ` Alt text set on ${res.updatedInDoc} image node(s) in the document.`
|
|
578
|
+
: ' The image already had that alt text, so the document was left as it was.'
|
|
579
|
+
: '';
|
|
580
|
+
return text(
|
|
581
|
+
`Updated: file name "${res?.filename}", alt "${res?.alt || ''}".${inDoc} The file name is what WordPress gets on the next publish.`,
|
|
582
|
+
);
|
|
583
|
+
}
|
|
457
584
|
if (name === 'workover_edit_doc') {
|
|
458
585
|
const md = String(args.markdown || '').trim();
|
|
459
586
|
if (!md) return err('Provide the full revised document as `markdown`.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workover/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Workover MCP server — let Claude Code and other MCP clients read and cowork on your Workover documents.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ScaleMath",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
35
|
+
"@modelcontextprotocol/sdk": "^1.31.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"test": "node --test"
|