MP

m13253/pdflens-mcp

Developer tools
20 stars 0 forks Quality 50 Trend 31

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

Overview

An MCP server for reading PDFs, coded by human, designed for AI. Pdflens MCP is designed to use the MCP Root mechanism for privacy and security boundary within workspaces, so the user can auto-approve all Pdflens MCP tool calls, knowing that LLMs will not accidentally upload PDF contents outside user’s workspaces to LLM inference providers. However, MCP decided to deprecate the Root mechanism (SEP-2577), and will remove it at around June 2027. The documentation also states that my approach to use MCP Root for access control is wrong. Until MCP provides an alternative mechanism (e.g., SEP-1708), maintaining the core functionality of this MCP Server is impossible. Therefore, I am pausing the maintenance of this project until I find any alternative method to allow auto-approved PDF reading. Current coding agents may still be able to use Pdflens MCP for now, but newer coding agents will eventually be incompatible with it.

README

pdflens-mcp

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

⚠️ Out-of-maintenance notice ⚠️

Pdflens MCP is designed to use the MCP Root mechanism for privacy and security boundary within workspaces, so the user can auto-approve all Pdflens MCP tool calls, knowing that LLMs will not accidentally upload PDF contents outside user’s workspaces to LLM inference providers.

However, MCP decided to deprecate the Root mechanism (SEP-2577), and will remove it at around June 2027. The documentation also states that my approach to use MCP Root for access control is wrong.

Until MCP provides an alternative mechanism (e.g., SEP-1708), maintaining the core functionality of this MCP Server is impossible. Therefore, I am pausing the maintenance of this project until I find any alternative method to allow auto-approved PDF reading. Current coding agents may still be able to use Pdflens MCP for now, but newer coding agents will eventually be incompatible with it.

When the day comes, please try other options, for example, running pdftotext and pdftoppm commands inside terminal sandboxes. VS Code supports sandboxes since 1.109, and Zed since 1.14.2. For OCR requirements, please check Firecrawl/pdf-inspector.

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 --git https://codeberg.org/m13253/pdflens-mcp.git 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. Codex

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

      mcpServers:
        - name: pdflens
          command: sh
          args:
            - -c
            - exec ~/.cargo/bin/pdflens-mcp
      
    5. Kilo Code

      {
        "mcpServers": {
          "pdflens": {
              "command": "sh",
              "args": ["-c", "exec ~/.cargo/bin/pdflens-mcp"],
              "alwaysAllow": [
                  "get_pdf_num_pages",
                  "read_pdf_as_text"
              ],
              "disabledTools": ["read_pdf_page_as_image"]
          }
        }
      }
      
    6. Roo Code

      {
        "mcpServers": {
          "pdflens": {
              "command": "sh",
              "args": ["-c", "exec ~/.cargo/bin/pdflens-mcp"],
              "alwaysAllow": [
                  "get_pdf_num_pages",
                  "read_pdf_as_text",
                  "read_pdf_page_as_image"
              ]
          }
        }
      }
      
    7. Zed

      {
        "agent": {
          "tool_permissions": {
            "tools": {
              "mcp:pdflens:get_pdf_num_pages": {"default": "allow"},
              "mcp:pdflens:read_pdf_as_text": {"default": "allow"},
              "mcp:pdflens:read_pdf_page_as_image": {"default": "allow"}
            }
          }
        },
        "context_servers": {
          "pdflens": {
            "command": "sh",
            "args": ["-c", "exec ~/.cargo/bin/pdflens-mcp"],
            "remote": true,
            "enabled": true,
          }
        }
      }
      

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"
    }
  }
}

Running pdflens-mcp on remote development environments

Some IDEs and editors allows you to specify where pdflens-mcp runs, so it can access remote files.

On Visual Studio Code, write the MCP configuration on remote workspace settings.

On Zed, specify "remote": true.

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 pdf-extract#142 to land on its master branch.

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.

View the full README on GitHub

Install

This server does not publish a one-line install command.

Open the repository installation guide New to MCP? Start with the mcpskill.org guide →

Configuration

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