MCP ExplorerExplorer

Mcp Btpanel

@aaPanelon 10 months ago
2 MIT
FreeCommunity
AI Systems
这是一个基于MCP协议开发的宝塔面板API接口工具,可以通过MCP协议与宝塔面板API进行交互

Overview

What is Mcp Btpanel

mcp_btpanel is an API interface tool developed based on the MCP protocol, designed to interact with the Baota panel API. It allows users to perform various operations on the Baota panel through the MCP protocol.

Use cases

Use cases for mcp_btpanel include automating website creation, managing databases, monitoring server status, and integrating with other tools or services that require interaction with the Baota panel API.

How to use

To use mcp_btpanel, clone the repository, install dependencies using ‘go mod tidy’, and build the project. Configure environment variables for the Baota panel address and API token, then start the service and use MCP protocol calls to interact with the panel.

Key features

Key features of mcp_btpanel include retrieving system information and network status, querying PHP website lists, creating new PHP websites, managing MySQL databases, Docker container and image management, email account management, and accessing public configuration information of the panel.

Where to use

mcp_btpanel can be used in web development environments, server management, and automation tasks where interaction with the Baota panel is required.

Content

宝塔面板 MCP 接口

这是一个基于MCP协议开发的宝塔面板API接口工具,可以通过MCP协议与宝塔面板API进行交互。

功能特性

  • 获取面板系统信息和网络状态
  • 查询PHP网站列表
  • 创建新的PHP网站
  • 查询MySQL数据库列表
  • Docker容器管理
    • 查看容器列表
    • 查看容器详细信息
  • Docker镜像管理
    • 查看本地镜像列表
  • 邮箱管理
    • 添加邮箱账户
    • 查看邮件列表
  • 获取面板公共配置信息
  • 更多功能持续开发中…

环境要求

  • Go 1.18+
  • 宝塔面板API访问权限
  • 宝塔面板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配置方式

在Cursor中使用时,可以通过以下步骤配置:

  1. 打开Cursor设置 > 扩展 > MCP工具
  2. 添加新的MCP工具
  3. 按照以下格式填写配置:
{
  "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协议调用示例

// 获取网站列表
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请求控制器

添加新功能

  1. 在相应的模块目录下创建或修改文件
  2. 定义新的工具常量和工具对象
  3. 实现处理函数
  4. 在main.go的registerTools函数中注册工具

许可证

本项目采用MIT许可证,详情请参阅LICENSE文件。

贡献

欢迎提交问题和功能请求!如果您想做出贡献,请:

  1. Fork本仓库
  2. 创建您的特性分支 (git checkout -b feature/amazing-feature)
  3. 提交您的更改 (git commit -m 'Add some amazing feature')
  4. 推送到分支 (git push origin feature/amazing-feature)
  5. 开放一个Pull Request

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers