mcpField
A
amazon-kdp

amazon-kdp

github.com/joshyattridgeMarketing & growth1649 installsUpdated 16w ago
Repository

About amazon-kdp

amazon-kdp is an automation skill for managing Amazon KDP titles through a local Express service and Playwright browser session. It is intended for agents handling catalog, reporting, and publishing tasks, with sequential, verified write operations.

Key features

  1. 01Sync and audit book metadata
  2. 02Download and parse royalty reports
  3. 03Update listing details and pricing
  4. 04Upload interior and cover PDFs
  5. 05Create, publish, and manage titles
  6. 06Retry blocked writes with recovery steps

Use cases

  1. 01Summarize royalty reports for a date range
  2. 02Review and update book keywords or descriptions
  3. 03Upload a cover and publish titles one at a time

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/joshyattridge/amazon-kdp-skill --skill amazon-kdp

After installing, type/amazon-kdpin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

.gitignore
.env.example
package.json
README.md
package-lock.json
examples/
publish-book.example.json
lib/
royaltyDate.ts
parseKdpUploaderWorkbook.ts
parseKdpWorkbook.ts
references/
metadata-fields.md
api-endpoints.md
troubleshooting.md
scripts/
add-second-category.ts
debug-categories.ts
debug-desc-no-h1.ts
approve-roulette-content.ts
debug-direct-save.ts
debug-desc-plain.ts
debug-description-fill.ts
debug-new-title-save.ts
debug-fill-and-save.ts
debug-pricing-multi.ts
debug-pricing-playwright-fill.ts
debug-pricing-save.ts
export-metadata-xlsx.mjs
debug-stock-market-save.ts
finish-roulette-final.ts
discover-kdp-apis.mjs
debug-save-persist.ts
kdp-cli.mjs

Details

From the project README

Amazon KDP Automation

Self-contained skill repo with a local Express + Playwright server. Amazon has no public KDP metadata API — this uses saved browser session cookies to call KDP's internal pages and report endpoints.

Agent responsibilities

You run everything. Do not ask the user to run terminal commands.

  1. Ensure setup: npm install, copy .env.example → .env if missing.
  2. Start the server if not running: npm run server:start (background).
  3. Check session before any sync/update/download: npm run status.
  4. Run all KDP tasks yourself via npm scripts or the local REST API.
  5. Only pause for the user during Amazon login — they must complete sign-in (incl. MFA) in the visible Chromium window. Poll npm run status until connected: true.

Session persists in .kdp-session/ (gitignored).

Sequential operations (required)

When the user asks for multiple books or multiple write tasks, process them one at a time — never in parallel and never in a single batch request.

Do:

  • Complete one book (or one metadata/pricing/content update) fully before starting the next
  • Use single-book endpoints: /api/kdp/metadata/update, /api/kdp/pricing/update, /api/kdp/content/upload, /api/kdp/publish — one HTTP call per book
  • Run npm run publish:book -- spec.json --live once per title; generate a separate spec JSON per book if needed
  • Wait for each call to finish (publish can take several minutes) and verify the result before continuing
  • If a step fails, stop or fix that book before moving on — do not fire the rest of the queue blindly

Do not:

  • Create batch scripts that loop inside one long-running process without user approval
  • Call batch API routes (/batch endpoints) for multiple titles in one request
  • Run multiple publish/upload commands in parallel or in background at the same time
  • Open more than one Playwright browser session for KDP writes at once

This avoids HTTP timeouts, Amazon "Server Busy" rate limits, and browser/session conflicts. Batch endpoints exist for advanced use only; agents should default to sequential single-book calls.

Sub-skills — read the matching file before acting

TaskSkill file
Sign in / session statusskills/connect-session/SKILL.md
Account info + reports catalogskills/account-info/SKILL.md
Download royalty reportsskills/download-reports/SKILL.md
Parse royalty Excel → JSON summaryskills/parse-reports/SKILL.md
Pull book metadata (all or one)skills/sync-metadata/SKILL.md
Export metadata to Excelskills/export-metadata/SKILL.md
Audit metadata (keywords, categories)skills/analyze-metadata/SKILL.md
Push listing changes (details page)skills/update-metadata/SKILL.md
Push pricing / KDP Selectskills/update-pricing/SKILL.md
Upload interior / cover PDFsskills/upload-content/SKILL.md
Full publish wizard (create → publish)skills/publish-book/SKILL.md

