PDF Reader MCP server

Securely extracts text, metadata, and page information from PDF files within a project directory using pdfjs-dist for both local files and remote URLs.
Back to servers
Provider
shtse8
Release date
Apr 05, 2025
Language
TypeScript
Package
Stats
1.2K downloads
43 stars

PDF Reader MCP Server is a tool that enables AI agents to securely extract text, metadata, and page count information from PDF files within your project context. It provides a structured interface for reading PDFs through the Model Context Protocol (MCP).

Installation

Using npm

Install the package in your MCP host environment:

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

Configure your MCP host settings (e.g., in mcp_settings.json):

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

Using Docker

Pull the Docker image:

docker pull sylphlab/pdf-reader-mcp:latest

Configure your MCP host to use the Docker container:

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

Usage Examples

Once you've configured the server in your MCP host, you can send requests to it for processing PDF files.

Basic Example

To retrieve metadata and text from a specific page:

{
  "tool_name": "read_pdf",
  "arguments": {
    "sources": [
      {
        "path": "./documents/my_report.pdf",
        "pages": [2]
      }
    ],
    "include_metadata": true,
    "include_page_count": false,
    "include_full_text": false
  }
}

The server will respond with structured JSON:

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

Reading Multiple PDFs

You can process multiple PDF files in a single request:

{
  "tool_name": "read_pdf",
  "arguments": {
    "sources": [
      {
        "path": "./documents/first.pdf"
      },
      {
        "path": "./documents/second.pdf",
        "pages": [1, 2, 3]
      }
    ],
    "include_metadata": true
  }
}

Using URL Sources

The server can also process PDFs from URLs:

{
  "tool_name": "read_pdf",
  "arguments": {
    "sources": [
      {
        "path": "https://example.com/sample.pdf"
      }
    ]
  }
}

Features

The PDF Reader MCP Server offers several capabilities:

  • Text Extraction: Get full text or specific pages from PDFs
  • Metadata Access: Retrieve author, title, creation date, etc.
  • Page Count: Get the total number of pages
  • Multiple Sources: Process several PDFs in one request
  • Path Flexibility: Use local files or URLs
  • Security: Confined to project root directory
  • Structured Output: Clean JSON format for easy parsing

Configuration Options

When making requests, you can customize behavior with these parameters:

Source Options

  • path: Path to the PDF file (relative to project root) or URL
  • pages: Optional array of page numbers to extract (1-based indexing)

Global Options

  • include_metadata: Include document metadata (default: false)
  • include_page_count: Include total page count (default: true)
  • include_full_text: Extract all text if no pages specified (default: true)

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later