@modelcontextprotocol/server-pdf 1.2.2 → 1.3.1

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/dist/server.d.ts CHANGED
@@ -10,6 +10,15 @@
10
10
  * - read_pdf_bytes: Stream PDF data in chunks (used by viewer)
11
11
  */
12
12
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
13
+ /**
14
+ * PDF Standard-14 fonts from CDN. Used by both server and viewer so we
15
+ * declare a single well-known origin in CSP connectDomains.
16
+ *
17
+ * pdf.js in Node defaults to NodeStandardFontDataFactory (fs.readFile) which
18
+ * can't fetch URLs, so we pass {@link FetchStandardFontDataFactory} alongside.
19
+ * The browser viewer uses the DOM factory by default and just needs the URL.
20
+ */
21
+ export declare const STANDARD_FONT_DATA_URL: string;
13
22
  export declare const DEFAULT_PDF = "https://arxiv.org/pdf/1706.03762";
14
23
  export declare const MAX_CHUNK_BYTES: number;
15
24
  export declare const RESOURCE_URI = "ui://pdf-viewer/mcp-app.html";
@@ -19,10 +28,54 @@ export declare const CACHE_INACTIVITY_TIMEOUT_MS = 10000;
19
28
  export declare const CACHE_MAX_LIFETIME_MS = 60000;
20
29
  /** Max size for cached PDFs (defensive limit to prevent memory exhaustion) */
21
30
  export declare const CACHE_MAX_PDF_SIZE_BYTES: number;
22
- /** Allowed local file paths (populated from CLI args) */
31
+ /** Allowed local file paths (CLI args + file roots — read access). */
23
32
  export declare const allowedLocalFiles: Set<string>;
24
- /** Allowed local directories (populated from MCP roots) */
33
+ /** Allowed local directories (CLI args + directory roots — read access). */
25
34
  export declare const allowedLocalDirs: Set<string>;
35
+ /**
36
+ * Subset of allowedLocalFiles that came from CLI args (not MCP roots).
37
+ * Only these individual files are writable. File roots from the client
38
+ * are uploaded copies in ad-hoc hidden folders — treat as read-only.
39
+ * Directory roots are mounted folders; files UNDER them are writable.
40
+ */
41
+ export declare const cliLocalFiles: Set<string>;
42
+ /**
43
+ * Write-permission flags. Object wrapper (not a bare `let`) so main.ts can
44
+ * mutate via the exported binding without re-import gymnastics — same
45
+ * pattern as the Sets above.
46
+ */
47
+ export declare const writeFlags: {
48
+ /**
49
+ * Claude Desktop mounts its per-conversation drop folder as a directory
50
+ * root whose basename is literally `uploads`. Files in there are one-shot
51
+ * copies the client doesn't expect us to overwrite. Default: read-only.
52
+ * `--writeable-uploads-root` flips this for local testing.
53
+ */
54
+ allowUploadsRoot: boolean;
55
+ };
56
+ /**
57
+ * Saving is allowed iff:
58
+ * (a) the file was passed as a CLI arg — the user explicitly named it
59
+ * when starting the server, so overwriting is clearly intentional; OR
60
+ * (b) the file is STRICTLY UNDER a directory root at any depth
61
+ * (isAncestorDir excludes rel === "", so the root itself never
62
+ * counts), AND the client did not ALSO send it as a file root.
63
+ * A file root is the client's way of saying "here's an upload" —
64
+ * treat that signal as authoritative even when the path happens
65
+ * to fall inside a mounted directory.
66
+ *
67
+ * EXCEPTION to (b): a dir root whose basename is `uploads` is treated
68
+ * as read-only unless `writeFlags.allowUploadsRoot` is set. This is how
69
+ * Claude Desktop surfaces attached files — writing back to them
70
+ * surprises the user (the attachment doesn't update).
71
+ *
72
+ * With no directory roots and no CLI files, nothing is writable.
73
+ */
74
+ export declare function isWritablePath(resolved: string): boolean;
75
+ import type { PdfCommand } from "./src/commands.js";
76
+ export type { PdfCommand };
77
+ export declare function startFileWatch(viewUUID: string, filePath: string): void;
78
+ export declare function stopFileWatch(viewUUID: string): void;
26
79
  export declare function isFileUrl(url: string): boolean;
27
80
  export declare function isArxivUrl(url: string): boolean;
28
81
  export declare function normalizeArxivUrl(url: string): string;
@@ -64,6 +117,13 @@ export interface PdfCache {
64
117
  */
65
118
  export declare function createPdfCache(): PdfCache;
66
119
  export interface CreateServerOptions {
120
+ /**
121
+ * Enable the `interact` tool and related command-queue infrastructure
122
+ * (in-memory command queue, `poll_pdf_commands`, `submit_page_data`).
123
+ * Only suitable for single-instance deployments (e.g. stdio transport).
124
+ * Defaults to false — server exposes only `list_pdfs` and `display_pdf` (read-only).
125
+ */
126
+ enableInteract?: boolean;
67
127
  /**
68
128
  * Whether to honour MCP roots sent by the client.
69
129
  *
@@ -83,5 +143,10 @@ export interface CreateServerOptions {
83
143
  * @default false
84
144
  */
85
145
  useClientRoots?: boolean;
146
+ /**
147
+ * Emit debug metadata to the viewer (currently: allowed roots shown
148
+ * in a floating bubble). Toggled by the `--debug` CLI flag.
149
+ */
150
+ debug?: boolean;
86
151
  }
87
152
  export declare function createServer(options?: CreateServerOptions): McpServer;