关于 Ebook-MCP
Ebook-MCP 是一个用于处理电子书的 MCP 服务,目前支持 EPUB 和 PDF 格式。它面向希望通过 LLM 应用与本地电子书交互的读者和开发者,以标准化接口提供元数据、目录和章节内容等功能。
主要功能
- 01提取 EPUB 与 PDF 的元数据和目录
- 02按章节或页码提取内容
- 03输出 Markdown 格式内容
- 04支持批量处理 EPUB 与 PDF 文件
适用场景
- 01在 Cursor 或 Claude 中查询本地电子书库的文件与信息
- 02针对某一章节生成摘要或测验题
- 03按主题定位书中相关章节
MCP 相关
作为 MCP 服务运行,将电子书的文件检索、元数据、目录及章节提取等能力以 API 形式提供给 LLM 应用调用。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
Ebook-MCP
English | 中文 | 日本語 | 한국어 | Français | Deutsch
Ebook-MCP 是一款用于处理电子书的强大 Model Context Protocol(MCP)服务。它基于 Model Context Protocol 构建,为大模型应用与电子书处理功能之间的无缝集成提供一组标准化 API。目前支持 EPUB 和 PDF 格式。
使用场景与价值
Ebook-MCP 通过支持与阅读材料进行自然语言对话,改变你与数字图书的交互方式。它可与 Cursor 和 Claude 等现代 AI 驱动的 IDE 无缝集成,让你能够:
- 智能图书管理:只需询问“显示下载文件夹中的所有 EPUB 文件”或“在我的图书库中查找有关 GenAI 的书籍”
- 交互式阅读体验:与书籍自然对话:
- “简要介绍一下《LLM Engineer Handbook》”
- “第 3 章讲了什么?”
- “总结这本书中关于 RAG 的要点”
- 主动学习支持:通过 AI 驱动的交互提升学习效果:
- “根据第 5 章中的 RAG 概念创建一份测验”
- “解释本章讨论的不同架构之间的区别”
- “根据本节中的概念提供一些实践练习”
- 内容导航:通过自然语言查询轻松浏览书籍:
- “查找所有讨论提示词工程的章节”
- “显示有关微调的章节”
- “带我转到有关向量数据库的部分”
Ebook-MCP 搭起了传统电子书与 AI 能力之间的桥梁,帮助读者通过直观的对话式交互,从数字图书库中获取更多价值。
快速演示 - 使用 DeepSeek 运行(请在 mcp-client-example 文件夹中查看所有 Claude/OpenAI 示例)
Query:Please check all the epub books in my download folder. user id is onebird.
......
Query: Can you ask me a few questions to test my understanding of this book?
Answer: Sure! Here are 5 questions about Elon Musk by Walter Isaacson to test your understanding of the book. Please answer based on your knowledge — I’ll give feedback and add details after each response.
Question 1:
How did Musk’s childhood and family background shape his personality and career later in life?
(Hint: His relationship with his father, growing up in South Africa, etc.)
Question 2:
Zip2 and X.com (later PayPal) were Musk’s early startups. What problems did they solve? How did Musk eventually exit from these companies?
(Hint: Zip2’s business model, X.com’s merger with Confinity, etc.)
Question 3:
In 2008, both SpaceX and Tesla were on the verge of bankruptcy. How did Musk save these two companies?
(Hint: Falcon 1’s fourth launch, NASA contract, Tesla’s last-minute rescue, etc.)
Question 4:
What controversies surround Musk’s management style? What specific incidents in the book illustrate his “hardcore” or “extreme” work culture?
(Hint: Fremont factory’s “production hell,” Twitter layoffs, etc.)
Question 5:
What is Musk’s attitude toward Artificial Intelligence (AI)? Why did he simultaneously support both OpenAI and Neuralink, which seem to have conflicting goals?
(Hint: AI as an existential threat, brain-machine interface vision, etc.)
Please answer each question. I’ll provide feedback and additional details or correct any misunderstandings!
(If a question isn’t clear, feel free to ask me.)
Query:
Question 1: His father’s abusive attitude made him less empathetic towards others.
Question 2: Zip2 solved the problem of electronic maps and online yellow pages. X.com solved online payments.
Question 3: He secured a contract with NASA. Tesla solved its production problems by building a factory in China.
Question 4: I don’t know. Please answer for me.
Question 5: He believes open-source technology is necessary to ensure AI is safe and open.
Answer: Your answers have captured some key points from the book. Let me add details, correct some inaccuracies, and provide further background for Questions 4 and 5:
Question 1 — Correction & Supplement
Influence of His Father:
Musk's father, Errol, was indeed extremely harsh — for example, forcing young Elon to kneel and count grains of rice for hours. The book emphasizes that this emotional desensitization shaped Musk into an extremely goal-oriented person — indifferent to others’ suffering but obsessively committed to his goals.
Reverse Impact:
It’s not that Musk is incapable of empathy — it’s selective. For instance, he may treat employees coldly but personally study medical equipment for his son X’s health issues.
Question 2 — Correction & Supplement
Zip2:
Essentially an online Yellow Pages + map navigation service (helping newspapers go online). Musk wrote much of the early code himself and slept in the office. Eventually, Compaq acquired Zip2 for $307 million (Musk received $22 million).
X.com:
Not just online payments — it was Musk’s attempt to create a comprehensive financial platform (aiming to replace banks). Later merged with Confinity (the precursor of PayPal). Musk was ousted due to internal conflicts, but when eBay acquired PayPal, Musk earned $180 million.
(Note: Musk later bought back the domain X.com — it’s now Twitter’s parent company name).
Question 3 — Correction & Supplement
SpaceX:
In 2008, Falcon 1 succeeded on its fourth launch (after three failures drained their funds). Right after that, SpaceX secured a $1.6 billion NASA contract for cargo resupply — a lifeline for the company.
Tesla:
In 2008, Tesla survived through a $50 million investment from Daimler and a loan from the U.S. Department of Energy.
Building the Gigafactory in China (2019) came much later. In the early years, survival depended on the launch of Model S (2012) and Musk’s personal gamble — selling all his real estate to fund Tesla.
Question 4 — Explanation: Controversy Around His Management Style
“Hardcore” Culture:
At SpaceX/Tesla: Musk demanded employees work 80+ hours per week, even sleeping at the factory. ("If you’re not here, your replacement is.")
After acquiring Twitter: He immediately laid off 75% of staff and asked the remaining employees to sign a "hardcore commitment" — agreeing to long hours and high-intensity output.
Extreme Cases:
At the Fremont Factory: During the "production hell" of the Model 3, Musk slept on the production line and once yelled at employees calling them "worse than dogs" (he later apologized).
Firing Executives: Musk once fired a senior Tesla executive on the spot because the font size in their PowerPoint presentation wasn’t big enough.
Question 5 — Correction & Supplement
AI Threat Theory:
Musk believes that AI could destroy humanity ("more dangerous than nuclear weapons"). Therefore:
OpenAI: He initially supported it to promote safe, open-source AI (but left later due to disputes over control).
Neuralink: He aims to use brain-machine interfaces to merge humans with AI — to prevent humans from being left behind.
Contradictions:
While warning about AI risks, Musk is simultaneously pushing for Full Self-Driving (FSD) technology at Tesla and has founded xAI to research Artificial General Intelligence (AGI).
Overall Evaluation:
✅ You have captured the key events accurately, but the details need to be strengthened (such as timelines and specific figures).
🔍 Recommended areas for further study: Musk's multi-threaded management style (running five companies simultaneously) and his skill in media manipulation (governing through Twitter).
功能
EPUB 支持
- 提取元数据(标题、作者、出版日期等)
- 提取目录
- 提取章节内容(以 Markdown 格式输出)
- 批量处理 EPUB 文件
PDF 支持
- 提取元数据(标题、作者、创建日期等)
- 提取目录
- 按页码提取内容
- 按章节标题提取内容
- 支持 Markdown 输出
- 批量处理 PDF 文件
安装
- 克隆仓库:
git clone https://github.com/yourusername/ebook-mcp.git
cd ebook-mcp
- 使用
uv安装依赖项:
uv pip install -e .
用法
在开发模式下启动 MCP 服务
在开发模式下运行服务:
uv run mcp dev src/ebook_mcp/main.py
你可以访问 http://localhost:5173/ 进行测试和调试。 你也可以安装 inspector 进行测试。
npx @modelcontextprotocol/inspector uv --directory . run src/ebook_mcp/main.py
在生产模式下启动 MCP 服务
运行服务:
uv run src/ebook_mcp/main.py
在 Cursor 中配置 MCP
在 Cursor 中添加以下配置
"ebook-mcp":{
"command": "uv",
"args": [
"--directory",
"/Users/onebird/github/ebook-mcp/src/ebook_mcp/",
"run",
"main.py"
]
}
EPUB 处理示例
# Get all EPUB files in a directory
epub_files = get_all_epub_files("/path/to/books")
# Get EPUB metadata
metadata = get_metadata("/path/to/book.epub")
# Get table of contents
toc = get_toc("/path/to/book.epub")
# Get specific chapter content (in Markdown format)
chapter_content = get_chapter_markdown("/path/to/book.epub", "chapter_id")
PDF 处理示例
# Get all PDF files in a directory
pdf_files = get_all_pdf_files("/path/to/books")
# Get PDF metadata
metadata = get_pdf_metadata("/path/to/book.pdf")
# Get table of contents
toc = get_pdf_toc("/path/to/book.pdf")
# Get specific page content
page_text = get_pdf_page_text("/path/to/book.pdf", 1)
page_markdown = get_pdf_page_markdown("/path/to/book.pdf", 1)
# Get specific chapter content
chapter_content, page_numbers = get_pdf_chapter_content("/path/to/book.pdf", "Chapter 1")
API 参考
EPUB API
get_all_epub_files(path: str) -> List[str]
获取指定目录中的所有 EPUB 文件。
get_metadata(epub_path: str) -> Dict[str, Union[str, List[str]]]
获取 EPUB 文件的元数据。
get_toc(epub_path: str) -> List[Tuple[str, str]]
获取 EPUB 文件的目录。
get_chapter_markdown(epub_path: str, chapter_id: str) -> str
以 Markdown 格式获取章节内容。
PDF API
get_all_pdf_files(path: str) -> List[str]
获取指定目录中的所有 PDF 文件。
get_pdf_metadata(pdf_path: str) -> Dict[str, Union[str, List[str]]]
获取 PDF 文件的元数据。
get_pdf_toc(pdf_path: str) -> List[Tuple[str, int]]
获取 PDF 文件的目录。
get_pdf_page_text(pdf_path: str, page_number: int) -> str
获取指定页面的纯文本内容。
get_pdf_page_markdown(pdf_path: str, page_number: int) -> str
获取指定页面的 Markdown 格式内容。
get_pdf_chapter_content(pdf_path: str, chapter_title: str) -> Tuple[str, List[int]]
根据章节标题获取章节内容和对应的页码。
依赖项
主要依赖项包括:
- ebooklib:EPUB 文件处理
- PyPDF2:基础 PDF 处理
- PyMuPDF:高级 PDF 处理
- beautifulsoup4:HTML 解析
- html2text:HTML 转 Markdown
- pydantic:数据验证
- fastmcp:MCP 服务框架
重要说明
- PDF 处理依赖文档的目录。如果没有目录,某些功能可能无法使用。
- 对于大型 PDF 文件,建议按页码范围处理,以避免一次性加载整个文件。
- EPUB 章节 ID 必须从目录结构中获取。
架构
┌────────────────────────────┐
│ Agent Layer │
│ - Translation Strategy │
│ - Style Consistency Check │
│ - LLM Call & Interaction │
└────────────▲─────────────┘
│ Tool Calls
┌────────────┴─────────────┐
│ MCP Tool Layer │
│ - extract_chapter │
│ - write_translated_chapter│
│ - generate_epub │
└────────────▲─────────────┘
│ System/IO Calls
┌────────────┴─────────────┐
│ System Base Layer │
│ - File Reading │
│ - ebooklib Parsing │
│ - File Path Storage/Check│
└────────────────────────────┘
贡献
欢迎提交 Issues 和 Pull Requests!
如需了解近期更改的详细信息,请参阅 CHANGELOG.md。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。
