Advanced zai-cli Usage and Performance Tuning

VerifiedSafe

Covers advanced zai-cli commands including raw MCP tools, TypeScript code mode, and performance tuning. Helps optimize startup times, configure tool discovery caching, retries, and timeouts.

Sby Skills Guide Bot
DevelopmentAdvanced
6/2/2026
Claude CodeCursorWindsurf
#zai-cli#mcp#performance-tuning#code-mode

Recommended for

Automated summary

Provides advanced commands and performance tuning options for the zai-cli command-line tool, including direct MCP tool invocation, TypeScript tool chain execution, and cache/timeout management.

Strengths

  • Enables direct interaction with MCP tools via schemas and raw calls.
  • Offers a code mode to run TypeScript scripts and evaluate expressions.
  • Provides environment variables to fine-tune caching, retries, and timeouts.

Limitations

  • Requires deep knowledge of zai-cli and MCP tools.
  • Performance settings are specific to zai-cli and not portable.
  • MCP error handling may need manual adjustments.
When to use it

Best for automating complex workflows with zai-cli, debugging MCP tools, or optimizing performance in production environments.

When not to use it

Avoid when using zai-cli with basic commands or when network performance optimization is unnecessary.

Security analysis

Safe
Quality score85/100

The skill provides reference documentation for the zai-cli tool, with no destructive or exfiltrating instructions. All commands are standard CLI usage and environment variable settings, posing no execution risk.

No concerns found

How this analysis is made

Examples

List all MCP tools with full schemas
Show me all available MCP tools with their full schemas, but skip vision-related ones.
Execute a TypeScript tool chain
Run the TypeScript tool chain from ./chain.ts using zai-cli code mode.
Optimize MCP tool discovery cache
Set the MCP tool cache TTL to 5 minutes and enable caching for faster tool discovery.

Advanced Usage

This reference covers advanced commands and performance tuning for zai-cli.

Raw MCP Tools

Use these when you need schemas or direct tool invocation.

  • zai-cli tools [--filter <text>] [--full] [--typescript] [--no-vision]
  • zai-cli tool <name> [--no-vision]
  • zai-cli call <tool> [--json <json> | --file <path> | --stdin] [--dry-run] [--no-vision]

Examples

zai-cli tools --filter vision --full
zai-cli tool zai.zread.search_doc --no-vision
zai-cli call zai.search.webSearchPrime --json '{"search_query":"LLM tools"}'

Code Mode (TypeScript tool chains)

zai-cli code run ./chain.ts
zai-cli code eval "await call('zai.search.webSearchPrime', { search_query: 'zai cli' })"
zai-cli code interfaces

Performance Tuning

Skip vision MCP startup

zai-cli tools --no-vision
zai-cli doctor --no-vision

Tool discovery cache (speeds tools/tool/doctor)

Defaults: enabled, 24 hour TTL.

export ZAI_MCP_TOOL_CACHE=1
export ZAI_MCP_TOOL_CACHE_TTL_MS=300000
export ZAI_MCP_CACHE_DIR="$HOME/.cache/zai-cli"

Retries for transient MCP failures

# Vision-only retries (default 2)
export ZAI_MCP_VISION_RETRY_COUNT=2

# Global retries for all tools
export ZAI_MCP_RETRY_COUNT=1

Timeout

export Z_AI_TIMEOUT=300000  # milliseconds

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/advanced-zai-cli-usage-and-performance-tuning-mm5t8cif/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/advanced-zai-cli-usage-and-performance-tuning-mm5t8cif' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/advanced-zai-cli-usage-and-performance-tuning-mm5t8cif/download' --output '.skill-downloads/advanced-zai-cli-usage-and-performance-tuning-mm5t8cif/SKILL.md.part' && mv '.skill-downloads/advanced-zai-cli-usage-and-performance-tuning-mm5t8cif/SKILL.md.part' '.skill-downloads/advanced-zai-cli-usage-and-performance-tuning-mm5t8cif/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/advanced-zai-cli-usage-and-performance-tuning-mm5t8cif/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills