Skip to main content
Glama
README.md
<div align="center">

# ๐ŸŒ mcp-porkbun

**A [Model Context Protocol](https://modelcontextprotocol.io) server for Porkbun domain registration and DNS management.**
Let AI agents buy domains and configure DNS โ€” no browser required.

<br/>

[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white)](https://python.org)
[![License: MIT](https://img.shields.io/badge/license-MIT-22c55e?style=flat-square)](LICENSE)
[![MCP](https://img.shields.io/badge/MCP-compatible-8b5cf6?style=flat-square)](https://modelcontextprotocol.io)
[![Porkbun API](https://img.shields.io/badge/Porkbun_API-v3-f97316?style=flat-square)](https://porkbun.com/api/json/v3/documentation)

</div>

---

## โœจ Overview

`mcp-porkbun` exposes Porkbun's domain registration and DNS API as MCP tools, enabling AI agents to:

- ๐Ÿ” **Check availability** โ€” look up domains and get first-year + renewal pricing
- ๐Ÿ›’ **Register domains** โ€” purchase domains programmatically
- ๐Ÿ“‹ **List domains** โ€” inventory all domains in the account
- ๐Ÿ”ง **Manage DNS** โ€” create, list, and delete any DNS record type

Originally built to power **cold email infrastructure automation**: an AI agent checks availability, purchases domains, and configures MX + SPF + DMARC records โ€” all in a single workflow.

---

## ๐Ÿ“‹ Prerequisites

1. A [Porkbun](https://porkbun.com) account
2. A Porkbun **API key** and **secret key** โ€” generate them at [porkbun.com/account/api](https://porkbun.com/account/api)
3. API access **enabled per domain** in the Porkbun dashboard (Domain Settings โ†’ API)
4. Python 3.11+

---

## ๐Ÿš€ Setup

### 1. Install

```bash
git clone https://github.com/keyserfaty/mcp-porkbun
cd mcp-porkbun

python -m venv .venv
source .venv/bin/activate    # Windows: .venv\Scripts\activate

pip install -e .
```

### 2. Configure Environment

```bash
export PORKBUN_API_KEY="pk1_..."
export PORKBUN_SECRET_KEY="sk1_..."
```

---

## โš™๏ธ MCP Configuration

Add to your `~/.claude.json` (or project `.mcp.json`):

```json
{
  "mcpServers": {
    "porkbun": {
      "type": "stdio",
      "command": "/path/to/.venv/bin/python",
      "args": ["/path/to/mcp-porkbun/server.py"],
      "env": {
        "PORKBUN_API_KEY": "pk1_...",
        "PORKBUN_SECRET_KEY": "sk1_..."
      }
    }
  }
}
```

---

## ๐Ÿ› ๏ธ Tools Reference

### Auth

| Tool | Description |
|------|-------------|
| `ping` | Test credentials โ€” returns your public IP if successful |

### Domain Management

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `check_domain` | Check availability and pricing | `domain: str` |
| `register_domain` | Purchase a domain | `domain`, `price_dollars`, `years?`, `autorenew?` |
| `list_domains` | List all domains in the account | `start?: int` |
| `get_domain_info` | Get nameservers and status for a domain | `domain: str` |

**Typical purchase flow:**

```python
# 1. Check availability + price
result = check_domain("example.com")
# โ†’ result["available"] == True, result["price_first_year"] == "9.73"

# 2. Register using the exact price returned
register_domain("example.com", price_dollars=9.73)
```

> โš ๏ธ After registering, **enable API access** for the domain in the Porkbun dashboard (Domain โ†’ Settings โ†’ API) before making DNS calls.

### DNS Management

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `get_dns_records` | List records, optionally filtered | `domain`, `record_type?`, `subdomain?` |
| `create_dns_record` | Add a DNS record | `domain`, `record_type`, `content`, `name?`, `ttl?`, `priority?` |
| `delete_dns_record` | Delete a record by ID | `domain`, `record_id` |
| `delete_dns_records_by_type` | Bulk delete all records of a type | `domain`, `record_type`, `subdomain?` |

**Google Workspace DNS setup example:**

```python
# SPF
create_dns_record("example.com", "TXT", "v=spf1 include:_spf.google.com ~all", name="@")

# DMARC
create_dns_record("example.com", "TXT", "v=DMARC1; p=none; rua=mailto:dmarc@example.com", name="_dmarc")

# MX records
create_dns_record("example.com", "MX", "ASPMX.L.GOOGLE.COM", name="@", priority=1)
create_dns_record("example.com", "MX", "ALT1.ASPMX.L.GOOGLE.COM", name="@", priority=5)

# DKIM (after generating key in Google Workspace)
create_dns_record("example.com", "TXT", "v=DKIM1; k=rsa; p=...", name="google._domainkey")
```

---

## ๐Ÿค– Example Agent Workflow

```
1. check_domain("newdomain.com")           โ€” confirm available + get price
2. register_domain("newdomain.com", 9.73)  โ€” purchase
3. create_dns_record(...)                  โ€” SPF, DMARC, MX (ร—5), DKIM
4. get_dns_records("newdomain.com")        โ€” verify all records are live
```

---

## ๐Ÿ“ Project Structure

```
mcp-porkbun/
โ”œโ”€โ”€ server.py       # MCP server & tool definitions
โ”œโ”€โ”€ api.py          # Porkbun API helper (auth + requests)
โ”œโ”€โ”€ pyproject.toml  # Package metadata & dependencies
โ””โ”€โ”€ README.md
```

---

## ๐Ÿค Contributing

Contributions welcome โ€” especially:

- **Domain transfer** tools
- **URL forwarding** management
- **SSL certificate** retrieval
- **Bulk operations** with built-in rate limiting

---

## ๐Ÿ“„ License

MIT ยฉ [Karen Serfaty](https://github.com/keyserfaty)

---

<div align="center">
<sub>Built for use with <a href="https://claude.ai/claude-code">Claude Code</a> ยท Powered by <a href="https://modelcontextprotocol.io">Model Context Protocol</a></sub>
</div>