Skip to main content

namecheap-cli — titanium keystone and ice-blue alignment seam

Namecheap CLI

Guarded Namecheap DNS automation for AI agents, CI pipelines, and terminal workflows.

CI Website Python 3.11+ Zero runtime dependencies Agent Skill MIT License


Namecheap's domains.dns.setHosts XML endpoint overwrites an entire zone in a single call—one missing field in an ad-hoc script can wipe existing MX, TXT, or CNAME records.

namecheap-cli wraps Namecheap BasicDNS and nameserver management in a zero-dependency CLI engineered for autonomous AI agents and deterministic scripts:

  • Dry-run by default — Every mutation (dns set, dns add, dns remove, dns apply, ns set, restore) computes a structured diff and SHA-256 state_hash without touching live DNS until --yes --if-match <HASH> is supplied.
  • Versioned JSON contract — Every command prints one schema_version: 1 JSON envelope on stdout (including validation errors and exit codes), with --human available for terse terminal output.
  • Guarded whole-zone writes — Holds a local per-account/domain lock, writes a 0600 backup and recovery journal before calling setHosts, preserves mail-routing modes (MX, MXE, FWD, OX), and verifies every record, TTL, and MX preference afterward.
  • Live public DNS verification — namecheap dns check queries Cloudflare DNS-over-HTTPS to confirm public resolvers match Namecheap's stored zone.

Why namecheap-cli?

Capability namecheap-cli Ad-hoc XML scripts Always-on MCP servers
Whole-zone clobber protection Diff preview + --if-match SHA-256 + post-write verify Easy to drop MX/TXT records Rarely optimistic-locked
Pre-write backup & rollback Automatic 0600 backup + namecheap restore Manual Manual
Idle context window cost 0 tokens until needed (namecheap schema) Requires reading custom script Tool definitions loaded every turn
Live propagation verification Built-in namecheap dns check (Cloudflare DoH) Separate dig / nslookup glue Separate tooling
Runtime footprint Python 3.11+ stdlib only (0 dependencies) requests, lxml, python-dotenv Persistent Node/Python server

Install

Requires Python 3.11+ with zero third-party runtime dependencies.

# Install globally in an isolated environment with uv
uv tool install 'git+https://github.com/R-Varun/namecheap-cli'

# Or with pipx
pipx install 'git+https://github.com/R-Varun/namecheap-cli'

Want to inspect the full command and schema catalogue first with zero installation and no API credentials?

uvx --from 'git+https://github.com/R-Varun/namecheap-cli' namecheap schema

Quickstart

1. Configure allowlist & credentials

Enable Namecheap API access and whitelist your machine's public IPv4 address in your Namecheap account.

namecheap config init --domain example.com
namecheap auth setup --username YOUR_NAMECHEAP_USERNAME
namecheap doctor
  • auth setup reads your API key from a hidden terminal prompt and saves it to a 0600 local credential file.
  • For agents and CI, pass NAMECHEAP_API_USER and NAMECHEAP_API_KEY via your secret store or environment instead—never pass keys on the command line or inside prompts.
  • Only allowlisted domains can be read or modified by domain-targeted commands. Manage scope with namecheap config allow example.net and namecheap config disallow example.net.

2. Preview, apply, and verify live DNS

# 1. Inspect current zone
namecheap dns list example.com

# 2. Preview a change (read-only dry run; returns diff + state_hash)
namecheap dns set example.com @ A 203.0.113.10

# 3. Apply using the 64-character SHA-256 state_hash from step 2
namecheap dns set example.com @ A 203.0.113.10 --yes --if-match <STATE_HASH>

# 4. Verify live public DNS propagation over HTTPS
namecheap dns check example.com --host @ --type A

Common operations

# Records: set replaces conflicting/same-type records; add appends multi-value records
namecheap dns set example.com www CNAME @
namecheap dns add example.com @ TXT 'v=spf1 include:_spf.example.net ~all'
namecheap dns add example.com @ MX mail.example.com --mxpref 10 --email-type MX
namecheap dns remove example.com staging A --value 203.0.113.20

# Atomic multi-record zone apply from a file or stdin (-)
namecheap dns apply example.com zone.json
jq '.data.zone | .hosts += [{"name":"api","type":"A","address":"203.0.113.30","ttl":1800}]' current.json \
  | namecheap dns apply example.com -

# Nameserver delegation & availability checks
namecheap ns list example.com
namecheap ns set example.com --custom ns1.example.net ns2.example.net
namecheap domains list
namecheap domains check example.org example.net

Built for AI Agents

No MCP server or custom XML wrapper needed—agents invoke namecheap directly over subprocess and parse deterministic JSON on stdout.

Install the bundled Agent Skill (SKILL.md)

Copy skills/namecheap-dns into your agent's skills directory (Claude Code, Codex, Cursor, OpenClaw):

# Claude Code
mkdir -p ~/.claude/skills && cp -R skills/namecheap-dns ~/.claude/skills/

