使用说明
Porkbun MCP服务器
一个生产就绪的模型上下文协议(MCP)服务器,向Claude和LibreChat等人工智能助手公开完整的Porkbun域和DNS管理API。
特性
27个MCP工具 提供全面的Porkbun API访问:
身份验证和常规(2个工具)
porkbun_ping-测试API连接并获取您的IPporkbun_get_pricing-获取所有顶级域名的域名定价
域管理(4个工具)
porkbun_list_domains-列出帐户中的所有域porkbun_check_domain-检查域可用性porkbun_update_nameservers-更新注册表中的名称服务器porkbun_get_nameservers-获取当前名称服务器
URL转发(3个工具)
porkbun_add_url_forward-创建URL重定向(301/302)porkbun_get_url_forwarding-列表URL转发porkbun_delete_url_forward-删除转发的URL
胶水记录(4个工具)
porkbun_create_glue_record-创建胶水记录porkbun_update_glue_record-更新胶水记录porkbun_delete_glue_record-删除胶水记录porkbun_get_glue_records-列出胶水记录
DNS记录(8个工具)
porkbun_create_dns_record-创建DNS记录(A、AAAA、CNAME、MX、TXT、NS、SRV等)porkbun_edit_dns_record-按ID编辑DNS记录porkbun_edit_dns_records_by_name_type-按子域名/类型批量编辑porkbun_delete_dns_record-按ID删除DNS记录porkbun_delete_dns_records_by_name_type-按子域名/类型批量删除porkbun_retrieve_dns_records-获取所有或特定DNS记录porkbun_retrieve_dns_records_by_name_type-按子域名/类型获取记录
DNSSEC(3个工具)
porkbun_create_dnssec_record-创建DNSSEC记录porkbun_get_dnssec_records-列出DNSSEC记录porkbun_delete_dnssec_record-删除DNSSEC记录
SSL证书(1个工具)
porkbun_retrieve_ssl_bundle-获取SSL证书包
快速开始
先决条件
- Docker和Docker Compose
- Porkbon API证书来自 porkbun.com/account/api
- 必须在Porkbun仪表板中为您的域启用API访问
安装
- 克隆存储库:
git clone https://github.com/myroslavtryhubets/porkbun-mcp.git
cd porkbun-mcp
- 创建环境配置:
make install
# Or manually:
cp .env.example .env
- 编辑
.env使用您的Porkbun API证书:
PORKBUN_API_KEY=your_api_key_here
PORKBUN_SECRET_API_KEY=your_secret_api_key_here
- 构建并启动服务器:
make build
make up
- 验证服务器是否正在运行:
make test
# Or manually:
curl http://localhost:8000/health
curl http://localhost:8000/
配置
环境变量
| 变量 | 必填 | 默认 | 描述 |
|---|---|---|---|
PORKBUN_API_KEY |
是 | - | 您的Porkbon API密钥 |
PORKBUN_SECRET_API_KEY |
是 | - | 您的Porkbon秘密API密钥 |
PORKBUN_BASE_URL |
没有 | https://api.porkbun.com/api/json/v3 |
Porkbon API基础URL |
TIMEOUT |
没有 | 30 |
请求超时(秒) |
MCP_PORT |
没有 | 8000 |
MCP服务器端口 |
获取Porkbun API凭据
- 登录您的Porkbun帐户
- 首选 API访问
- 创建API密钥
- 为要管理的域启用API访问
MCP客户端配置
LibreChat配置
方法1:环境变量
添加到您的LibreChat .env 文件:
MCP_SERVERS='{"porkbun":{"url":"http://localhost:8000/porkbun/mcp","name":"Porkbun Domain & DNS","type":"streamable-http","instructions":"You are an assistant with access to Porkbun domain and DNS management. Use these tools to help users manage their domains, configure DNS records, set up URL forwarding, and maintain domain security. Always confirm destructive operations before executing."}}'
方法2:配置文件
添加到 librechat.yaml:
mcpServers:
porkbun:
url: "http://localhost:8000/porkbun/mcp"
name: "Porkbun Domain & DNS"
type: streamable-http # Use 'type', not 'transport'
instructions: |
You are an assistant with access to Porkbun domain and DNS management.
Available capabilities:
- Domain management (list, check availability, nameservers)
- DNS record management (create, edit, delete A/AAAA/CNAME/MX/TXT/etc.)
- URL forwarding setup
- Glue record management
- DNSSEC configuration
- SSL certificate retrieval
Always confirm destructive operations (delete, bulk operations) with the user first.
timeout: 120000
Claude桌面配置
添加到 claude_desktop_config.json:
地点:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 窗户:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
配置:
{
"mcpServers": {
"porkbun": {
"url": "http://localhost:8000/porkbun/mcp",
"transport": "http"
}
}
}
使用示例
与AI助手的对话示例
检查域可用性:
User: "Is example.com available for registration?"
Assistant: [Uses porkbun_check_domain]
列出域:
User: "Show me all my domains"
Assistant: [Uses porkbun_list_domains]
创建DNS记录:
User: "Add an A record for www.example.com pointing to 1.2.3.4"
Assistant: [Uses porkbun_create_dns_record with domain="example.com", record_type="A", content="1.2.3.4", name="www"]
设置URL转发:
User: "Forward old-site.com to https://new-site.com with a permanent redirect"
Assistant: [Uses porkbun_add_url_forward with domain="old-site.com", location="https://new-site.com", forward_type="permanent"]
查看DNS记录:
User: "What are the DNS records for example.com?"
Assistant: [Uses porkbun_retrieve_dns_records]
API文档
服务器运行后,访问:
- OpenAPI文档: http://localhost:8000/docs
- OpenAPI JSON: http://localhost:8000/porkbun/openapi.json
- 健康检查: http://localhost:8000/health
- 服务器信息: http://localhost:8000/
发展
项目结构
porkbun-mcp/
├── src/
│ ├── __init__.py # Package initialization
│ ├── main.py # FastAPI app with MCP integration
│ └── models.py # Pydantic configuration models
├── services/
│ ├── __init__.py
│ └── client.py # Porkbun API client
├── ci/
│ └── semver.json # Version metadata
├── Dockerfile # Container build configuration
├── docker-compose.yml # Service orchestration
├── requirements.txt # Python dependencies
├── Makefile # Convenience commands
├── .env.example # Environment template
├── .gitignore # Git ignore rules
└── README.md # This file
Makefile命令
make help # Show all available commands
make build # Build Docker image
make up # Start server
make down # Stop server
make restart # Restart server
make logs # View server logs
make clean # Remove containers and images
make test # Test server endpoints
make install # Create .env from template
不使用Docker运行
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create .env file with your credentials
cp .env.example .env
# Edit .env with your API keys
# Run the server
python -m src.main
日志记录
日志将写入:
- 慰问: Docker日志(查看
make logs) - 文件:
porkbun_mcp.log(集装箱内)
日志格式:
%(asctime)s - %(name)s - %(levelname)s - %(message)s
敏感数据(API密钥)在日志中被自动屏蔽。
安全最佳实践
- 永不承诺
.env文件 -它包含您的API证书 - 限制生产中的CORS -更新
allow_origins在src/main.py - 在生产环境中使用HTTPS -使用SSL在反向代理后部署
- 定期旋转API键 -在porkbun.com/account/api生成新密钥
- 监控API使用情况 -检查Porkbun仪表板是否有异常活动
- 启用2FA -使用双因素身份验证保护您的Porkbun帐户
故障排除
服务器无法启动
检查日志:
make logs
常见问题:
- 中缺少API凭据
.env - 端口8000已在使用中(更改
MCP_PORT在.env) - API密钥无效(请在porkbun.com/account/API进行验证)
API调用失败
检查API访问:
- 在Porkbun仪表板中验证您的域是否已启用API访问
- 使用ping端点进行测试:
curl http://localhost:8000/porkbun/mcp - 检查API密钥是否具有正确的权限
MCP客户端无法连接
Librechat:
- 验证
type: streamable-http(不是transport) - 检查URL是否与服务器匹配:
http://localhost:8000/porkbun/mcp - 配置更改后重新启动LibreChat
克劳德桌面:
- 验证
transport: http在配置中 - 检查是否可以从Claude Desktop访问URL
- 配置更改后重新启动Claude Desktop
速率限制
Porkbon API有费率限制:
- 域检查: 限制(响应中返回的速率限制信息)
- 其他操作: 一般来说,限额很慷慨
如果超过速率限制,服务器将返回错误消息。
建筑
此MCP服务器遵循 三层架构模式:
- MCP传输层 -FastAPI
fastapi_mcp适用于流式HTTP - FastAPI应用层 -带Pydantic验证的RESTful端点
- 外部API客户端层 -异步
httpxPorkbun API客户端
关键技术
- 快速API -现代异步web框架
- fastapi_mcp -MCP协议集成
- httpx -异步HTTP客户端
- 派丹蒂克 -配置和验证
- 优维康 -ASGI服务器
- 码头工人 -集装箱化
贡献
欢迎投稿!拜托:
- 分叉存储库
- 创建要素分支
- 进行更改
- 如果适用,添加测试
- 提交拉取请求
许可证
MIT许可证-请参阅 许可证 文件以获取详细信息。
版权所有(c)2025 Myroslav Tryhubets
更新日志
版本1.0.0(2025-10-29)
初始版本包含27个MCP工具:
- 完整的Porkbun API覆盖范围
- 域名管理
- DNS记录操作
- URL转发
- 胶水记录
- DNSSEC支持
- SSL证书检索
- Docker部署
- LibreChat和Claude桌面支持