Cover image
Try Now
2025-04-07

An MCP server built with Node.js/TypeScript that allows AI agents to securely read PDF files (local or URL) and extract text, metadata, or page counts. Uses pdf-parse.

3 years

Works with Finder

1

Github Watches

0

Github Forks

4

Github Stars

PDF Reader MCP Server (@sylphlab/pdf-reader-mcp)

CI/CD Pipeline codecov npm version Docker Pulls License: MIT

Empower your AI agents (like Cline) with the ability to securely read and extract information (text, metadata, page count) from PDF files within your project context using a single, flexible tool.

Installation

Using npm (Recommended)

Install as a dependency in your MCP host environment or project:

pnpm add @sylphlab/pdf-reader-mcp # Or npm install / yarn add

Configure your MCP host (e.g., mcp_settings.json) to use npx:

{
  "mcpServers": {
    "pdf-reader-mcp": {
      "command": "npx",
      "args": ["@sylphlab/pdf-reader-mcp"],
      "name": "PDF Reader (npx)"
    }
  }
}

(Ensure the host sets the correct cwd for the target project)

Using Docker

Pull the image:

docker pull sylphlab/pdf-reader-mcp:latest

Configure your MCP host to run the container, mounting your project directory to /app:

{
  "mcpServers": {
    "pdf-reader-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "/path/to/your/project:/app", // Or use "$PWD:/app", "%CD%:/app", etc.
        "sylphlab/pdf-reader-mcp:latest"
      ],
      "name": "PDF Reader (Docker)"
    }
  }
}

Local Build (For Development)

  1. Clone: git clone https://github.com/sylphlab/pdf-reader-mcp.git
  2. Install: cd pdf-reader-mcp && pnpm install
  3. Build: pnpm run build
  4. Configure MCP Host:
    {
      "mcpServers": {
        "pdf-reader-mcp": {
          "command": "node",
          "args": ["/path/to/cloned/repo/pdf-reader-mcp/build/index.js"],
          "name": "PDF Reader (Local Build)"
        }
      }
    }
    
    (Ensure the host sets the correct cwd for the target project)

Quick Start

Assuming the server is running and configured in your MCP host:

MCP Request (Get metadata and page 2 text from a local PDF):

{
  "tool_name": "read_pdf",
  "arguments": {
    "sources": [
      {
        "path": "./documents/my_report.pdf",
        "pages": [2]
      }
    ],
    "include_metadata": true,
    "include_page_count": false, // Default is true, explicitly false here
    "include_full_text": false // Ignored because 'pages' is specified
  }
}

Expected Response Snippet:

{
  "results": [
    {
      "source": "./documents/my_report.pdf",
      "success": true,
      "data": {
        "page_texts": [
          { "page": 2, "text": "Text content from page 2..." }
        ],
        "info": { ... },
        "metadata": { ... }
        // num_pages not included as requested
      }
    }
  ]
}

Why Choose This Project?

  • 🛡️ Secure: Confines file access strictly to the project root directory.
  • 🌐 Flexible: Handles both local relative paths and public URLs.
  • 🧩 Consolidated: A single read_pdf tool serves multiple extraction needs (full text, specific pages, metadata, page count).
  • ⚙️ Structured Output: Returns data in a predictable JSON format, easy for agents to parse.
  • 🚀 Easy Integration: Designed for seamless use within MCP environments via npx or Docker.
  • ✅ Robust: Uses pdfjs-dist for reliable parsing and Zod for input validation.

Performance Advantages

Initial benchmarks using Vitest on a sample PDF show efficient handling of various operations:

Scenario Operations per Second (hz) Relative Speed
Handle Non-Existent File ~12,933 Fastest
Get Full Text ~5,575
Get Specific Page (Page 1) ~5,329
Get Specific Pages (Pages 1 & 2) ~5,242
Get Metadata & Page Count ~4,912 Slowest

(Higher hz indicates better performance. Results may vary based on PDF complexity and environment.)

See the Performance Documentation for more details and future plans.

Features

  • Read full text content from PDF files.
  • Read text content from specific pages or page ranges.
  • Read PDF metadata (author, title, creation date, etc.).
  • Get the total page count of a PDF.
  • Process multiple PDF sources (local paths or URLs) in a single request.
  • Securely operates within the defined project root.
  • Provides structured JSON output via MCP.
  • Available via npm and Docker Hub.

Design Philosophy

The server prioritizes security through context confinement, efficiency via structured data transfer, and simplicity for easy integration into AI agent workflows. It aims for minimal dependencies, relying on the robust pdfjs-dist library.

See the full Design Philosophy documentation.

Comparison with Other Solutions

Compared to direct file access (often infeasible) or generic filesystem tools, this server offers PDF-specific parsing capabilities. Unlike external CLI tools (e.g., pdftotext), it provides a secure, integrated MCP interface with structured output, enhancing reliability and ease of use for AI agents.

See the full Comparison documentation.

Future Plans (Roadmap)

  • Documentation:
    • Finalize all documentation sections (Guide, API, Design, Comparison).
    • Resolve TypeDoc issue and generate API documentation.
    • Add more examples and advanced usage patterns.
    • Implement PWA support and mobile optimization for the docs site.
    • Add share buttons and growth metrics to the docs site.
  • Benchmarking:
    • Conduct comprehensive benchmarks with diverse PDF files (size, complexity).
    • Measure memory usage.
    • Compare URL vs. local file performance.
  • Core Functionality:
    • Explore potential optimizations for very large PDF files.
    • Investigate options for extracting images or annotations (longer term).
  • Testing:
    • Increase test coverage towards 100% where practical.
    • Add runtime tests once feasible.

Documentation

For detailed usage, API reference, and guides, please visit the Full Documentation Website (Link to be updated upon deployment).

Community & Support

  • Found a bug or have a feature request? Please open an issue on GitHub Issues.
  • Want to contribute? We welcome contributions! Please see CONTRIBUTING.md.
  • Star & Watch: If you find this project useful, please consider starring ⭐ and watching 👀 the repository on GitHub to show your support and stay updated!

License

This project is licensed under the MIT License.

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • 林乔安妮
  • A fashion stylist GPT offering outfit suggestions for various scenarios.

  • apappascs
  • Discover the most comprehensive and up-to-date collection of MCP servers in the market. This repository serves as a centralized hub, offering an extensive catalog of open-source and proprietary MCP servers, complete with features, documentation links, and contributors.

  • ShrimpingIt
  • Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx

  • pontusab
  • The Cursor & Windsurf community, find rules and MCPs

  • av
  • Effortlessly run LLM backends, APIs, frontends, and services with one command.

  • GeyserMC
  • A library for communication with a Minecraft client/server.

  • Mintplex-Labs
  • The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.

  • awslabs
  • AWS MCP Servers — specialized MCP servers that bring AWS best practices directly to your development workflow

  • 1Panel-dev
  • 🔥 1Panel provides an intuitive web interface and MCP Server to manage websites, files, containers, databases, and LLMs on a Linux server.

  • modelcontextprotocol
  • Model Context Protocol Servers

    Reviews

    1 (1)
    Avatar
    user_R2UXPMgM
    2025-04-17

    As a dedicated user of pdf-reader-mcp, I am extremely impressed by its performance and user-friendly interface. Created by sylphlab, this tool provides a seamless PDF reading experience. It's open-source and available on GitHub, allowing easy access and contributions from the community. Highly recommended for anyone needing a reliable PDF reader.