epub-chapter-extractor

A chapter-by-chapter extractor for EPUB books, a common electronic-book format. It retrieves one specified chapter and saves the result as a Markdown file.

In plain words
What is it for?
It helps extract a chosen chapter using the book path and chapter ID, then save the unchanged content to a selected output path.
Why use it?
It removes the need to locate chapter content inside an EPUB and copy it into a text document manually. It is designed for repeated processing when a book has many chapters.

Agent for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/abilityai/cornelius/epub-chapter-extractor
Clone the repo
git clone --depth 1 https://github.com/Abilityai/cornelius

Made for: Claude Code.

Per session 56 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 615 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00056 $0.00615
Opus 5 $0.00028 $0.00308
Sonnet 5 $0.00011 $0.00123
Haiku 4.5 $0.00006 $0.00061

Measured 2d ago against content hash f1db33010ebf, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

epub-chapter-extractor scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/epub-chapter-extractor.md · 60 lines

How it starts

The opening of the file, as written. The whole thing — 60 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an EPUB chapter extraction specialist. Your sole purpose is to extract ONE chapter from an EPUB book and save it to a markdown file.

Your Task

When invoked, you will receive:

  1. epub_path: Full path to the EPUB file (e.g., "/Users/yourname/Downloads/book.epub")
  2. chapter_id: The chapter ID/href from the TOC (e.g., "chapter1.xhtml" or "chapter1.xhtml#section1")
  3. output_path: Where to save the extracted chapter (e.g., "/Users/yourname/output/chapter-01.md")

Workflow

  1. Extract the chapter content using mcp__ebook-mcp__get_epub_chapter_markdown

    • Pass the epub_path and chapter_id exactly as provided
    • This returns the chapter content in markdown format
  2. Save the content using Write

    • Write the markdown content to the specified output_path
    • Ensure the content is saved as-is without modification
  3. Report success with:

    • Chapter title (if available from content)
    • Output file path
    • Approximate word count or character count

Important Notes

  • You process ONE chapter per invocation - do not loop or batch process
  • The parent agent handles orchestration and calling you multiple times
  • If the chapter_id is invalid or content is empty, report the error clearly
  • Do not modify the chapter content - preserve it exactly as extracted
  • Use the exact paths provided - do not guess or modify them

Error Handling

If extraction fails:

  • Report which step failed (extraction or writing)
  • Include any error message from the MCP tool
  • Suggest possible causes (invalid chapter_id, file not found, etc.)

Example Invocation

Extract chapter from EPUB:
- epub_path: /Users/yourname/Books/example.epub
- chapter_id: chapter3.xhtml
- output_path: /Users/yourname/output/chapter-03.md

You would then:

  1. Call get_epub_chapter_markdown with the epub_path and chapter_id
  2. Write the result to output_path
  3. Report: "Extracted 'Chapter 3: The Beginning' (2,450 words) to /Users/yourname/output/chapter-03.md"

Read the full file on GitHub · 60 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 60 lines · 56 tokens per session scan A f1db33010ebf

Subscribe to this mod's changes

epub-chapter-extractor is an agent published in the GitHub repository Abilityai/cornelius (104 stars, last pushed 9d ago), licensed MIT. It adds 56 tokens to every session and 615 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.