Skip to content

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

@EliottDelhaye

Description

@EliottDelhaye

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions