cf-cli
Cloudflare API CLI with encrypted multi-token storage, interactive TUI, and MCP server for AI tool integration.
Install```bash
go install github.com/SevensRequiem/cf-cli/cmd/cf-cli@latest
Or build from source:```bash
git clone https://github.com/SevensRequiem/cf-cli.git
cd cf-cli
make build
Quick Start```bash
Add your first API token
cf-cli token add main --api-token=your-token-here --default
List your zones
cf-cli zone list
List DNS records
cf-cli dns list -z example.com
Add a DNS record
cf-cli dns add -z example.com --type=A --name=sub --content=1.2.3.4 --proxied
JSON output (for piping)
cf-cli dns list -z example.com --json | jq '.[] | .name'
Launch interactive TUI
cf-cli tui
## Token Management
Tokens are stored in a local SQLite database at `$XDG_DATA_HOME/cf-cli/tokens.db`, encrypted with AES-256-GCM. Key derivation uses argon2id with an empty default password.```bash
# Add tokens with zone/scope metadata
cf-cli token add prod --api-token=xxx --zones=zone-id-1,zone-id-2 --scopes=dns
cf-cli token add staging --api-token=yyy --default
# List stored tokens (metadata only, never prints raw tokens)
cf-cli token list
# Set a different default
cf-cli token default prod
# Set an encryption password
cf-cli token password
# Remove a token
cf-cli token remove staging
Token Resolution
When a command needs an API token, cf-cli checks (in order):
--tokenflag (raw token, one-off use)CF_API_TOKENenvironment variable--profileflag (named token from store)--zoneflag (zone-matched token from store)- Default token (marked with
is_default)
Commands
| Command | Subcommands |
|---|---|
token |
add, list, remove, default, password |
dns |
list, add, update, delete |
zone |
list, info |
cache |
purge |
ssl |
get, update |
firewall |
list, add, delete |
rules |
list, add, delete |
speed |
get, update |
settings |
get, update |
mcp |
serve |
tui |
(interactive) |
Global Flags```
--json Force JSON output
--zone, -z Zone name or ID
--profile, -p Named token profile
--token Raw API token override
--verbose, -v Debug logging to stderr
## MCP Server
Run as an MCP server for AI assistants (stdio transport):```bash
cf-cli mcp serve
Exposes tools: dns_list, dns_add, dns_update, dns_delete, zone_list, cache_purge, firewall_list, firewall_add.
Claude Desktop config```json
{
"mcpServers": {
"cf-cli": {
"command": "cf-cli",
"args": ["mcp", "serve"]
}
}
}
```
Output Modes
- TTY + subcommand - human-readable tables
--jsonor piped stdout - JSON outputcf-cli tui- interactive terminal UIcf-cli mcp serve- MCP protocol over stdio
License
MIT