Quick commands (agent runs these)

npm run status                    # session connected?
npm run account:info              # catalog size, vendor code
npm run bookshelf:list            # fast title/format refs
npm run catalog:get               # all titles + ASINs from kdpreports
npm run download:report           # lifetime royalties → output/
npm run parse:report -- file.xlsx # summarize royalties
npm run sync:metadata             # full Bookshelf scrape → cache
npm run sync:book -- ID paperback # refresh one book
npm run metadata:get              # print cached JSON
npm run metadata:export           # cache → Excel
npm run metadata:analyze          # keyword/category audit
npm run update:metadata -- file.json --dry-run
npm run publish:book -- examples/publish-book.example.json

Architecture

Browser session (.kdp-session/amazon-kdp.json)
        ↓
Local server (server/src/index.ts) — REST API
        ↓
Playwright session cookies
        ↓
Request-first: kdpreports JSON APIs → HTML GET + parse → browser fallback
        ↓
Global rate limit (KDP_REQUEST_DELAY_MS between every request)

Read operations

OperationEndpoint / command
Session statusGET /api/kdp/status
Account infoGET /api/kdp/account
Reports catalogGET /api/kdp/catalog
Bookshelf list (fast)GET /api/kdp/bookshelf
Metadata cacheGET /api/kdp/metadata
Full metadata syncPOST /api/kdp/metadata/sync
Single book syncPOST /api/kdp/metadata/sync/:titleId/:format
Metadata auditGET /api/kdp/metadata/analyze
Lifetime royaltiesPOST /api/kdp/sync
Date-range royaltiesPOST /api/kdp/reports/download

Write operations

OperationEndpoint
Update details (keywords, description, author, flags)POST /api/kdp/metadata/update
Batch metadata updatePOST /api/kdp/metadata/update/batch
Update pricing / KDP SelectPOST /api/kdp/pricing/update
Batch pricing updatePOST /api/kdp/pricing/update/batch
Upload interior/coverPOST /api/kdp/content/upload
Batch uploadPOST /api/kdp/content/upload/batch
Create new titlePOST /api/kdp/titles/create
Update categoriesPOST /api/kdp/categories/update
Full publish wizardPOST /api/kdp/publish
Unpublish live titlePOST /api/kdp/titles/unpublish
Delete draftPOST /api/kdp/titles/delete
Archive titlePOST /api/kdp/titles/archive
Recovery learningsGET /api/kdp/recovery/learnings

Always dry-run one book before live writes on additional books. Never set publish: true without explicit user confirmation.

Batch REST endpoints (/batch) are for manual/advanced use. Agents must not use them for multi-book work — call the single-book endpoint repeatedly, one title at a time, waiting for each to complete.

Automatic error recovery

Write flows (details save, content upload, pricing, publish wizard) retry with recovery when KDP blocks progress:

  • Built-in playbook: dismiss modals, set release date, approve manuscript preview, select cover upload accordion, bypass Server Busy, wait for processing, etc.
  • Learnings file: .kdp-session/recovery-learnings.json — successful error→action pairs are ranked higher on future runs.
  • Publish API responses may include recoveryLog describing what was tried.

If recovery exhausts retries, read errors and recoveryLog, then fix the underlying issue (e.g. invalid cover PDF dimensions).

Rules for agents

  1. Always check session (npm run status) before sync/update. If connected: false, run login sub-skill first.
  2. One operation at a time for writes — see Sequential operations. No batch scripts, no parallel publishes, no /batch API for multiple titles.
  3. Never commit .kdp-session/ or downloaded .xlsx files.
  4. Rate limiting: the server spaces every KDP page load and API call by KDP_REQUEST_DELAY_MS (default 4s). Do not bypass this.
  5. Metadata/pricing updates: dry-run one book, then apply live changes one book per request.
  6. Verify saves by re-reading metadata from KDP (built into update flows).
  7. Categories: writable via browse node IDs or modal path picker (POST /api/kdp/categories/update or publish wizard).
  8. Publish: use npm run publish:book dry-run first; live publish requires "publish": true and user confirmation. One book per publish:book invocation.

References

Comments

Markdown supported