{"_id":"@mailgun/cli","name":"@mailgun/cli","dist-tags":{"latest":"0.2.0"},"versions":{"0.2.0":{"name":"@mailgun/cli","version":"0.2.0","description":"Mailgun CLI - agent-first developer surface","license":"Apache-2.0","author":{"name":"Mailgun"},"homepage":"https://github.com/mailgun/mailgun-cli#readme","bugs":{"url":"https://github.com/mailgun/mailgun-cli/issues"},"repository":{"type":"git","url":"git+https://github.com/mailgun/mailgun-cli.git"},"type":"module","bin":{"mailgun":"dist/index.js"},"engines":{"node":">=20"},"publishConfig":{"access":"public"},"scripts":{"build":"node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json && chmod +x dist/index.js","test":"node -e \"require('fs').rmSync('dist-test',{recursive:true,force:true})\" && tsc -p tsconfig.test.json && node --test $(find dist-test -name '*.test.js')","prepublishOnly":"npm run build","dev":"node --loader ts-node/esm src/index.ts","start":"node dist/index.js"},"dependencies":{"chalk":"^5.3.0","commander":"^12.1.0","ora":"^8.1.1","zod":"^3.23.8"},"devDependencies":{"@types/node":"^20.14.10","ts-node":"^10.9.2","typescript":"^5.5.3"},"gitHead":"0dabffeaddf3901312a49e7533594e2ad1688994","_id":"@mailgun/cli@0.2.0","_nodeVersion":"26.7.0","_npmVersion":"11.19.0","dist":{"integrity":"sha512-BgYWCzXlXYh+udYFOy6j3Dn5jLWqrZpqBtRd9s5b9DCvMvz/oK3UZSnqTkpKKMWLVqDF+iefo4lVIlF3cZnTpA==","shasum":"127f81d3e0c5dc93800321b5058b4c068ab6a194","tarball":"https://registry.npmjs.org/@mailgun/cli/-/cli-0.2.0.tgz","fileCount":65,"unpackedSize":277318,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHDPJJdOXICtdGTJBFB8Bg+fx3MDCFK5Tvmd1PZk0YXCAiB2CjSdzRKymdauKI0/+glbJ2LV9Q7v3LdaF6iu6vmpNw=="}]},"_npmUser":{"name":"jtetlermg","email":"jtetler@mailgun.com"},"directories":{},"maintainers":[{"name":"jtetlermg","email":"jtetler@mailgun.com"},{"name":"zeefarmer","email":"admin@mailgunhq.com"},{"name":"oleksandr-mazepa","email":"zepa1993@gmail.com"},{"name":"pw_dev","email":"devs@mailgun.net"},{"name":"ai-wintermute","email":"dorokhova.olha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cli_0.2.0_1789506657878_0.3225020475668574"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-15T21:10:57.639Z","0.2.0":"2026-09-15T21:10:58.013Z","modified":"2026-09-15T21:10:58.305Z"},"maintainers":[{"name":"jtetlermg","email":"jtetler@mailgun.com"},{"name":"zeefarmer","email":"admin@mailgunhq.com"},{"name":"oleksandr-mazepa","email":"zepa1993@gmail.com"},{"name":"pw_dev","email":"devs@mailgun.net"},{"name":"ai-wintermute","email":"dorokhova.olha@gmail.com"}],"description":"Mailgun CLI - agent-first developer surface","homepage":"https://github.com/mailgun/mailgun-cli#readme","repository":{"type":"git","url":"git+https://github.com/mailgun/mailgun-cli.git"},"author":{"name":"Mailgun"},"bugs":{"url":"https://github.com/mailgun/mailgun-cli/issues"},"license":"Apache-2.0","readme":"# @mailgun/cli\n\n[![npm version](https://img.shields.io/npm/v/@mailgun/cli.svg)](https://www.npmjs.com/package/@mailgun/cli)\n[![License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](LICENSE)\n\nAn agent-first CLI for working with Mailgun from terminals, scripts, CI systems,\nand coding agents. It provides one consistent command surface for understanding\nand operating a Mailgun account, with clean JSON output and a machine-readable\n`agent-context` schema.\n\nMost commands are read-only. Write commands are labeled in `agent-context` and\nuse the explicit, non-interactive guard described below.\n\n> [!NOTE]\n> This is an early preview. The command surface and output may still change.\n> Feedback and feature requests are welcome in\n> [GitHub issues](https://github.com/mailgun/mailgun-cli/issues).\n\n## Requirements\n\n- Node.js 20 or newer\n- A Mailgun account and API key from [API security settings](https://app.mailgun.com/settings/api_security)\n\n## Install\n\nThe CLI is published to npm as [`@mailgun/cli`](https://www.npmjs.com/package/@mailgun/cli).\n\n```bash\nnpm install -g @mailgun/cli\nmailgun --help\n```\n\nFor a one-off run without a global install:\n\n```bash\nnpx -y @mailgun/cli --help\n```\n\nIn CI or a project, install it as a dependency and invoke `mailgun` from `node_modules/.bin`, or use `npx @mailgun/cli`.\n\n## Authentication\n\nAuth is HTTP Basic (`api:$MAILGUN_API_KEY`). Provide credentials via environment\nvariables or flags; flags take precedence over environment variables. API keys\nare **not** region-scoped.\n\n| Concern        | Environment variable  | Flag                                              |\n| -------------- | --------------------- | ------------------------------------------------- |\n| API key        | `MAILGUN_API_KEY`     | `--api-key <key>`                                 |\n| Sending domain | `MAILGUN_DOMAIN`      | `--domain <domain>` (only where a domain applies) |\n| API region     | `MAILGUN_API_REGION`  | `--region <us\\|eu>`                               |\n\nRegion defaults to `us` (`api.mailgun.net`); `eu` routes to `api.eu.mailgun.net`.\nAny value other than `us`/`eu` is a usage error.\n\nPrefer environment variables for API keys on shared machines. Keys are redacted\nfrom all CLI output, but flags may be captured in shell history.\n\nShared flags work before or after the subcommand:\n\n```bash\nmailgun metrics summary --domain acme.com --json\nmailgun --domain acme.com metrics summary --json\n```\n\n## Commands\n\n```bash\n# Sending metrics summary (counts + computed rates; defaults to a 24h window)\n# --duration/--window is already a lookback ending now (<number><m|h|d>, e.g. 30m, 24h, 7d) — no leading \"-\"\nmailgun metrics summary --domain acme.com --json\nmailgun metrics summary --domain acme.com --duration 7d --json\nmailgun metrics summary --domain acme.com --start 2026-06-01T00:00:00Z --end 2026-06-08T00:00:00Z --json\n\n# Validate a single address (positional or --address)\nmailgun validate-email user@example.com --json\nmailgun validate-email --address user@example.com --provider-lookup true --json\n\n# Inbox placement (Optimize): discover result IDs, then fetch a result\nmailgun inbox-placement list --limit 10 --json\nmailgun inbox-placement result --result result_123 --json\n\n# Email preview (Inspect): discover clients/tests, run QA, or resume a result\nmailgun preview clients --json\nmailgun preview list --limit 10 --json\nmailgun preview result --test-id preview_123 --json\nmailgun preview issues preview_123 --check accessibility\nmailgun preview render preview_123 iphone16gmail_18 --output ./iphone.png\nmailgun preview run --subject \"June campaign\" --html ./rendered.html --dry-run --json\nmailgun preview run --subject \"June campaign\" --html ./rendered.html --yes --json\n\n# Live delivery events (single fetch or continuous --tail)\nmailgun events --domain acme.com --json\nmailgun events --domain acme.com --tail\n```\n\nA single `mailgun events` fetch returns the most recent `--limit` events (default\n10, max 100) from the last 24 hours. `--tail` shows that backlog first, then\npolls forward for new events every `--interval` milliseconds:\n\n```bash\nmailgun events --domain acme.com --tail --limit 5 --interval 5000\n```\n\n## Write commands\n\nEvery write command requires exactly one of:\n\n- `--dry-run` to validate and summarize the action without credentials or network access;\n- `--yes` to execute without prompting.\n\nPassing both or neither is a usage error (exit `2`). Commands never prompt, so\nthe behavior is deterministic in scripts and agent workflows.\n\n`preview run` is currently the only write command. It creates one remote Mailgun\nInspect preview test and consumes preview quota. V2 does\nnot document create idempotency, so the CLI sends at most one create request and\nnever recreates automatically after a timeout or uncertain outcome.\n\n## Email Preview QA\n\n`preview run` accepts a subject and rendered HTML file, creates one preview test,\nand polls the requested structured checks. `preview result` safely resumes an\nexisting test without creating anything.\n\nAfter the summary, `preview issues` turns a link, image, or accessibility result\nreference into individual failures with native impact, description, source\nlocation, target/snippet, and URL where available. It fetches only the selected\ncheck and omits passing records.\n\n`preview render` retrieves exactly one client result. Without download flags it\nlists metadata and available API-provided screenshot keys. Passing `--output`\ndownloads the `default` screenshot when present, otherwise another available\nfull screenshot before falling back to a thumbnail. `--variant` can select an\nexplicit key returned by the metadata call. Signed URLs are never printed;\ndownloads are limited to 25 MiB and refuse to overwrite an existing file.\nAn HTTP `425` from a screenshot asset is retried within the existing 30-second\ndownload deadline because the asset may still be propagating; no preview test is\ncreated or retried by this read-only operation.\n\n- HTML is file-only; inline HTML and stdin are not accepted.\n- Omitting `--clients` uses Mailgun's default client set. Use `preview clients`\n  to discover explicit IDs.\n- The four checks are `link_validation`, `image_validation`, `accessibility`, and\n  `code_analysis`. All run by default; pass a subset or `none` explicitly.\n- Check completion drives polling. Slow client screenshots do not block the\n  result and are reported through client state plus a `render_incomplete` gap.\n- Accessibility headline counts are issue instances; the corresponding\n  `*_rules` fields count distinct rules.\n- Code analysis `count` is Mailgun's `meta.count` feature total, while\n  `instances` sums the reported occurrences.\n- `--reference-id` is a correlation value only. It is not an idempotency key or\n  a guaranteed lookup field.\n- Preview HTML is limited to 5 MiB. Oversized files are rejected before a\n  preview test is created.\n\nJSON output matches the MCP composite summary: render counts and client IDs,\nper-check lifecycle and references, native severity/support breakdowns,\nwarnings, and `data_gaps`. It deliberately contains no raw HTML, individual\nissue records, or Mailgun-authored overall pass/fail verdict. Consumers define\ntheir own gate from the reported evidence.\n\n## Agent context\n\n`agent-context` emits a machine-readable schema of the entire command surface —\nflags, output fields, and examples — so agents can discover capabilities without\nscraping help text:\n\n```bash\nmailgun agent-context | jq '.commands | keys'\n```\n\n## Output conventions\n\n- `--json` emits clean, machine-readable JSON on stdout. `events --json` emits\n  NDJSON (one event per line).\n- Errors always go to stderr; stdout stays clean and parseable.\n- `--quiet` suppresses spinners and prefixes but never the final result.\n- Every normalized result includes a structured `data_gaps` array (`[]` when\n  none) describing missing upstream data that affects interpretation.\n- Successful-but-incomplete upstream states (e.g. `processing`, undeliverable\n  addresses) exit `0` and represent status in the payload.\n\nExit codes:\n\n| Code | Meaning                                                              |\n| ---- | ------------------------------------------------------------------- |\n| `0`  | Success (including negative or incomplete upstream outcomes)        |\n| `1`  | Runtime/API/network failure                                         |\n| `2`  | Usage/config error (bad input, missing key, invalid region)        |\n\n## Product availability\n\nEach command depends on one of Mailgun's core products: Send, Optimize,\nValidate, or Inspect. Product labels are used for discovery and agent context;\nactual availability is determined by the Mailgun API response at call time. A\n`403` surfaces the API response body rather than a CLI-authored entitlement\nclaim.\n\n## Development\n\n```bash\ngit clone https://github.com/mailgun/mailgun-cli.git\ncd mailgun-cli\nnpm install\nnpm run build      # type-check and compile to dist/\nnpm test           # compile to dist-test/ and run the test suite\nnpm link           # optional: expose a local `mailgun` binary on your PATH\n```\n\nWithout linking, invoke a local build with `./dist/index.js <command>`.\n\nTests use Node's built-in runner: pure unit tests for request builders,\nnormalizers, and validation, plus subprocess tests that intercept the API via a\nlocal mock server. No live credentials are required.\n\n## Project layout\n\nLibrary code lives under `src/lib/` in layers (`core/`, `cli/`, `products/`).\nSee [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) for the full module map,\nconventions, and planned growth.\n\n## License\n\n[Apache-2.0](LICENSE)\n","readmeFilename":"README.md","_rev":"1-a813024bc519bba84b24bf805de734a7"}