quire-editor-mcp 2.0.0 → 2.2.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 +3 -1
  2. package/package.json +3 -3
  3. package/server.mjs +161 -5
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # quire-editor-mcp
2
2
 
3
- Lets Claude read, edit, compile and review projects in [Quire](https://quire.deployment.work), the browser LaTeX and Typst editor. No dependencies, Node 18 or newer.
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
+
5
+ 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.
4
6
 
5
7
  ```
6
8
  claude mcp add quire -- npx -y quire-editor-mcp
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "quire-editor-mcp",
3
- "version": "2.0.0",
4
- "description": "MCP server that lets Claude read, edit, compile and review projects in the Quire LaTeX and Typst editor",
3
+ "version": "2.2.0",
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" },
7
7
  "files": ["server.mjs"],
8
8
  "engines": { "node": ">=18" },
9
- "keywords": ["mcp", "claude", "latex", "typst", "quire"]
9
+ "keywords": ["mcp", "claude", "latex", "typst", "quire", "openalex", "literature review"]
10
10
  }
package/server.mjs CHANGED
@@ -5,6 +5,7 @@ import readline from 'node:readline'
5
5
  import fs from 'node:fs'
6
6
  import os from 'node:os'
7
7
  import path from 'node:path'
8
+ import { fileURLToPath } from 'node:url'
8
9
  import { StringDecoder } from 'node:string_decoder'
9
10
 
10
11
  const PORT = +process.env.QUIRE_PORT || 7357
@@ -166,6 +167,14 @@ hub()
166
167
 
167
168
  const S = (props = {}, required = []) => ({ type: 'object', properties: props, required, additionalProperties: false })
168
169
  const str = d => ({ type: 'string', description: d })
170
+ const FILTERS = {
171
+ from_year: { type: 'integer', description: 'Published in or after this year' },
172
+ to_year: { type: 'integer', description: 'Published in or before this year' },
173
+ type: { type: 'string', enum: ['article', 'conference', 'review', 'book', 'preprint', 'thesis'], description: 'Kind of work' },
174
+ peer_reviewed: { type: 'boolean', description: 'Only works published in a journal or conference proceedings' },
175
+ open_access: { type: 'boolean', description: 'Only works with free full text' },
176
+ min_citations: { type: 'integer', minimum: 0 }
177
+ }
169
178
  const TOOLS = [
170
179
  { name: 'status', description: 'Current Quire project: id, name, kind (typst or latex), main file, files with line counts, what the user has open and selected in the editor, and the last compile result. Call this first.', inputSchema: S() },
171
180
  { name: 'list_projects', description: 'List all projects stored in the browser.', inputSchema: S() },
@@ -192,14 +201,66 @@ const TOOLS = [
192
201
  { name: 'list_changes', description: 'List tracked changes (insertions and deletions) waiting for review.', inputSchema: S({ path: str('Only changes in this file') }) },
193
202
  { name: 'accept_changes', description: 'Accept tracked changes. Without ids, all of them.', inputSchema: S({ ids: { type: 'array', items: { type: 'string' } } }) },
194
203
  { name: 'reject_changes', description: 'Reject tracked changes, which undoes them. Without ids, all of them.', inputSchema: S({ ids: { type: 'array', items: { type: 'string' } } }) },
204
+ { name: 'search_papers', description: 'Search scholarly works in OpenAlex (Crossref when OpenAlex is out of budget). Returns title, authors, year, venue, type, peer_reviewed, citation count, DOI, free PDF link, abstract and bib_key when the work is already in the project bibliography. Results also appear in the Research panel in Quire.', inputSchema: S({ query: str('Words, a phrase in quotes, or a whole claim sentence. Boolean AND, OR, NOT work'), ...FILTERS, sort: { type: 'string', enum: ['relevance', 'citations', 'newest'] }, limit: { type: 'integer', minimum: 1, maximum: 50, description: 'Default 15' }, page: { type: 'integer', minimum: 1 } }, ['query']) },
205
+ { name: 'get_paper', description: 'Full record of one work with the complete abstract, reference count and a ready BibTeX entry. Use it to read a paper before citing it.', inputSchema: S({ id: str('OpenAlex id (W…), DOI or arXiv id') }, ['id']) },
206
+ { name: 'citation_graph', description: 'Snowballing. references lists what a work cites, cited_by lists newer works that cite it (filters apply, sorted by citations unless sort says otherwise), similar lists related works.', inputSchema: S({ id: str('OpenAlex id, DOI or arXiv id'), direction: { type: 'string', enum: ['references', 'cited_by', 'similar'] }, ...FILTERS, sort: { type: 'string', enum: ['citations', 'newest'] }, limit: { type: 'integer', minimum: 1, maximum: 60 } }, ['id', 'direction']) },
207
+ { name: 'key_papers', description: 'The key papers of a topic. Reads the 200 most relevant papers on it and ranks the works they cite by the share of papers citing them. Use it to find the foundational works a field expects. Year and peer review filters choose which papers are read.', inputSchema: S({ topic: str('Topic, e.g. prompt injection'), from_year: FILTERS.from_year, to_year: FILTERS.to_year, peer_reviewed: FILTERS.peer_reviewed, kind: { type: 'string', enum: ['all', 'article', 'book', 'review', 'preprint'] }, limit: { type: 'integer', minimum: 1, maximum: 60, description: 'Default 25' } }, ['topic']) },
208
+ { name: 'recommend_papers', description: 'Related work for the open project from its .bib references and its text. builds_on_your_sources are works citing several of the project references, foundations_not_cited are works the references cite most that the project does not cite, on_your_topic comes from the main keywords of the text.', inputSchema: S({ limit: { type: 'integer', minimum: 1, maximum: 30, description: 'Per group, default 10' } }) },
209
+ { name: 'check_bibliography', description: 'Verify every .bib entry of the open project against OpenAlex and Crossref. Reports retracted works, DOIs that point to a different work, entries no database knows (possibly invented), missing DOIs, wrong years, arXiv preprints that have a published version, keys cited in the text but missing, and entries never cited.', inputSchema: S() },
210
+ { name: 'add_reference', description: 'Add a work to the project bibliography as BibTeX with a stable key (lastnameYEARword) and return the key and how to cite it. Does nothing but return the key when the work is already there.', inputSchema: S({ id: str('OpenAlex id, DOI or arXiv id'), file: str('Target .bib file, default the bibliography the main file uses') }, ['id']) },
211
+ { name: 'update_reference', description: 'Replace a .bib entry with the record of a work and keep its key, so citations stay valid. Use it to fix entries flagged by check_bibliography, for example to cite the published version of a preprint.', inputSchema: S({ key: str('Citation key of the entry'), id: str('OpenAlex id, DOI or arXiv id of the correct work') }, ['key', 'id']) },
212
+ { name: 'save_paper', description: 'Put a work on the reading list of the project with a short note on why it matters, or remove it. The user sees the list in Sources, next to the page, and decides what to cite.', inputSchema: S({ id: str('OpenAlex id, DOI or arXiv id'), note: str('One or two sentences on why it matters for this text'), remove: { type: 'boolean' } }, ['id']) },
213
+ { name: 'list_saved', description: 'The reading list of the project with notes and who saved each paper.', inputSchema: S() },
214
+ { name: 'staged_changes', description: 'What the next sync of the project would send to its folder, GitHub repository or Dropbox: files added, modified or deleted since the last sync, each with a line diff against the last synced version, like git diff --staged. Also when the project last synced and whether files wait for a conflict decision.', inputSchema: S({ path: str('Only this file'), diff: { type: 'boolean', description: 'Include diffs, default true' } }) },
215
+ { name: 'zotero_pdf', description: 'Fetch the PDF of a work from the Zotero app on this computer and read it. Find the work by citation key of the open project, DOI, title or Zotero item key. Returns the path of the file on disk and the text of the pages asked for. With save_as the PDF is also added to the project and opened next to the editor, for example to clip from it. Needs Zotero 7 or newer running with Settings, Advanced, Allow other applications on this computer to communicate with Zotero.', inputSchema: S({ key: str('Citation key from the project bibliography'), doi: str('DOI'), title: str('Title of the work'), item: str('Zotero item or attachment key'), pages: str('Pages to read, e.g. 3 or 1-10. Default the first 20, at most 60'), save_as: str('Project path for a copy of the PDF, e.g. sources/smith2020.pdf') }) },
195
216
  { name: 'set_track_changes', description: 'Turn track changes on or off for the project. While on, every edit, including yours, becomes a suggestion the user can accept or reject.', inputSchema: S({ on: { type: 'boolean' } }, ['on']) }
196
217
  ]
197
- const SLOW = { compile: 240000, render_page: 240000, open_project: 60000, create_project: 60000 }
218
+ const SLOW = { zotero_pdf: 120000, staged_changes: 60000, compile: 240000, render_page: 240000, open_project: 60000, create_project: 60000, search_papers: 60000, get_paper: 60000, citation_graph: 90000, key_papers: 150000, recommend_papers: 150000, check_bibliography: 300000, add_reference: 60000, update_reference: 60000, save_paper: 60000 }
219
+
220
+ /* Zotero on this computer through its local API, so PDFs never have to be synced to zotero.org */
221
+ const ZP = +process.env.ZOTERO_PORT || 23119
222
+ const ZOFF = 'Zotero is not reachable on this computer. Start Zotero 7 or newer and turn on Settings, Advanced, Allow other applications on this computer to communicate with Zotero.'
223
+ async function zget(lib, p, text) {
224
+ let r
225
+ try { r = await fetch(`http://127.0.0.1:${ZP}/api/${lib}${p}`, { headers: { 'Zotero-API-Version': '3' }, signal: AbortSignal.timeout(10000) }) } catch { throw new Error(ZOFF) }
226
+ if (r.status === 403) throw new Error(ZOFF)
227
+ if (!r.ok) throw new Error(`Zotero answered ${r.status} for ${p}`)
228
+ return text ? r.text() : r.json()
229
+ }
230
+ const zn = s => String(s || '').toLowerCase().replace(/[^a-z0-9]/g, '')
231
+ async function zItem(a) {
232
+ let lib = 'users/0', info = {}
233
+ if (a.item) return { lib, item: a.item }
234
+ if (a.key) {
235
+ info = await call('cite_info', { key: a.key }).catch(() => ({}))
236
+ if (info.zotero) return { lib: info.zotero.library.startsWith('groups/') ? info.zotero.library : lib, item: info.zotero.item, info }
237
+ }
238
+ const doi = a.doi || info.doi, title = a.title || info.title
239
+ for (const q of [doi, a.key, title].filter(Boolean)) {
240
+ const j = await zget(lib, `/items/top?q=${encodeURIComponent(q)}&qmode=everything&limit=25`)
241
+ const hit = j.find(i => doi && (zn(i.data?.DOI) === zn(doi) || zn(i.data?.extra).includes(zn(doi)))) || j.find(i => a.key && (i.data?.citationKey === a.key || new RegExp(`^Citation Key:\\s*${a.key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*$`, 'mi').test(i.data?.extra || ''))) || j.find(i => title && zn(i.data?.title) === zn(title))
242
+ if (hit) return { lib, item: hit.key, info }
243
+ }
244
+ throw new Error(`No item in Zotero matches ${[a.key, doi, title].filter(Boolean).join(', ') || 'that'}`)
245
+ }
246
+ async function zoteroPdf(a) {
247
+ const { lib, item } = await zItem(a), it = await zget(lib, `/items/${item}`)
248
+ const att = it.data?.itemType === 'attachment' ? it : (await zget(lib, `/items/${item}/children`)).find(c => c.data?.itemType === 'attachment' && c.data.contentType === 'application/pdf' && c.data.linkMode !== 'linked_url')
249
+ if (!att) throw new Error(`${it.data?.title || item} has no PDF in Zotero`)
250
+ let file = null
251
+ try { const u = (await zget(lib, `/items/${att.key}/file/view/url`, true)).trim(); if (u.startsWith('file:')) file = fileURLToPath(u) } catch { }
252
+ if (!file || !fs.existsSync(file)) file = [att.data.path && path.isAbsolute(att.data.path) ? att.data.path : null, path.join(os.homedir(), 'Zotero', 'storage', att.key, att.data.filename || '')].find(f => f && fs.existsSync(f))
253
+ if (!file) throw new Error('The PDF is not on this computer. Open it once in Zotero so it downloads')
254
+ const b = fs.readFileSync(file), [from, to] = String(a.pages || '').split('-').map(x => parseInt(x))
255
+ const head = { title: it.data?.title || att.data?.title, zotero_item: it.data?.parentItem || item, file, bytes: b.length }
256
+ try { return { ...head, ...await call('pdf_text', { data: b.toString('base64'), from: from || 1, to: to || (a.pages && from) || undefined, save_as: a.save_as }, 120000) } }
257
+ catch (e) { return { ...head, text: null, note: 'Could not read the text through Quire: ' + (e.message || e) + '. Read the file at the path instead.' } }
258
+ }
198
259
 
