Skip to main content
Glama
books-word-converter

books-word-converter

books-word-converter

License: MIT Node MCP

MCP server for massive PDF book conversion (150+ books, 10+ GB) to Word and Markdown.

Converts entire libraries locally through a free Model Context Protocol (MCP) server: no browser memory leaks, no tab crashes, < 80 MB RAM, automatic resume, scheduled ZIP bundles (every 15 books). All AI calls happen server-side — you never need a local Gemini API key.

Works from OpenCode, Claude Desktop, Cursor, Antigravity, Windsurf (any MCP client over stdio).


What it does

Capability

Detail

scan_books_directory

Inventory a folder: file count, total size, per-file pages.

convert_book_to_word

PDF → .docx + .md with RTL Arabic layout (Amiri, verses ﴿﴾, poetry, tables).

batch_convert_folder

Sequential low-memory batch + TIMESTAMPED ZIP every N books + batch_resume.json state.

get_batch_status

Resume progress and bundle index.

CLI batch-runner.js

Same engine from terminal, no MCP client required.

Related MCP server: MarkItDown MCP Server

Architecture

Your machine (MCP server + CLI)
  │  POST /api/convert-pdf  (base64 chunks, 2–4 pages)
  ▼
AI Studio converter (ai-studio server-side)
  │  Gemini OCR → Markdown (RTL, tables, verses)
  ▼
Local rebuild:  DOCX (docx)  +  .md  +  ZIP bundles (jszip)
  • Health: GET /api/health → 200 {"status":"ok","mcpSupported":true,"cliSupported":true}

  • CORS: Access-Control-Allow-Origin: * + OPTIONS → 204 (any external client).

  • Retry: exponential backoff, small chunks (10 pages → 6 on QA failure).

Quick start

Prerequisites

  • Node.js ≥ 20

  • Free AI Studio account (server-side key — zero local keys needed)

Install (MCP host)

git clone https://github.com/abedmohamed258/books-word-converter.git
cd books-word-converter
npm install        # pdf-lib + docx + jszip

OpenCode

In ~/.config/opencode/opencode.json (V2):

{
  "mcp": {
    "servers": {
      "books-word-converter": {
        "type": "local",
        "command": ["node", "/absolute/path/to/books-word-converter/mcp-server.js"],
        "disabled": false
      }
    }
  }
}

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "books-word-converter": {
      "command": "node",
      "args": ["/absolute/path/to/books-word-converter/mcp-server.js"],
      "env": {
        "CONVERTER_SERVER_URL": "https://ais-dev-wpsct27fdufcpry5x6ikjn-685461883733.europe-west2.run.app"
      }
    }
  }
}

CLI (no MCP client)

node batch-runner.js --input="D:/books" --output="D:/output" --bundle-size=15 \
  --server="https://ais-dev-wpsct27fdufcpry5x6ikjn-685461883733.europe-west2.run.app"

MCP tools are then available automatically: scan_books_directory, convert_book_to_word, batch_convert_folder, get_batch_status.

Server

Endpoint

Method

Notes

/api/health

GET

200 JSON, no cookie gate

/api/convert-pdf

POST

{ pdfBase64, filename, options: { direction: "rtl" } } → { success, data: { markdown } }

/api/cli/download/{mcp-server,batch-runner-js,mcpServer,cmd}

GET

302 → file (iframe gate)

/api/* bypass the AI-Studio cookie/iframe check; CORS is * with 204 preflight.

Quality notes

  • Quranic verses are returned verbatim with tashkeel (﴿﴾) — no summarizing.

  • Poetry, tables (| … |), and footnotes (١) preserved.

  • QA gate (qa_gates.py in arabic-pdf-to-book): page ratio ≥ 85%, chars/page ≥ 250, short lines ≤ 28%, duplicates ≤ 15%, tables equal columns.

  • Local OCR fallback (Tesseract) for large / quota-exhausted runs.

Security

  • No secrets in repo or config — server key stays server-side.

  • node_modules/ and batch_resume.json are git-ignored.

  • The server logs to stderr only; stdout is JSON-RPC-only.

Troubleshooting

Symptom

Cause / Fix

ERR_MODULE_NOT_FOUND pdf-lib

Run npm install in the clone root (deps were not vendored in the download zip).

Unexpected token '<' … not valid JSON (CLI)

Old 302 __cookie_check.html — the /api/ cookie bypass was missing. Update to ≥ 1.1.0 / current ais-dev deployment.

opencode mcp list shows stale failed

opencode reload (config was edited after the last session).

Connection closed on MCP

Node < 20, or package.json missing "type":"module".

License

MIT — see LICENSE.

Available Tools

4 tools
batch_convert_folderB

Executes a sequential, low-memory batch conversion on an entire folder (e.g. 150+ books). Automatically bundles every N books into a timestamped ZIP archive and maintains resume state.

NameRequiredDescriptionDefault
input_dirYesFolder containing the source PDF books (5-10+ GB)
output_dirNoFolder where output files and scheduled ZIP bundles will be saved
bundle_sizeNoNumber of books per scheduled ZIP archive bundle (default: 15)
convert_book_to_wordA

Converts a single PDF or document into a professional Word (.docx) and Markdown (.md) file with strict RTL Arabic layout fidelity.

NameRequiredDescriptionDefault
file_pathYesPath to the input PDF book on the local system
output_dirNoFolder where converted .docx and .md files should be saved
get_batch_statusA

Checks the current batch progress and resume state of a conversion directory.

NameRequiredDescriptionDefault
output_dirYesThe output folder where books are being converted
scan_books_directoryB

Scans a local directory for PDF and Word books, calculates total file count, estimated pages, and file sizes.

NameRequiredDescriptionDefault
recursiveNoWhether to scan subdirectories recursively (default: true)
directory_pathYesAbsolute or relative path to the folder containing books (e.g. "D:/books" or "./my_books")

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv1.1.0
    • First observedbatch_convert_folder
    • First observedconvert_book_to_word
    • First observedget_batch_status
    • First observedscan_books_directory

TDQS

A3.7/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a clearly distinct role: scanning for inventory, converting one book, batch converting a folder, and checking batch status. The boundary between single and batch conversion is explicit, and status checking is separate from execution.

Naming Consistency4/5

All names use snake_case and begin with recognizable action-oriented terms. The pattern is mostly verb_object, though convert_book_to_word and batch_convert_folder add extra descriptive segments that slightly break a strict convention.

Tool Count5/5

Four tools is well-scoped for a book conversion server. Each tool earns its place by covering discovery, single conversion, batch conversion, and progress tracking without redundancy.

Completeness4/5

The surface covers the main lifecycle: scanning inputs, converting a single file, batch converting folders with resume state, and checking batch progress. Minor gaps exist around cancellation, output listing, or conversion option configuration, but core workflows are supported.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    A
    quality
    D
    maintenance
    A comprehensive Model Context Protocol server that processes Microsoft Word documents with full formatting support, enabling text extraction, HTML/Markdown conversion, structure analysis, and image extraction.
    5
    2
    -
  • A
    license
    A
    quality
    B
    maintenance
    A Model Context Protocol server that converts over 29 file formats, including PDFs, Office documents, and audio, into structured Markdown using Microsoft's MarkItDown library. It enables AI assistants to process diverse document types through single file conversion and batch directory processing.
    3
    109 PyPI
    47
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A high-performance Model Context Protocol server that enables AI agents to extract text, images, and metadata from PDF documents using parallel processing. It features intelligent Y-coordinate content ordering to preserve natural reading flow and supports both local files and URL-based sources.
    6 npm
    MIT