Skip to content

Commit 91880a6

Browse files
committed
feat(pdf-server): rewrite display_pdf prompts to steer model toward interact
The model was calling display_pdf again to add annotations instead of using interact with the existing viewUUID. Root cause: the description's first two sentences invited exactly that -- 'Use this to display, annotate, edit, and fill form fields' 'when the user wants to ... annotate, edit, sign, stamp' -- then the CRITICAL warning arrived three paragraphs later, after the model had already pattern-matched 'user wants to sign' -> display_pdf. Three changes: - First sentence is now narrow: 'Open a PDF. Call this ONCE per PDF.' - Follow-up-actions-go-through-interact is sentence 2, not paragraph 3. - Result text is directive at the decision point: tells the model to call interact with the viewUUID, warns against re-calling display_pdf.
1 parent 391bd5b commit 91880a6

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

examples/pdf-server/server.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,16 +1228,14 @@ export function createServer(options: CreateServerOptions = {}): McpServer {
12281228
Use this tool when the user wants to view or read a PDF. The renderer displays the document for viewing.
12291229
12301230
Accepts local files (use list_pdfs), client MCP root directories, or any HTTPS URL.`
1231-
: `Show and render a PDF in an interactive viewer. Use this to display, annotate, edit, and fill form fields in PDF documents.
1231+
: `Open a PDF in an interactive viewer. Call this ONCE per PDF.
12321232
1233-
Use this tool when the user wants to view, read, annotate, edit, sign, stamp, or fill out a PDF. The renderer displays the document with full annotation, signature/image placement, and form support.
1233+
**All follow-up actions go through the \`interact\` tool** with the returned viewUUID — annotating, signing, stamping, filling forms, navigating, searching, extracting text/screenshots. Calling display_pdf again creates a second viewer and discards the existing one with all its state.
12341234
1235-
**CRITICAL — DO NOT call display_pdf again on an already-displayed PDF.** Use the \`interact\` tool with the viewUUID from the result instead. Calling display_pdf again discards the existing viewer and all its state.
1236-
1237-
Returns a viewUUID in structuredContent. Use it with \`interact\` for follow-up actions:
1238-
- navigate, search, find, search_navigate, zoom
1235+
Returns a viewUUID in structuredContent. Pass it to \`interact\`:
12391236
- add_annotations, update_annotations, remove_annotations, highlight_text
12401237
- fill_form (fill PDF form fields)
1238+
- navigate, search, find, search_navigate, zoom
12411239
- get_text, get_screenshot (extract content)
12421240
12431241
Accepts local files (use list_pdfs), client MCP root directories, or any HTTPS URL.
@@ -1402,7 +1400,12 @@ Set \`elicit_form_inputs\` to true to prompt the user to fill form fields before
14021400
type: "text",
14031401
text: disableInteract
14041402
? `Displaying PDF: ${normalized}`
1405-
: `Displaying PDF: ${normalized} (viewUUID: ${uuid})`,
1403+
: `PDF opened. viewUUID: ${uuid}
1404+
1405+
→ To annotate, sign, stamp, fill forms, navigate, or extract: call \`interact\` with this viewUUID.
1406+
→ DO NOT call display_pdf again — that creates a second viewer and loses all state.
1407+
1408+
URL: ${normalized}`,
14061409
},
14071410
];
14081411

0 commit comments

Comments
 (0)