pdflens-mcp

m13253/pdflens-mcp

3.3

If you are the rightful owner of pdflens-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

An MCP server for reading PDFs, coded by human, designed for AI.

Tools
4
Resources
0
Prompts
0

pdflens-mcp

Download the crate from crates.io

An MCP server for reading PDFs, coded by human, designed for AI.

Provided tools

  • get_pdf_num_pages
  • read_pdf_as_text
  • read_pdf_page_as_image

‡ Not all MCP clients support images.

Usage

  1. Install Rust compiler: https://rustup.rs/

  2. Download and build pdflens-mcp from crates.io

    cargo install pdflens-mcp
    

    Usually, the program is installed to $HOME/.cargo/bin/pdflens-mcp. You can use cargo install --root /another/path pdflens-mcp to set a custom installation path.

  3. Add this MCP server to your MCP client of choice.

    (Note: We use sh to expand ~ to your actual home directory. If you are using Microsoft Windows, please instead put the full path to pdflens-mcp.exe to "command" and leave "args" empty.)

    1. If your MCP client supports mcp.json:

      {
        "mcpServers": {
          "pdflens": {
            "command": "sh",
            "args": ["-c", "exec ~/.cargo/bin/pdflens-mcp"]
          }
        }
      }
      
    2. Visual Studio Code:

      code --add-mcp "{\"name\": \"pdflens\", \"command\": \"sh\", \"args\": [\"-c\", \"exec ~/.cargo/bin/pdflens-mcp\"]}"
      
    3. Continue.dev

      mcpServers:
        - name: pdflens
          command: sh
          args:
            - -c
            - exec ~/.cargo/bin/pdflens-mcp
      
    4. Codex

      [mcp_servers.pdflens]
      command = "sh"
      args = ["-c", "exec ~/.cargo/bin/pdflens-mcp"]
      

Path sandboxing

Pdflens is designed to only read PDFs located within the user’s workspace directories, also called MCP root directories.

Each time before reading the PDFs, it checks the file path after resolving any symbolic links. If the PDF exists but is outside any user’s workspace directories, pdflens will return an error, asking the user to check the root path settings.

If your MCP client doesn’t specify a root path, pdflens will fallback to the current directory it is started in.

{
  "mcpServers": {
    "pdflens": {
      "command": "sh",
      "args": ["-c", "exec ~/.cargo/bin/pdflens-mcp"],
      "cwd": "/path/to/workspace/if/root/path/is/unsupported"
    }
  }
}

Known issue

  1. pdflens uses pdf-extract to extract text from PDFs. It is not perfect and may crash with some PDFs. I am waiting for a new feature that is recently added into hayro#457 to release. Switching the extraction library to hayro will hopefully support more PDFs.

Not-vibe-coded declaration

This project is developed mainly with human effort. I have throughoutly read and checked every piece of code in this repository to ensure its quality.