Ebook-MCP について
Ebook-MCP は電子書籍を処理する MCP サーバーで、現在 EPUB と PDF に対応しています。ローカルの電子書籍を LLM アプリケーションから扱いたい読者や開発者を対象とし、標準化された API でメタデータ、目次、章の内容の抽出を提供します。
主な機能
- 01EPUB と PDF のメタデータと目次の抽出
- 02章またはページ番号を指定した内容の抽出
- 03Markdown 形式での出力
- 04EPUB と PDF のバッチ処理
活用シーン
- 01Cursor や Claude からローカルの電子書籍ライブラリを検索
- 02特定の章の要約や確認問題の作成
- 03トピックに関連するセクションの検索
MCP 対応
MCP サーバーとして動作し、電子書籍のファイル検索、メタデータ、目次、章の抽出を API として公開し、LLM アプリケーションから呼び出せるようにします。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
Ebook-MCP
English | 中文 | 日本語 | 한국어 | Français | Deutsch
Ebook-MCP は、電子書籍を処理するための強力な Model Context Protocol(MCP)サーバーです。Model Context Protocol を基盤として構築されており、LLM アプリケーションと電子書籍処理機能をシームレスに連携するための標準化された API を提供します。現在、EPUB 形式と PDF 形式に対応しています。
ユースケースと価値
Ebook-MCP は、読書資料と自然言語で会話できるようにすることで、デジタル書籍との関わり方を変革します。Cursor や Claude などの最新の AI 搭載 IDE とシームレスに連携し、次のことができます。
- スマートなライブラリ管理:「ダウンロードフォルダーにあるすべての EPUB ファイルを表示して」や「ライブラリから GenAI に関する本を探して」と尋ねるだけです。
- インタラクティブな読書体験:書籍について自然な会話ができます。
- 「『LLM Engineer Handbook』の概要を教えて」
- 「第 3 章では何を扱っていますか?」
- 「この本にある RAG の要点を要約して」
- アクティブラーニングのサポート:AI を活用したやり取りを通じて、学習を深められます。
- 「第 5 章の RAG の概念に基づいてクイズを作成して」
- 「この章で説明されているアーキテクチャの違いを説明して」
- 「このセクションの概念に基づいた実践的な演習を作成して」
- コンテンツのナビゲーション:自然言語で質問して、書籍内を簡単に移動できます。
- 「プロンプトエンジニアリングを扱っているすべてのセクションを探して」
- 「ファインチューニングに関する章を表示して」
- 「ベクトルデータベースについて説明している箇所に移動して」
従来の電子書籍と AI 機能の間をつなぐことで、Ebook-MCP は直感的な会話形式のやり取りを通じて、読者がデジタルライブラリからより多くの価値を引き出せるよう支援します。
クイックデモ - 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│
└────────────────────────────┘
貢献
Issue と Pull Request を歓迎します!
最近の変更について詳しくは、CHANGELOG.md をご覧ください。
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。
