@workover/mcp 0.1.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.
Files changed (3) hide show
  1. package/README.md +39 -0
  2. package/index.mjs +148 -0
  3. package/package.json +35 -0
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # @workover/mcp
2
+
3
+ An [MCP](https://modelcontextprotocol.io) server for [Workover](https://workover.dev) — lets Claude Code (and other MCP clients) read your Workover documents and propose edits you review.
4
+
5
+ ## Setup
6
+
7
+ First sign in with the [Workover CLI](https://www.npmjs.com/package/@workover/cli):
8
+
9
+ ```sh
10
+ npm i -g @workover/cli
11
+ workover login
12
+ ```
13
+
14
+ Then add the server to Claude Code:
15
+
16
+ ```sh
17
+ claude mcp add workover -- npx -y @workover/mcp
18
+ ```
19
+
20
+ That's it. Ask Claude Code things like *"read my Workover doc about onboarding and tighten the intro"* — it reads the document and its proposed changes appear in Workover as tracked-change **suggestions** you accept or reject.
21
+
22
+ ## Tools
23
+
24
+ - `workover_search_docs(query)` — find documents by title/content
25
+ - `workover_read_doc(docId)` — read a document's text
26
+ - `workover_list_projects()` — list your projects
27
+ - `workover_propose_edit(docId, markdown, note)` — propose a revised version (rendered as suggestions; never applied or published automatically)
28
+
29
+ ## Safety
30
+
31
+ The server authenticates with the token from `workover login` and is **read + propose only**. It cannot publish to WordPress, change your account, or apply changes without you. Every edit is a suggestion a human accepts, and only a human publishes. Revoke access anytime in **Workover → Settings → Developer**.
32
+
33
+ ## Configuration
34
+
35
+ The API endpoint comes from your `workover login` (defaults to `https://api.workover.dev`).
36
+
37
+ ---
38
+
39
+ © ScaleMath. All rights reserved.
package/index.mjs ADDED
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+ // Workover MCP server (Phase 2 — read tools). Lets Claude Code / any MCP client read the signed-in
3
+ // user's Workover documents. Auth = the token stored by `workover login` (~/.workover/config.json).
4
+ // Read-only for now; propose-edits (as suggestions) lands in Phase 3. Never publishes to WordPress.
5
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
7
+ import {
8
+ ListToolsRequestSchema,
9
+ CallToolRequestSchema,
10
+ } from '@modelcontextprotocol/sdk/types.js';
11
+ import { readFileSync } from 'fs';
12
+ import { homedir } from 'os';
13
+ import { join } from 'path';
14
+
15
+ function loadAuth() {
16
+ try {
17
+ const cfg = JSON.parse(readFileSync(join(homedir(), '.workover', 'config.json'), 'utf8'));
18
+ if (cfg?.token && cfg?.api) return cfg;
19
+ } catch {
20
+ /* not signed in */
21
+ }
22
+ return null;
23
+ }
24
+
25
+ const auth = loadAuth();
26
+
27
+ async function api(path, init) {
28
+ const res = await fetch(`${auth.api}${path}`, {
29
+ ...init,
30
+ headers: { authorization: `Bearer ${auth.token}`, ...(init?.headers || {}) },
31
+ });
32
+ if (res.status === 401) throw new Error('Your Workover login expired or was revoked. Run `workover login`.');
33
+ if (res.status === 403) throw new Error('This token isn’t allowed to do that.');
34
+ if (!res.ok) throw new Error(`Workover API error (${res.status}).`);
35
+ return res.json();
36
+ }
37
+ const apiPost = (path, body) =>
38
+ api(path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
39
+
40
+ const stripHtml = (h) =>
41
+ (h || '').replace(/<[^>]+>/g, ' ').replace(/&[a-z]+;/g, ' ').replace(/\s+/g, ' ').trim();
42
+ const text = (t) => ({ content: [{ type: 'text', text: t }] });
43
+ const err = (t) => ({ content: [{ type: 'text', text: t }], isError: true });
44
+
45
+ const TOOLS = [
46
+ {
47
+ name: 'workover_search_docs',
48
+ description:
49
+ 'Search your Workover documents by title and content. Returns matching documents with their ids — use workover_read_doc to read one.',
50
+ inputSchema: {
51
+ type: 'object',
52
+ properties: { query: { type: 'string', description: 'What to search for.' } },
53
+ required: ['query'],
54
+ },
55
+ },
56
+ {
57
+ name: 'workover_read_doc',
58
+ description: 'Read the full text of a Workover document by its id.',
59
+ inputSchema: {
60
+ type: 'object',
61
+ properties: { docId: { type: 'number', description: 'The document id.' } },
62
+ required: ['docId'],
63
+ },
64
+ },
65
+ {
66
+ name: 'workover_list_projects',
67
+ description: 'List the projects/workspaces you can access in Workover.',
68
+ inputSchema: { type: 'object', properties: {} },
69
+ },
70
+ {
71
+ name: 'workover_propose_edit',
72
+ description:
73
+ "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.",
74
+ inputSchema: {
75
+ type: 'object',
76
+ properties: {
77
+ docId: { type: 'number', description: 'The document id to propose changes to.' },
78
+ markdown: {
79
+ type: 'string',
80
+ description: 'The complete revised document as markdown (not just the changed parts).',
81
+ },
82
+ note: {
83
+ type: 'string',
84
+ description: 'A short summary of what you changed and why (shown to the reviewer).',
85
+ },
86
+ },
87
+ required: ['docId', 'markdown'],
88
+ },
89
+ },
90
+ ];
91
+
92
+ const server = new Server(
93
+ { name: 'workover', version: '0.1.0' },
94
+ { capabilities: { tools: {} } },
95
+ );
96
+
97
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
98
+
99
+ server.setRequestHandler(CallToolRequestSchema, async (req) => {
100
+ if (!auth)
101
+ return err('Not signed in to Workover. Run `workover login` in your terminal first.');
102
+ const { name, arguments: args = {} } = req.params;
103
+ try {
104
+ if (name === 'workover_search_docs') {
105
+ const { results = [] } = await api(
106
+ `/search/documents?q=${encodeURIComponent(String(args.query || ''))}&limit=10`,
107
+ );
108
+ if (!results.length) return text('No matching documents.');
109
+ return text(
110
+ results
111
+ .map(
112
+ (r) =>
113
+ `#${r.id} — ${r.title || 'Untitled'}${r.snippet ? `\n ${stripHtml(r.snippet)}` : ''}`,
114
+ )
115
+ .join('\n'),
116
+ );
117
+ }
118
+ if (name === 'workover_read_doc') {
119
+ const d = await api(`/project/doc/${Number(args.docId)}`);
120
+ if (!d || !d.id) return err(`Document ${args.docId} not found (or no access).`);
121
+ const body = d.bodyText || stripHtml(d.content) || '(empty document)';
122
+ return text(`# ${d.title || 'Untitled'} (id ${d.id})\n\n${body}`);
123
+ }
124
+ if (name === 'workover_list_projects') {
125
+ const projects = await api('/project');
126
+ const list = Array.isArray(projects) ? projects : projects?.projects || [];
127
+ if (!list.length) return text('No projects.');
128
+ return text(list.map((p) => `#${p.id} — ${p.name || p.title || 'Project'}`).join('\n'));
129
+ }
130
+ if (name === 'workover_propose_edit') {
131
+ const md = String(args.markdown || '').trim();
132
+ if (!md) return err('Provide the full revised document as `markdown`.');
133
+ const res = await apiPost(`/project/doc/${Number(args.docId)}/propose`, {
134
+ markdown: md,
135
+ note: args.note ? String(args.note) : undefined,
136
+ source: 'Claude Code',
137
+ });
138
+ return text(
139
+ `Proposed your changes to document #${args.docId}. They'll appear as suggestions to accept or reject when the document is open in Workover${res?.documentUrl ? `:\n${res.documentUrl}` : '.'}\n\nNothing is published until the person reviews and accepts.`,
140
+ );
141
+ }
142
+ return err(`Unknown tool: ${name}`);
143
+ } catch (e) {
144
+ return err(e?.message || 'Something went wrong.');
145
+ }
146
+ });
147
+
148
+ await server.connect(new StdioServerTransport());
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@workover/mcp",
3
+ "version": "0.1.0",
4
+ "description": "Workover MCP server — let Claude Code and other MCP clients read and cowork on your Workover documents.",
5
+ "license": "UNLICENSED",
6
+ "author": "ScaleMath",
7
+ "homepage": "https://workover.dev",
8
+ "bugs": {
9
+ "url": "https://workover.dev"
10
+ },
11
+ "keywords": [
12
+ "workover",
13
+ "mcp",
14
+ "model-context-protocol",
15
+ "claude",
16
+ "documents"
17
+ ],
18
+ "type": "module",
19
+ "bin": {
20
+ "workover-mcp": "index.mjs"
21
+ },
22
+ "files": [
23
+ "index.mjs",
24
+ "README.md"
25
+ ],
26
+ "engines": {
27
+ "node": ">=20"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "dependencies": {
33
+ "@modelcontextprotocol/sdk": "^1.12.0"
34
+ }
35
+ }