mcp-pdf-reader
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-pdf-readershow me the contents of report.pdf"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP PDF Reader
一个基于 Model Context Protocol (MCP) 的 PDF 文件读取服务器,为 AI 助手(如 Claude)提供强大的 PDF 文件处理能力。
功能特性
📖 读取 PDF 文件:提取 PDF 文件的完整文本内容
📊 获取 PDF 元数据:获取文件信息(标题、作者、页数、创建日期等)
📄 按页读取:支持读取指定页面范围的内容
🔍 文本搜索:在 PDF 中搜索特定文本,支持大小写敏感搜索
⚡ 稳定可靠:使用 CommonJS 方式加载 pdf-parse,避免 ESM 兼容性问题
🛡️ 错误处理:完善的错误处理和用户友好的错误信息
Related MCP server: PDF Reader MCP Server
安装
前置要求
Node.js 16.0 或更高版本
npm 或 yarn
安装步骤
克隆仓库:
git clone https://github.com/DonChengCheng/mcp-pdf-reader.git
cd mcp-pdf-reader安装依赖:
npm install构建项目:
npm run build配置使用
在 Claude Desktop 中使用
在 Claude Desktop 的配置文件中添加以下配置:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"pdf-reader": {
"command": "node",
"args": ["/path/to/mcp-pdf-reader/build/index.js"]
}
}
}将 /path/to/mcp-pdf-reader 替换为实际的项目路径。
重启 Claude Desktop 后,即可在对话中使用 PDF 读取功能。
可用工具
1. read_pdf
读取 PDF 文件的完整文本内容。
参数:
file_path(string, 必需): PDF 文件的路径
使用示例:
请读取文件 /Users/xxx/Documents/report.pdf返回:
PDF 文件的完整文本内容
总页数信息
2. get_pdf_info
获取 PDF 文件的元数据信息。
参数:
file_path(string, 必需): PDF 文件的路径
返回信息:
文件路径、文件名、文件大小
页数
标题、作者、创建者、制作者
创建日期、修改日期
文本字符数、文本行数
使用示例:
获取 /Users/xxx/Documents/report.pdf 的详细信息3. read_pages
读取 PDF 文件的特定页面范围。
参数:
file_path(string, 必需): PDF 文件的路径start_page(number, 必需): 起始页码(从 1 开始)end_page(number, 可选): 结束页码(从 1 开始)
使用示例:
读取文件 /Users/xxx/Documents/report.pdf 的第 5 到第 10 页4. search_in_pdf
在 PDF 文件中搜索特定文本。
参数:
file_path(string, 必需): PDF 文件的路径search_text(string, 必需): 要搜索的文本case_sensitive(boolean, 可选): 是否大小写敏感,默认为 false
使用示例:
在文件 /Users/xxx/Documents/report.pdf 中搜索 "重要数据"返回:
匹配项的总数
包含匹配文本的行(最多显示前 10 个)
每个匹配项的行号
开发
项目结构
mcp-pdf-reader/
├── src/
│ └── index.ts # 主服务器代码
├── build/ # 编译后的 JavaScript 文件
├── package.json # 项目配置
├── tsconfig.json # TypeScript 配置
├── .gitignore # Git 忽略文件
└── README.md # 本文档开发命令
npm run build- 构建项目npm run watch- 监视文件变化并自动重新构建npm run inspector- 运行 MCP 检查器进行调试
技术实现
ESM 与 CommonJS 兼容性处理
项目使用 ESM 模块系统,但通过 createRequire 方法加载 CommonJS 模块:
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const pdf = require('pdf-parse');这种方式确保了与 pdf-parse 库的完美兼容。
错误处理机制
文件存在性检查
PDF 文件格式验证
页码范围验证
详细的错误信息返回
性能优化
搜索结果限制(最多显示前 10 个匹配项)
大文件处理优化
内存友好的流式处理
技术栈
TypeScript: 类型安全的开发语言
@modelcontextprotocol/sdk: MCP 官方 SDK
pdf-parse: PDF 文件解析库
canvas: PDF 渲染支持(pdf-parse 的依赖)
限制和注意事项
文本提取限制:目前只支持文本内容提取,不支持:
图片提取
表格结构保持
复杂格式保留
页面分离:由于 pdf-parse 库的限制,按页读取功能目前返回的是全文内容
搜索结果:为避免输出过长,搜索结果最多显示前 10 个匹配项
文件大小:处理超大 PDF 文件时可能需要更多内存
故障排除
常见问题
Canvas 编译错误
确保系统安装了必要的编译工具
macOS: 安装 Xcode Command Line Tools
Windows: 安装 windows-build-tools
Linux: 安装 build-essential
PDF 解析失败
检查 PDF 文件是否损坏
确认文件路径是否正确
验证文件权限
MCP 连接失败
检查配置文件路径是否正确
确保构建后的文件存在
重启 Claude Desktop
贡献指南
欢迎贡献代码!请遵循以下步骤:
Fork 本仓库
创建功能分支 (
git checkout -b feature/AmazingFeature)提交更改 (
git commit -m 'Add some AmazingFeature')推送到分支 (
git push origin feature/AmazingFeature)开启 Pull Request
许可证
本项目采用 MIT 许可证 - 详见 LICENSE 文件
作者
dongchengcheng
致谢
Model Context Protocol - 提供协议标准
MCP SDK - 官方 SDK
pdf-parse - PDF 解析库
更新日志
v1.0.0 (2024)
初始版本发布
实现基础 PDF 读取功能
添加元数据获取
实现文本搜索功能
解决 ESM/CommonJS 兼容性问题
联系方式
如有问题或建议,请通过以下方式联系:
提交 Issue
发起 Discussion
Available Tools
4 toolsget_pdf_infoA
Get metadata information from a PDF file (title, author, pages, etc.)
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Path to the PDF file to analyze |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It implicitly indicates a read-only operation by focusing on metadata, but does not explicitly state that no content is extracted or that the file is not modified. This is adequate for a simple metadata getter, but lacks explicit safety or return-format details.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, focused sentence that opens with the verb and resource, mentions the key metadata fields, and contains no redundant information. It is concise and well-structured for the tool's simplicity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple tool with one parameter, full schema coverage, and no output schema, the description adequately conveys the purpose and hints at the return content via examples (title, author, pages). It could explicitly state what is returned, but the examples and clear scope make it reasonably complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The single parameter file_path has a full schema description, so schema coverage is 100%. The tool description adds no extra meaning beyond what the schema already provides, such as path format or constraints, so it stays at the baseline.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'Get' and the resource 'metadata information from a PDF file', with examples of the metadata returned. It is clearly distinct from sibling tools like read_pdf and read_pages, which handle content extraction, making the purpose unmistakable.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies the tool should be used when metadata is needed, but provides no explicit guidance on when to use it versus alternatives. There are no stated exclusions or references to sibling tools, so the usage context is implied rather than explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
read_pagesB
Read text content from specific pages of a PDF file
| Name | Required | Description | Default |
|---|---|---|---|
| end_page | No | Ending page number (1-based, optional) | |
| file_path | Yes | Path to the PDF file to read | |
| start_page | Yes | Starting page number (1-based) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must carry the full burden of behavioral disclosure. It only states the basic operation and does not mention return format, page range validation, error handling, or limitations. This leaves the agent without expected behavior details.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that front-loads the verb and resource. It contains no unnecessary words or content, making it highly efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is simple and the parameter schema is clear, but there are no annotations, no output schema, and no elaboration on behavior or usage. The description covers the basic function but leaves gaps in behavioral context and alternative guidance, making it only minimally complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema descriptions cover 100% of parameters, so the baseline is 3. The description adds no additional meaning beyond the schema, only referencing 'specific pages' which aligns with start_page and end_page. It does not compensate for any missing parameter context.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Read text content') and the resource ('specific pages of a PDF file'), which gives a precise scope. However, it does not explicitly distinguish itself from sibling tools like read_pdf, though the 'specific pages' qualifier helps infer the differentiation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies the tool is for reading text from selected pages, but it provides no explicit guidance on when to use this tool versus alternatives (e.g., read_pdf for full documents, search_in_pdf for searching). No excluded scenarios or alternative recommendations are mentioned.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
read_pdfC
Read and extract text content from a PDF file
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Path to the PDF file to read |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It does not mention whether the entire PDF is processed, how scanned or image-based PDFs are handled, or what the output format looks like. 'Read' implies non-destructive, but no explicit safety or limitation details are given.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence that clearly states the core function with no unnecessary words. It is efficient and easy to parse.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with siblings and no output schema, the description is too sparse. It does not clarify the scope (full document vs specific pages), mention handling of scanned PDFs, or describe the extracted text format. This could lead to confusion when an agent chooses between read_pdf and read_pages.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema provides 100% coverage for the single file_path parameter, so the description adds no additional parameter meaning beyond what is already documented. A baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action (read/extract) and resource (PDF file text content), but it does not differentiate from sibling tool read_pages, which also reads text from PDF pages. It is specific and easy to understand.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to use this tool versus alternatives like read_pages or search_in_pdf. It simply states the function without any context about exclusions or preferred use cases.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_in_pdfB
Search for specific text within a PDF file
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Path to the PDF file to search in | |
| search_text | Yes | Text to search for in the PDF | |
| case_sensitive | No | Whether the search should be case sensitive |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the basic action and fails to disclose important behavioral details such as whether the search works with scanned PDFs, what the return value looks like (e.g., page numbers, matches), or how edge cases (e.g., no match) are handled.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence with no filler words. It effectively communicates the core purpose without redundancy, making it highly concise and well-structured.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool has no output schema and no annotations, so the description should explain return behavior and limitations. It does not mention what the tool returns (e.g., page numbers, boolean, matches) or any constraints like text-based PDFs requirement. For a search tool, this is a significant gap when compared to sibling tools that have clearer outputs.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema covers all three parameters with meaningful descriptions, so the baseline is 3. The tool description adds no additional parameter information, but since schema coverage is 100%, it does not need to compensate. The description is neutral on parameters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly identifies the tool's function: searching for specific text within a PDF file. It uses a specific verb ('Search') and resource ('PDF file'), and distinguishes itself from siblings like 'read_pdf' and 'read_pages' which focus on reading rather than searching.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage: use this tool when you need to find text within a PDF. However, it does not explicitly state when not to use it or how it compares to alternatives like 'read_pdf' or 'get_pdf_info'. There is no mention of exclusions or alternative selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
Each tool has a clearly distinct purpose: extracting full text, reading specific pages, searching, and retrieving metadata. No overlapping functionality that would confuse an agent.
All tool names follow a consistent verb_noun pattern (read_pdf, get_pdf_info, read_pages, search_in_pdf). The verbs and nouns are clear and uniform.
Four tools is well-scoped for a PDF reader, covering the essential operations without redundancy or bloat.
The tool set covers the common lifecycle of reading a PDF: extracting text, reading selective pages, searching, and accessing metadata. No critical dead ends for a standard PDF-reading workflow.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Hosted MCP server: convert PDFs to clean, LLM-ready Markdown with tables, formulas and OCR.
Generate and read PDFs for AI agents: a generate_pdf and a read_pdf tool, priced per document.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that allows AI assistants to discover, load, and process local documents on Windows systems, with support for multiple file formats and OCR capabilities for scanned PDFs.2
- FlicenseAqualityNot gradedmaintenanceA Model Context Protocol server that extracts and processes content from PDF documents, providing text extraction, metadata retrieval, page-level processing, and PDF validation capabilities.41
- AlicenseAqualityCmaintenanceA Model Context Protocol server that enables the extraction of text, metadata, and embedded images from PDF files. It provides tools for searching text with context, reading specific pages, and counting total pages within a document.7291MIT
- AlicenseAqualityAmaintenanceA Model Context Protocol server that enables AI agents to read, search, and extract content from PDF files.13130MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/DonChengCheng/mcp-pdf-reader'
If you have feedback or need assistance with the MCP directory API, please join our Discord server