Loading...
Loading...
Build CLI scripts alongside MCP servers for terminal environments. File I/O, batch processing, caching, richer output formats. Templates for TypeScript scripts and SCRIPTS.md. Use when: MCP companion scripts, batch processing, saving results to files, CLI API wrappers. Troubleshoot: context too large, no file access, batch input.
npx skill4agent add jezweb/claude-skills mcp-cli-scripts| Aspect | Remote MCP (Claude.ai) | CLI Scripts (Claude Code) |
|---|---|---|
| Context | Results flow through model context window | Results stay local, only relevant parts shared |
| File System | No access | Full read/write access |
| Batch Operations | One call at a time | Can process files of inputs |
| Caching | Stateless | Can cache results locally |
| Output | JSON to model | JSON, CSV, table, file, or stdout |
| Chaining | Model orchestrates | Scripts can pipe/chain directly |
mcp-{name}/
├── src/
│ └── index.ts # MCP server (for Claude.ai, remote clients)
├── scripts/
│ ├── {tool-name}.ts # One script per tool
│ ├── {another-tool}.ts
│ └── _shared.ts # Shared auth/config helpers (optional)
├── SCRIPTS.md # Documents available scripts for Claude Code
├── package.json
└── README.md// Good - structured output
console.log(JSON.stringify({ success: true, data: result }, null, 2));
// Avoid - unstructured text (unless --format text requested)
console.log("Found 5 results:");// Input/Output files
--input data.csv // Batch process from file
--output results.json // Save results to file
--append // Append to existing file
// Caching
--cache // Use local cache
--cache-ttl 3600 // Cache for 1 hour
--no-cache // Force fresh request
// Output formats
--format json|csv|table // Different output formats
--quiet // Suppress non-essential output
--verbose // Extra debugging info
// Batch operations
--batch // Process multiple items
--concurrency 5 // Parallel processing limit# Standard patterns
--input <file> # Read input from file
--output <file> # Write output to file
--format <type> # Output format
--profile <name> # Auth profile (for multi-account)
--verbose # Debug output
--help # Show usage#!/usr/bin/env npx tsx
/**
* Brief description of what this script does
*
* Usage:
* npx tsx scripts/tool-name.ts <required-arg>
* npx tsx scripts/tool-name.ts --option value
*
* Examples:
* npx tsx scripts/tool-name.ts 12345
* npx tsx scripts/tool-name.ts --input batch.csv --output results.json
*/#!/usr/bin/env npx tsx{ success: false, error: "..." }console.log()nodets-nodesrc/
├── core/
│ ├── lookup.ts # Pure function, no I/O assumptions
│ └── index.ts # Export all core functions
├── mcp/
│ └── index.ts # MCP handlers, import from core
└── cli/
└── lookup.ts # CLI wrapper, import from core# Copy to your project
cp ~/.claude/skills/mcp-cli-scripts/templates/script-template.ts scripts/new-tool.ts# Copy to your project
cp ~/.claude/skills/mcp-cli-scripts/templates/SCRIPTS-TEMPLATE.md SCRIPTS.md.claude/rules/cp ~/.claude/skills/mcp-cli-scripts/rules/mcp-cli-scripts.md .claude/rules/{
"devDependencies": {
"tsx": "^4.21.0"
}
}{
"devDependencies": {
"tsx": "^4.21.0"
}
}scripts/npx tsx scripts/tool-name.ts --help