这是一个基于MCP协议开发的宝塔面板API接口工具,可以通过MCP协议与宝塔面板API进行交互。
# 克隆仓库
git clone https://cnb.cool/btpanel/mcp_btpanel.git
cd mcp_btpanel
# 安装依赖
go mod tidy
# 构建项目
make build
程序通过环境变量进行配置:
# 设置宝塔面板地址
export BT_BASE_URL="http://your-panel-address:8888"
# 设置宝塔面板API令牌
export BT_API_TOKEN="your-api-token"
在Cursor中使用时,可以通过以下步骤配置:
{
"mcpServers": {
"mcp-btpanel": {
"command": "C:\\Users\\Administrator\\实际目录\\mcp_btpanel\\build\\mcp-btpanel.exe",
"env": {
"BT_BASE_URL": "http://192.168.xx.xx:8888/",
"BT_API_TOKEN": "xxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}
./build/mcp-btpanel
// 获取网站列表 mcp.tool("get_sites_list") // 创建新网站 mcp.tool("add_site", { "domains": "example.com,www.example.com" }) // 获取MySQL数据库列表 mcp.tool("get_mysql_list")
mcp_btpanel/ ├── main.go # 主程序入口 ├── modules/ # 模块目录 │ ├── databases/ # 数据库相关模块 │ │ └── mysql.go # MySQL数据库操作 │ ├── sites/ # 网站相关模块 │ │ └── sites.go # 网站操作 │ └── system/ # 系统相关模块 │ └── system.go # 系统信息操作 └── utils/ # 工具函数 └── panelHttpController.go # 宝塔面板HTTP请求控制器
本项目采用MIT许可证,详情请参阅LICENSE文件。
欢迎提交问题和功能请求!如果您想做出贡献,请:
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)