Output Formats
Every mcp2cli command supports three output formats — human-readable text, JSON, and NDJSON — for both interactive use and programmatic consumption.
Formats
Human (default)
Optimized for terminal readability:
email lssend tool Send an email messagereply tool Reply to a threadinbox resource mail://inboxsimple-prompt prompt A simple prompt with no argumentsJSON
Structured envelope for programmatic parsing:
email --json ls{ "app_id": "email", "command": "discover", "summary": "discovered 14 capabilities", "lines": [ "send tool Send an email message", "reply tool Reply to a thread" ], "data": { "category": "capabilities", "items": [ { "id": "send", "kind": "tool", "summary": "Send an email message" }, { "id": "reply", "kind": "tool", "summary": "Reply to a thread" } ] }}NDJSON
Newline-delimited JSON — one JSON object per line:
email --output ndjson ls{"app_id":"email","command":"discover","summary":"discovered 14 capabilities","lines":[...],"data":{...}}Best for streaming pipelines and log ingestion.
Selecting a Format
CLI Flags
email --json ls # JSONemail --output json ls # Same as --jsonemail --output ndjson ls # NDJSONemail --output human ls # Explicit humanemail ls # Human (default)Config Default
defaults: output: json # Default for all commandsPrecedence
--json flag → --output flag → config defaults.output → human
JSON Envelope Structure
Every JSON response follows a consistent envelope:
{ "app_id": "email", // Config name or alias "command": "invoke", // Operation type "summary": "called send", // Human-readable summary "lines": ["..."], // Human-format lines (for compatibility) "data": { ... } // Command-specific structured data}Extracting Data with jq
# List tool namesemail --json ls --tools | jq -r '.data.items[].id'
# Get send result contentemail --json send --to user@example.com --subject "Hi" --body "..." | jq '.data.content'
# Check server healthemail --json doctor | jq '.data.server'
# Get auth stateemail --json auth status | jq '.data.auth_session.state'
# Count capabilitiesemail --json ls | jq '.data.items | length'
# Filter tools by nameemail --json ls | jq '[.data.items[] | select(.id | test("draft"))]'Piping and Scripting
JSON output makes mcp2cli a first-class citizen in shell pipelines:
# Store result for later useRESULT=$(email --json send --to user@example.com --subject "Hi" --body "hello")echo "$RESULT" | jq '.data.content[0].text'
# Chain operationsemail --json ls --tools | jq -r '.data.items[].id' | while read tool; do echo "Testing: $tool" email --json "$tool" --help 2>/dev/null || truedone
# Compare before/afterBEFORE=$(email --json ls | jq '.data.items | length')# ... do something ...AFTER=$(email --json ls | jq '.data.items | length')echo "Tools changed: $BEFORE → $AFTER"Host Command Output
Host-level commands (config, link, use, daemon) also respect --json:
mcp2cli --json config list | jq '.[].name'mcp2cli --json daemon status | jq '.data.daemons[] | select(.status == "running")'mcp2cli --json use --show | jq '.data.config_name'See Also
- Shell Scripting with MCP — full scripting patterns
- AI Agents + MCP via CLI — JSON output for agent integration
- Configuration Reference —
defaults.outputconfig