rubien-mcp-server 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.
- package/LICENSE +202 -0
- package/README.md +180 -0
- package/dist/auth.js +36 -0
- package/dist/auth.js.map +1 -0
- package/dist/cli.js +140 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +121 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas.js +166 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.js +33 -0
- package/dist/server.js.map +1 -0
- package/dist/toolHelpers.js +48 -0
- package/dist/toolHelpers.js.map +1 -0
- package/dist/tools/annotations.js +13 -0
- package/dist/tools/annotations.js.map +1 -0
- package/dist/tools/citations.js +44 -0
- package/dist/tools/citations.js.map +1 -0
- package/dist/tools/io.js +50 -0
- package/dist/tools/io.js.map +1 -0
- package/dist/tools/pdf.js +147 -0
- package/dist/tools/pdf.js.map +1 -0
- package/dist/tools/properties.js +247 -0
- package/dist/tools/properties.js.map +1 -0
- package/dist/tools/references.js +207 -0
- package/dist/tools/references.js.map +1 -0
- package/dist/tools/sync.js +10 -0
- package/dist/tools/sync.js.map +1 -0
- package/dist/tools/views.js +78 -0
- package/dist/tools/views.js.map +1 -0
- package/dist/tools/web.js +40 -0
- package/dist/tools/web.js.map +1 -0
- package/dist/versionGuard.js +30 -0
- package/dist/versionGuard.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CliError, invokeCliTyped } from "../cli.js";
|
|
3
|
+
import { flagsFromOptions, runCliAsTool } from "../toolHelpers.js";
|
|
4
|
+
export function registerPdfTools(server) {
|
|
5
|
+
server.registerTool("rubien_pdf_info", {
|
|
6
|
+
title: "Probe PDF metadata + outline",
|
|
7
|
+
description: "Return page count, hasTextLayer (sampled across first/middle/last page), file size, isEncrypted, documentTitle, and the flattened outline `sections` (or null when the PDF has no outline). Each section carries title, level (1=top), startPage, and endPage; parent ranges span their descendants. Call this before `rubien_pdf_text` so you know whether to use sections or page ranges.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
id: z.number().int().describe("Reference ID"),
|
|
10
|
+
},
|
|
11
|
+
annotations: { readOnlyHint: true },
|
|
12
|
+
}, async ({ id }) => runCliAsTool(["pdf", "info", String(id)]));
|
|
13
|
+
server.registerTool("rubien_pdf_text", {
|
|
14
|
+
title: "Extract text from a PDF",
|
|
15
|
+
description: "Extract page-keyed text from a reference's attached PDF. Two mutually-exclusive selection modes: `pages` (e.g. '1-3' or '1-3,8-10') or `sections` (array of section title substrings; case-insensitive). When neither is provided the whole document is returned (subject to maxChars). Each returned page carries `text` and `sectionPath` (breadcrumb of containing sections). Errors with `no-outline` when `sections` is requested but the PDF has no outline — fall back to `pages` in that case.",
|
|
16
|
+
inputSchema: {
|
|
17
|
+
id: z.number().int().describe("Reference ID"),
|
|
18
|
+
pages: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Page range string, e.g. '1-3' or '1-3,8-10' or '12-'. Mutually exclusive with `sections`."),
|
|
22
|
+
sections: z
|
|
23
|
+
.array(z.string().min(1))
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Section title substrings (case-insensitive, repeatable). Mutually exclusive with `pages`. Use after `rubien_pdf_info` confirms `sections != null`."),
|
|
26
|
+
maxChars: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.positive()
|
|
30
|
+
.max(500_000)
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("Cap total returned characters (default 50000). Truncation is at page boundary."),
|
|
33
|
+
},
|
|
34
|
+
annotations: { readOnlyHint: true },
|
|
35
|
+
}, async (args) => {
|
|
36
|
+
if (args.pages && args.sections && args.sections.length > 0) {
|
|
37
|
+
return {
|
|
38
|
+
content: [
|
|
39
|
+
{
|
|
40
|
+
type: "text",
|
|
41
|
+
text: JSON.stringify({
|
|
42
|
+
error: "pages-and-sections-mutually-exclusive",
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
isError: true,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const cliArgs = ["pdf", "text", String(args.id)];
|
|
50
|
+
if (args.pages)
|
|
51
|
+
cliArgs.push("--pages", args.pages);
|
|
52
|
+
if (args.sections) {
|
|
53
|
+
for (const s of args.sections)
|
|
54
|
+
cliArgs.push("--section", s);
|
|
55
|
+
}
|
|
56
|
+
cliArgs.push(...flagsFromOptions({
|
|
57
|
+
"--max-chars": args.maxChars,
|
|
58
|
+
}));
|
|
59
|
+
return runCliAsTool(cliArgs);
|
|
60
|
+
});
|
|
61
|
+
server.registerTool("rubien_pdf_page_image", {
|
|
62
|
+
title: "Render a PDF page as an image",
|
|
63
|
+
description: "Render a single PDF page (1-indexed) and return it as an MCP image content block. Use this when text extraction is empty/garbled (scanned page, dense math) or when a figure/table is referenced in the surrounding text. Defaults: JPEG at scale=2.0 (~192 DPI) with quality stepdown to honor maxBytes. PNG mode is opt-in for lossless output but hard-fails on maxBytes.",
|
|
64
|
+
inputSchema: {
|
|
65
|
+
id: z.number().int().describe("Reference ID"),
|
|
66
|
+
page: z.number().int().positive().describe("Page number (1-indexed)"),
|
|
67
|
+
scale: z
|
|
68
|
+
.number()
|
|
69
|
+
.positive()
|
|
70
|
+
.max(8)
|
|
71
|
+
.optional()
|
|
72
|
+
.describe("Render scale (default 2.0; 1.0 ≈ 96 DPI)"),
|
|
73
|
+
maxBytes: z
|
|
74
|
+
.number()
|
|
75
|
+
.int()
|
|
76
|
+
.positive()
|
|
77
|
+
.optional()
|
|
78
|
+
.describe("Hard cap on rendered image bytes (default 2000000)"),
|
|
79
|
+
format: z
|
|
80
|
+
.enum(["jpeg", "png"])
|
|
81
|
+
.optional()
|
|
82
|
+
.describe("Output format (default jpeg)"),
|
|
83
|
+
},
|
|
84
|
+
annotations: { readOnlyHint: true },
|
|
85
|
+
}, async (args) => {
|
|
86
|
+
const cliArgs = [
|
|
87
|
+
"pdf",
|
|
88
|
+
"page-image",
|
|
89
|
+
String(args.id),
|
|
90
|
+
"--page",
|
|
91
|
+
String(args.page),
|
|
92
|
+
...flagsFromOptions({
|
|
93
|
+
"--scale": args.scale,
|
|
94
|
+
"--max-bytes": args.maxBytes,
|
|
95
|
+
"--format": args.format,
|
|
96
|
+
}),
|
|
97
|
+
];
|
|
98
|
+
try {
|
|
99
|
+
const result = await invokeCliTyped(cliArgs);
|
|
100
|
+
const meta = JSON.stringify({
|
|
101
|
+
id: result.id,
|
|
102
|
+
page: result.page,
|
|
103
|
+
widthPx: result.widthPx,
|
|
104
|
+
heightPx: result.heightPx,
|
|
105
|
+
qualityUsed: result.qualityUsed,
|
|
106
|
+
mimeType: result.mimeType,
|
|
107
|
+
}, null, 2);
|
|
108
|
+
return {
|
|
109
|
+
content: [
|
|
110
|
+
{ type: "text", text: meta },
|
|
111
|
+
{
|
|
112
|
+
type: "image",
|
|
113
|
+
data: result.data,
|
|
114
|
+
mimeType: result.mimeType,
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
if (err instanceof CliError) {
|
|
121
|
+
return {
|
|
122
|
+
content: [{ type: "text", text: err.message }],
|
|
123
|
+
isError: true,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
throw err;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
server.registerTool("rubien_pdf_download", {
|
|
130
|
+
title: "Download the open-access PDF for a reference",
|
|
131
|
+
description: "Fetch the open-access PDF (via DOI or arXiv resolution) and attach it to the reference. Skip-if-attached by default; pass `force: true` to detach the existing PDF and re-download. Side effects: writes a file under the library's PDF storage and inserts a pdfCache row + pdfUploadQueue row (so the running app's sync engine will push to CloudKit). Returns `{ id, ok, action, filename? }` where `action` is `\"downloaded\" | \"replaced\" | \"already-attached\" | \"already-pending\"`. Errors (isError) when the reference is missing, has no DOI/arXiv, or the network fetch fails. Long-running — up to 5 minutes.",
|
|
132
|
+
inputSchema: {
|
|
133
|
+
id: z.number().int().describe("Reference ID"),
|
|
134
|
+
force: z
|
|
135
|
+
.boolean()
|
|
136
|
+
.optional()
|
|
137
|
+
.describe("Replace an existing attached PDF instead of skipping."),
|
|
138
|
+
},
|
|
139
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
140
|
+
}, async ({ id, force }) => {
|
|
141
|
+
const args = ["pdf", "download", String(id)];
|
|
142
|
+
if (force)
|
|
143
|
+
args.push("--force");
|
|
144
|
+
return runCliAsTool(args, { timeoutMs: 300_000 });
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf.js","sourceRoot":"","sources":["../../src/tools/pdf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAYnE,MAAM,UAAU,gBAAgB,CAAC,MAAiB;IAChD,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,8BAA8B;QACrC,WAAW,EACT,6XAA6X;QAC/X,WAAW,EAAE;YACX,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;SAC9C;QACD,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;KACpC,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAC5D,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,yBAAyB;QAChC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MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;YAC7C,KAAK,EAAE,CAAC;iBACL,OAAO,EAAE;iBACT,QAAQ,EAAE;iBACV,QAAQ,CAAC,uDAAuD,CAAC;SACrE;QACD,WAAW,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE;KAC7D,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QACtB,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7C,IAAI,KAAK;YAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChC,OAAO,YAAY,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;IACpD,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { flagsFromOptions, runCliAsTool } from "../toolHelpers.js";
|
|
3
|
+
const PROPERTY_TYPES = [
|
|
4
|
+
"string",
|
|
5
|
+
"url",
|
|
6
|
+
"number",
|
|
7
|
+
"singleSelect",
|
|
8
|
+
"multiSelect",
|
|
9
|
+
"date",
|
|
10
|
+
"checkbox",
|
|
11
|
+
];
|
|
12
|
+
/// Tags are exposed as the seeded built-in PropertyDefinition with
|
|
13
|
+
/// `defaultFieldKey == "tags"`. All operations below treat Tags as a regular
|
|
14
|
+
/// multiSelect property — `set` / `add_values` / `remove_values` accept tag
|
|
15
|
+
/// IDs (stringified), `add_option` creates a new Tag from a name + color,
|
|
16
|
+
/// `rename_option` / `delete_option` operate by tag ID. The retired
|
|
17
|
+
/// rubien_tags_* tool family folded into this surface.
|
|
18
|
+
function tagsContractNote(extra = "") {
|
|
19
|
+
return ("For the built-in Tags property (defaultFieldKey == 'tags'): values are " +
|
|
20
|
+
"tag IDs (stringified). Create new tags via rubien_properties_add_option " +
|
|
21
|
+
"(value=name, color=hex)." +
|
|
22
|
+
(extra ? " " + extra : ""));
|
|
23
|
+
}
|
|
24
|
+
export function registerPropertyTools(server) {
|
|
25
|
+
server.registerTool("rubien_properties_list", {
|
|
26
|
+
title: "List property definitions (incl. Tags)",
|
|
27
|
+
description: "List property definitions. Returns PropertyDefinitionDTO[] with options inlined: " +
|
|
28
|
+
"{value, label, color}. For the built-in Tags property each option is one Tag row " +
|
|
29
|
+
"(value = stringified tag id, label = name). " +
|
|
30
|
+
"Pass `ids` and/or `names` to filter; selectors are unioned, exact case-sensitive on names, " +
|
|
31
|
+
"and override `visible`. Unresolved selectors fail loudly with an `unresolved-selectors` error envelope.",
|
|
32
|
+
inputSchema: {
|
|
33
|
+
ids: z
|
|
34
|
+
.array(z.string())
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Repeatable property IDs to include. Errors if any ID does not exist."),
|
|
37
|
+
names: z
|
|
38
|
+
.array(z.string())
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("Repeatable property names (exact, case-sensitive) to include. Errors if any name does not exist."),
|
|
41
|
+
visible: z
|
|
42
|
+
.boolean()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("Restrict to user-visible properties. Ignored when ids/names are supplied."),
|
|
45
|
+
},
|
|
46
|
+
annotations: { readOnlyHint: true },
|
|
47
|
+
}, async ({ ids, names, visible }) => {
|
|
48
|
+
const args = ["properties"];
|
|
49
|
+
if (visible)
|
|
50
|
+
args.push("--visible");
|
|
51
|
+
for (const id of ids ?? [])
|
|
52
|
+
args.push("--id", id);
|
|
53
|
+
for (const n of names ?? [])
|
|
54
|
+
args.push("--name", n);
|
|
55
|
+
return runCliAsTool(args);
|
|
56
|
+
});
|
|
57
|
+
server.registerTool("rubien_properties_create", {
|
|
58
|
+
title: "Create custom property",
|
|
59
|
+
description: "Create a new custom property definition. To create a new tag instead, use rubien_properties_add_option against the built-in Tags property.",
|
|
60
|
+
inputSchema: {
|
|
61
|
+
name: z.string(),
|
|
62
|
+
type: z.enum(PROPERTY_TYPES),
|
|
63
|
+
options: z
|
|
64
|
+
.string()
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("For singleSelect/multiSelect, comma-separated option labels."),
|
|
67
|
+
},
|
|
68
|
+
}, async ({ name, type, options }) => runCliAsTool([
|
|
69
|
+
"properties",
|
|
70
|
+
"--create",
|
|
71
|
+
...flagsFromOptions({
|
|
72
|
+
"--name": name,
|
|
73
|
+
"--type": type,
|
|
74
|
+
"--options": options,
|
|
75
|
+
}),
|
|
76
|
+
]));
|
|
77
|
+
server.registerTool("rubien_properties_delete", {
|
|
78
|
+
title: "Delete custom property",
|
|
79
|
+
description: "Remove a property definition and all its values on references. Cannot delete default/built-in properties (Tags included — use rubien_properties_delete_option to remove individual tags).",
|
|
80
|
+
inputSchema: { id: z.string() },
|
|
81
|
+
annotations: { destructiveHint: true },
|
|
82
|
+
}, async ({ id }) => runCliAsTool(["properties", "--delete", id]));
|
|
83
|
+
server.registerTool("rubien_properties_rename", {
|
|
84
|
+
title: "Rename custom property",
|
|
85
|
+
description: "Change a property's display name. Built-in properties (incl. Tags) cannot be renamed.",
|
|
86
|
+
inputSchema: { id: z.string(), name: z.string() },
|
|
87
|
+
}, async ({ id, name }) => runCliAsTool(["properties", "--rename", "--id", id, "--name", name]));
|
|
88
|
+
server.registerTool("rubien_properties_show", {
|
|
89
|
+
title: "Show property in UI",
|
|
90
|
+
description: "Mark a property as visible in the app UI.",
|
|
91
|
+
inputSchema: { id: z.string() },
|
|
92
|
+
}, async ({ id }) => runCliAsTool(["properties", "--show", "--id", id]));
|
|
93
|
+
server.registerTool("rubien_properties_hide", {
|
|
94
|
+
title: "Hide property in UI",
|
|
95
|
+
description: "Mark a property as hidden in the app UI.",
|
|
96
|
+
inputSchema: { id: z.string() },
|
|
97
|
+
}, async ({ id }) => runCliAsTool(["properties", "--hide", "--id", id]));
|
|
98
|
+
server.registerTool("rubien_properties_add_option", {
|
|
99
|
+
title: "Add option to select property (creates a Tag for the Tags property)",
|
|
100
|
+
description: "Append an option to a singleSelect/multiSelect property. " +
|
|
101
|
+
"For the built-in Tags property, this creates a new Tag row with `value` as the tag name " +
|
|
102
|
+
"and `color` as the tag color; the returned option's `value` is the new tag's stable id.",
|
|
103
|
+
inputSchema: {
|
|
104
|
+
id: z.string().describe("Property ID"),
|
|
105
|
+
value: z
|
|
106
|
+
.string()
|
|
107
|
+
.describe("Option label (or, for Tags, the new tag's display name)"),
|
|
108
|
+
color: z.string().optional().describe("Optional hex color"),
|
|
109
|
+
},
|
|
110
|
+
}, async ({ id, value, color }) => runCliAsTool([
|
|
111
|
+
"properties",
|
|
112
|
+
"--add-option",
|
|
113
|
+
"--id",
|
|
114
|
+
id,
|
|
115
|
+
...flagsFromOptions({ "--value": value, "--color": color }),
|
|
116
|
+
]));
|
|
117
|
+
server.registerTool("rubien_properties_rename_option", {
|
|
118
|
+
title: "Rename a select option (renames the underlying Tag for Tags)",
|
|
119
|
+
description: "Rename an existing option on a singleSelect/multiSelect property and bulk-update affected references. " +
|
|
120
|
+
"For Tags: `from` is the stringified tag id (identity-stable), `to` is the new display name. " +
|
|
121
|
+
"Pivots are not touched. For other multiSelect: rewrites the JSON arrays in every affected propertyValue row.",
|
|
122
|
+
inputSchema: {
|
|
123
|
+
id: z.string().describe("Property ID"),
|
|
124
|
+
from: z.string().describe("Existing option value (tag id for Tags)"),
|
|
125
|
+
to: z.string().describe("New option value (new tag name for Tags)"),
|
|
126
|
+
},
|
|
127
|
+
}, async ({ id, from, to }) => runCliAsTool([
|
|
128
|
+
"properties",
|
|
129
|
+
"--rename-option",
|
|
130
|
+
"--id",
|
|
131
|
+
id,
|
|
132
|
+
"--from",
|
|
133
|
+
from,
|
|
134
|
+
"--to",
|
|
135
|
+
to,
|
|
136
|
+
]));
|
|
137
|
+
server.registerTool("rubien_properties_delete_option", {
|
|
138
|
+
title: "Delete a select option (deletes the underlying Tag for Tags)",
|
|
139
|
+
description: "Remove a select option from a property. " + tagsContractNote("For Tags, deleting a tag with attached references requires `replaceWith` (the stringified id of another tag) — affected references are re-tagged before the old tag is removed. Without `replaceWith`, in-use options surface an `optionInUse` error.") +
|
|
140
|
+
" To delete an in-use option without migrating, set `clearInUse: true` — affected references have the option cleared from their value (singleSelect loses its value; multiSelect drops just this option). `clearInUse` and `replaceWith` are mutually exclusive.",
|
|
141
|
+
inputSchema: {
|
|
142
|
+
id: z.string().describe("Property ID"),
|
|
143
|
+
value: z.string().describe("Option value to delete (tag id for Tags)"),
|
|
144
|
+
replaceWith: z
|
|
145
|
+
.string()
|
|
146
|
+
.optional()
|
|
147
|
+
.describe("Replacement option value for affected rows (required when the option is in use)"),
|
|
148
|
+
clearInUse: z
|
|
149
|
+
.boolean()
|
|
150
|
+
.optional()
|
|
151
|
+
.describe("Clear the option from affected references instead of migrating. Mutually exclusive with replaceWith."),
|
|
152
|
+
},
|
|
153
|
+
annotations: { destructiveHint: true },
|
|
154
|
+
}, async ({ id, value, replaceWith, clearInUse }) => runCliAsTool([
|
|
155
|
+
"properties",
|
|
156
|
+
"--delete-option",
|
|
157
|
+
"--id",
|
|
158
|
+
id,
|
|
159
|
+
"--value",
|
|
160
|
+
value,
|
|
161
|
+
...flagsFromOptions({
|
|
162
|
+
"--replace-with": replaceWith,
|
|
163
|
+
"--clear-in-use": clearInUse,
|
|
164
|
+
}),
|
|
165
|
+
]));
|
|
166
|
+
server.registerTool("rubien_properties_set", {
|
|
167
|
+
title: "Set property value on reference (replace semantics)",
|
|
168
|
+
description: "Assign a property value to a reference using replace semantics. For multiSelect (incl. Tags), pass comma-separated values — the existing set is overwritten. " +
|
|
169
|
+
"Use rubien_properties_add_values / rubien_properties_remove_values for incremental edits. " +
|
|
170
|
+
tagsContractNote(),
|
|
171
|
+
inputSchema: {
|
|
172
|
+
reference: z.number().int(),
|
|
173
|
+
id: z.string().describe("Property ID"),
|
|
174
|
+
value: z.string(),
|
|
175
|
+
},
|
|
176
|
+
}, async ({ reference, id, value }) => runCliAsTool([
|
|
177
|
+
"properties",
|
|
178
|
+
"--set",
|
|
179
|
+
"--reference",
|
|
180
|
+
String(reference),
|
|
181
|
+
"--id",
|
|
182
|
+
id,
|
|
183
|
+
"--value",
|
|
184
|
+
value,
|
|
185
|
+
]));
|
|
186
|
+
server.registerTool("rubien_properties_add_values", {
|
|
187
|
+
title: "Add values to a multiSelect property (additive, idempotent)",
|
|
188
|
+
description: "Append one or more values to a multiSelect property on a reference without disturbing existing selections. " +
|
|
189
|
+
"Idempotent: re-adding a present value is a no-op (no sync churn). " +
|
|
190
|
+
tagsContractNote("For Tags this inserts ReferenceTag pivots."),
|
|
191
|
+
inputSchema: {
|
|
192
|
+
reference: z.number().int(),
|
|
193
|
+
id: z.string().describe("Property ID"),
|
|
194
|
+
value: z.string().describe("Comma-separated values (tag IDs for Tags)"),
|
|
195
|
+
},
|
|
196
|
+
}, async ({ reference, id, value }) => runCliAsTool([
|
|
197
|
+
"properties",
|
|
198
|
+
"--set",
|
|
199
|
+
"--add-value",
|
|
200
|
+
"--reference",
|
|
201
|
+
String(reference),
|
|
202
|
+
"--id",
|
|
203
|
+
id,
|
|
204
|
+
"--value",
|
|
205
|
+
value,
|
|
206
|
+
]));
|
|
207
|
+
server.registerTool("rubien_properties_remove_values", {
|
|
208
|
+
title: "Remove values from a multiSelect property (subtractive, idempotent)",
|
|
209
|
+
description: "Remove one or more values from a multiSelect property on a reference without disturbing other selections. " +
|
|
210
|
+
"Idempotent: removing an absent value is a no-op. " +
|
|
211
|
+
tagsContractNote("For Tags this deletes ReferenceTag pivots."),
|
|
212
|
+
inputSchema: {
|
|
213
|
+
reference: z.number().int(),
|
|
214
|
+
id: z.string().describe("Property ID"),
|
|
215
|
+
value: z.string().describe("Comma-separated values (tag IDs for Tags)"),
|
|
216
|
+
},
|
|
217
|
+
annotations: { destructiveHint: true },
|
|
218
|
+
}, async ({ reference, id, value }) => runCliAsTool([
|
|
219
|
+
"properties",
|
|
220
|
+
"--set",
|
|
221
|
+
"--remove-value",
|
|
222
|
+
"--reference",
|
|
223
|
+
String(reference),
|
|
224
|
+
"--id",
|
|
225
|
+
id,
|
|
226
|
+
"--value",
|
|
227
|
+
value,
|
|
228
|
+
]));
|
|
229
|
+
server.registerTool("rubien_properties_clear", {
|
|
230
|
+
title: "Clear property value on reference",
|
|
231
|
+
description: "Remove a property value from a reference. " +
|
|
232
|
+
tagsContractNote("For Tags this removes all of the reference's tag assignments."),
|
|
233
|
+
inputSchema: {
|
|
234
|
+
reference: z.number().int(),
|
|
235
|
+
id: z.string().describe("Property ID"),
|
|
236
|
+
},
|
|
237
|
+
annotations: { destructiveHint: true },
|
|
238
|
+
}, async ({ reference, id }) => runCliAsTool([
|
|
239
|
+
"properties",
|
|
240
|
+
"--clear",
|
|
241
|
+
"--reference",
|
|
242
|
+
String(reference),
|
|
243
|
+
"--id",
|
|
244
|
+
id,
|
|
245
|
+
]));
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../src/tools/properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEnE,MAAM,cAAc,GAAG;IACrB,QAAQ;IACR,KAAK;IACL,QAAQ;IACR,cAAc;IACd,aAAa;IACb,MAAM;IACN,UAAU;CACF,CAAC;AAEX,mEAAmE;AACnE,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,oEAAoE;AACpE,uDAAuD;AACvD,SAAS,gBAAgB,CAAC,KAAK,GAAG,EAAE;IAClC,OAAO,CACL,yEAAyE;QACzE,0EAA0E;QAC1E,0BAA0B;QAC1B,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAC3B,CAA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,CAAC;QACjB,MAAM;QACN,EAAE;KACH,CAAC,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { flagsFromOptions, runCliAsTool } from "../toolHelpers.js";
|
|
3
|
+
export function registerReferenceTools(server) {
|
|
4
|
+
server.registerTool("rubien_search", {
|
|
5
|
+
title: "Full-text search",
|
|
6
|
+
description: "Full-text search across the Rubien library. By default searches all 12 indexed FTS columns (title, authors, abstract, notes, journal, doi, publisher, isbn, issn, institution, webContent, siteName). Use `in` to constrain to specific columns — e.g. `in: ['title','abstract']` for topic searches that should ignore notes/web content. Use `op: 'or'` when looking for any of several alternative terms instead of all of them. Returns an array of ReferenceDTO.",
|
|
7
|
+
inputSchema: {
|
|
8
|
+
query: z.string().describe("Search query (space-separated tokens)"),
|
|
9
|
+
limit: z.number().int().positive().max(500).optional()
|
|
10
|
+
.describe("Maximum results (default 20)"),
|
|
11
|
+
in: z
|
|
12
|
+
.array(z.enum([
|
|
13
|
+
"title",
|
|
14
|
+
"abstract",
|
|
15
|
+
"notes",
|
|
16
|
+
"authors",
|
|
17
|
+
"journal",
|
|
18
|
+
"doi",
|
|
19
|
+
"publisher",
|
|
20
|
+
"isbn",
|
|
21
|
+
"issn",
|
|
22
|
+
"institution",
|
|
23
|
+
"webContent",
|
|
24
|
+
"siteName",
|
|
25
|
+
]))
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Restrict FTS to these columns (default: all 12 indexed columns)."),
|
|
28
|
+
op: z
|
|
29
|
+
.enum(["and", "or"])
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("Combine multiple query tokens with AND (every token must match) or OR (any token). Default: and."),
|
|
32
|
+
},
|
|
33
|
+
annotations: { readOnlyHint: true },
|
|
34
|
+
}, async ({ query, limit, in: inFields, op }) => runCliAsTool([
|
|
35
|
+
"search",
|
|
36
|
+
query,
|
|
37
|
+
...flagsFromOptions({
|
|
38
|
+
"--limit": limit,
|
|
39
|
+
"--in": inFields && inFields.length > 0 ? inFields.join(",") : undefined,
|
|
40
|
+
"--op": op,
|
|
41
|
+
}),
|
|
42
|
+
]));
|
|
43
|
+
server.registerTool("rubien_list", {
|
|
44
|
+
title: "List references",
|
|
45
|
+
description: "List references with filters and sorting. Returns ReferenceDTO[]. Use this for 'most recent', 'by author', 'by year range' queries.",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
limit: z.number().int().nonnegative().optional()
|
|
48
|
+
.describe("Maximum results (0 = all)"),
|
|
49
|
+
offset: z.number().int().nonnegative().optional().describe("Skip first N"),
|
|
50
|
+
tag: z.number().int().optional().describe("Filter by tag ID"),
|
|
51
|
+
author: z.string().optional().describe("Filter by author name (fuzzy)"),
|
|
52
|
+
yearFrom: z.number().int().optional(),
|
|
53
|
+
yearTo: z.number().int().optional(),
|
|
54
|
+
journal: z.string().optional().describe("Filter by journal name (fuzzy)"),
|
|
55
|
+
type: z.string().optional().describe("Reference type, e.g. 'Journal Article'"),
|
|
56
|
+
hasPdf: z.boolean().optional(),
|
|
57
|
+
keyword: z.string().optional().describe("Keyword across title/abstract/notes"),
|
|
58
|
+
readingStatus: z
|
|
59
|
+
.enum(["unread", "reading", "skimmed", "read"])
|
|
60
|
+
.optional(),
|
|
61
|
+
sortBy: z
|
|
62
|
+
.enum(["year", "dateAdded", "title"])
|
|
63
|
+
.optional(),
|
|
64
|
+
asc: z.boolean().optional().describe("Sort ascending (default is descending)"),
|
|
65
|
+
},
|
|
66
|
+
annotations: { readOnlyHint: true },
|
|
67
|
+
}, async (args) => runCliAsTool([
|
|
68
|
+
"list",
|
|
69
|
+
...flagsFromOptions({
|
|
70
|
+
"--limit": args.limit,
|
|
71
|
+
"--offset": args.offset,
|
|
72
|
+
"--tag": args.tag,
|
|
73
|
+
"--author": args.author,
|
|
74
|
+
"--year-from": args.yearFrom,
|
|
75
|
+
"--year-to": args.yearTo,
|
|
76
|
+
"--journal": args.journal,
|
|
77
|
+
"--type": args.type,
|
|
78
|
+
"--has-pdf": args.hasPdf,
|
|
79
|
+
"--keyword": args.keyword,
|
|
80
|
+
"--reading-status": args.readingStatus,
|
|
81
|
+
"--sort-by": args.sortBy,
|
|
82
|
+
"--asc": args.asc,
|
|
83
|
+
}),
|
|
84
|
+
]));
|
|
85
|
+
server.registerTool("rubien_get", {
|
|
86
|
+
title: "Get reference by ID",
|
|
87
|
+
description: "Fetch a single reference by ID. Returns ReferenceDTO.",
|
|
88
|
+
inputSchema: {
|
|
89
|
+
id: z.number().int().describe("Reference ID"),
|
|
90
|
+
},
|
|
91
|
+
annotations: { readOnlyHint: true },
|
|
92
|
+
}, async ({ id }) => runCliAsTool(["get", String(id)]));
|
|
93
|
+
server.registerTool("rubien_add", {
|
|
94
|
+
title: "Add reference",
|
|
95
|
+
description: "Create a reference (or surface an existing one). Choose one input method: identifier (DOI/arXiv/PMID/ISBN, triggers metadata lookup, slow), bibtex (inline BibTeX/BibLaTeX string, returns array of envelopes for multi-entry), or title (minimal manual entry). Output is an envelope: `{ reference: ReferenceDTO, status: 'created' | 'existing', pdfDownload: { ok, action?, filename?, error? } | null }`. `status='existing'` means the input matched an existing row (deduped by normalized DOI / PMID / PMCID / ISBN / URL / ISSN+title+year); `mergedReference` folded any non-empty incoming fields into the existing row, and `reference.id` is the existing row's id. `pdfDownload` is always present: `null` unless `downloadPdf: true` was set (identifier only). For `method='bibtex'`, output is an array of envelopes, one per parsed entry.",
|
|
96
|
+
inputSchema: {
|
|
97
|
+
method: z.enum(["identifier", "bibtex", "title"]),
|
|
98
|
+
value: z
|
|
99
|
+
.string()
|
|
100
|
+
.describe("The identifier / BibTeX source / title, depending on method."),
|
|
101
|
+
downloadPdf: z
|
|
102
|
+
.boolean()
|
|
103
|
+
.optional()
|
|
104
|
+
.describe("Only valid with method='identifier'. After metadata lookup, attempt to fetch the open-access PDF. Reference is still saved if the PDF fetch fails. Adds up to ~3min to the timeout."),
|
|
105
|
+
},
|
|
106
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
107
|
+
}, async ({ method, value, downloadPdf }) => {
|
|
108
|
+
if (downloadPdf && method !== "identifier") {
|
|
109
|
+
return {
|
|
110
|
+
content: [
|
|
111
|
+
{
|
|
112
|
+
type: "text",
|
|
113
|
+
text: JSON.stringify({
|
|
114
|
+
error: "downloadPdf requires method='identifier'",
|
|
115
|
+
}),
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
isError: true,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const flag = method === "identifier"
|
|
122
|
+
? "--identifier"
|
|
123
|
+
: method === "bibtex"
|
|
124
|
+
? "--bibtex"
|
|
125
|
+
: "--title";
|
|
126
|
+
const args = ["add", flag, value];
|
|
127
|
+
if (downloadPdf)
|
|
128
|
+
args.push("--download-pdf");
|
|
129
|
+
const timeoutMs = downloadPdf
|
|
130
|
+
? 300_000
|
|
131
|
+
: method === "identifier"
|
|
132
|
+
? 120_000
|
|
133
|
+
: undefined;
|
|
134
|
+
return runCliAsTool(args, { timeoutMs });
|
|
135
|
+
});
|
|
136
|
+
server.registerTool("rubien_update", {
|
|
137
|
+
title: "Update reference fields",
|
|
138
|
+
description: "Modify fields on an existing reference. Pass only the fields to change. Use `clearField` (repeatable) to null out a field entirely.",
|
|
139
|
+
inputSchema: {
|
|
140
|
+
id: z.number().int(),
|
|
141
|
+
title: z.string().optional(),
|
|
142
|
+
year: z.number().int().optional(),
|
|
143
|
+
authors: z.string().optional(),
|
|
144
|
+
type: z.string().optional(),
|
|
145
|
+
journal: z.string().optional(),
|
|
146
|
+
volume: z.string().optional(),
|
|
147
|
+
issue: z.string().optional(),
|
|
148
|
+
pages: z.string().optional(),
|
|
149
|
+
doi: z.string().optional(),
|
|
150
|
+
url: z.string().optional(),
|
|
151
|
+
abstract: z.string().optional(),
|
|
152
|
+
notes: z.string().optional(),
|
|
153
|
+
publisher: z.string().optional(),
|
|
154
|
+
isbn: z.string().optional(),
|
|
155
|
+
issn: z.string().optional(),
|
|
156
|
+
language: z.string().optional(),
|
|
157
|
+
edition: z.string().optional(),
|
|
158
|
+
readingStatus: z
|
|
159
|
+
.enum(["unread", "reading", "skimmed", "read"])
|
|
160
|
+
.optional(),
|
|
161
|
+
clearField: z.array(z.string()).optional()
|
|
162
|
+
.describe("Field names to clear (set to NULL). Repeatable."),
|
|
163
|
+
},
|
|
164
|
+
annotations: { destructiveHint: true },
|
|
165
|
+
}, async (args) => {
|
|
166
|
+
const flags = flagsFromOptions({
|
|
167
|
+
"--title": args.title,
|
|
168
|
+
"--year": args.year,
|
|
169
|
+
"--authors": args.authors,
|
|
170
|
+
"--type": args.type,
|
|
171
|
+
"--journal": args.journal,
|
|
172
|
+
"--volume": args.volume,
|
|
173
|
+
"--issue": args.issue,
|
|
174
|
+
"--pages": args.pages,
|
|
175
|
+
"--doi": args.doi,
|
|
176
|
+
"--url": args.url,
|
|
177
|
+
"--abstract": args.abstract,
|
|
178
|
+
"--notes": args.notes,
|
|
179
|
+
"--publisher": args.publisher,
|
|
180
|
+
"--isbn": args.isbn,
|
|
181
|
+
"--issn": args.issn,
|
|
182
|
+
"--language": args.language,
|
|
183
|
+
"--edition": args.edition,
|
|
184
|
+
"--reading-status": args.readingStatus,
|
|
185
|
+
});
|
|
186
|
+
if (args.clearField) {
|
|
187
|
+
for (const f of args.clearField)
|
|
188
|
+
flags.push("--clear-field", f);
|
|
189
|
+
}
|
|
190
|
+
return runCliAsTool(["update", String(args.id), ...flags]);
|
|
191
|
+
});
|
|
192
|
+
server.registerTool("rubien_delete", {
|
|
193
|
+
title: "Delete references",
|
|
194
|
+
description: "Permanently delete references by ID. Accepts one or many IDs. Returns { deleted: 'id1,id2,...' }.",
|
|
195
|
+
inputSchema: {
|
|
196
|
+
ids: z
|
|
197
|
+
.array(z.number().int())
|
|
198
|
+
.min(1)
|
|
199
|
+
.describe("One or more reference IDs to delete"),
|
|
200
|
+
},
|
|
201
|
+
annotations: { destructiveHint: true, idempotentHint: false },
|
|
202
|
+
},
|
|
203
|
+
// Always passes --force: the MCP client's permission layer is the user
|
|
204
|
+
// confirmation point for destructive tools, not the CLI's TTY prompt.
|
|
205
|
+
async ({ ids }) => runCliAsTool(["delete", "--force", ...ids.map((n) => String(n))]));
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../../src/tools/references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEnE,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,YAAY,CACjB,eAAe,EACf;QACE,KAAK,EAAE,kBAAkB;QACzB,WAAW,EACT,ucAAuc;QACzc,WAAW,EAAE;YACX,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;YACnE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;iBACnD,QAAQ,CAAC,8BAA8B,CAAC;YAC3C,EAAE,EAAE,CAAC;iBACF,KAAK,CACJ,CAAC,CAAC,IAAI,CAAC;gBACL,OAAO;gBACP,UAAU;gBACV,OAAO;gBACP,SAAS;gBACT,SAAS;gBACT,KAAK;gBACL,WAAW;gBACX,MAAM;gBACN,MAAM;gBACN,aAAa;gBACb,YAAY;gBACZ,UAAU;aACX,CAAC,CACH;iBACA,QAAQ,EAAE;iBACV,QAAQ,CACP,kEAAkE,CACnE;YACH,EAAE,EAAE,CAAC;iBACF,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;iBACnB,QAAQ,EAAE;iBACV,QAAQ,CACP,kGAAkG,CACnG;SACJ;QACD,WAAW,EAAE,EAAE,YAAY,EAA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pE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { runCliAsTool } from "../toolHelpers.js";
|
|
2
|
+
export function registerSyncTools(server) {
|
|
3
|
+
server.registerTool("rubien_sync_status", {
|
|
4
|
+
title: "CloudKit sync status",
|
|
5
|
+
description: "Report the current CloudKit sync state without starting the engine. Shows entitlement presence, iCloud account availability, dirty counts per entity type, tombstones, and engine state snapshot.",
|
|
6
|
+
inputSchema: {},
|
|
7
|
+
annotations: { readOnlyHint: true },
|
|
8
|
+
}, async () => runCliAsTool(["sync", "status"]));
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=sync.js.map
|