@porkbunllc/mcp-server 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +102 -0
- package/dist/api.js +58 -0
- package/dist/index.js +51 -0
- package/dist/tools.js +104 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Porkbun, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Porkbun MCP Server
|
|
2
|
+
|
|
3
|
+
A [Model Context Protocol](https://modelcontextprotocol.io) server that exposes the [Porkbun v3 API](https://porkbun.com/api/json/v3/documentation) as native tools for AI agents — Claude Desktop, Cursor, Cline, and any other MCP-compatible client.
|
|
4
|
+
|
|
5
|
+
> **Status:** v0.1 — read-only tools only. Write operations (register, DNS edits, SSL provisioning) coming in subsequent releases.
|
|
6
|
+
|
|
7
|
+
## What's included (v0.1)
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `ping` | Verify API connectivity and credentials |
|
|
12
|
+
| `check_domain` | Check availability and pricing for a single domain |
|
|
13
|
+
| `list_domains` | Paginate through domains in the authenticated account |
|
|
14
|
+
| `get_balance` | Get account credit balance |
|
|
15
|
+
| `get_pricing` | Get registration/renewal/transfer pricing for all TLDs |
|
|
16
|
+
| `list_dns_records` | List DNS records for a domain |
|
|
17
|
+
| `get_ssl_bundle` | Retrieve the free Porkbun-issued SSL bundle for a domain |
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
You'll need [Node.js](https://nodejs.org) 18 or newer.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx -y @porkbunllc/mcp-server
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This downloads and runs the latest version on demand. No global install needed.
|
|
28
|
+
|
|
29
|
+
## Configure your MCP client
|
|
30
|
+
|
|
31
|
+
### Claude Desktop
|
|
32
|
+
|
|
33
|
+
Add this to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"porkbun": {
|
|
39
|
+
"command": "npx",
|
|
40
|
+
"args": ["-y", "@porkbunllc/mcp-server"],
|
|
41
|
+
"env": {
|
|
42
|
+
"PORKBUN_API_KEY": "pk1_your_public_key_here",
|
|
43
|
+
"PORKBUN_SECRET_API_KEY": "sk1_your_secret_key_here"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Restart Claude Desktop. Porkbun tools should appear in the tool picker.
|
|
51
|
+
|
|
52
|
+
### Cursor / Cline / Continue
|
|
53
|
+
|
|
54
|
+
Most MCP-aware editors use a similar `mcpServers` config block. See your client's documentation for the exact location.
|
|
55
|
+
|
|
56
|
+
## Get API keys
|
|
57
|
+
|
|
58
|
+
Create API keys at [porkbun.com/account/api](https://porkbun.com/account/api). You'll need both the public key (`pk1_…`) and the secret key (`sk1_…`).
|
|
59
|
+
|
|
60
|
+
By default, API access is opt-in per domain. To use the API to manage all your domains, enable the "Opt In All Domains" toggle in the same settings page. Otherwise you'll need to enable API access for each domain individually under Domain Management.
|
|
61
|
+
|
|
62
|
+
## Environment variables
|
|
63
|
+
|
|
64
|
+
| Variable | Required | Purpose |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| `PORKBUN_API_KEY` | yes | Your Porkbun public API key |
|
|
67
|
+
| `PORKBUN_SECRET_API_KEY` | yes | Your Porkbun secret API key |
|
|
68
|
+
| `PORKBUN_BASE_URL` | no | Override the API base URL (e.g. for testing against `api-betamax.porkbun.com/api/json/v3`) |
|
|
69
|
+
|
|
70
|
+
## Local development
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/oborseth/Porkbun-MCP.git
|
|
74
|
+
cd Porkbun-MCP
|
|
75
|
+
npm install
|
|
76
|
+
npm run build
|
|
77
|
+
npm start # or: node dist/index.js
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The server speaks JSON-RPC 2.0 over stdio. Smoke test from a shell:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
(printf '%s\n' \
|
|
84
|
+
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' \
|
|
85
|
+
'{"jsonrpc":"2.0","method":"notifications/initialized"}' \
|
|
86
|
+
'{"jsonrpc":"2.0","id":2,"method":"tools/list"}') \
|
|
87
|
+
| PORKBUN_API_KEY=pk1_… PORKBUN_SECRET_API_KEY=sk1_… node dist/index.js
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Reliability
|
|
91
|
+
|
|
92
|
+
All write operations (when added in future releases) will automatically attach a per-call `Idempotency-Key` header. Retried calls within 24 hours return the cached response — your agent can safely retry on network errors without double-charging.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT
|
|
97
|
+
|
|
98
|
+
## Links
|
|
99
|
+
|
|
100
|
+
- [Porkbun API documentation](https://porkbun.com/api/json/v3/documentation)
|
|
101
|
+
- [Model Context Protocol](https://modelcontextprotocol.io)
|
|
102
|
+
- [Issues / contributions](https://github.com/oborseth/Porkbun-MCP/issues)
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
const DEFAULT_BASE_URL = "https://api.porkbun.com/api/json/v3";
|
|
3
|
+
export function loadConfig() {
|
|
4
|
+
const apiKey = process.env.PORKBUN_API_KEY?.trim() ?? "";
|
|
5
|
+
const secretApiKey = process.env.PORKBUN_SECRET_API_KEY?.trim() ?? "";
|
|
6
|
+
const baseUrl = (process.env.PORKBUN_BASE_URL?.trim() || DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
7
|
+
const userAgent = `porkbun-mcp/${process.env.npm_package_version ?? "0.1.0"}`;
|
|
8
|
+
if (!apiKey || !secretApiKey) {
|
|
9
|
+
throw new Error("Missing credentials. Set PORKBUN_API_KEY and PORKBUN_SECRET_API_KEY environment variables. " +
|
|
10
|
+
"Create keys at https://porkbun.com/account/api");
|
|
11
|
+
}
|
|
12
|
+
return { apiKey, secretApiKey, baseUrl, userAgent };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Call a Porkbun v3 API endpoint. The path is relative to the base URL and
|
|
16
|
+
* should start with a slash (e.g. `/domain/listAll`). Auth is injected
|
|
17
|
+
* automatically: header-based for GET, body-based for POST.
|
|
18
|
+
*/
|
|
19
|
+
export async function call(config, path, opts = {}) {
|
|
20
|
+
const method = opts.method ?? "POST";
|
|
21
|
+
const url = `${config.baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
|
|
22
|
+
const headers = {
|
|
23
|
+
"User-Agent": config.userAgent,
|
|
24
|
+
Accept: "application/json",
|
|
25
|
+
};
|
|
26
|
+
let body;
|
|
27
|
+
if (method === "GET") {
|
|
28
|
+
headers["X-API-Key"] = config.apiKey;
|
|
29
|
+
headers["X-Secret-API-Key"] = config.secretApiKey;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
headers["Content-Type"] = "application/json";
|
|
33
|
+
body = JSON.stringify({
|
|
34
|
+
...(opts.body ?? {}),
|
|
35
|
+
apikey: config.apiKey,
|
|
36
|
+
secretapikey: config.secretApiKey,
|
|
37
|
+
});
|
|
38
|
+
if (opts.idempotent) {
|
|
39
|
+
headers["Idempotency-Key"] = randomUUID();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const res = await fetch(url, { method, headers, body });
|
|
43
|
+
const text = await res.text();
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = text ? JSON.parse(text) : {};
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw new Error(`Porkbun API returned non-JSON response (HTTP ${res.status}): ${text.slice(0, 300)}`);
|
|
50
|
+
}
|
|
51
|
+
const data = parsed;
|
|
52
|
+
if (!res.ok || data.status === "ERROR") {
|
|
53
|
+
const code = data.code ? ` [${data.code}]` : "";
|
|
54
|
+
const msg = data.message ?? `HTTP ${res.status}`;
|
|
55
|
+
throw new Error(`Porkbun API error${code}: ${msg}`);
|
|
56
|
+
}
|
|
57
|
+
return parsed;
|
|
58
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { loadConfig } from "./api.js";
|
|
5
|
+
import { tools } from "./tools.js";
|
|
6
|
+
const server = new McpServer({
|
|
7
|
+
name: "porkbun-mcp",
|
|
8
|
+
version: "0.1.0",
|
|
9
|
+
});
|
|
10
|
+
// Defer config loading until the first tool call. tools/list works without
|
|
11
|
+
// credentials so MCP clients can still discover what's available.
|
|
12
|
+
let cachedConfig = null;
|
|
13
|
+
function getConfig() {
|
|
14
|
+
if (!cachedConfig)
|
|
15
|
+
cachedConfig = loadConfig();
|
|
16
|
+
return cachedConfig;
|
|
17
|
+
}
|
|
18
|
+
for (const tool of tools) {
|
|
19
|
+
server.registerTool(tool.name, {
|
|
20
|
+
description: tool.description,
|
|
21
|
+
inputSchema: tool.inputSchema,
|
|
22
|
+
}, async (args) => {
|
|
23
|
+
try {
|
|
24
|
+
const result = await tool.handler(getConfig(), args);
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: "text",
|
|
29
|
+
text: JSON.stringify(result, null, 2),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
36
|
+
return {
|
|
37
|
+
isError: true,
|
|
38
|
+
content: [{ type: "text", text: message }],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async function main() {
|
|
44
|
+
const transport = new StdioServerTransport();
|
|
45
|
+
await server.connect(transport);
|
|
46
|
+
// Errors during transport are already logged by the SDK.
|
|
47
|
+
}
|
|
48
|
+
main().catch((err) => {
|
|
49
|
+
console.error("Fatal:", err);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
});
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { call } from "./api.js";
|
|
3
|
+
const ping = {
|
|
4
|
+
name: "ping",
|
|
5
|
+
description: "Verify the Porkbun API connection and credentials. Returns the caller's public IP and whether the API key is valid. Use this as a first sanity check before making other calls.",
|
|
6
|
+
inputSchema: {},
|
|
7
|
+
handler: async (config) => {
|
|
8
|
+
return await call(config, "/ping", { method: "POST" });
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
const check_domain = {
|
|
12
|
+
name: "check_domain",
|
|
13
|
+
description: "Check whether a single domain is available for registration and what it costs. Returns availability, registration price, renewal price, transfer price, and (for premium domains) extended pricing details. Pricing is in USD. Use this BEFORE register_domain to confirm cost — Porkbun rejects registrations whose `cost` doesn't match the current quote.",
|
|
14
|
+
inputSchema: {
|
|
15
|
+
domain: z
|
|
16
|
+
.string()
|
|
17
|
+
.min(3)
|
|
18
|
+
.describe("Fully qualified domain name to check, e.g. `example.com`"),
|
|
19
|
+
},
|
|
20
|
+
handler: async (config, args) => {
|
|
21
|
+
const domain = String(args.domain).toLowerCase();
|
|
22
|
+
return await call(config, `/domain/checkSingleDomain/${encodeURIComponent(domain)}`, {
|
|
23
|
+
method: "GET",
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const list_domains = {
|
|
28
|
+
name: "list_domains",
|
|
29
|
+
description: "List domains in the authenticated Porkbun account. Returns one page of domains with metadata (expire date, auto-renew status, lock status, whois privacy status). Supports pagination with `start`. Use `includeLabels` to also return user-defined labels.",
|
|
30
|
+
inputSchema: {
|
|
31
|
+
start: z
|
|
32
|
+
.number()
|
|
33
|
+
.int()
|
|
34
|
+
.min(0)
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Pagination offset. Defaults to 0. Each page returns up to 1000 domains."),
|
|
37
|
+
includeLabels: z
|
|
38
|
+
.boolean()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("If true, include user-defined domain labels in the response."),
|
|
41
|
+
},
|
|
42
|
+
handler: async (config, args) => {
|
|
43
|
+
const params = new URLSearchParams();
|
|
44
|
+
if (args.start !== undefined)
|
|
45
|
+
params.set("start", String(args.start));
|
|
46
|
+
if (args.includeLabels)
|
|
47
|
+
params.set("includeLabels", "yes");
|
|
48
|
+
const qs = params.toString() ? `?${params.toString()}` : "";
|
|
49
|
+
return await call(config, `/domain/listAll${qs}`, { method: "GET" });
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
const get_balance = {
|
|
53
|
+
name: "get_balance",
|
|
54
|
+
description: "Get the available account credit balance for the authenticated Porkbun account. Returns the balance in cents (integer) and a human-readable display string (e.g. `$12.34`). Use this to check spend headroom before initiating registrations or renewals.",
|
|
55
|
+
inputSchema: {},
|
|
56
|
+
handler: async (config) => {
|
|
57
|
+
return await call(config, "/account/balance", { method: "GET" });
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const get_pricing = {
|
|
61
|
+
name: "get_pricing",
|
|
62
|
+
description: "Get current Porkbun pricing for all supported TLDs. Returns registration, renewal, and transfer prices per TLD in USD. No authentication required. Useful when an agent needs to compare TLD costs before registering. Note: this returns standard pricing only — premium domains have their own per-domain pricing reported by check_domain.",
|
|
63
|
+
inputSchema: {},
|
|
64
|
+
handler: async (config) => {
|
|
65
|
+
return await call(config, "/pricing/get", { method: "POST" });
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
const list_dns_records = {
|
|
69
|
+
name: "list_dns_records",
|
|
70
|
+
description: "List all DNS records for a domain in the authenticated account. Returns each record's id, type (A, AAAA, CNAME, MX, TXT, etc.), name (subdomain or empty for apex), content, ttl, and priority (where applicable). The `id` field is required when editing or deleting a specific record.",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
domain: z
|
|
73
|
+
.string()
|
|
74
|
+
.min(3)
|
|
75
|
+
.describe("Fully qualified domain name registered at Porkbun, e.g. `example.com`"),
|
|
76
|
+
},
|
|
77
|
+
handler: async (config, args) => {
|
|
78
|
+
const domain = String(args.domain).toLowerCase();
|
|
79
|
+
return await call(config, `/dns/retrieve/${encodeURIComponent(domain)}`, { method: "GET" });
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
const get_ssl_bundle = {
|
|
83
|
+
name: "get_ssl_bundle",
|
|
84
|
+
description: "Retrieve the free Porkbun-issued SSL certificate bundle for a domain. Returns the certificate chain, private key, and public key (PEM-encoded strings). Porkbun automatically provisions Let's Encrypt certificates for all registered domains using Porkbun nameservers. Use this to install TLS on a server you control.",
|
|
85
|
+
inputSchema: {
|
|
86
|
+
domain: z
|
|
87
|
+
.string()
|
|
88
|
+
.min(3)
|
|
89
|
+
.describe("Fully qualified domain name registered at Porkbun, e.g. `example.com`"),
|
|
90
|
+
},
|
|
91
|
+
handler: async (config, args) => {
|
|
92
|
+
const domain = String(args.domain).toLowerCase();
|
|
93
|
+
return await call(config, `/ssl/retrieve/${encodeURIComponent(domain)}`, { method: "GET" });
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
export const tools = [
|
|
97
|
+
ping,
|
|
98
|
+
check_domain,
|
|
99
|
+
list_domains,
|
|
100
|
+
get_balance,
|
|
101
|
+
get_pricing,
|
|
102
|
+
list_dns_records,
|
|
103
|
+
get_ssl_bundle,
|
|
104
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@porkbunllc/mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Porkbun MCP server — exposes the Porkbun v3 API as tools for AI agents (Claude Desktop, Cursor, etc.)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"porkbun-mcp": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"start": "node dist/index.js",
|
|
17
|
+
"dev": "tsc --watch",
|
|
18
|
+
"prepublishOnly": "rm -rf dist && tsc"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"mcp",
|
|
22
|
+
"porkbun",
|
|
23
|
+
"domain",
|
|
24
|
+
"dns",
|
|
25
|
+
"ai",
|
|
26
|
+
"agent",
|
|
27
|
+
"claude"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/oborseth/Porkbun-MCP.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/oborseth/Porkbun-MCP/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/oborseth/Porkbun-MCP#readme",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
43
|
+
"zod": "^4.4.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^25.6.1",
|
|
47
|
+
"typescript": "^6.0.3"
|
|
48
|
+
}
|
|
49
|
+
}
|