Extract text and images from EPUB files and reconstruct as Markdown
Project description
epub-content-extractor
EPUBファイルのテキストと画像を抽出し、Markdownファイル群として出力するCLIツール。FastMCPによるMCPサーバとしても動作します。
必要なもの
- uv — パッケージマネージャ。公式インストール手順に従ってインストールしてください。
MCPクライアント別の設定
Claude Code
-
以下のコマンドを実行します。
claude mcp add epub-content-extractor uvx epub-content-extractor
または プロジェクトルートに
.mcp.jsonを作成し、以下を記述します。{ "mcpServers": { "epub-content-extractor": { "command": "uvx", "args": ["epub-content-extractor"] } } }
-
Claude Code を再起動します。
Cursor
-
プロジェクトルートに
.cursor/mcp.jsonを作成します(グローバル設定の場合は~/.cursor/mcp.json)。 -
以下の内容を記述します。
{ "mcpServers": { "epub-content-extractor": { "command": "uvx", "args": ["epub-content-extractor"] } } }
-
Cursor を再起動します。
VS Code (GitHub Copilot)
-
プロジェクトルートに
.vscode/mcp.jsonを作成します。 -
以下の内容を記述します。
{ "servers": { "epub-content-extractor": { "command": "uvx", "args": ["epub-content-extractor"] } } }
-
VS Code を再起動し、Copilot Chat から MCP ツールが利用可能になっていることを確認します。
CLIとして直接使う(uvx経由)
注意:
uvx epub-content-extractorは MCP サーバーを起動するコマンドです。ヘルプは表示されません。 CLI ツールのエントリポイントはepub-extractです。uvx 経由では--fromフラグを使って以下のように実行します。
uvx --from epub-content-extractor epub-extract INPUT.epub [OUTPUT_DIR]
INPUT.epub: 入力EPUBファイルのパス(必須)OUTPUT_DIR: 出力先ディレクトリ(省略時は{epub_dir}/{epub_stem}/)
出力例
output/
├── chapter_001.md
├── chapter_002.md
└── images/
└── fig001.png
各 .md ファイルはYAML Front Matter付き:
---
title: "書籍タイトル"
authors:
- "著者名"
language: ja
publisher: "出版社"
identifier: "urn:isbn:..."
epub_layout: fixed-layout
page_progression_direction: rtl
chapter_title: "第1章"
spine_order: 1
---
ツールリファレンス
extract_epub
EPUBの全コンテンツをMarkdownファイルとして出力します。
パラメータ
| パラメータ | 型 | デフォルト | 説明 |
|---|---|---|---|
source |
string | 必須 | EPUBファイルの絶対パスまたは相対パス |
output_dir |
string | null | 出力先ディレクトリ(省略時は {epub_dir}/{epub_stem}/) |
レスポンス
{
"output_dir": "/path/to/output",
"files": [
"/path/to/output/chapter_001.md",
"/path/to/output/chapter_002.md"
],
"chapters": 2
}
get_epub_metadata
EPUBのメタデータを取得します(ファイル出力なし)。
パラメータ
| パラメータ | 型 | デフォルト | 説明 |
|---|---|---|---|
source |
string | 必須 | EPUBファイルの絶対パスまたは相対パス |
レスポンス
{
"title": "書籍タイトル",
"authors": ["著者名"],
"language": "ja",
"layout": "fixed-layout",
"page_progression_direction": "rtl",
"publisher": "出版社",
"identifier": "urn:isbn:..."
}
list_epub_spine
スパインアイテム(章)を読み順で一覧表示します(ファイル出力なし)。
パラメータ
| パラメータ | 型 | デフォルト | 説明 |
|---|---|---|---|
source |
string | 必須 | EPUBファイルの絶対パスまたは相対パス |
レスポンス
{
"spine": [
{
"id": "chapter01",
"href": "OEBPS/chapter01.xhtml",
"title": "第1章",
"order": 1
}
]
}
対応EPUBレイアウト
- リフロー型: HTML構造から自然な読み順でテキスト抽出
- フィックス型:
position: absoluteCSS座標によるソート(RTL/LTR対応) - AHL型: スパインアイテムごとにフィックス型/リフロー型を判定
開発者向け
開発環境のセットアップ
uv sync --group dev
テスト・Lint
uv run pytest tests/ -v
uv run ruff check .
TestPyPI での動作確認
リリース前に TestPyPI へアップロードされたパッケージを uvx で検証する。
TestPyPI には lxml>=5.0 が存在しないため、--extra-index-url で PyPI を補助インデックスとして追加し、--index-strategy unsafe-best-match で全インデックスから最適バージョンを選択させる必要がある。
# MCP サーバーとして起動確認
uvx --from "epub-content-extractor" \
--index "https://test.pypi.org/simple/" \
--extra-index-url "https://pypi.org/simple/" \
--index-strategy unsafe-best-match \
epub-content-extractor
# CLI ツールとして動作確認
uvx --from "epub-content-extractor" \
--index "https://test.pypi.org/simple/" \
--extra-index-url "https://pypi.org/simple/" \
--index-strategy unsafe-best-match \
epub-extract <EPUBファイルパス>
# バージョンを指定する場合
uvx --from "epub-content-extractor==0.2.2" \
--index "https://test.pypi.org/simple/" \
--extra-index-url "https://pypi.org/simple/" \
--index-strategy unsafe-best-match \
epub-content-extractor
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file epub_content_extractor-0.2.6.tar.gz.
File metadata
- Download URL: epub_content_extractor-0.2.6.tar.gz
- Upload date:
- Size: 160.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7d1eedc8a7ff8462154fd3fe3a3b62bf68c0e608efb832fb32b4dc511422a49
|
|
| MD5 |
9d7def843193d72ade61469796563491
|
|
| BLAKE2b-256 |
4c0769ae7b8452aae610a61a65685e18c08b4a978cc2629a88018dae2af05574
|
Provenance
The following attestation bundles were made for epub_content_extractor-0.2.6.tar.gz:
Publisher:
publish.yml on HizZaniya/epub-content-extractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
epub_content_extractor-0.2.6.tar.gz -
Subject digest:
b7d1eedc8a7ff8462154fd3fe3a3b62bf68c0e608efb832fb32b4dc511422a49 - Sigstore transparency entry: 1811208488
- Sigstore integration time:
-
Permalink:
HizZaniya/epub-content-extractor@eace2c7368859ed92615059ba8f88771b028961c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/HizZaniya
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eace2c7368859ed92615059ba8f88771b028961c -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file epub_content_extractor-0.2.6-py3-none-any.whl.
File metadata
- Download URL: epub_content_extractor-0.2.6-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abcd18cdab1b368d5b9401307fd1a6eb3b2dce8fe7ec6cf6465199318bd65a37
|
|
| MD5 |
7d4382dde5ca1e678407840577beaa5f
|
|
| BLAKE2b-256 |
81c78cca7a73fa33559fe23b0f7f981d829fe8006d88005c96e1b1b1f77e3287
|
Provenance
The following attestation bundles were made for epub_content_extractor-0.2.6-py3-none-any.whl:
Publisher:
publish.yml on HizZaniya/epub-content-extractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
epub_content_extractor-0.2.6-py3-none-any.whl -
Subject digest:
abcd18cdab1b368d5b9401307fd1a6eb3b2dce8fe7ec6cf6465199318bd65a37 - Sigstore transparency entry: 1811208589
- Sigstore integration time:
-
Permalink:
HizZaniya/epub-content-extractor@eace2c7368859ed92615059ba8f88771b028961c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/HizZaniya
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eace2c7368859ed92615059ba8f88771b028961c -
Trigger Event:
workflow_run
-
Statement type: