Skip to main content
Glama

leanpub-mcp

An MCP server for the Leanpub author API — preview, publish, royalties, coupons, readers.

Why this exists

Leanpub documents an official hosted MCP server at https://leanpub.com/api/mcp. As of 2026-09-14 that endpoint 404s on every method (GET/POST/HEAD/OPTIONS), despite the docs describing it as live ("very early beta"). This is a local stdio server that talks to the same documented REST API directly, so preview/publish workflows aren't blocked on Leanpub finishing their rollout. Drop it once leanpub.com/api/mcp actually answers.

Related MCP server: deliverable-mcp

Setup

npm install

API key

Requires a Pro plan API key from https://leanpub.com/account/api_key. Resolved fresh on every tool call (never cached), checked in this order:

  1. LEANPUB_API_KEY env var (literal key)

  2. LEANPUB_API_KEY_FILE env var (path to a file containing the key)

  3. .leanpub-api-key in the current working directory

  4. ~/.config/leanpub/api_key

Writing the key to a file takes effect on the very next tool call — no server restart needed.

Register with Claude Code

As a personal, cross-project tool (recommended — keeps the machine-specific path out of any repo's committed .mcp.json):

claude mcp add --scope user --transport stdio leanpub -- node /absolute/path/to/leanpub-mcp/bin/leanpub-mcp.js

Or add to a specific project's .mcp.json:

{
  "mcpServers": {
    "leanpub": {
      "command": "node",
      "args": ["/absolute/path/to/leanpub-mcp/bin/leanpub-mcp.js"]
    }
  }
}

### MCP client timeout for `wait_for_job`

`wait_for_job` polls internally for up to `timeoutSeconds` (default 120),
but that's a single MCP tool call the whole time -- most MCP clients kill a
tool call after their own default request timeout (often 30s) regardless of
what the server is doing internally, since this server sends no progress
notifications. Confirmed live: a 180s `wait_for_job` call was killed at 30s
with `Request timeout after 30000ms` even though the underlying Leanpub job
finished fine.

Fix: set a per-server timeout in your MCP client config, comfortably above
whatever `timeoutSeconds` you pass. In Claude Code / OMP's `.mcp.json`:

```json
{
  "mcpServers": {
    "leanpub": {
      "command": "node",
      "args": ["/absolute/path/to/leanpub-mcp/bin/leanpub-mcp.js"],
      "timeout": 300000
    }
  }
}

Without that, just poll get_job_status directly in a loop (5s between calls, per Leanpub's own rate-limit guidance) instead of calling wait_for_job.

Tools

Tool

Leanpub endpoint

verify_api_key

GET /current_user.json

get_book

GET /{slug}.json

check_book_exists

GET /{slug}/exists.json

create_book

POST /books.json

create_bundle

POST /bundles.json

create_course

POST /courses.json

create_track

POST /tracks.json

preview_book

POST /{slug}/preview.json

preview_subset

POST /{slug}/preview/subset.json

preview_single

POST /{slug}/preview/single.json

publish_book

POST /{slug}/publish.json

unpublish_book

POST /{slug}/unpublish.json

retire_book

POST /{slug}/retire.json

close_book

POST /{slug}/close.json

get_job_status

GET /{slug}/job_status.json

wait_for_job

polls get_job_status every 5s until complete or timeout

get_royalties

GET /{slug}/royalties.json

get_individual_purchases

GET /{slug}/individual_purchases.json

list_coupons / get_coupon / create_coupon / update_coupon

/{slug}/coupons[.json/{code}.json]

get_user_reader_emails / get_book_reader_emails

/reader_emails.json

register_interest / get_interested_readers

/{slug}/interested*.json

preview_course / publish_course

/c/{...}/preview.json, /c/{...}/publish.json

Not implemented: file upload to upload-mode books, XML response formats (JSON only). Add them if you need them — src/client.js follows one pattern per resource.

Typical workflow

Preview the book, then tell me when it's ready.

Calls preview_book, then wait_for_job, then reports the pdf_preview_url / epub_preview_url from a follow-up get_book call.

Testing

npm test          # unit tests for URL building, error parsing, key resolution

Unit tests don't hit the network. To confirm the server is wired to the real API, run verify_api_key with a real (or intentionally wrong) key and check you get back a 200 with your username, or a clean 401.

Available Tools

28 tools
check_book_existsB

Check whether a book slug exists and you are an author of it.

Inputs: slug (required).

close_bookC

Close a book completely — hidden from the store (primary author only).

Inputs: slug (required).

create_bookC

Create a new Leanpub book (Browser, GitHub, or Upload mode).

Inputs: slug (required), title (required), syncMode, githubPath, +4 more.

create_bundleC

Create a new Leanpub bundle.

Inputs: slug (required), title (required), publisherId.

create_couponC

Create a new coupon for a book.

Inputs: slug (required), startDate (required), couponCode (required), discountedPrice (required), +4 more.

create_courseC

Create a new Leanpub course.

Inputs: slug (required), title (required), languageId (required), syncMode, +4 more.

create_trackC

Create a new Leanpub track (curated collection of courses).

Inputs: slug (required), title (required), publisherId.

get_bookB

Get a book's summary: title, word/page counts, sales, and preview/published download URLs.

Inputs: slug (required).

get_book_reader_emailsB

Get emails of readers of a specific book who opted to share them.

Inputs: slug (required).

get_couponC

Get details for a specific coupon.

Inputs: slug (required), couponCode (required).

get_individual_purchasesC

Get a paginated list of individual purchases for a book.

Inputs: slug (required), page, email.

get_interested_readersC

List readers who registered interest and opted to share their email.

Inputs: slug (required).

get_job_statusC

Check the status of a running preview/publish job. Returns {} when no job is running.

Inputs: slug (required).

get_royaltiesC

Get a book's sales and royalties summary.

Inputs: slug (required).

get_user_reader_emailsA

Get emails of readers who opted to share them with you, across all your books/courses.

Inputs: username (required), type.

list_couponsB

List all coupons for a book.

Inputs: slug (required).

preview_bookA

Start a full preview generation (PDF + EPUB) for a book. Returns immediately; poll get_job_status or use wait_for_job to know when it's done.

Inputs: slug (required).

preview_courseB

Start a preview generation for a course (self-published, organization, or university).

Inputs: slug (required), universitySlug, organizationSlug.

preview_singleA

Preview a single chapter from raw Markdown content without touching Subset.txt. Saved as {slug}-single-file.pdf.

Inputs: slug (required), markdown (required).

preview_subsetC

Generate a faster PDF-only preview using Subset.txt.

Inputs: slug (required).

publish_bookB

Publish a book, making the latest version available to readers.

Inputs: slug (required), emailReaders, releaseNotes.

publish_courseC

Publish a course (self-published, organization, or university).

Inputs: slug (required), emailReaders, releaseNotes, universitySlug, +2 more.

register_interestA

Register a reader's interest in an unpublished book so they're notified on publish.

Inputs: name (required), slug (required), email (required), shareEmailWithAuthor.

retire_bookA

Retire a published book — no new purchases, existing readers keep access (primary author only).

Inputs: slug (required).

unpublish_bookB

Unpublish a book (primary author only).

Inputs: slug (required).

update_couponB

Update an existing coupon (suspend/resume, change uses, etc). Only include fields to change.

Inputs: slug (required), couponCode (required), note, endDate, +2 more.

verify_api_keyA

Verify the configured Leanpub API key and return the authenticated user.

Inputs: no named parameters.

wait_for_jobA

Poll get_job_status every 5s (configurable) until the job completes or the timeout elapses. Use right after preview_book/publish_book.

Inputs: slug (required), timeoutSeconds, intervalSeconds.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 28 tools

    Disambiguation4/5

    Most tools target distinct actions (get, create, publish, preview) on specific entities. However, the three preview tools (preview_book, preview_subset, preview_single) and the three reader-email tools are closely related, though descriptions sufficiently clarify their different use cases.

    Naming Consistency5/5

    Tool names follow a consistent snake_case verb_noun pattern throughout, such as get_book, create_coupon, publish_course, and wait_for_job. Minor compound names like check_book_exists still fit the established convention without introducing style inconsistencies.

    Tool Count2/5

    With 28 tools, the set exceeds the 25-tool threshold for 'too many.' While the scope spans multiple entity types (books, courses, bundles, coupons, readers, jobs), the count feels heavy, especially since several entities only have creation tools (e.g., create_bundle, create_track), inflating the surface without corresponding coverage.

    Completeness2/5

    The tool surface has significant gaps. Books have create/publish/preview/status transitions, but there is no list_books or update_book. Bundles and tracks only have create operations—no get, update, or delete—and courses lack get/update/delete as well. This incompleteness will force agents to rely on out-of-band knowledge or fail when managing those entities.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Zero-dependency stdio bridge to Moltline Studio's fleet of 14 hosted MCP servers covering code review, time operations, data transforms, business ops, education, research, outreach and more. Free tier requires no registration; premium tools unlock with a license. Independently audited, MCPize Verified A.
      10
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables MCP clients to render Markdown to HTML, estimate page counts, verify document delivery constraints, and atomically ship documents through a zero-dependency JSON-RPC stdio server.
      4
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables MCP clients to connect to a WordPress site with a scoped API key and manage posts, pages, custom post types, taxonomies, comments, media, approved settings, plugins, and themes. It runs locally over stdio and requires the companion WordPress plugin to be installed and activated.
      42
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Connects MCP clients to a self-hosted photo library through its REST API, exposing assets, albums, people, search, and optional administrative toolsets with read-only defaults and confirm-gated writes. It supports stdio and localhost Streamable HTTP transports.
      5
      76 npm
      MIT