modelcontextprotocol / modelcontextprotocol/ext-apps

server-pdf: get_viewer_state always returns pageCount: 1 and get_text returns empty in VS Code

Open
#617 0 comments 0 reactions 0 assignees View on GitHub

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_state should return the correct page count
  • get_text should extract text content from PDF pages
  • get_screenshot should return a page image

Actual Behavior

For every PDF tested:

  • get_viewer_state returns { currentPage: 1, pageCount: 1, zoom: 100, ... }
  • get_text returns --- Page 1 --- with no text content
  • get_screenshot returns ERROR: No screenshot returned
  • The totalBytes in the display_pdf response is correct, suggesting the file is loaded by the server

Reproduction Steps
  1. Configure the server in VS Code user mcp.json:
    {
      "servers": {
        "pdf": {
          "command": "npx",
          "args": ["-y", "@modelcontextprotocol/server-pdf", "--stdio"]
        }
      }
    }
    
  2. Open GitHub Copilot Chat (Agent mode)
  3. Ask it to display any PDF, for example the default arxiv paper:
    display_pdf with url https://arxiv.org/pdf/1706.03762
    
  4. Then ask it to get the viewer state or extract text:
    get_viewer_state
    get_text page 1
    
  5. Observe: pageCount is 1, text is empty

PDFs Tested (all show same behavior)
PDF 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.