Skip to main content

MD Book Tools - A DI/SOA markdown book reader and writer with MCP server support

Reason this release was yanked:

invalid

Project description

MD Book Tools

A markdown book reader and writer with DI/SOA architecture and MCP server support for Claude Code integration.

Features

  • Multi-Format Support: mdBook, GitBook, Leanpub, Bookdown, and auto-detection
  • YAML Frontmatter: Extract metadata (title, author, date, draft status)
  • Interactive Reader: Terminal navigation with chapter jumping
  • Book Writing: Initialize projects, add chapters, generate TOC
  • MCP Server: Expose book operations as tools for AI assistants

Architecture

mdbook/
├── domain/           # Core entities (Book, Chapter, ChapterMetadata)
├── services/         # Business logic with interface protocols
│   ├── interfaces.py # IBookService, IReaderService, IWriterService, IStructureService
│   ├── book_service.py
│   ├── reader_service.py
│   ├── writer_service.py
│   └── structure_service.py
├── repositories/     # Data access layer
│   ├── interfaces.py # IFileRepository, IConfigRepository
│   ├── file_repository.py
│   └── config_repository.py
├── infrastructure/   # DI container and composition root
│   └── container.py  # ServiceContainer with lazy singleton resolution
├── mcp/              # Model Context Protocol server
│   └── server.py     # Exposes book operations as MCP tools
└── cli.py            # Unified Click-based CLI

Installation

Using uv (recommended)

cd book-reader
uv pip install -e .

Using pip

cd book-reader
pip install -e .

This installs the single mdbook command with all subcommands.

Quick Start

# Read a book (pass book path as argument)
mdbook read /path/to/book

# Or use --book/-b global option
mdbook --book /path/to/book read

# Show book info
mdbook info /path/to/book

# Create a new book
mdbook init ./my-book -t "My Book Title" -a "Author Name"

# Add a chapter
mdbook new-chapter ./my-book -t "Introduction"

# Regenerate table of contents
mdbook toc ./my-book

# Start MCP server for a specific book
mdbook serve-mcp /path/to/book

# Auto-configure Claude Code MCP integration
mdbook setup /path/to/book

Command Reference

mdbook [OPTIONS] COMMAND [ARGS]

Commands:
  read         Read a markdown book interactively
  info         Show book information
  init         Initialize a new book project
  new-chapter  Add a new chapter to a book
  toc          Regenerate table of contents
  serve-mcp    Start MCP server for Claude Code
  setup        Auto-configure Claude Code MCP integration

Global Options:
  -b, --book PATH  Book directory (used by all commands)
  --version        Show version and exit
  --help           Show help message and exit

read

mdbook read [BOOK] [OPTIONS]

Arguments:
  BOOK         Book directory (or use global --book option)

Options:
  -c, --chapter NUM    Start at specific chapter

init

mdbook init PATH [OPTIONS]

Arguments:
  PATH         Directory to create book in

Options:
  -t, --title TEXT     Book title (required)
  -a, --author TEXT    Author name (required)

new-chapter

mdbook new-chapter [BOOK] [OPTIONS]

Arguments:
  BOOK         Book directory (or use global --book option)

Options:
  -t, --title TEXT     Chapter title (required)
  -d, --draft          Mark as draft

setup

mdbook setup [BOOK]

Arguments:
  BOOK         Book directory (or use global --book option)

Auto-configures Claude Code MCP integration by updating .mcp.json
in the project directory. Creates the file if it doesn't exist or
adds/updates the mdbook server configuration.

MCP Server Integration

The MCP server exposes book operations as tools for Claude Code and other AI assistants.

Available MCP Tools

Tool Description
book_info Get book metadata and chapter list
read_chapter Read chapter content by number
list_chapters List all chapters with metadata
create_book Create a new book project
add_chapter Add a chapter to a book
update_toc Regenerate SUMMARY.md

Claude Code Configuration

Add to your .mcp.json:

{
  "mcpServers": {
    "mdbook": {
      "command": "mdbook",
      "args": ["serve-mcp"]
    }
  }
}

Or with uv:

{
  "mcpServers": {
    "mdbook": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/book-reader", "mdbook", "serve-mcp"]
    }
  }
}

Supported Book Formats

Format Detection File
mdBook/GitBook SUMMARY.md
mdBook book.toml
Leanpub Book.txt
Bookdown _bookdown.yml
Auto Directory scan

Requirements

  • Python 3.10+
  • click, rich, markdown, pyyaml, mcp

License

MIT License

Version History

  • v3.1.0 - Multi-book support with BOOK argument and --book/-b global option, new setup command for Claude Code MCP auto-configuration
  • v3.0.0 - Complete rewrite with DI/SOA architecture, unified mdbook CLI, MCP server integration
  • v2.1.0 - Added md-book-writer tool
  • v2.0.0 - Generic multi-format support, YAML frontmatter parsing
  • v1.0.0 - Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

md_book-3.1.0.tar.gz (64.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

md_book-3.1.0-py3-none-any.whl (33.7 kB view details)

Uploaded Python 3

File details

Details for the file md_book-3.1.0.tar.gz.

File metadata

  • Download URL: md_book-3.1.0.tar.gz
  • Upload date:
  • Size: 64.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for md_book-3.1.0.tar.gz
Algorithm Hash digest
SHA256 8d2054e8fc6157d182efddb6981a57e6c27a1d32c363a28a34e5dadc7b943d39
MD5 41e295dd1ed9bd275ee6cfb261a1eb37
BLAKE2b-256 04ade4c015bcbcaa74b99d1ee7becb2291066bd2ab793c0010e5bc6694a25ffd

See more details on using hashes here.

File details

Details for the file md_book-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: md_book-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for md_book-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7dd29762c387c30668701371aafae097e4bd55e28f9b4dadc8a18dd3f7fc80ef
MD5 ca5201d06f18bda135a95f0dfd1649eb
BLAKE2b-256 6eaa75149ba4766781981e566ac9151d8e427cd97d19d36949bbc3f58960eb8d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page