You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pdf-server: add example prompts, testing docs, and updated tools table to README
- Example prompts for annotations, navigation, page extraction, stamps, forms
- Documents how to run E2E tests and API prompt discovery tests
- Updated tools table to include interact tool
- Updated key patterns table with annotations, command queue, file download
- Added pdf-lib to dependencies list
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|`list_pdfs`| Model | List available local files and origins |
162
+
|`display_pdf`| Model + UI | Display interactive viewer |
163
+
|`interact`| Model | Navigate, annotate, search, extract pages, fill forms |
164
+
|`read_pdf_bytes`| App only | Stream PDF data in chunks |
165
+
166
+
## Example Prompts
167
+
168
+
After the model calls `display_pdf`, it receives the `viewUUID` and a description of all capabilities. Here are example prompts and follow-ups that exercise annotation features:
169
+
170
+
### Annotating
171
+
172
+
> **User:** Show me the Attention Is All You Need paper
173
+
>
174
+
> _Model calls `display_pdf` → viewer opens_
175
+
>
176
+
> **User:** Highlight the title and add an APPROVED stamp on the first page.
177
+
>
178
+
> _Model calls `interact` with `highlight_text` for the title and `add_annotations` with a stamp_
179
+
180
+
> **User:** Can you annotate this PDF? Mark important sections for me.
181
+
>
182
+
> _Model calls `interact` with `get_pages` to read content first, then `add_annotations` with highlights/notes_
183
+
184
+
> **User:** Add a note on page 1 saying "Key contribution" at position (200, 500), and highlight the abstract.
185
+
>
186
+
> _Model calls `interact` with `add_annotations` containing a `note` and either `highlight_text` or a `highlight` annotation_
187
+
188
+
### Navigation & Search
189
+
190
+
> **User:** Search for "self-attention" in the paper.
191
+
>
192
+
> _Model calls `interact` with action `search`, query `"self-attention"`_
193
+
194
+
> **User:** Go to page 5.
195
+
>
196
+
> _Model calls `interact` with action `navigate`, page `5`_
# Run annotation E2E tests (renders annotations in a real browser)
224
+
npx playwright test tests/e2e/pdf-annotations.spec.ts
225
+
226
+
# Run all PDF server tests
227
+
npx playwright test -g "PDF Server"
228
+
```
229
+
230
+
### API Prompt Discovery Tests
231
+
232
+
These tests verify that Claude can discover and use annotation capabilities by calling the Anthropic Messages API with the tool schemas. They are **disabled by default** — skipped unless `ANTHROPIC_API_KEY` is set:
233
+
234
+
```bash
235
+
ANTHROPIC_API_KEY=sk-ant-... npx playwright test tests/e2e/pdf-annotations-api.spec.ts
236
+
```
237
+
238
+
The API tests simulate a conversation where `display_pdf` has already been called, then send a follow-up user message and verify the model uses annotation actions (or at least the `interact` tool). Three scenarios are tested:
239
+
240
+
| Scenario | User prompt | Expected model behavior |
0 commit comments