Skip to main content
Glama
README.md
<p align="center">
  <img src="assets/logo.svg" width="92" alt="PDF Reader logo">
</p>

<h1 align="center">PDF Reader — Universal Agent Plugin</h1>

<p align="center">
  <strong>Read local PDFs side-by-side with <em>Antigravity</em>, <em>Claude Desktop</em>, and <em>DeepSeek Harness</em> — highlight, switch to Night Mode, crop equations to ask your agent, and sync live to Typora / Markdown.</strong>
</p>

<p align="center">
  <a href="https://github.com/Aludel/antigravity-pdf-reader/releases/latest"><img src="https://img.shields.io/github/v/release/Aludel/antigravity-pdf-reader?style=flat-square&color=2563eb" alt="Release"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-0ea5e9?style=flat-square" alt="License: MIT"></a>
  <img src="https://img.shields.io/badge/Google-Antigravity-4285F4?style=flat-square" alt="Antigravity">
  <img src="https://img.shields.io/badge/Claude_Desktop-.mcpb-D97757?style=flat-square" alt="Claude Desktop">
  <img src="https://img.shields.io/badge/DeepSeek_Harness-dsh%20%2F%20Cordis-4F46E5?style=flat-square" alt="DeepSeek Harness">
  <img src="https://img.shields.io/badge/Typora-Live%20Sync-10b981?style=flat-square" alt="Typora Live Sync">
</p>

<p align="center">
  <strong>English</strong> · <a href="README.zh-CN.md">简体中文</a>
</p>

<p align="center">
  <img src="assets/demo.svg" width="100%" alt="PDF Reader interactive workflow demo: Highlight, Night Mode, Crop & Ask, and Typora Live Sync">
</p>

---

## 🌐 Works Natively Across Three Agent Ecosystems

| Host | Visual Reader Experience | MCP & Skill Integration | One-Step Install |
| :--- | :--- | :--- | :--- |
| **Google Antigravity** | Docked right-hand sidecar pane (`sidecar://pdf-reader/reader/`) | `plugin.json` + `mcp_config.json` + `SKILL.md` + `AGENTS.md` | `agy plugin install ...` or unzip `pdf-reader-v1.1.0.zip` |
| **Claude Desktop** *(+ Claude Code)* | Local standalone `pdf.js` web reader (`http://127.0.0.1:18765`, auto-launched on `pdf_open`) | One-click `.mcpb` bundle (`manifest.json`) + `claude_desktop_config.json` + `~/.claude/skills` | Double-click `pdf-reader-v1.1.0.mcpb` or `bash bin/install.sh --target claude-desktop` |
| **DeepSeek Harness (`dsh`)** | Local standalone `pdf.js` web reader (`http://127.0.0.1:18765`, auto-launched on `pdf_open`) | Cordis plugin (`package.json`) + `@deepseek-ai/dsh-mcp-client` (`cordis.patch.yml`) + `.agents/skills` | `bash bin/install.sh --target deepseek-harness` |

---

## ✨ Key Features

- **Immersive `pdf.js` 5.4 Reader + Night Mode (`Dark Pages`)**: Smooth continuous reading with an auto-hiding frosted top bar, byte-range streaming for multi-hundred-MB textbooks, one-click **Dark Pages (Night Mode)** (`🌙`), per-book zoom memory, and automatic resume at your last-read page.
- **4-Color Semantic Highlighter & Page Notes**: Mark passages as 🟨 **Key Point**, 🟥 **Hard**, 🟩 **Concept**, or 🟦 **Question**, attach inline comments, or press `H` for **Highlighter Pen Mode** (drag-select to highlight immediately, with full `⌘Z` / `⌘⇧Z` undo & redo).
- **One-Click Ask, Explain, Translate & Formula Crop**:
  - Select text or drag a **Crop** box around dense equations, figures, or tables.
  - **In Antigravity**: Sends directly into the active chat pane and auto-syncs the agent's reply from the session transcript.
  - **In Claude Desktop & DeepSeek Harness**: Queues the question + cropped PNG in `pdf_current().pending_qa` and copies the structured prompt to your clipboard (`⌘V`) — when the agent calls `pdf_save_answer`, its reply appears live in the Reader's **Q&A** tab and Markdown notes!
