mcpField
C
chinese-poetry-api

chinese-poetry-api

github.com/wmy2981Creative & media157 installsUpdated 5w ago
Repository

About chinese-poetry-api

chinese-poetry-api is a command-line skill that calls the chinese-poetry-api REST service for users looking up Chinese poetry. It supports simplified and traditional Chinese output, with queries for poems, authors, dynasties, and types.

Key features

  1. 01List and filter poems
  2. 02Search titles, content, or authors
  3. 03Fetch a random poem
  4. 04Look up authors, dynasties, and types
  5. 05Switch between simplified and traditional Chinese

Use cases

  1. 01Find poems by author or dynasty
  2. 02Search poem titles or text
  3. 03Fetch a random poem for reading

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/wmy2981/skills --skill chinese-poetry-api

After installing, type/chinese-poetry-apiin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

.claude-plugin/
plugin.json
scripts/
.env.example
main.ts
package.json
tsconfig.json

Details

From the project README

Chinese Poetry API

CLI wrapper around the chinese-poetry-api REST service (Go, ~370k poems, simplified/traditional Chinese via lang).

Execution Rule

Run the user's command directly without pre-checking; fix on failure.

Requirements

  • Bun runtime (>= 1.0)
  • A reachable chinese-poetry-api instance

Setup

The script reads the POETRY_API_URL environment variable — a full API base URL (the script appends no prefix). The default is https://poetry.palemoky.com/api, an online test instance provided by the upstream developer. It may rate-limit, change data, or go offline without notice — treat it as a demo only. For real work, point POETRY_API_URL at your own instance (local Docker or self-hosted deployment).

  1. Read scripts/.env.example for the variable name.
  2. Add or update POETRY_API_URL in the shared global file ~/.wmyskills/.env.
  3. Do not copy .env.example to .env directly — that would overwrite existing config.

If the user's request needs an instance that isn't running, start one after notifying the user:

docker run -d -p 1279:1279 palemoky/chinese-poetry-api:latest

Usage

bun run scripts/main.ts <command> [options]

All output is the raw JSON body from the server — print it verbatim, do not reformat or summarize it. Non-2xx responses print Error <status>: <body> to stderr and exit 1.

CommandDescriptionOptions
healthHealth check—
statsOverall statistics—
poemsList poems (filters are combinable)--dynasty --author --dynasty-id --type-id (repeatable, OR) --page --page-size (max 100)
searchFull-text search (FTS5)--q (required) --type (all default, title, content, author) --page --page-size
randomRandom poem--author --author-id --dynasty --dynasty-id --type (repeatable, OR) --type-id --char
authorsList authors (paginated)--page --page-size
authorAuthor by ID--id (required)
dynastiesList dynasties (with poem counts)—
dynastyDynasty by ID--id (required)
typesList poetry types—
typePoetry type by ID--id (required)

Every command accepts --lang zh-Hans|zh-Hant to switch simplified/traditional Chinese (zh-Hans is the default). Invalid flags or arguments are rejected with an error before any request is sent.

Examples

# Health check and overall stats
bun run scripts/main.ts health
bun run scripts/main.ts stats

# Li Bai's poems, page 2
bun run scripts/main.ts poems --author 李白 --page 2 --page-size 10

# Poems from the Tang dynasty in traditional Chinese
bun run scripts/main.ts poems --dynasty 唐 --lang zh-Hant

# Full-text search
bun run scripts/main.ts search --q 静夜思
bun run scripts/main.ts search --q 明月光 --type content

# Random 五言绝句 by Li Bai (multiple types are OR)
bun run scripts/main.ts random --author 李白 --type 五言绝句 --type 七言绝句

# 飞花令 — poem containing a single character
bun run scripts/main.ts random --char 春

# Metadata
bun run scripts/main.ts authors --page 1 --page-size 20
bun run scripts/main.ts author --id 1
bun run scripts/main.ts dynasties
bun run scripts/main.ts dynasty --id 6
bun run scripts/main.ts types
bun run scripts/main.ts type --id 10

Notes

  • --char (飞花令) accepts exactly one character and can only be combined with --lang — other filters return 400 from the server.
  • Query params are validated server-side: unknown params or page_size over 100 return 400, so don't invent filters the API doesn't document.

Comments

Markdown supported