Kling AI MCP and CLI

Kling AI MCP and CLI is a free agent skill maintained by Scopeful. It teaches an AI coding agent such as Claude Code, Cursor, Windsurf or Codex how to drive this tool correctly, so you do not have to re-explain it every session. Every published Scopeful skill is free and the install command is public, with no sign-in required. Scopeful also tracks hand-verified USD pricing for 39 AI creative tools at https://www.scopeful.org/tools.

'Use this skill whenever the user wants to generate video or images with Kling AI from inside an AI assistant (Cursor, Claude, OpenClaw, Hermes, Codex, Copilot) or from a terminal via the official `kling` CLI. Triggers on "Kling MCP", "kling CLI", "kling --help", "npx skills add klingai", "install Kling", "Kling in Cursor", "Kling in Claude", or any task where the agent itself is the caller, not a backend service. Do not trigger for direct REST API calls from app code; use the `kling-api` skill for that.'

Tags: kling, kuaishou, video, image, mcp, cli

Reference


name: kling description: 'Use this skill whenever the user wants to generate video or images with Kling AI from inside an AI assistant (Cursor, Claude, OpenClaw, Hermes, Codex, Copilot) or from a terminal via the official kling CLI. Triggers on "Kling MCP", "kling CLI", "kling --help", "npx skills add klingai", "install Kling", "Kling in Cursor", "Kling in Claude", or any task where the agent itself is the caller, not a backend service. Do not trigger for direct REST API calls from app code; use the kling-api skill for that.' metadata: version: 1.0.0

Kling AI MCP + CLI Skill

This skill is the end-user playbook for Kling AI's two user-facing surfaces: the MCP server at https://kling.ai/mcp and the official @klingai/cli-global (and @klingai/cli-cn for the China region) command-line tool. It is syntax-first so a coding agent can drive either surface without guessing. The deeper REST integration patterns live in the kling-api skill.

What this skill is for. Generating a video or image with Kling from an AI assistant or terminal. Installing the MCP into Cursor, Claude, OpenClaw, or any other MCP client. Running a one-off kling text_to_video job and getting the result back.

What this skill is not for. Building a production backend that calls Kling over REST from app code. Use the kling-api skill for that. Pricing comparison and model recommendations across vendors live in the Scopeful MCP, not here.

When To Use

Use this skill when the user needs to:

Working Style

