---
description: Quick MCP availability check before MCP tool calls
trigger: tool-use
match: mcp__smartstack__*
blocking: false
---

# MCP Quick Check (Low Token)

Lightweight pre-check before MCP calls. Reads cache only, no LLM processing.

## Script

```bash
#!/bin/bash
STATUS_FILE=".claude/mcp-status.json"
MAX_AGE_DAYS=7

# Create .claude if missing
mkdir -p .claude

# Check if status file exists
if [ ! -f "$STATUS_FILE" ]; then
  echo "⚠️ MCP: First use - run /mcp healthcheck"
  exit 0
fi

# Check file age (cross-platform)
if command -v stat &> /dev/null; then
  if [[ "$OSTYPE" == "darwin"* ]]; then
    FILE_AGE=$(( ($(date +%s) - $(stat -f %m "$STATUS_FILE")) / 86400 ))
  else
    FILE_AGE=$(( ($(date +%s) - $(stat -c %Y "$STATUS_FILE")) / 86400 ))
  fi

  if [ "$FILE_AGE" -gt "$MAX_AGE_DAYS" ]; then
    echo "⚠️ MCP: Cache expired ($FILE_AGE days) - run /mcp healthcheck"
  fi
fi

# Check last status
STATUS=$(grep -o '"status":\s*"[^"]*"' "$STATUS_FILE" 2>/dev/null | cut -d'"' -f4)
if [ "$STATUS" = "error" ]; then
  echo "❌ MCP: Last check failed - run /mcp healthcheck"
  exit 1
fi

exit 0
```

## Behavior

| Condition | Output | Blocks? |
|-----------|--------|---------|
| No cache file | Warning message | No |
| Cache > 7 days | Warning message | No |
| Last status = error | Error message | Yes |
| All OK | Silent (no output) | No |

## Token Cost

- **Normal case (cache valid):** 0 tokens (pure bash, no LLM)
- **Warning case:** ~10 tokens (displays message)
- **Full healthcheck:** ~100-200 tokens (only when explicitly called)
