modelcontextprotocol / modelcontextprotocol/ext-apps
server-pdf: get_viewer_state always returns pageCount: 1 and get_text returns empty in VS Code
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 387
- Avg merge
- 3h 21m
- Merged PRs (30d)
- 6
Description
Summary
When using @modelcontextprotocol/server-pdf (v1.6.0) in VS Code with GitHub Copilot Chat, display_pdf opens a viewer but get_viewer_state always reports pageCount: 1 and get_text returns empty content for all PDFs -- local files and remote URLs alike.
Expected Behavior
get_viewer_stateshould return the correct page countget_textshould extract text content from PDF pagesget_screenshotshould return a page image
Actual Behavior
For every PDF tested:
get_viewer_statereturns{ currentPage: 1, pageCount: 1, zoom: 100, ... }get_textreturns--- Page 1 ---with no text contentget_screenshotreturnsERROR: No screenshot returned- The
totalBytesin thedisplay_pdfresponse is correct, suggesting the file is loaded by the server
Reproduction Steps
- Configure the server in VS Code user
mcp.json:{ "servers": { "pdf": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-pdf", "--stdio"] } } } - Open GitHub Copilot Chat (Agent mode)
- Ask it to display any PDF, for example the default arxiv paper:
display_pdf with url https://arxiv.org/pdf/1706.03762 - Then ask it to get the viewer state or extract text:
get_viewer_state get_text page 1 - Observe: pageCount is 1, text is empty
PDFs Tested (all show same behavior)
| Type | Pages (pdfinfo) | Pages (MCP) | Text (MCP) | |
|---|---|---|---|---|
| Local LaTeX Beamer slides (362x272 pts) | Local file | 51 | 1 | empty |
| Local pdflatex A4 article | Local file | 3 | 1 | empty |
https://arxiv.org/pdf/1706.03762 (Attention paper) |
Remote URL | 15 | 1 | empty |
All PDFs have verified text content via pdftotext and correct page counts via pdfinfo.
Environment
- VS Code: latest stable (April 2026)
- GitHub Copilot Chat extension: v0.44.1
- server-pdf version: 1.6.0 (latest)
- OS: macOS (Apple Silicon)
- Node: via npx
Analysis
The display_pdf tool returns a correct totalBytes value, so the server reads the file. The issue appears to be that get_viewer_state and get_text query the PDF.js viewer (MCP App), but the viewer either hasn't finished loading the document or isn't properly communicating its state back through the command queue.
This could be a timing issue (commands sent before PDF.js finishes rendering) or a VS Code MCP App host issue where the iframe doesn't properly initialize.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue through display_pdf, then inspect the PDF.js viewer interactions behind get_viewer_state, get_text, and get_screenshot, including the command queue and iframe communication. Compare behavior for local and remote PDFs; done means correct page counts, extracted text, and screenshots are returned in VS Code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100