quire-editor-mcp 2.2.0 → 2.4.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/package.json +1 -1
- package/server.mjs +27 -17
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Lets Claude read, edit, compile, review and research projects in [Quire](https://quire.deployment.work), the browser LaTeX and Typst editor. No dependencies, Node 18 or newer.
|
|
4
4
|
|
|
5
|
+
Clippings, the screenshots of sources that back passages, can be listed, viewed as images, added from an image or a crop of a PDF in the project, edited, moved to another passage and deleted.
|
|
6
|
+
|
|
5
7
|
Research tools search OpenAlex from your Quire tab: papers with filters, the key papers of a topic, citation trails, suggestions from the project's references, a bibliography check and a reading list. The prompts `literature_review`, `peer_review`, `support_claims`, `address_review` and `fix_bibliography` are research and review loops Claude runs in rounds.
|
|
6
8
|
|
|
7
9
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quire-editor-mcp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "MCP server that lets Claude read, edit, compile, review and research projects in the Quire LaTeX and Typst editor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "quire-editor-mcp": "server.mjs" },
|
package/server.mjs
CHANGED
|
@@ -44,32 +44,35 @@ function frame(op, data) {
|
|
|
44
44
|
return Buffer.concat([h, data])
|
|
45
45
|
}
|
|
46
46
|
function wsServe(s) {
|
|
47
|
-
let
|
|
47
|
+
let bufs = [], have = 0, parts = [], plen = 0
|
|
48
48
|
const ws = {
|
|
49
49
|
open: true,
|
|
50
50
|
send: t => ws.open && s.write(frame(1, Buffer.from(t))),
|
|
51
51
|
close: () => { if (!ws.open) return; ws.open = false; try { s.end(frame(8, Buffer.alloc(0))) } catch { } }
|
|
52
52
|
}
|
|
53
53
|
s.on('data', d => {
|
|
54
|
-
|
|
54
|
+
bufs.push(d); have += d.length
|
|
55
|
+
if (have > 80 * 1024 * 1024) return s.destroy()
|
|
55
56
|
for (;;) {
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
if (have < 2) return
|
|
58
|
+
const h = bufs[0].length >= 14 ? bufs[0] : Buffer.concat(bufs, Math.min(have, 14))
|
|
59
|
+
const fin = h[0] & 0x80, op = h[0] & 15, masked = h[1] & 0x80
|
|
60
|
+
let n = h[1] & 127, o = 2
|
|
61
|
+
if (n === 126) { if (have < 4) return; n = h.readUInt16BE(2); o = 4 }
|
|
62
|
+
else if (n === 127) { if (have < 10) return; n = Number(h.readBigUInt64BE(2)); o = 10 }
|
|
63
|
+
if (!masked || n > 64 * 1024 * 1024) return s.destroy()
|
|
64
|
+
const need = o + 4 + n
|
|
65
|
+
if (have < need) return
|
|
66
|
+
const buf = bufs.length > 1 ? Buffer.concat(bufs, have) : bufs[0], mask = buf.subarray(o, o + 4), p = Buffer.from(buf.subarray(o + 4, need))
|
|
67
|
+
for (let i = 0; i < p.length; i++) p[i] ^= mask[i & 3]
|
|
68
|
+
bufs = need < have ? [buf.subarray(need)] : []; have -= need
|
|
67
69
|
if (op === 8) { ws.close(); return }
|
|
68
70
|
if (op === 9) { s.write(frame(10, p)); continue }
|
|
69
71
|
if (op === 10) continue
|
|
70
|
-
parts.push(p)
|
|
72
|
+
parts.push(p); plen += p.length
|
|
73
|
+
if (plen > 64 * 1024 * 1024) return s.destroy()
|
|
71
74
|
if (!fin) continue
|
|
72
|
-
const msg = Buffer.concat(parts).toString('utf8'); parts = []
|
|
75
|
+
const msg = Buffer.concat(parts, plen).toString('utf8'); parts = []; plen = 0
|
|
73
76
|
ws.onmessage?.(msg)
|
|
74
77
|
}
|
|
75
78
|
})
|
|
@@ -194,6 +197,12 @@ const TOOLS = [
|
|
|
194
197
|
{ name: 'list_versions', description: 'List saved versions (history) of the open project, newest first. Named versions are ones the user or Claude labelled.', inputSchema: S() },
|
|
195
198
|
{ name: 'save_version', description: 'Save the current state of the open project as a named version. Do this before large or risky changes so the user can roll back.', inputSchema: S({ label: str('Short name for the version, e.g. Before restructuring chapters') }) },
|
|
196
199
|
{ name: 'restore_version', description: 'Restore the open project to a saved version. The current state is kept as a version first.', inputSchema: S({ id: str('Version id from list_versions') }, ['id']) },
|
|
200
|
+
{ name: 'list_clippings', description: 'List clippings: screenshots of sources attached to passages of the text. Each has its id, file, line range, the passage it backs, the quote it had when attached, source key, page, note, src, the text on the screenshot and the image size. attached false means it lost its passage (last_passage is its text when it was last attached, image_missing means the screenshot file is gone); attach it again with move_clipping.', inputSchema: S({ file: str('Only clippings in this file'), detached: { type: 'boolean', description: 'true for only the ones that are not attached, false for only attached ones' } }) },
|
|
201
|
+
{ name: 'get_clipping', description: 'One clipping with its details and the screenshot itself as an image, so you can read what the source says.', inputSchema: S({ id: str('Clipping id from list_clippings') }, ['id']) },
|
|
202
|
+
{ name: 'add_clipping', description: 'Back a passage with a screenshot of its source. Name the passage by its exact text (passage) or by lines. The image is base64 PNG, JPEG or WebP or a data URL, or a region of a PDF in the project: pdf, pdf_page and crop as fractions of the page. Source key, page and note default to the citation in the passage.', inputSchema: S({ file: str('File with the passage'), passage: str('Exact text of the passage'), occurrence: { type: 'integer', minimum: 1, description: 'Which match, when passage appears more than once' }, from_line: { type: 'integer', minimum: 1 }, to_line: { type: 'integer', minimum: 1 }, image: str('Base64 image or data URL'), pdf: str('PDF file in the project to crop the screenshot from'), pdf_page: { type: 'integer', minimum: 1, description: 'Page of that PDF, default 1' }, crop: { type: 'object', properties: { x: { type: 'number' }, y: { type: 'number' }, w: { type: 'number' }, h: { type: 'number' } }, additionalProperties: false, description: 'Region of the page, each 0 to 1 from the top left. Default the whole page' }, key: str('Citation key of the source'), page: str('Page in the source, e.g. 83'), note: str('Short note, e.g. Table 2'), src: str('Source when there is no citation key') }, ['file']) },
|
|
203
|
+
{ name: 'update_clipping', description: 'Change the source key, page, note, src or the text on the screenshot of a clipping.', inputSchema: S({ id: str('Clipping id'), key: str('Citation key'), page: str('Page'), note: str('Note'), src: str('Source'), text: str('Text on the screenshot') }, ['id']) },
|
|
204
|
+
{ name: 'move_clipping', description: 'Attach a clipping to a passage, e.g. after an edit moved or rewrote the text it backs. The passage must match exactly once unless occurrence is given. Clippings that share a passage should move together, pass them as ids.', inputSchema: S({ id: str('Clipping id from list_clippings'), ids: { type: 'array', items: { type: 'string' }, description: 'Several clipping ids that move together' }, file: str('File path'), passage: str('Exact text of the passage'), occurrence: { type: 'integer', minimum: 1, description: 'Which match, when passage appears more than once' } }, ['file', 'passage']) },
|
|
205
|
+
{ name: 'delete_clipping', description: 'Delete a clipping and its screenshot. The user can undo it in Quire.', inputSchema: S({ id: str('Clipping id') }, ['id']) },
|
|
197
206
|
{ name: 'list_comments', description: 'List review comments with the text they point at, line, author and replies. Resolved ones only with resolved true.', inputSchema: S({ path: str('Only comments in this file'), resolved: { type: 'boolean' } }) },
|
|
198
207
|
{ name: 'add_comment', description: 'Add a review comment on an exact piece of text, the way a reviewer would. It appears in the review panel with Claude as author.', inputSchema: S({ path: str('File path'), quote: str('Exact text the comment is about'), text: str('The comment'), occurrence: { type: 'integer', minimum: 1, description: 'Which match, when quote appears more than once' } }, ['path', 'quote', 'text']) },
|
|
199
208
|
{ name: 'reply_comment', description: 'Reply to a comment.', inputSchema: S({ id: str('Comment id'), text: str('Reply') }, ['id', 'text']) },
|
|
@@ -261,6 +270,7 @@ async function tool(name, args) {
|
|
|
261
270
|
if (!TOOLS.some(t => t.name === name)) return { content: [{ type: 'text', text: 'Unknown tool ' + name }], isError: true }
|
|
262
271
|
try {
|
|
263
272
|
const r = name === 'zotero_pdf' ? await zoteroPdf(args || {}) : await call(name, args || {}, SLOW[name])
|
|
273
|
+
if (name === 'get_clipping' && r?.data) { const { data, mime, ...o } = r; return { content: [{ type: 'image', data, mimeType: mime }, { type: 'text', text: JSON.stringify(o, null, 2) }] } }
|
|
264
274
|
if (name === 'render_page') return { content: [{ type: 'image', data: r.png, mimeType: 'image/png' }, { type: 'text', text: `Page ${r.page} of ${r.pages}` }] }
|
|
265
275
|
if (name === 'compile' && r && !r.ok) return { content: [{ type: 'text', text: JSON.stringify(r, null, 2) }], isError: true }
|
|
266
276
|
return { content: [{ type: 'text', text: typeof r === 'string' ? r : JSON.stringify(r, null, 2) }] }
|
|
@@ -356,12 +366,12 @@ Add a comment on the heading of the section that summarises the rounds, which ke
|
|
|
356
366
|
5. Tell the user what you fixed and what needs their decision.`
|
|
357
367
|
}
|
|
358
368
|
]
|
|
359
|
-
const INSTR = 'Quire is a browser LaTeX and Typst editor. These tools act on the project open in the connected Quire tab, and every edit shows up live in the editor. Start with status. Prefer edit_file for small changes. Call save_version before large rewrites. After editing, call compile, and use render_page to check how a page looks. When status shows track_changes on, your edits become suggestions; use add_comment to leave review notes instead of editing when the user asks for feedback. Research tools search the scholarly literature (OpenAlex, Crossref). Never cite a work you have not looked up: get it with search_papers or get_paper, read its abstract, then add_reference and use the returned key. Prefer peer reviewed versions over preprints. Run check_bibliography after adding references. zotero_pdf reads the PDF of a source from the Zotero app on this computer, staged_changes shows what the next sync would send. The prompts literature_review, peer_review, support_claims and address_review are ready made loops.'
|
|
369
|
+
const INSTR = 'Quire is a browser LaTeX and Typst editor. These tools act on the project open in the connected Quire tab, and every edit shows up live in the editor. Start with status. Prefer edit_file for small changes. Call save_version before large rewrites. Passages can carry clippings (screenshots of sources); edit_file and write_file report clippings whose passage you changed or removed, fix detached ones with list_clippings and move_clipping. get_clipping shows a screenshot, add_clipping backs a passage with an image or a crop of a PDF in the project. After editing, call compile, and use render_page to check how a page looks. When status shows track_changes on, your edits become suggestions; use add_comment to leave review notes instead of editing when the user asks for feedback. Research tools search the scholarly literature (OpenAlex, Crossref). Never cite a work you have not looked up: get it with search_papers or get_paper, read its abstract, then add_reference and use the returned key. Prefer peer reviewed versions over preprints. Run check_bibliography after adding references. zotero_pdf reads the PDF of a source from the Zotero app on this computer, staged_changes shows what the next sync would send. The prompts literature_review, peer_review, support_claims and address_review are ready made loops.'
|
|
360
370
|
async function handle(m) {
|
|
361
371
|
const { id, method, params } = m
|
|
362
372
|
if (id === undefined) return
|
|
363
373
|
try {
|
|
364
|
-
if (method === 'initialize') return out({ jsonrpc: '2.0', id, result: { protocolVersion: params?.protocolVersion || '2025-06-18', capabilities: { tools: {}, prompts: {} }, serverInfo: { name: 'quire', version: '2.
|
|
374
|
+
if (method === 'initialize') return out({ jsonrpc: '2.0', id, result: { protocolVersion: params?.protocolVersion || '2025-06-18', capabilities: { tools: {}, prompts: {} }, serverInfo: { name: 'quire', version: '2.3.0' }, instructions: INSTR } })
|
|
365
375
|
if (method === 'ping') return out({ jsonrpc: '2.0', id, result: {} })
|
|
366
376
|
if (method === 'tools/list') return out({ jsonrpc: '2.0', id, result: { tools: TOOLS } })
|
|
367
377
|
if (method === 'tools/call') return out({ jsonrpc: '2.0', id, result: await tool(params?.name, params?.arguments) })
|