199
260
  async function tool(name, args) {
200
261
  if (!TOOLS.some(t => t.name === name)) return { content: [{ type: 'text', text: 'Unknown tool ' + name }], isError: true }
201
262
  try {
202
- const r = await call(name, args || {}, SLOW[name])
263
+ const r = name === 'zotero_pdf' ? await zoteroPdf(args || {}) : await call(name, args || {}, SLOW[name])
203
264
  if (name === 'render_page') return { content: [{ type: 'image', data: r.png, mimeType: 'image/png' }, { type: 'text', text: `Page ${r.page} of ${r.pages}` }] }
204
265
  if (name === 'compile' && r && !r.ok) return { content: [{ type: 'text', text: JSON.stringify(r, null, 2) }], isError: true }
205
266
  return { content: [{ type: 'text', text: typeof r === 'string' ? r : JSON.stringify(r, null, 2) }] }
@@ -207,17 +268,112 @@ async function tool(name, args) {
207
268
  }
208
269
 
209
270
  const out = m => process.stdout.write(JSON.stringify(m) + '\n')
210
- 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.'
271
+ const Y = new Date().getFullYear()
272
+ const arg = (name, description, required = false) => ({ name, description, required })
273
+ const PROMPTS = [
274
+ {
275
+ name: 'literature_review', description: 'Research a topic and write or extend the related work of the open project, in rounds until coverage, recency and citations hold up',
276
+ arguments: [arg('topic', 'What the related work is about', true), arg('file', 'File and section to write in, e.g. chapters/related.tex. Default the main file'), arg('rounds', 'Most rounds of search and revision, default 3')],
277
+ text: a => `Write the related work on "${a.topic}" in the open Quire project${a.file ? `, in ${a.file}` : ''}. Work in rounds, at most ${+a.rounds || 3}.
278
+
279
+ Setup
280
+ 1. Call status and read the main file${a.file ? ` and ${a.file}` : ''} to learn the argument of the text, its style, language and citation commands. Call save_version with the label "Before literature review".
281
+ 2. Call list_saved and check_bibliography so you know what is already there.
282
+
283
+ Each round
284
+ 1. Map the field. Call key_papers for the topic. Call search_papers with peer_reviewed true and from_year ${Y - 3}, sorted by citations, and once more sorted by newest. Call recommend_papers when the project already has references. For the two or three most central works call citation_graph with direction cited_by to find what came after them.
285
+ 2. Read before you use. Call get_paper for every work you consider and decide from its abstract what it actually shows. Never cite from a title alone and never cite a work you did not look up. Prefer the peer reviewed version of a preprint.
286
+ 3. Curate. Call save_paper for each work you will use or that the user should read, with one sentence on why it matters for this text.
287
+ 4. Write. Group the literature into themes that serve the argument of the text, compare and contrast the works, and end each theme with the gap this text addresses. Do not write one paragraph per paper. Add every source with add_reference and cite it with the returned key. Make claims only as strong as the abstracts support.
288
+ 5. Verify. Call check_bibliography and fix every error with update_reference or by editing. Compile and fix errors. Look at the pages with render_page.
289
+ 6. Critique your section against this list and note every miss.
290
+ a. Every work in the top ten of key_papers is cited or deliberately left out for a reason you can name.
291
+ b. At least a third of the sources are from ${Y - 2} or later, unless the field is older.
292
+ c. Contradicting or competing findings are represented, not only supporting ones.
293
+ d. Every paragraph makes a point and every factual sentence has a citation.
294
+ e. No preprint is cited where a published version exists.
295
+ If anything misses, start the next round aimed at exactly those gaps. Stop when the list holds or the rounds are used up.
296
+
297
+ Finish
298
+ Add a comment on the heading of the section that summarises the rounds, which key papers you left out and why, and what the user should read on the reading list. Then tell the user the same in a few sentences.`
299
+ },
300
+ {
301
+ name: 'peer_review', description: 'Review the open project like a reviewer for a venue, with comments anchored in the text, a literature check of novelty and claims, and a final report. Does not edit',
302
+ arguments: [arg('venue', 'Venue or kind of review, e.g. NeurIPS, a journal, a bachelor thesis'), arg('focus', 'Anything to look at in particular')],
303
+ text: a => `Review the open Quire project as an expert reviewer${a.venue ? ` for ${a.venue}` : ''}.${a.focus ? ` Pay particular attention to ${a.focus}.` : ''} Do not edit any file. All output goes into review comments.
304
+
305
+ 1. Read. Call status, read every source file, compile and look at each page with render_page, including figures and tables.
306
+ 2. Understand. Write down for yourself the research question, the claimed contributions and the evidence for each.
307
+ 3. Novelty. For each claimed contribution call search_papers with the claim and call key_papers for the topic. If prior work already does it or something close, that is a major point; name the work with its DOI.
308
+ 4. Soundness. Check that the method fits the question, that the evidence supports each claim, that baselines, data and limitations are adequate. For surprising or central factual claims, search the literature for supporting and contradicting evidence.
309
+ 5. Citations. Call check_bibliography and report its errors. Note important related work that is missing, found through recommend_papers and key_papers.
310
+ 6. Clarity. Structure, definitions before use, figures, notation and language.
311
+ 7. Comment. For each finding call add_comment on the exact passage. Start the text with [Major], [Minor] or [Nit], say what is wrong, why it matters and what would fix it. Back literature points with title, year and DOI.
312
+ 8. Second pass. Call list_comments and reread your comments as a meta reviewer. Merge duplicates, sharpen vague ones with reply_comment, and make sure every major point is justified.
313
+ 9. Report. Add one comment on the title with the summary of the paper, strengths, weaknesses, questions to the authors, a recommendation (accept, minor revision, major revision or reject) and your confidence. Then give the user the same report.`
314
+ },
315
+ {
316
+ name: 'support_claims', description: 'Find claims without sources, search the literature for each, cite what supports them and flag what does not, as tracked changes',
317
+ arguments: [arg('file', 'File to work on, default the main file'), arg('limit', 'Most claims per round, default 12')],
318
+ text: a => `Make sure every factual claim in ${a.file || 'the main file of the open Quire project'} is backed by the literature. Work in rounds of at most ${+a.limit || 12} claims until none are left or three rounds have passed.
319
+
320
+ 1. Call status and save_version with the label "Before sourcing claims". Call set_track_changes with on true so the user can accept or reject each change. Remember whether it was on before.
321
+ 2. Read the file and list the sentences that state facts, numbers, trends, comparisons or what "studies show" without a citation. Skip the contribution of the text itself and common knowledge.
322
+ 3. For each claim call search_papers with the sentence and peer_reviewed true, and get_paper for the two or three best hits. Decide from the abstracts whether a work supports the claim, supports a weaker version, contradicts it, or whether nothing fits.
323
+ Supports. add_reference and insert the returned citation into the sentence with edit_file.
324
+ Weaker version. Cite it and soften the wording to what the source shows.
325
+ Contradicts. Do not edit. add_comment on the sentence with the contradicting work, its year and DOI.
326
+ Nothing fits. add_comment starting with [Needs source] and say what kind of evidence would do.
327
+ 4. Call check_bibliography, fix its errors, compile and fix errors.
328
+ 5. Reread the file. If unsourced claims remain, run another round.
329
+ 6. Restore track changes to how it was if the user had it off, and tell the user how many claims you sourced, softened, flagged and left.`
330
+ },
331
+ {
332
+ name: 'address_review', description: 'Work through the open review comments of the project, revise the text as tracked changes, reply to each comment and repeat until every comment is handled',
333
+ arguments: [arg('file', 'Only comments in this file')],
334
+ text: a => `Address the open review comments in the open Quire project${a.file ? `, in ${a.file}` : ''}.
335
+
336
+ 1. Call status, save_version with the label "Before addressing review" and set_track_changes with on true.
337
+ 2. Call list_comments${a.file ? ` with path ${a.file}` : ''}. Sort them so major points come first.
338
+ 3. For each comment decide whether it asks for a change, asks a question, or is something you disagree with for a good reason.
339
+ Change. Edit the text with edit_file. When it asks for literature or evidence use search_papers, get_paper and add_reference, and never cite what you did not look up.
340
+ Question. Answer it in the text when the reader would have the same question, otherwise only in the reply.
341
+ Disagree. Leave the text and explain why in the reply, politely and with evidence.
342
+ Then reply_comment saying what you changed and where. Resolve only your own comments. Leave comments by people open so they can check your change.
343
+ 4. Compile and fix errors, and run check_bibliography when you added references.
344
+ 5. Call list_comments again. Every open comment must now have your reply. Handle any you missed, then stop.
345
+ 6. Tell the user what you changed per comment in a short list, and which points need their decision.`
346
+ },
347
+ {
348
+ name: 'fix_bibliography', description: 'Check every reference and fix the bibliography in a loop until no errors are left',
349
+ arguments: [],
350
+ text: () => `Clean up the bibliography of the open Quire project.
351
+
352
+ 1. Call save_version with the label "Before fixing the bibliography", then check_bibliography.
353
+ 2. Fix what is certain. Use update_reference with the record for DOIs that point to another work, wrong years and preprints with a published version. Add missing DOIs. For keys cited but missing, search_papers for the intended work and add_reference, then replace the key in the text if it changed.
354
+ 3. Do not guess. For entries no database knows, retracted works and anything ambiguous, add_comment on the citation in the text and explain what the user has to decide.
355
+ 4. Call check_bibliography again and repeat until no errors are left that you can fix, at most three times. Compile.
356
+ 5. Tell the user what you fixed and what needs their decision.`
357
+ }
358
+ ]
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.'
211
360
  async function handle(m) {
212
361
  const { id, method, params } = m
213
362
  if (id === undefined) return
214
363
  try {
215
- if (method === 'initialize') return out({ jsonrpc: '2.0', id, result: { protocolVersion: params?.protocolVersion || '2025-06-18', capabilities: { tools: {} }, serverInfo: { name: 'quire', version: '2.0.0' }, instructions: INSTR } })
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.2.0' }, instructions: INSTR } })
216
365
  if (method === 'ping') return out({ jsonrpc: '2.0', id, result: {} })
217
366
  if (method === 'tools/list') return out({ jsonrpc: '2.0', id, result: { tools: TOOLS } })
218
367
  if (method === 'tools/call') return out({ jsonrpc: '2.0', id, result: await tool(params?.name, params?.arguments) })
219
368
  if (method === 'resources/list') return out({ jsonrpc: '2.0', id, result: { resources: [] } })
220
- if (method === 'prompts/list') return out({ jsonrpc: '2.0', id, result: { prompts: [] } })
369
+ if (method === 'prompts/list') return out({ jsonrpc: '2.0', id, result: { prompts: PROMPTS.map(({ text, ...p }) => p) } })
370
+ if (method === 'prompts/get') {
371
+ const p = PROMPTS.find(p => p.name === params?.name)
372
+ if (!p) return out({ jsonrpc: '2.0', id, error: { code: -32602, message: 'Unknown prompt ' + params?.name } })
373
+ const a = params?.arguments || {}, miss = p.arguments.filter(x => x.required && !a[x.name]).map(x => x.name)
374
+ if (miss.length) return out({ jsonrpc: '2.0', id, error: { code: -32602, message: 'Missing arguments: ' + miss.join(', ') } })
375
+ return out({ jsonrpc: '2.0', id, result: { description: p.description, messages: [{ role: 'user', content: { type: 'text', text: p.text(a) } }] } })
376
+ }
221
377
  out({ jsonrpc: '2.0', id, error: { code: -32601, message: 'Method not found: ' + method } })
222
378
  } catch (e) { out({ jsonrpc: '2.0', id, error: { code: -32603, message: String(e.message || e) } }) }
223
379
  }