When this skill is active:

  1. Pick the right surface first. MCP for AI-assistant workflows, CLI for terminal / CI / scripted workflows. Do not install both in the same client (per the upstream guide, the assistant may pick either unpredictably).
  2. Discover, do not hardcode. Run who_am_i (MCP) or kling who_am_i (CLI) to get the live model list and parameter specs. The skill body has the shape, not the specific model names; those change.
  3. Treat generation as async. MCP and CLI both return a generation_id (or task_id for the API surface); poll query_tasks until the status is terminal. The CLI has a --poll flag that does this for you.
  4. Never log the token. Both surfaces store auth locally (~/.kling/ for the CLI, the MCP client's credential store for the server). Never echo or persist the token yourself.
  5. Region split is real. If the user's account is on the China site, they need @klingai/cli-cn and a different MCP endpoint. Ask before assuming global.

Choose the Right Surface

Situation Use
Generate from inside an AI assistant (natural language) MCP
Generate from a terminal or shell script CLI
Generate from CI / cron / Makefile CLI
Generate from a backend service in your own code REST (use kling-api skill)
Bulk scripted generation with retry logic CLI
Interactive exploration (chat, prompt tuning) MCP

For the same AI assistant, install MCP or CLI, not both. The assistant's tool selector may pick the wrong one if both are present.

MCP Install

The MCP server is a single URL: https://kling.ai/mcp. It uses the Streamable HTTP transport and authenticates via a one-click account binding through the user's browser (a "Connect" flow). There is no API key to paste.

Cursor

  1. Settings > Tools & MCPs > Add Custom MCP.
  2. Add entry: klingai with URL https://kling.ai/mcp.
  3. Click Connect. Sign in with the Kling account in the browser popup. Done.

Claude (Desktop or claude.ai)

  1. Customize > Connectors > Add custom connector.
  2. Add entry: klingai with URL https://kling.ai/mcp.
  3. Click Add > Connect. Browser sign-in.

Other clients (Codex, Copilot, OpenClaw, Hermes, Windsurf, etc.)

Any MCP client that supports a custom HTTP transport can point at https://kling.ai/mcp. The auth flow is the same browser-based Connect. CLI install (the CLI is a thin MCP client) is the preferred path on OpenClaw and Hermes per the upstream guide.

MCP Tools (8)

Every MCP call starts with who_am_i. It returns the current user identity plus the live model list and per-model parameter specs. Call it once per session; cache the result for the rest of the session.

Tool Category Returns
who_am_i Discovery identity, available models, parameter specs
text_to_video Generation generation_id (poll query_tasks)
image_to_video Generation generation_id
text_to_image Generation generation_id
image_to_image Generation generation_id (reference image + prompt)
query_tasks Task Query status + asset URL by generation_id
file_upload File Upload one-time upload ticket; bytes uploaded by the client
query_membership_and_credits Monetization subscription status, available credits

Generation flow (applies to all four generation tools):

  1. Call the generation tool with the prompt and any parameters. The tool returns a generation_id immediately. Status will be submitted.
  2. Poll query_tasks with the generation_id every 5-10 seconds until status is succeed (or succeeded on the new endpoint shape), failed, or your timeout. Back off to 30s after a minute.
  3. The successful response includes works[] with url and url_without_watermark. Download the URL promptly (30-day TTL, hotlink-protected).

File upload uses a one-time ticket. The file_upload tool returns a ticket; the client uploads the bytes directly to the ticket's upload URL. This avoids the MCP server being a bottleneck for large media. The CLI handles this transparently - if you pass a local file path to kling image_to_video --image ./photo.jpg, the CLI uploads it for you.

CLI Install

The kling CLI is published to npm as @klingai/cli-global (international) and @klingai/cli-cn (mainland China). Both install the same kling binary. Pick the one that matches the user's account region.

# International
npm i -g @klingai/cli-global

# China region
npm i -g @klingai/cli-cn

Requirements: Node.js 18 or newer. Cross-platform: macOS, Linux, Windows.

Verify the install:

kling --version

If the version prints, the install is good. The current latest version is 0.1.1.

CLI Login

kling login

Opens the system browser to a Kling OAuth page. Sign in. The CLI stores the resulting token locally under ~/.kling/ (NOT .credentials - the older MCP/CLI guide's reference is vague, the actual path is ~/.kling/). The CLI never prints the token.

To revoke:

kling logout

CLI Commands (11)

The CLI is a thin wrapper around the backend MCP server. Command names match the MCP tools. There are no aliases.

Command Maps to MCP tool Description
kling who_am_i who_am_i identity, available models, parameter specs
kling text_to_image <prompt> text_to_image submit text-to-image
kling image_to_image --image <url|path> <prompt> image_to_image image-to-image with one or more reference images
kling text_to_video <prompt> text_to_video submit text-to-video
kling image_to_video --image <url|path> <prompt> image_to_video submit image-to-video (animate a still)
kling query_tasks <generationId> query_tasks poll status and result URLs
kling file_upload <filePath> file_upload upload a local file, return a public URL
kling account (combined) identity + subscription status + credit balance
kling tool_list (MCP tools/list) list tools advertised by the backend MCP server
kling login n/a browser OAuth login
kling logout n/a revoke and clear saved login state

kling account is a composite command (combines who_am_i plus membership information). The MCP surface keeps these as separate tools (who_am_i and query_membership_and_credits); the CLI merges them. This is the only place where the CLI surface is asymmetric with the MCP surface.

CLI Global Flags

Flag Description
--model <name> Select a model from who_am_i (required for generation unless --omni)
--omni Pick the omni-family model for generation commands
--skill-name <n> Optional telemetry: identify the calling skill (forwarded to the server; never changes behavior)
--skill-version <v> Optional telemetry: skill version, paired with --skill-name
--poll [N] Poll for up to N seconds. Bare --poll defaults to 60.
--quiet, -q Compact single-line JSON output
--help, -h Top-level or per-command help
--version, -v Print CLI version

--skill-name and --skill-version are how the backend identifies the calling agent (Scopeful, etc.). They are pure telemetry and never change the result. Set them in wrapper scripts so usage shows up in the Kling dashboard by source.

CLI Examples

Text to Image

kling text_to_image --model kling-image-v3_0 "cyberpunk city at night" \
  --aspectRatio 16:9 --imgResolution 2k --imageCount 4 --poll 120

Image to Image

kling image_to_image --model kling-image-v3_0 --image ./cat.jpg --image ./style.png \
  "Turn the cat in image 1 into the style of image 2" --poll 120

Text to Video

kling text_to_video --model kling-video-v1 "drone shot flying over a snowy mountain peak" \
  --duration 10 --aspectRatio 16:9 --poll 300

Image to Video

kling image_to_video --model kling-video-v1 --image ./first.jpg --tailImage ./last.jpg \
  "slow camera push-in" --duration 6 --poll 300

Submit First, Then Poll

kling text_to_video --model kling-video-v1 "aerial shot of a coastline" --duration 5
# prints {"generation_id": "..."}

kling query_tasks <generationId> --poll 120

Upload a File

kling file_upload ./photo.jpg
# prints {"url": "https://..."}

Check Account

kling account
# prints identity + plan + remaining credits

Output And Exit Codes

stdout is JSON by default. Use --quiet (or -q) for compact single-line JSON. Progress and diagnostics go to stderr. Pipe stdout to jq or other JSON consumers in scripts.

Exit codes:

Cost Awareness (Quick Reference)

Per-second billing for video, per-call for image / audio. Live prices in units (1 unit = $0.14 USD) at https://kling.ai/document-api/pricing/base/video. Always verify before a batch run.

Model 720P 1080P 4K
kling-3.0-turbo (with audio) 0.8/s 1.0/s -
kling-v3 (no audio) 0.6/s 0.8/s 3.0/s
kling-v3 (with audio) 0.9/s 1.2/s 3.0/s
kling-v3-omni (no video in, with audio) 0.8/s 1.0/s 3.0/s
kling-v2-6 (no audio) 0.3/s 0.5/s -
kling-v2-6 (with audio, with voice) - 1.2/s -
kling-v1-6 (no audio) 0.4/s 0.7/s -

Iterate on kling-v1-6 std mode, lock the prompt, render finals on kling-v2-1-master pro (1080P, 2.0/s = $0.28/s) or kling-v3 4k (3.0/s = $0.42/s).

Migrating From Third-Party Wrappers

Common wrappers that re-sell Kling behind a single static API key:

When to migrate to the official surface:

When to stay on a wrapper:

Migrating From AK/SK (Legacy) to API Key

If the user has a pre-2026 Kling integration using the AK/SK JWT flow, the migration to the new API Key surface is mandatory for Kling 3.0 Turbo and the /tasks query shape. Verified at POST /image-to-video/kling-3.0-turbo with no auth (and again with AK/SK auth): the endpoint returns {"code":1002,"message":"Authentication error. The current API does not support AK/SK; please go to the console (https://kling.ai/dev/api-key) to create API key."}.

Migration steps:

  1. Issue an API Key at https://kling.ai/dev/api-key.
  2. Drop the JWT generation / signing code.
  3. Send Authorization: Bearer <API_KEY> directly.
  4. The CLI and MCP handle the new auth automatically - no change needed there.

Common Pitfalls

  1. Both surfaces installed in the same client. The AI assistant may pick either. Install one, uninstall the other.
  2. Wrong region package. International users on @klingai/cli-cn (or vice versa) get auth errors. Match the package to the account region.
  3. Hardcoded model names in scripts. The available model list changes (3.0 Turbo shipped 2026-06-17, others retire). Run kling who_am_i and use the live names.
  4. Polling faster than every 5 seconds. Kling rate-limits with code 1302 above the documented 5 QPS for non-subscribers. Back off.
  5. Polling for more than the timeout. Video can take 1-5 minutes per the upstream guide. Image 20-60 seconds. Element creation 30s-2 min. Set your timeout to at least 5 minutes for video.
  6. Logging the bearer token. The CLI and MCP both store the token locally; never echo or persist it yourself.
  7. No cancellation. Per the upstream guide, generation tasks cannot be canceled once submitted. Plan your queue accordingly.
  8. Output URL 30-day TTL. Hotlink-protected, single-tenant. Download the bytes promptly and rehost on your own CDN if the asset needs to live longer.
  9. Resulting works[].url is signed. The URL embeds auth parameters; do not share it as a static link.
  10. .credentials was the old path. Use ~/.kling/. If you see a .credentials file, it is from an older install - safe to delete.

Useful Follow-Ups

Resources

For direct REST integration from app code, see the kling-api skill (the deeper surface, with full request/response shapes, error codes, and migration paths).