- **Live Markdown & Typora Sync**: Every highlight, comment, page note, and Q&A pair syncs atomically into `~/Documents/PDF Notes/<Title>.md`, grouped by page while preserving your own handwritten summary block (`<!-- My Notes:start ... -->`). Click **Open in Typora** (`☰` or `⋯`) anytime.
- **11-Tool MCP Server (`pdf_reader_mcp`)**: Gives any MCP-capable agent live awareness of your open PDF, current page, active text selection, high-DPI page renders (`pdf_page_image`), full-text search, and direct PDF highlighting.

---

## 🚀 Installation

### Prerequisites (All Hosts)

- **Node.js** >= 18 (zero `npm install` needed — uses built-in Node APIs only)
- **Python 3** with `mcp` and `pymupdf` (or `uv` installed — the launcher auto-detects conda, Homebrew, system Python, or `uv run`):
  ```bash
  pip install -r requirements.txt
  ```

---

### Quick Install (Any or All Hosts)

Clone the repository anywhere and run the unified installer (automatically backs up existing configs before merging):

```bash
git clone https://github.com/Aludel/antigravity-pdf-reader
cd antigravity-pdf-reader
pip install -r requirements.txt

# Install for all three hosts at once:
bash bin/install.sh --target all

# Or target a single host:
bash bin/install.sh --target antigravity
bash bin/install.sh --target claude-desktop
bash bin/install.sh --target deepseek-harness
```

---

### Host-Specific Setup Details

#### 1. Claude Desktop (One-Click `.mcpb` Extension)

