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
506/2/2026
Claude CodeCursorWindsurf
#zai-cli#mcp#performance-tuning#code-mode

Recommended for

Our review

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

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
Related skills