paper-reader-mcp 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +69 -2
- package/dist/install.d.ts +34 -0
- package/dist/install.js +76 -0
- package/dist/install.js.map +1 -0
- package/dist/opencode.json.example +13 -0
- package/dist/publish.d.ts +22 -0
- package/dist/publish.js +216 -0
- package/dist/publish.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +62 -0
- package/dist/server.js.map +1 -0
- package/dist/skills/paper-reader/SKILL.md +62 -0
- package/dist/skills/paper-reader/examples/publish-request.json +26 -0
- package/dist/skills/paper-reader/opencode.json.example +13 -0
- package/dist/skills/paper-reader/scripts/crop-figures.mjs +109 -0
- package/package.json +48 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lealiaxiong
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# paper-reader-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Local stdio [Model Context Protocol](https://modelcontextprotocol.io/) server for Paper Reader BYOM publishing.
|
|
4
|
+
|
|
5
|
+
This npm package also bundles the Paper Reader OpenCode skill. You do not need to clone the Paper Reader app repository to install the tools.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx -y paper-reader-mcp install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The installer:
|
|
14
|
+
|
|
15
|
+
1. Copies the bundled Paper Reader skill into your OpenCode skills directory.
|
|
16
|
+
2. Prints an MCP `opencode.json` block for the installed `paper-reader-mcp` command.
|
|
17
|
+
3. Uses the hosted Paper Reader deployment by default.
|
|
18
|
+
|
|
19
|
+
Then set the publisher token in the shell that launches OpenCode:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
export PAPER_READER_TOKEN='your-publisher-token'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Restart OpenCode after adding the MCP configuration.
|
|
26
|
+
|
|
27
|
+
## OpenCode configuration
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"mcp": {
|
|
32
|
+
"paper-reader": {
|
|
33
|
+
"type": "local",
|
|
34
|
+
"command": ["npx", "-y", "paper-reader-mcp"],
|
|
35
|
+
"environment": {
|
|
36
|
+
"PAPER_READER_URL": "https://paper-reader-omega.vercel.app",
|
|
37
|
+
"PAPER_READER_TOKEN": "{env:PAPER_READER_TOKEN}"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`PAPER_READER_URL` defaults to the hosted deployment. Override it only for local development:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
export PAPER_READER_URL='http://localhost:3000'
|
|
48
|
+
PUBLISH_TOKENS='your-publisher-token' npm run dev
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Tools
|
|
52
|
+
|
|
53
|
+
- `paper_format`: returns the publish JSON Schema and a worked example.
|
|
54
|
+
- `publish_paper`: posts a payload to `POST /api/publish` and returns the ephemeral reader URL.
|
|
55
|
+
|
|
56
|
+
## Environment
|
|
57
|
+
|
|
58
|
+
- `PAPER_READER_URL`: base URL, for example `https://paper-reader-omega.vercel.app` or `http://localhost:3000` for local development.
|
|
59
|
+
- `PAPER_READER_TOKEN`: a publisher bearer token accepted by `PUBLISH_TOKENS` on the server.
|
|
60
|
+
|
|
61
|
+
`PAPER_READER_URL` is the Paper Reader site origin (the same URL you open in a browser), not the paper URL; the MCP server posts to `${PAPER_READER_URL}/api/publish`.
|
|
62
|
+
|
|
63
|
+
## Repository development
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
npm --prefix mcp install
|
|
67
|
+
npm --prefix mcp run build
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
For local development, use `http://localhost:3000` and set `PUBLISH_TOKENS` on the local server.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export declare const DEFAULT_PAPER_READER_URL = "https://paper-reader-omega.vercel.app";
|
|
3
|
+
export declare function opencodeConfig(serverPath: string): {
|
|
4
|
+
mcp: {
|
|
5
|
+
"paper-reader": {
|
|
6
|
+
type: string;
|
|
7
|
+
command: string[];
|
|
8
|
+
environment: {
|
|
9
|
+
PAPER_READER_URL: string;
|
|
10
|
+
PAPER_READER_TOKEN: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare function install(options?: {
|
|
16
|
+
args?: string[];
|
|
17
|
+
env?: Partial<NodeJS.ProcessEnv>;
|
|
18
|
+
here?: string;
|
|
19
|
+
log?: (message: string) => void;
|
|
20
|
+
}): {
|
|
21
|
+
target: string;
|
|
22
|
+
config: {
|
|
23
|
+
mcp: {
|
|
24
|
+
"paper-reader": {
|
|
25
|
+
type: string;
|
|
26
|
+
command: string[];
|
|
27
|
+
environment: {
|
|
28
|
+
PAPER_READER_URL: string;
|
|
29
|
+
PAPER_READER_TOKEN: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
package/dist/install.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Install the bundled Paper Reader OpenCode skill and print the MCP
|
|
4
|
+
* configuration. This is intentionally small and dependency-free:
|
|
5
|
+
* the npm package ships the skill beside the build, so no repository
|
|
6
|
+
* checkout or local build is required.
|
|
7
|
+
*/
|
|
8
|
+
import { chmodSync, cpSync, existsSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { homedir, tmpdir } from "node:os";
|
|
10
|
+
import { dirname, join, resolve } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
export const DEFAULT_PAPER_READER_URL = "https://paper-reader-omega.vercel.app";
|
|
13
|
+
function findSkillSource(here) {
|
|
14
|
+
const candidates = [
|
|
15
|
+
join(here, "skills", "paper-reader"),
|
|
16
|
+
join(here, "..", "skills", "paper-reader"),
|
|
17
|
+
join(here, "..", ".opencode", "skills", "paper-reader"),
|
|
18
|
+
join(here, "..", "..", ".opencode", "skills", "paper-reader"),
|
|
19
|
+
];
|
|
20
|
+
return candidates.find((candidate) => existsSync(join(candidate, "SKILL.md")));
|
|
21
|
+
}
|
|
22
|
+
export function opencodeConfig(serverPath) {
|
|
23
|
+
return {
|
|
24
|
+
mcp: {
|
|
25
|
+
"paper-reader": {
|
|
26
|
+
type: "local",
|
|
27
|
+
command: [process.execPath, serverPath],
|
|
28
|
+
environment: {
|
|
29
|
+
PAPER_READER_URL: DEFAULT_PAPER_READER_URL,
|
|
30
|
+
PAPER_READER_TOKEN: "{env:PAPER_READER_TOKEN}",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function install(options = {}) {
|
|
37
|
+
const here = options.here ?? dirname(fileURLToPath(import.meta.url));
|
|
38
|
+
const skillSource = findSkillSource(here);
|
|
39
|
+
if (!skillSource)
|
|
40
|
+
throw new Error("Bundled skill not found");
|
|
41
|
+
const env = options.env ?? process.env;
|
|
42
|
+
const target = env.PAPER_READER_SKILL_HOME
|
|
43
|
+
? resolve(env.PAPER_READER_SKILL_HOME)
|
|
44
|
+
: join(homedir(), ".opencode", "skills", "paper-reader");
|
|
45
|
+
const log = options.log ?? ((message) => console.log(message));
|
|
46
|
+
const args = new Set(options.args ?? process.argv.slice(2));
|
|
47
|
+
const config = opencodeConfig(join(here, "server.js"));
|
|
48
|
+
if (args.has("--check")) {
|
|
49
|
+
log(JSON.stringify({
|
|
50
|
+
skill: target,
|
|
51
|
+
installed: existsSync(join(target, "SKILL.md")),
|
|
52
|
+
}, null, 2));
|
|
53
|
+
return { target, config };
|
|
54
|
+
}
|
|
55
|
+
cpSync(skillSource, target, { recursive: true });
|
|
56
|
+
chmodSync(join(target, "scripts", "crop-figures.mjs"), 0o755);
|
|
57
|
+
if (args.has("--config")) {
|
|
58
|
+
const path = join(tmpdir(), `paper-reader-opencode-${process.pid}.json`);
|
|
59
|
+
writeFileSync(path, `${JSON.stringify(config, null, 2)}\n`);
|
|
60
|
+
log(`Wrote ${path}`);
|
|
61
|
+
}
|
|
62
|
+
log(`Paper Reader skill installed at ${target}`);
|
|
63
|
+
log("Add this to your OpenCode MCP configuration:");
|
|
64
|
+
log(JSON.stringify(config, null, 2));
|
|
65
|
+
const token = options.env?.PAPER_READER_TOKEN?.trim() ??
|
|
66
|
+
process.env.PAPER_READER_TOKEN?.trim();
|
|
67
|
+
if (!token) {
|
|
68
|
+
log("\nSet PAPER_READER_TOKEN in your shell before launching OpenCode:");
|
|
69
|
+
log("export PAPER_READER_TOKEN='your-publisher-token'");
|
|
70
|
+
}
|
|
71
|
+
return { target, config };
|
|
72
|
+
}
|
|
73
|
+
if (process.argv[2] === "install") {
|
|
74
|
+
install({ args: process.argv.slice(2), env: process.env });
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,wBAAwB,GACnC,uCAAuC,CAAC;AAE1C,SAAS,eAAe,CAAC,IAAY;IACnC,MAAM,UAAU,GAAG;QACjB,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC;QACpC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,CAAC;QACvD,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,CAAC;KAC9D,CAAC;IACF,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CACnC,UAAU,C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GAAG,CAAC,kDAAkD,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;IAClC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://opencode.ai/config.json",
|
|
3
|
+
"mcp": {
|
|
4
|
+
"paper-reader": {
|
|
5
|
+
"type": "local",
|
|
6
|
+
"command": ["npx", "-y", "paper-reader-mcp"],
|
|
7
|
+
"environment": {
|
|
8
|
+
"PAPER_READER_URL": "https://paper-reader-omega.vercel.app",
|
|
9
|
+
"PAPER_READER_TOKEN": "{env:PAPER_READER_TOKEN}"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const INSTRUCTIONS = "Return a JSON Schema describing the Paper Reader publish payload and a compact worked example.\n\nThe payload is an object with:\n{\n \"arxivId\": \"2401.01234\",\n \"title\": \"Paper title\",\n \"authors\": [\"First Author\", \"Second Author\"],\n \"paragraphs\": [\n {\"id\": \"p1\", \"text\": \"Plain paragraph text used for mapping.\", \"html\": \"Allowed <b>inline</b> HTML.\", \"mathTex\": []}\n ],\n \"figures\": [\n {\n \"id\": \"f1\",\n \"label\": \"Figure 1\",\n \"number\": 1,\n \"kind\": \"figure\",\n \"caption\": \"Figure 1: Verbatim caption.\",\n \"pdfPage\": 2,\n \"bbox\": [0.1, 0.2, 0.5, 0.4]\n }\n ],\n \"paraFigureMap\": {\"p1\": [\"f1\"]},\n \"client\": {\"name\": \"opencode\", \"model\": \"model-name\", \"skillVersion\": \"0.1.0\"}\n}\n\nRules:\n- Paragraph ids are p1, p2, ... in reading order; figure ids are f1, f2, ...\n- html may use only a, b, i, em, strong, cite, sub, sup, code, span, br. No scripts, styles, ids, event handlers, or external image URLs.\n- Inline math uses @@K0@@, @@K1@@, ... in html; raw TeX strings are in mathTex in the same order.\n- Captions are verbatim. Never invent numbers.\n- Every figure has either tableHtml or a 1-based pdfPage, optionally a normalized bbox [x, y, width, height] in [0, 1].\n- imageUrl is not accepted in v1.\n- The server recomputes paraFigureMap; include it only to fill gaps.\n- Before publishing, ask the user where to save the payload as a JSON file. The suggested default is ~/Documents/paper-reader/payloads/paper-reader-<arxivId>.json; use the user-approved location and do not save it in the Paper Reader repository unless requested. On expiry, re-send that saved payload instead of extracting the PDF again.\n- A publish is accepted only for PDF-only arXiv papers. If arXiv HTML or ar5iv exists, use the normal reader instead.";
|
|
2
|
+
export declare const EXAMPLE: Record<string, unknown>;
|
|
3
|
+
export declare const SCHEMA: Record<string, unknown>;
|
|
4
|
+
export interface PublishResult {
|
|
5
|
+
slug: string;
|
|
6
|
+
url: string;
|
|
7
|
+
expiresAt: string;
|
|
8
|
+
deduped: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface PublishError {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
details?: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface ClientConfig {
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
token: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_PAPER_READER_URL = "https://paper-reader-omega.vercel.app";
|
|
20
|
+
export declare function configFromEnv(env?: Partial<NodeJS.ProcessEnv>): ClientConfig;
|
|
21
|
+
export declare function publishPaper(config: ClientConfig, payload: Record<string, unknown>, fetchImpl?: typeof fetch): Promise<PublishResult>;
|
|
22
|
+
export declare function formatPaperFormat(): string;
|
package/dist/publish.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
export const INSTRUCTIONS = `Return a JSON Schema describing the Paper Reader publish payload and a compact worked example.
|
|
2
|
+
|
|
3
|
+
The payload is an object with:
|
|
4
|
+
{
|
|
5
|
+
"arxivId": "2401.01234",
|
|
6
|
+
"title": "Paper title",
|
|
7
|
+
"authors": ["First Author", "Second Author"],
|
|
8
|
+
"paragraphs": [
|
|
9
|
+
{"id": "p1", "text": "Plain paragraph text used for mapping.", "html": "Allowed <b>inline</b> HTML.", "mathTex": []}
|
|
10
|
+
],
|
|
11
|
+
"figures": [
|
|
12
|
+
{
|
|
13
|
+
"id": "f1",
|
|
14
|
+
"label": "Figure 1",
|
|
15
|
+
"number": 1,
|
|
16
|
+
"kind": "figure",
|
|
17
|
+
"caption": "Figure 1: Verbatim caption.",
|
|
18
|
+
"pdfPage": 2,
|
|
19
|
+
"bbox": [0.1, 0.2, 0.5, 0.4]
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"paraFigureMap": {"p1": ["f1"]},
|
|
23
|
+
"client": {"name": "opencode", "model": "model-name", "skillVersion": "0.1.0"}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Rules:
|
|
27
|
+
- Paragraph ids are p1, p2, ... in reading order; figure ids are f1, f2, ...
|
|
28
|
+
- html may use only a, b, i, em, strong, cite, sub, sup, code, span, br. No scripts, styles, ids, event handlers, or external image URLs.
|
|
29
|
+
- Inline math uses @@K0@@, @@K1@@, ... in html; raw TeX strings are in mathTex in the same order.
|
|
30
|
+
- Captions are verbatim. Never invent numbers.
|
|
31
|
+
- Every figure has either tableHtml or a 1-based pdfPage, optionally a normalized bbox [x, y, width, height] in [0, 1].
|
|
32
|
+
- imageUrl is not accepted in v1.
|
|
33
|
+
- The server recomputes paraFigureMap; include it only to fill gaps.
|
|
34
|
+
- Before publishing, ask the user where to save the payload as a JSON file. The suggested default is ~/Documents/paper-reader/payloads/paper-reader-<arxivId>.json; use the user-approved location and do not save it in the Paper Reader repository unless requested. On expiry, re-send that saved payload instead of extracting the PDF again.
|
|
35
|
+
- A publish is accepted only for PDF-only arXiv papers. If arXiv HTML or ar5iv exists, use the normal reader instead.`;
|
|
36
|
+
export const EXAMPLE = {
|
|
37
|
+
arxivId: "2401.01234",
|
|
38
|
+
title: "Invented example with math and a vector figure",
|
|
39
|
+
authors: ["Jane Example", "Alex Sample"],
|
|
40
|
+
paragraphs: [
|
|
41
|
+
{
|
|
42
|
+
id: "p1",
|
|
43
|
+
text: "The loss falls from 0.90 to 0.42 as shown in Figure 1.",
|
|
44
|
+
html: "The loss falls from 0.90 to @@K0@@ as shown in <b>Figure 1</b>.",
|
|
45
|
+
mathTex: ["0.42"],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
figures: [
|
|
49
|
+
{
|
|
50
|
+
id: "f1",
|
|
51
|
+
label: "Figure 1",
|
|
52
|
+
number: 1,
|
|
53
|
+
kind: "figure",
|
|
54
|
+
caption: "Figure 1: Training loss by epoch.",
|
|
55
|
+
pdfPage: 2,
|
|
56
|
+
bbox: [0.12, 0.18, 0.76, 0.52],
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
paraFigureMap: { p1: ["f1"] },
|
|
60
|
+
client: { name: "opencode", model: "model-name", skillVersion: "0.1.0" },
|
|
61
|
+
};
|
|
62
|
+
export const SCHEMA = {
|
|
63
|
+
type: "object",
|
|
64
|
+
additionalProperties: false,
|
|
65
|
+
required: ["arxivId", "title", "authors", "paragraphs", "figures"],
|
|
66
|
+
properties: {
|
|
67
|
+
arxivId: { type: "string", pattern: "^\\d{4}\\.\\d{4,5}$" },
|
|
68
|
+
title: { type: "string", minLength: 1, maxLength: 500 },
|
|
69
|
+
authors: {
|
|
70
|
+
type: "array",
|
|
71
|
+
minItems: 1,
|
|
72
|
+
maxItems: 100,
|
|
73
|
+
items: { type: "string", minLength: 1, maxLength: 200 },
|
|
74
|
+
},
|
|
75
|
+
paragraphs: {
|
|
76
|
+
type: "array",
|
|
77
|
+
minItems: 1,
|
|
78
|
+
maxItems: 500,
|
|
79
|
+
items: {
|
|
80
|
+
type: "object",
|
|
81
|
+
additionalProperties: false,
|
|
82
|
+
required: ["id", "text", "html", "mathTex"],
|
|
83
|
+
properties: {
|
|
84
|
+
id: { type: "string", pattern: "^p[1-9][0-9]*$" },
|
|
85
|
+
text: { type: "string", minLength: 1, maxLength: 20000 },
|
|
86
|
+
html: { type: "string", maxLength: 100000 },
|
|
87
|
+
mathTex: {
|
|
88
|
+
type: "array",
|
|
89
|
+
maxItems: 100,
|
|
90
|
+
items: { type: "string", maxLength: 4000 },
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
figures: {
|
|
96
|
+
type: "array",
|
|
97
|
+
maxItems: 100,
|
|
98
|
+
items: {
|
|
99
|
+
type: "object",
|
|
100
|
+
additionalProperties: false,
|
|
101
|
+
required: ["id", "label", "number", "kind", "caption"],
|
|
102
|
+
properties: {
|
|
103
|
+
id: { type: "string", pattern: "^f[1-9][0-9]*$" },
|
|
104
|
+
label: { type: "string", minLength: 1, maxLength: 100 },
|
|
105
|
+
number: { type: ["integer", "null"], minimum: 0 },
|
|
106
|
+
kind: { enum: ["figure", "table"] },
|
|
107
|
+
caption: { type: "string", minLength: 1, maxLength: 5000 },
|
|
108
|
+
tableHtml: { type: ["string", "null"], maxLength: 200000 },
|
|
109
|
+
explanation: { type: "string", maxLength: 500 },
|
|
110
|
+
pdfPage: { type: "integer", minimum: 1, maximum: 200 },
|
|
111
|
+
bbox: {
|
|
112
|
+
type: "array",
|
|
113
|
+
items: { type: "number", minimum: 0, maximum: 1 },
|
|
114
|
+
minItems: 4,
|
|
115
|
+
maxItems: 4,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
allOf: [
|
|
119
|
+
{
|
|
120
|
+
if: { required: ["bbox"] },
|
|
121
|
+
then: { required: ["pdfPage"] },
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
paraFigureMap: {
|
|
127
|
+
type: "object",
|
|
128
|
+
additionalProperties: {
|
|
129
|
+
type: "array",
|
|
130
|
+
maxItems: 20,
|
|
131
|
+
items: { type: "string", maxLength: 40 },
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
client: {
|
|
135
|
+
type: "object",
|
|
136
|
+
additionalProperties: false,
|
|
137
|
+
properties: {
|
|
138
|
+
name: { type: "string", maxLength: 80 },
|
|
139
|
+
model: { type: "string", maxLength: 120 },
|
|
140
|
+
skillVersion: { type: "string", maxLength: 40 },
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
function errorMessage(body, status) {
|
|
146
|
+
if (body &&
|
|
147
|
+
typeof body === "object" &&
|
|
148
|
+
"error" in body &&
|
|
149
|
+
typeof body.error === "object" &&
|
|
150
|
+
body.error !== null &&
|
|
151
|
+
typeof body.error.message ===
|
|
152
|
+
"string") {
|
|
153
|
+
return body.error.message;
|
|
154
|
+
}
|
|
155
|
+
if (body &&
|
|
156
|
+
typeof body === "object" &&
|
|
157
|
+
"error" in body &&
|
|
158
|
+
typeof body.error === "string") {
|
|
159
|
+
return body.error;
|
|
160
|
+
}
|
|
161
|
+
return `Paper Reader publish failed (${status})`;
|
|
162
|
+
}
|
|
163
|
+
export const DEFAULT_PAPER_READER_URL = "https://paper-reader-omega.vercel.app";
|
|
164
|
+
export function configFromEnv(env = process.env) {
|
|
165
|
+
const rawUrl = env.PAPER_READER_URL?.trim() || DEFAULT_PAPER_READER_URL;
|
|
166
|
+
const token = env.PAPER_READER_TOKEN?.trim() ?? "";
|
|
167
|
+
if (!rawUrl)
|
|
168
|
+
throw new Error("PAPER_READER_URL is required");
|
|
169
|
+
if (!token)
|
|
170
|
+
throw new Error("PAPER_READER_TOKEN is required");
|
|
171
|
+
let baseUrl;
|
|
172
|
+
try {
|
|
173
|
+
baseUrl = new URL(rawUrl);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
throw new Error("PAPER_READER_URL must be an absolute URL");
|
|
177
|
+
}
|
|
178
|
+
if (baseUrl.protocol !== "https:" && baseUrl.hostname !== "localhost") {
|
|
179
|
+
throw new Error("PAPER_READER_URL must use https, except for localhost");
|
|
180
|
+
}
|
|
181
|
+
return { baseUrl: baseUrl.toString().replace(/\/$/, ""), token };
|
|
182
|
+
}
|
|
183
|
+
export async function publishPaper(config, payload, fetchImpl = fetch) {
|
|
184
|
+
const res = await fetchImpl(`${config.baseUrl}/api/publish`, {
|
|
185
|
+
method: "POST",
|
|
186
|
+
headers: {
|
|
187
|
+
authorization: `Bearer ${config.token}`,
|
|
188
|
+
"content-type": "application/json",
|
|
189
|
+
accept: "application/json",
|
|
190
|
+
},
|
|
191
|
+
body: JSON.stringify(payload),
|
|
192
|
+
signal: AbortSignal.timeout(60_000),
|
|
193
|
+
});
|
|
194
|
+
const body = await res.json().catch(() => null);
|
|
195
|
+
if (!res.ok || !body || typeof body !== "object") {
|
|
196
|
+
const error = body;
|
|
197
|
+
throw new Error(`${errorMessage(body, res.status)}${error?.error?.code ? ` [${error.error.code}]` : ""}`);
|
|
198
|
+
}
|
|
199
|
+
const result = body;
|
|
200
|
+
if (typeof result.url !== "string" || typeof result.slug !== "string") {
|
|
201
|
+
throw new Error("Paper Reader publish response was malformed");
|
|
202
|
+
}
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
export function formatPaperFormat() {
|
|
206
|
+
return [
|
|
207
|
+
INSTRUCTIONS,
|
|
208
|
+
"",
|
|
209
|
+
"JSON Schema:",
|
|
210
|
+
JSON.stringify(SCHEMA, null, 2),
|
|
211
|
+
"",
|
|
212
|
+
"Worked example:",
|
|
213
|
+
JSON.stringify(EXAMPLE, null, 2),
|
|
214
|
+
].join("\n");
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAAA,MAAM,CAA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AK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAClD,EAAE,CACH,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,IAAqB,CAAC;IACrC,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,YAAY;QACZ,EAAE;QACF,cAAc;QACd,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/B,EAAE;QACF,iBAAiB;QACjB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;KACjC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/dist/server.d.ts
ADDED
package/dist/server.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { configFromEnv, formatPaperFormat, publishPaper, } from "./publish.js";
|
|
6
|
+
async function main() {
|
|
7
|
+
const installArgs = new Set(process.argv.slice(2));
|
|
8
|
+
if (installArgs.has("install")) {
|
|
9
|
+
const { install } = await import("./install.js");
|
|
10
|
+
install({ args: process.argv.slice(2) });
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const server = new McpServer({ name: "paper-reader-mcp", version: "0.1.0" });
|
|
14
|
+
server.registerTool("paper_format", {
|
|
15
|
+
title: "Get the Paper Reader publish format",
|
|
16
|
+
description: "Returns the publish JSON Schema and a worked example.",
|
|
17
|
+
inputSchema: {},
|
|
18
|
+
}, async () => {
|
|
19
|
+
const text = formatPaperFormat();
|
|
20
|
+
return {
|
|
21
|
+
content: [{ type: "text", text }],
|
|
22
|
+
isError: false,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
server.registerTool("publish_paper", {
|
|
26
|
+
title: "Publish a BYOM paper",
|
|
27
|
+
description: "Publishes an invented or model-extracted payload to Paper Reader and returns its ephemeral URL.",
|
|
28
|
+
inputSchema: {
|
|
29
|
+
arxivId: z.string(),
|
|
30
|
+
title: z.string(),
|
|
31
|
+
authors: z.array(z.string()),
|
|
32
|
+
paragraphs: z.array(z.record(z.string(), z.unknown())),
|
|
33
|
+
figures: z.array(z.record(z.string(), z.unknown())),
|
|
34
|
+
paraFigureMap: z
|
|
35
|
+
.record(z.string(), z.array(z.string()))
|
|
36
|
+
.optional(),
|
|
37
|
+
client: z.record(z.string(), z.unknown()).optional(),
|
|
38
|
+
},
|
|
39
|
+
}, async (args) => {
|
|
40
|
+
try {
|
|
41
|
+
const config = configFromEnv();
|
|
42
|
+
const payload = { ...args };
|
|
43
|
+
const result = await publishPaper(config, payload);
|
|
44
|
+
const text = `${result.url} (expires ${result.expiresAt}${result.deduped ? "; deduped" : ""})`;
|
|
45
|
+
return {
|
|
46
|
+
content: [{ type: "text", text }],
|
|
47
|
+
isError: false,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const message = error instanceof Error ? error.message : "Publish failed";
|
|
52
|
+
return {
|
|
53
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
54
|
+
isError: true,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const transport = new StdioServerTransport();
|
|
59
|
+
await server.connect(transport);
|
|
60
|
+
}
|
|
61
|
+
await main();
|
|
62
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"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C,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC;YAC5D,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE,EAAE,CAAC;gBACtD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;IAEF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: paper-reader
|
|
3
|
+
description: Use when the user wants to read a PDF-only paper in Paper Reader, or wants an invented worked-example payload for testing. This skill extracts a paper with the user's model and publishes it through Paper Reader; the server never parses the PDF.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Paper Reader: bring your own model
|
|
7
|
+
|
|
8
|
+
## Start
|
|
9
|
+
|
|
10
|
+
1. If the user supplies an arXiv ID, check whether the paper has an HTML or ar5iv reader at `/read/arxiv/<id>`; prefer the deterministic version.
|
|
11
|
+
2. If no deterministic reader exists, or the user wants an invented example, use this skill.
|
|
12
|
+
3. Call `paper_format` first and use its schema and worked example.
|
|
13
|
+
4. Read the PDF natively with the `read` tool. If that fails, follow [rasterization] below.
|
|
14
|
+
5. Emit the payload. Before publishing, ask the user where to save it as a JSON file. Suggest `~/Documents/paper-reader/payloads/paper-reader-<arxivId>.json` by default; use the directory or filename they choose. Do not save payloads inside the paper-reader repository unless the user explicitly asks. Then call `publish_paper`.
|
|
15
|
+
6. Return the published URL and the saved payload path. If the server says `HTML_AVAILABLE`, use its deterministic URL instead; retry on `RATE_LIMITED` or `METADATA_UNAVAILABLE`.
|
|
16
|
+
|
|
17
|
+
## Re-publishing after expiry
|
|
18
|
+
|
|
19
|
+
Save the emitted payload to the user-approved JSON file and note its path.
|
|
20
|
+
Treat that file as the reusable source of truth for the reading link. When the
|
|
21
|
+
link expires, re-send the saved file with `publish_paper` instead of extracting
|
|
22
|
+
the PDF again. If the user has not chosen a location, propose
|
|
23
|
+
`~/Documents/paper-reader/payloads/paper-reader-<arxivId>.json` and wait for
|
|
24
|
+
their confirmation before saving.
|
|
25
|
+
|
|
26
|
+
## Extraction contract
|
|
27
|
+
|
|
28
|
+
- Paragraphs are `p1`, `p2`, … in reading order. Each has plain `text`, sanitized `html`, and ordered `mathTex`.
|
|
29
|
+
- Paragraph HTML may use only `a`, `b`, `i`, `em`, `strong`, `cite`, `sub`, `sup`, `code`, `span`, and `br`.
|
|
30
|
+
- Inline math is `@@K0@@`, `@@K1@@`, … in the same order as `mathTex`.
|
|
31
|
+
- Figures are `f1`, `f2`, …; copy captions verbatim and never invent numbers.
|
|
32
|
+
- A figure uses `tableHtml` or a one-based `pdfPage`, with `bbox` as normalized `[x, y, width, height]`. Do not use `imageUrl`.
|
|
33
|
+
- Include `paraFigureMap` only for mappings the server's regex would miss.
|
|
34
|
+
- `client` selects `name`, `model`, and `skillVersion` so provenance remains useful.
|
|
35
|
+
|
|
36
|
+
## Native PDF reading
|
|
37
|
+
|
|
38
|
+
Use the `read` tool with the user's PDF path. Ask for vision when the attached pages need figures or equations; do not paste PDF bytes into a prompt.
|
|
39
|
+
|
|
40
|
+
## Rasterization
|
|
41
|
+
|
|
42
|
+
When native PDF reading is unavailable, run:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
node ~/.opencode/skills/paper-reader/scripts/crop-figures.mjs <paper.pdf> <output-dir>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If you installed the skill somewhere else, use that directory instead.
|
|
49
|
+
|
|
50
|
+
The script tries `pdftoppm`, then `mutool`, then `pdfimages`. It writes one PNG per page and a JSON manifest with normalized page rectangles. Read those PNGs with `read`, then publish page/bbox data. Rasters never leave the machine.
|
|
51
|
+
|
|
52
|
+
## Results
|
|
53
|
+
|
|
54
|
+
- `201` returns a short-lived handoff URL.
|
|
55
|
+
- `200` with `deduped: true` returns the previous link; do not extend it.
|
|
56
|
+
- `410` means the link expired; re-send the saved payload file with `publish_paper`. Do not re-read the PDF unless the paper or saved payload is stale.
|
|
57
|
+
- `422` means the metadata or figure source was wrong; inspect the expected values in `details` and fix the payload.
|
|
58
|
+
- `409 HTML_AVAILABLE` means the deterministic reader is preferable.
|
|
59
|
+
|
|
60
|
+
## Invented example
|
|
61
|
+
|
|
62
|
+
Use an invented paper only when requested for testing. Keep title, authors, and captions invented and label the example explicitly.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"arxivId": "2401.01234",
|
|
3
|
+
"title": "Invented example with math and a vector figure",
|
|
4
|
+
"authors": ["Jane Example", "Alex Sample"],
|
|
5
|
+
"paragraphs": [
|
|
6
|
+
{
|
|
7
|
+
"id": "p1",
|
|
8
|
+
"text": "The loss falls from 0.90 to 0.42 as shown in Figure 1.",
|
|
9
|
+
"html": "The loss falls from 0.90 to @@K0@@ as shown in <b>Figure 1</b>.",
|
|
10
|
+
"mathTex": ["0.42"]
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"figures": [
|
|
14
|
+
{
|
|
15
|
+
"id": "f1",
|
|
16
|
+
"label": "Figure 1",
|
|
17
|
+
"number": 1,
|
|
18
|
+
"kind": "figure",
|
|
19
|
+
"caption": "Figure 1: Training loss by epoch.",
|
|
20
|
+
"pdfPage": 2,
|
|
21
|
+
"bbox": [0.12, 0.18, 0.76, 0.52]
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"paraFigureMap": { "p1": ["f1"] },
|
|
25
|
+
"client": { "name": "opencode", "model": "model-name", "skillVersion": "0.1.0" }
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://opencode.ai/config.json",
|
|
3
|
+
"mcp": {
|
|
4
|
+
"paper-reader": {
|
|
5
|
+
"type": "local",
|
|
6
|
+
"command": ["npx", "-y", "paper-reader-mcp"],
|
|
7
|
+
"environment": {
|
|
8
|
+
"PAPER_READER_URL": "https://paper-reader-omega.vercel.app",
|
|
9
|
+
"PAPER_READER_TOKEN": "{env:PAPER_READER_TOKEN}"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import {
|
|
5
|
+
copyFileSync,
|
|
6
|
+
existsSync,
|
|
7
|
+
mkdirSync,
|
|
8
|
+
readdirSync,
|
|
9
|
+
writeFileSync,
|
|
10
|
+
} from "node:fs";
|
|
11
|
+
import { basename, extname, join, resolve } from "node:path";
|
|
12
|
+
|
|
13
|
+
const usage = `usage: crop-figures.mjs <paper.pdf> <output-dir>
|
|
14
|
+
|
|
15
|
+
Writes page-0001.png, page-0002.png, ... plus manifest.json.
|
|
16
|
+
Tries pdftoppm, then mutool, then pdfimages.
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const [pdfPath, outputDir] = process.argv.slice(2);
|
|
20
|
+
|
|
21
|
+
if (process.argv.length !== 4 || !pdfPath || !outputDir) {
|
|
22
|
+
console.error(usage);
|
|
23
|
+
process.exit(2);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const pdf = resolve(pdfPath);
|
|
27
|
+
const out = resolve(outputDir);
|
|
28
|
+
|
|
29
|
+
if (!existsSync(pdf)) {
|
|
30
|
+
console.error(`PDF not found: ${pdf}`);
|
|
31
|
+
process.exit(2);
|
|
32
|
+
}
|
|
33
|
+
if (extname(pdf).toLowerCase() !== ".pdf") {
|
|
34
|
+
console.error("input must be a .pdf file");
|
|
35
|
+
process.exit(2);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
mkdirSync(out, { recursive: true });
|
|
39
|
+
|
|
40
|
+
function pageFile(page) {
|
|
41
|
+
return `page-${String(page).padStart(4, "0")}.png`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function normalizeRenderedPages() {
|
|
45
|
+
const rendered = readdirSync(out)
|
|
46
|
+
.filter((name) => /^page-\d+\.png$/.test(name))
|
|
47
|
+
.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
|
48
|
+
const pages = rendered.map((name, index) => {
|
|
49
|
+
const target = pageFile(index + 1);
|
|
50
|
+
if (name !== target) {
|
|
51
|
+
copyFileSync(join(out, name), join(out, target));
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
page: index + 1,
|
|
55
|
+
file: target,
|
|
56
|
+
width: null,
|
|
57
|
+
height: null,
|
|
58
|
+
bbox: null,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
return pages;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const attempts = [
|
|
65
|
+
() => {
|
|
66
|
+
execFileSync("pdftoppm", ["-png", "-r", "150", pdf, join(out, "page")], {
|
|
67
|
+
stdio: "pipe",
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
() => {
|
|
71
|
+
execFileSync(
|
|
72
|
+
"mutool",
|
|
73
|
+
["draw", "-o", join(out, "page-%d.png"), "-r", "150", pdf],
|
|
74
|
+
{ stdio: "pipe" },
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
() => {
|
|
78
|
+
execFileSync("pdfimages", ["-png", pdf, join(out, "page")], {
|
|
79
|
+
stdio: "pipe",
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
let pages = [];
|
|
85
|
+
for (const attempt of attempts) {
|
|
86
|
+
try {
|
|
87
|
+
attempt();
|
|
88
|
+
} catch {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
pages = normalizeRenderedPages();
|
|
92
|
+
if (pages.length > 0) break;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (pages.length === 0) {
|
|
96
|
+
console.error(
|
|
97
|
+
"No page images were created. Install pdftoppm (poppler) or mutool.",
|
|
98
|
+
);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const manifest = {
|
|
103
|
+
pdf: basename(pdf, extname(pdf)),
|
|
104
|
+
pages,
|
|
105
|
+
bboxNote:
|
|
106
|
+
"Coordinates are normalized page-space [x,y,width,height]. Measure from the raster; 0,0 is the top-left.",
|
|
107
|
+
};
|
|
108
|
+
writeFileSync(join(out, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
109
|
+
console.log(`Wrote ${pages.length} page image(s) to ${out}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paper-reader-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Paper Reader MCP tools and OpenCode skill for BYOM publishing.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"paper-reader",
|
|
8
|
+
"mcp",
|
|
9
|
+
"opencode",
|
|
10
|
+
"arxiv",
|
|
11
|
+
"byom"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://paper-reader-omega.vercel.app/docs/pdf-only",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/lealiaxiong/paper-reader/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "lealiaxiong",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/lealiaxiong/paper-reader.git",
|
|
22
|
+
"directory": "mcp"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"skills",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"main": "dist/server.js",
|
|
34
|
+
"bin": {
|
|
35
|
+
"paper-reader-mcp": "dist/server.js"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc -p tsconfig.build.json && rm -rf dist/skills && mkdir -p dist/skills && cp -R ../.opencode/skills/paper-reader dist/skills/paper-reader && cp ../.opencode/skills/paper-reader/opencode.json.example dist/opencode.json.example",
|
|
42
|
+
"prepack": "npm run build",
|
|
43
|
+
"test": "vitest run --config ../../vitest.config.ts mcp/src",
|
|
44
|
+
"typecheck": "tsc --noEmit --project tsconfig.json"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
48
|
+
"zod": "^4.6.7"
|
|
49
|
+
}
|
|
50
|
+
}
|