1. Download **`pdf-reader-v1.1.0.mcpb`** from [Releases](https://github.com/Aludel/antigravity-pdf-reader/releases/latest).
2. Double-click `pdf-reader-v1.1.0.mcpb` — or open **Claude Desktop → Settings → Extensions → Advanced settings → Install Extension…** and select the `.mcpb` file.
3. Ask Claude: *"Open `~/Downloads/paper.pdf` on page 4 with PDF Reader"* — your browser opens the interactive reader side-by-side with Claude Desktop!

*(Manual `claude_desktop_config.json` template is also provided in [`integrations/claude-desktop/claude_desktop_config.example.json`](integrations/claude-desktop/claude_desktop_config.example.json).)*

#### 2. DeepSeek Harness (`dsh`)

`bash bin/install.sh --target deepseek-harness` sets up everything automatically:
- Copies `SKILL.md` into `~/.dsh/skills/pdf-reader/SKILL.md` and `~/.agents/skills/pdf-reader/SKILL.md` (and `.agents/skills/pdf-reader/SKILL.md` is bundled in-repo for workspace auto-discovery).
- Registers `pdf_reader_mcp` via `@deepseek-ai/dsh-mcp-client` in `~/.dsh/cordis.patch.yml` ( exposing `mcp__pdf_reader_mcp__pdf_open`, `mcp__pdf_reader_mcp__pdf_current`, etc.) and writes `~/.dsh/mcp.json`.
- Also exports a native Cordis plugin entry (`integrations/deepseek-harness/index.mjs` via root `package.json`). See [`integrations/deepseek-harness/cordis.patch.yml`](integrations/deepseek-harness/cordis.patch.yml) for manual profile patching (`~/.dsh/profiles/web/cordis.patch.yml`).

#### 3. Google Antigravity

```bash
# Option A: agy CLI
agy plugin install https://github.com/Aludel/antigravity-pdf-reader

# Option B: Release zip
mkdir -p ~/.gemini/config/plugins
unzip pdf-reader-v1.1.0.zip -d ~/.gemini/config/plugins/
```

---

## ⌨️ Controls & Shortcuts

| Action | Shortcut / Gesture |
| :--- | :--- |
| Previous / Next page, Jump to page | Scroll, `←` / `→`, or type a page number in the top bar and press `Enter` |
| Zoom & Fit mode | `⌘+` / `⌘-`, trackpad pinch, `⌘0` or click **Width / Page** (saved per document) |
| Night Mode (`Dark Pages`) | Top-right `⋯` → **Dark Pages** |
| Highlight selected text | Select text → click 🟨 **Key Point**, 🟥 **Hard**, 🟩 **Concept**, or 🟦 **Question** |
| Highlighter Pen Mode | Click the pen icon or press `H` (drag-select highlights immediately; `Esc` or `⌘E` exits) |
| Edit / Recolor / Delete / Follow up | Click any existing highlight on the page to open its popover |
| Add a page note | Press `N`, or click **+ Page Note** inside the `☰` Notes drawer |
| Undo / Redo annotations | `⌘Z` / `⌘⇧Z` |
| Ask / Explain / Translate selection | Select text → **Ask**, **Explain**, or **Translate** |
| Crop equation / figure & ask | Press `/` (or click `?`) → **Capture** → **Crop** → drag box → `Enter` |
| Open synced notes in Typora | `☰` drawer → **Open Notes in Typora** (or `⋯` → **Open Notes in Typora**) |

---

## 🛠️ MCP Tools (`pdf_reader_mcp`)

| Tool | Description |
| :--- | :--- |
| `pdf_current` | Returns active PDF, current/visible pages, text selection, `host_mode`, and any queued `pending_qa` |
| `pdf_open` | Opens a local PDF in Antigravity's sidecar pane or launches the standalone `pdf.js` web reader |
| `pdf_read` | Extracts text for a page spec (`"3"`, `"3-5"`, `"1,4,7-9"`, `"current"`, `"all"`) |
| `pdf_search` | Whitespace- and hyphen-tolerant full-text search with context snippets |
| `pdf_outline` | Reads PDF metadata and built-in bookmark hierarchy |
| `pdf_page_image` | Renders any page to PNG (returned as an MCP `Image`) for equations, figures, tables, or scans |
| `pdf_notes` | Lists highlights, comments, page notes, and Q&A items |
| `pdf_add_note` | Adds a page note or draws a colored highlight directly onto the PDF |
| `pdf_edit_note` | Updates a note's comment/color or deletes it |
| `pdf_save_answer` | Archives the agent's answer into the PDF's Q&A tab and synced Markdown file |
| `pdf_export_notes` | Syncs the Markdown note file (`~/Documents/PDF Notes/<Title>.md`) and opens it in Typora or Finder |

---

## 📂 Repository Layout

```text
plugin.json                     Antigravity plugin manifest
manifest.json                   Claude Desktop .mcpb extension manifest
package.json                    DeepSeek Harness (dsh) / Cordis package manifest
.claude-plugin/plugin.json      Claude Code plugin manifest
.agents/skills/pdf-reader/      DeepSeek Harness workspace auto-discovered skill
mcp_config.json                 Antigravity MCP server config
bin/mcp-launcher.mjs            Cross-platform Python/uv auto-discovery stdio launcher
bin/run-mcp-server.sh           POSIX shell launcher & CLI tool runner
bin/install.sh                  Safe multi-host installer (--target antigravity|claude-desktop|deepseek-harness|all)
server/mcp_server.py            FastMCP server + standalone reader supervisor + Markdown store
sidecars/reader/                Dual-mode pdf.js reader (Antigravity sidecar + standalone HTTP server)
integrations/                   Ready-to-use configs for Claude Desktop & DeepSeek Harness (cordis.patch.yml)
skills/pdf-reader/SKILL.md      Cross-host agent skill instructions
rules/AGENTS.md                 Always-on rule for <PDF_READER_REQUEST> prompts
assets/                         Logo (logo.svg, icon.png) & 5-act camera-tracked showcase (demo.svg)
```

---

## 📄 License

Plugin source code is licensed under the [MIT License](LICENSE). Vendored `pdf.js` (`5.4.624`) remains under its original Apache-2.0 license — see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) and [CHANGELOG.md](CHANGELOG.md).