# Codex / cross-agent ~/.agents/skills
mkdir -p ~/.agents/skills && cp -R skills/namecheap-dns ~/.agents/skills/

Or add a 5-line CLAUDE.md / AGENTS.md rule

## Namecheap DNS (`namecheap`)
- Run `namecheap schema` to inspect commands, arguments, zone schema, and error codes.
- Always preview mutations without `--yes` first, inspect `data.diff` and `warnings`, then apply with `--yes --if-match <data.state_hash>`.
- Pass arguments as an argv array (never shell-interpolate TXT values) or pipe zone JSON to `namecheap dns apply <domain> -`.
- Confirm public resolver propagation with `namecheap dns check <domain>` when needed.

Machine-readable discovery endpoints are also hosted at schema.json and llms.txt.

Write Safety & Recovery

Every confirmed write executes a strict transaction:

  1. Acquires a local lock scoped to (account, environment, domain).
  2. Reads the live zone and verifies --if-match matches the canonical SHA-256 state_hash.
  3. Writes a 0600 JSON backup and "prepared" recovery journal entry.
  4. Re-reads immediately before submission to catch concurrent external changes.
  5. Submits setHosts / setCustom / setDefault once (never auto-retries writes).
  6. Reads back and verifies every host record, TTL, MX preference, and email mode.

If a write cannot be verified (exit code 4, write_unverified), inspect error.details.outcome ("rejected" vs "unknown") and preview a rollback from the automatic backup:

namecheap restore /path/from/result/backup.json
namecheap restore /path/from/result/backup.json --yes --if-match <STATE_HASH>

Scope boundaries: namecheap-cli manages BasicDNS host records (A, AAAA, ALIAS, CNAME, MX, MXE, NS, TXT, URL, URL301, FRAME), nameserver delegation, account domain listing, availability checks, and public DoH verification. It never purchases, renews, or transfers domains, and it blocks writes rather than clobbering unsupported dashboard settings (such as DDNS or inactive host rows).

Troubleshooting

Error Code Exit Cause & Resolution
credentials_missing 66 Run namecheap auth setup --username USER or set NAMECHEAP_API_USER + NAMECHEAP_API_KEY.
ip_detection_failed 1 Set NAMECHEAP_CLIENT_IP to your Namecheap-whitelisted public IPv4 address.
out_of_scope 3 Domain is not in your local allowlist. Run namecheap config allow <domain>.
stale_state 3 Zone changed after your preview. Re-run the dry-run preview and use the new state_hash.
external_dns 3 Domain uses custom third-party nameservers (ns list) instead of Namecheap BasicDNS.
email_mode_unknown 3 Pass an explicit --email-type (MX, MXE, FWD, OX) when altering mail routing.
write_unverified 4 Check namecheap dns list <domain> and error.details.recovery.backup_file before retrying.

Documentation

Development

git clone https://github.com/R-Varun/namecheap-cli.git
cd namecheap-cli
uv sync --extra dev
uv run pytest --cov=namecheap_cli --cov-report=term-missing
uv run ruff check .
uv run ruff format --check .
uv build && uv run python scripts/check_distribution.py

CI validates Python 3.11–3.14 on Linux plus macOS and Windows, verifies wheel and sdist metadata in clean environments, and builds the static documentation site. See CONTRIBUTING.md, SECURITY.md, CHANGELOG.md, and LICENSE.


Unofficial open-source project. Not affiliated with, endorsed by, or sponsored by Namecheap, Inc.

Metadata

Release files for namecheap-agent-cli 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for namecheap-agent-cli 0.2.0
File Size Uploaded Provenance Actions
namecheap_agent_cli-0.2.0.tar.gz 1.4 MB With provenance Details for namecheap_agent_cli-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for namecheap-agent-cli 0.2.0
File Interpreter ABI Platform Actions
namecheap_agent_cli-0.2.0-py3-none-any.whl Python 3 none any Details for namecheap_agent_cli-0.2.0-py3-none-any.whl

Total release size: 1.4 MB

Release files / namecheap_agent_cli-0.2.0.tar.gz

Download URL namecheap_agent_cli-0.2.0.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
0be0163c27c0bb8855747ebd0d5c9e4943e9e3cd27e2e2542385e7892316a10e
BLAKE2b-256 checksum
How to use checksums
d3d415d49267507319b10fbec9e9a1cacdaf5c46448a379cba42b2f79351659a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / namecheap_agent_cli-0.2.0-py3-none-any.whl

Download URL namecheap_agent_cli-0.2.0-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b37f5c6f486747f88492fd3a5015e396f756d2349894c03c2e474368640d014
BLAKE2b-256 checksum
How to use checksums
db4638d1c0fba3fc1700e5d4c13bf07a13b30ac071c599cf4a3ae05b0046f509
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for namecheap-agent-cli 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for namecheap_agent_cli-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page