$npx -y skills add medusajs/medusa-agent-skills --skill mcloud-logsExecute mcloud logs to fetch and stream runtime logs for Cloud environments. Use when reading backend or storefront logs, filtering by time range, searching for errors, or scoping logs to a specific deployment.
| 1 | # Cloud CLI: Logs Command |
| 2 | |
| 3 | Execute `mcloud logs` to fetch runtime logs for a Cloud environment's backend or storefront. |
| 4 | |
| 5 | ## Constraints |
| 6 | |
| 7 | - `--follow` and `--json` are incompatible. For programmatic log analysis, use bounded time windows with `--from`/`--to` and `--json`. |
| 8 | - `--follow` streams until interrupted with `Ctrl+C` — do not use in scripts or pipelines. |
| 9 | - Default retrieves the last 500 log lines from the past 15 minutes. |
| 10 | |
| 11 | ## Command |
| 12 | |
| 13 | ```bash |
| 14 | mcloud logs \ |
| 15 | --organization <org-id> \ |
| 16 | --project <project-id-or-handle> \ |
| 17 | --environment <environment-handle> \ |
| 18 | [options] |
| 19 | ``` |
| 20 | |
| 21 | ## Options |
| 22 | |
| 23 | | Option | Description | Default | |
| 24 | |--------|-------------|---------| |
| 25 | | `-o/--organization <id>` | Organization ID | Active context | |
| 26 | | `-p/--project <id-or-handle>` | Project ID or handle | Active context | |
| 27 | | `-e/--environment <handle>` | Environment handle | Active context | |
| 28 | | `-f/--follow` | Stream logs continuously (incompatible with `--json`) | `false` | |
| 29 | | `--limit <1-5000>` | Max log lines (non-follow mode only) | `500` | |
| 30 | | `--from <ISO8601>` | Start of time range (e.g. `2026-04-22T10:00:00Z`) | 15 minutes ago | |
| 31 | | `--to <ISO8601>` | End of time range; if >15 min ago, must also pass `--from` | now | |
| 32 | | `--search <string>` | Filter by substring (same as dashboard search bar) | — | |
| 33 | | `--deployment <id>` | Filter by deployment or build ID | — | |
| 34 | | `--source <string>` | Filter by source (repeatable) | — | |
| 35 | | `--metadata <key=value>` | Filter by metadata field (repeatable; same key merges values) | — | |
| 36 | | `--type <backend\|storefront>` | Log stream to query | `backend` | |
| 37 | | `--json` | Output as JSON (incompatible with `--follow`) | `false` | |
| 38 | |
| 39 | ## Examples |
| 40 | |
| 41 | ```bash |
| 42 | # Basic log fetch (last 500 lines, last 15 min) |
| 43 | mcloud logs --json |
| 44 | |
| 45 | # Search for errors |
| 46 | mcloud logs --search error --limit 1000 --json |
| 47 | |
| 48 | # Filter for HTTP 500 errors via metadata |
| 49 | mcloud logs --metadata status=500 --limit 1000 --json |
| 50 | |
| 51 | # Logs for a specific deployment (build or deployment ID) |
| 52 | mcloud logs --deployment bld_01ABC123 --json |
| 53 | |
| 54 | # Structured output for agent analysis |
| 55 | mcloud logs --search error --json | jq '.[] | {timestamp, source, message}' |
| 56 | |
| 57 | # Storefront logs |
| 58 | mcloud logs --type storefront --json |
| 59 | |
| 60 | # Stream live logs (human-readable, not for scripts) |
| 61 | mcloud logs --follow |
| 62 | |
| 63 | # Logs within a specific time range |
| 64 | mcloud logs --from 2026-04-22T10:00:00Z --to 2026-04-22T11:00:00Z --limit 1000 --json |
| 65 | |
| 66 | # Logs from a time until now |
| 67 | mcloud logs --from 2026-04-22T10:00:00Z --json |
| 68 | |
| 69 | # Multiple source filters |
| 70 | mcloud logs --source api --source worker --json |
| 71 | |
| 72 | # Multiple metadata filters (HTTP 4xx and 5xx) |
| 73 | mcloud logs --metadata status=400 --metadata status=500 --limit 500 --json |
| 74 | ``` |
| 75 | |
| 76 | ## Time Range Notes |
| 77 | |
| 78 | - Default window is the past 15 minutes. |
| 79 | - Pass `--from` without `--to` to fetch from a time until now. |
| 80 | - Pass `--to` without `--from` only if `--to` is within the last 15 minutes; otherwise also pass `--from`. |
| 81 | - Both `--from` and `--to` accept ISO 8601 timestamps. |