Empowers AI agents to securely read and extract information (text, metadata, page count) from PDF files within project contexts using a flexible MCP tool.
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.
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)
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)" } } }
git clone https://github.com/sylphlab/pdf-reader-mcp.git
cd pdf-reader-mcp && pnpm install
pnpm run build
(Ensure the host sets the correct{ "mcpServers": { "pdf-reader-mcp": { "command": "node", "args": ["/path/to/cloned/repo/pdf-reader-mcp/build/index.js"], "name": "PDF Reader (Local Build)" } } }
cwd
for the target project)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 } } ] }
read_pdf
tool serves multiple extraction needs (full text, specific pages, metadata, page count).npx
or Docker.pdfjs-dist
for reliable parsing and Zod for input validation.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.
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.
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.
For detailed usage, API reference, and guides, please visit the Full Documentation Website (Link to be updated upon deployment).
This project is licensed under the MIT License.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!