mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: mcp server
This commit is contained in:
parent
c4a9d03bb3
commit
e8ee931e16
51 changed files with 2749 additions and 1526 deletions
|
@ -31,6 +31,15 @@ export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
|
|||
{ text: 'Contributing', link: '/guide/contributing' }
|
||||
]
|
||||
},
|
||||
{
|
||||
text: 'MCP',
|
||||
collapsed: false,
|
||||
items: [
|
||||
{ text: 'Overview', link: '/guide/mcp' },
|
||||
{ text: 'Configuration Management', link: '/guide/mcp-config' },
|
||||
{ text: 'Nginx Service Management', link: '/guide/mcp-nginx' },
|
||||
]
|
||||
},
|
||||
{
|
||||
text: 'Configuration',
|
||||
collapsed: false,
|
||||
|
|
|
@ -36,6 +36,15 @@ export const zhCNConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
|
|||
{ text: '贡献代码', link: '/zh_CN/guide/contributing' }
|
||||
]
|
||||
},
|
||||
{
|
||||
text: 'MCP',
|
||||
collapsed: false,
|
||||
items: [
|
||||
{ text: '概述', link: '/zh_CN/guide/mcp' },
|
||||
{ text: '配置文件管理', link: '/zh_CN/guide/mcp-config' },
|
||||
{ text: 'Nginx 服务管理', link: '/zh_CN/guide/mcp-nginx' },
|
||||
]
|
||||
},
|
||||
{
|
||||
text: '配置',
|
||||
collapsed: false,
|
||||
|
|
|
@ -36,6 +36,15 @@ export const zhTWConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
|
|||
{ text: '貢獻程式碼', link: '/zh_TW/guide/contributing' }
|
||||
]
|
||||
},
|
||||
{
|
||||
text: 'MCP',
|
||||
collapsed: false,
|
||||
items: [
|
||||
{ text: '概述', link: '/zh_TW/guide/mcp' },
|
||||
{ text: '配置文件管理', link: '/zh_TW/guide/mcp-config' },
|
||||
{ text: 'Nginx 服務管理', link: '/zh_TW/guide/mcp-nginx' },
|
||||
]
|
||||
},
|
||||
{
|
||||
text: '配置',
|
||||
collapsed: false,
|
||||
|
|
127
docs/guide/mcp-config.md
Normal file
127
docs/guide/mcp-config.md
Normal file
|
@ -0,0 +1,127 @@
|
|||
# MCP Configuration File Management
|
||||
|
||||
## Introduction
|
||||
|
||||
The MCP Configuration File Management module provides a set of tools and resources for managing Nginx configuration files. These features allow AI agents and automation tools to perform various configuration file operations, including reading, creating, modifying, and organizing configuration files.
|
||||
|
||||
## Feature List
|
||||
|
||||
### Get Nginx Configuration File Base Path
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_config_base_path`
|
||||
|
||||
### List Configuration Files
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_config_list`
|
||||
|
||||
### Get Configuration File Content
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_config_get`
|
||||
|
||||
### Add New Configuration File
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_config_add`
|
||||
|
||||
### Modify Existing Configuration File
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_config_modify`
|
||||
|
||||
### Rename Configuration File
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_config_rename`
|
||||
|
||||
### Create Configuration Directory
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_config_mkdir`
|
||||
|
||||
### History
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_config_history`
|
||||
|
||||
## Usage Examples
|
||||
|
||||
Here are some examples of using MCP Configuration File Management features:
|
||||
|
||||
### Get Base Path
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "nginx_config_base_path",
|
||||
"parameters": {}
|
||||
}
|
||||
```
|
||||
|
||||
Example response:
|
||||
|
||||
```json
|
||||
{
|
||||
"base_path": "/etc/nginx"
|
||||
}
|
||||
```
|
||||
|
||||
### List Configuration Files
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "nginx_config_list",
|
||||
"parameters": {
|
||||
"path": "/etc/nginx/conf.d"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Example response:
|
||||
|
||||
```json
|
||||
{
|
||||
"files": [
|
||||
{
|
||||
"name": "default.conf",
|
||||
"is_dir": false,
|
||||
"path": "/etc/nginx/conf.d/default.conf"
|
||||
},
|
||||
{
|
||||
"name": "example.conf",
|
||||
"is_dir": false,
|
||||
"path": "/etc/nginx/conf.d/example.conf"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Get Configuration File Content
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "nginx_config_get",
|
||||
"parameters": {
|
||||
"path": "/etc/nginx/conf.d/default.conf"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Modify Configuration File
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "nginx_config_modify",
|
||||
"parameters": {
|
||||
"path": "/etc/nginx/conf.d/default.conf",
|
||||
"content": "server {\n listen 80;\n server_name example.com;\n location / {\n root /usr/share/nginx/html;\n index index.html;\n }\n}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Important Notes
|
||||
|
||||
- All path operations are relative to the Nginx configuration base path
|
||||
- Configuration file modifications are automatically backed up and can be restored using the history feature
|
||||
- Some operations may require validation of configuration file syntax
|
22
docs/guide/mcp-nginx.md
Normal file
22
docs/guide/mcp-nginx.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
# MCP Nginx Service Management
|
||||
|
||||
## Introduction
|
||||
|
||||
The MCP Nginx Service Management module provides a set of tools and resources for monitoring and controlling the Nginx service. These features enable AI agents and automation tools to query Nginx status, reload configurations, and restart services without requiring traditional command-line interfaces.
|
||||
|
||||
## Feature List
|
||||
|
||||
### Get Nginx Status
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_status`
|
||||
|
||||
### Reload Nginx
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_reload`
|
||||
|
||||
### Restart Nginx Service
|
||||
|
||||
- Type: `tool`
|
||||
- Name: `nginx_restart`
|
43
docs/guide/mcp.md
Normal file
43
docs/guide/mcp.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
# MCP Module
|
||||
|
||||
## Introduction
|
||||
|
||||
MCP (Model Context Protocol) is a special interface provided by Nginx UI that allows AI agents to interact with Nginx UI. Through MCP, AI models can access and manage Nginx configuration files, perform Nginx-related operations (such as restart, reload), and get Nginx running status.
|
||||
|
||||
## Feature Overview
|
||||
|
||||
The MCP module is divided into two main functional areas:
|
||||
|
||||
- [Configuration File Management](./mcp-config.md) - Various operations for managing Nginx configuration files
|
||||
- [Nginx Service Management](./mcp-nginx.md) - Control and monitor Nginx service status
|
||||
|
||||
## Interface
|
||||
|
||||
The MCP interface is accessible through the `/mcp` path and provides streaming via SSE.
|
||||
|
||||
## Authentication
|
||||
|
||||
The MCP interface is authenticated using the `node_secret` query parameter.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
http://localhost:9000/mcp?node_secret=<your_node_secret>
|
||||
```
|
||||
|
||||
### Resources
|
||||
|
||||
Resources are readable information provided by MCP, such as Nginx status.
|
||||
|
||||
### Tools
|
||||
|
||||
Tools are executable operations provided by MCP, such as restarting Nginx, modifying configuration files, etc.
|
||||
|
||||
## Use Cases
|
||||
|
||||
MCP is mainly used in the following scenarios:
|
||||
|
||||
1. AI-driven Nginx configuration management
|
||||
2. Integration with automated operations tools
|
||||
3. Integration of third-party systems with Nginx UI
|
||||
4. Providing machine-readable APIs for automation scripts
|
55
docs/zh_CN/guide/mcp-config.md
Normal file
55
docs/zh_CN/guide/mcp-config.md
Normal file
|
@ -0,0 +1,55 @@
|
|||
# MCP 配置文件管理
|
||||
|
||||
## 简介
|
||||
|
||||
MCP 配置文件管理模块提供了一系列工具和资源,用于管理 Nginx 配置文件。这些功能允许 AI 代理和自动化工具执行各种配置文件操作,包括读取、创建、修改和组织配置文件。
|
||||
|
||||
## 功能列表
|
||||
|
||||
### 获取 Nginx 配置文件的根目录路径
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_config_base_path`
|
||||
- 描述:获取 Nginx 配置文件的根目录路径
|
||||
|
||||
### 列出配置文件
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_config_list`
|
||||
- 描述:获取指定目录下的配置文件和子目录列表
|
||||
|
||||
### 获取配置文件内容
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_config_get`
|
||||
- 描述:读取指定配置文件的内容
|
||||
|
||||
### 添加新的配置文件
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_config_add`
|
||||
- 描述:创建新的配置文件
|
||||
|
||||
### 修改现有配置文件
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_config_modify`
|
||||
- 描述:更新现有配置文件的内容
|
||||
|
||||
### 重命名配置文件
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_config_rename`
|
||||
- 描述:修改配置文件的名称或路径
|
||||
|
||||
### 创建配置目录
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_config_mkdir`
|
||||
- 描述:创建新的配置目录
|
||||
|
||||
### 历史记录
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_config_history`
|
||||
- 描述:获取配置文件的修改历史记录
|
22
docs/zh_CN/guide/mcp-nginx.md
Normal file
22
docs/zh_CN/guide/mcp-nginx.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
# MCP Nginx 服务管理
|
||||
|
||||
## 简介
|
||||
|
||||
MCP Nginx 服务管理模块提供了一组工具和资源,用于监控和控制 Nginx 服务。这些功能使 AI 代理和自动化工具能够查询 Nginx 状态、重新加载配置和重启服务,而无需通过传统命令行界面。
|
||||
|
||||
## 功能列表
|
||||
|
||||
### 获取 Nginx 状态
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_status`
|
||||
|
||||
### 重新加载 Nginx
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_reload`
|
||||
|
||||
### 重启 Nginx 服务
|
||||
|
||||
- 类型:`tool`
|
||||
- 名称:`nginx_restart`
|
43
docs/zh_CN/guide/mcp.md
Normal file
43
docs/zh_CN/guide/mcp.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
# MCP 模块
|
||||
|
||||
## 简介
|
||||
|
||||
MCP(Model Context Protocol)是 Nginx UI 提供的一个特殊接口,允许 AI 代理与 Nginx UI 交互。通过 MCP,AI 模型可以访问和管理 Nginx 配置文件、执行 Nginx 相关操作(如重启、重载)以及获取 Nginx 运行状态。
|
||||
|
||||
## 功能概览
|
||||
|
||||
MCP 模块主要分为两大部分功能:
|
||||
|
||||
- [配置文件管理](./mcp-config.md) - 管理 Nginx 配置文件的各种操作
|
||||
- [Nginx 服务管理](./mcp-nginx.md) - 控制和监控 Nginx 服务状态
|
||||
|
||||
## 接口
|
||||
|
||||
MCP 接口通过 `/mcp` 路径提供 SSE 流式传输。
|
||||
|
||||
## 认证
|
||||
|
||||
MCP 接口通过 `node_secret` 查询参数进行认证。
|
||||
|
||||
例如:
|
||||
|
||||
```
|
||||
http://localhost:9000/mcp?node_secret=<your_node_secret>
|
||||
```
|
||||
|
||||
### 资源(Resource)
|
||||
|
||||
资源是 MCP 提供的可读取信息,例如 Nginx 状态。
|
||||
|
||||
### 工具(Tool)
|
||||
|
||||
工具是 MCP 提供的可执行操作,例如重启 Nginx、修改配置文件等。
|
||||
|
||||
## 使用场景
|
||||
|
||||
MCP 主要用于以下场景:
|
||||
|
||||
1. AI 驱动的 Nginx 配置管理
|
||||
2. 自动化运维工具集成
|
||||
3. 第三方系统与 Nginx UI 的集成
|
||||
4. 提供机器可读的 API 以便于自动化脚本使用
|
127
docs/zh_TW/guide/mcp-config.md
Normal file
127
docs/zh_TW/guide/mcp-config.md
Normal file
|
@ -0,0 +1,127 @@
|
|||
# MCP 配置文件管理
|
||||
|
||||
## 簡介
|
||||
|
||||
MCP 配置文件管理模組提供了一系列工具和資源,用於管理 Nginx 配置文件。這些功能允許 AI 代理和自動化工具執行各種配置文件操作,包括讀取、創建、修改和組織配置文件。
|
||||
|
||||
## 功能列表
|
||||
|
||||
### 獲取 Nginx 配置文件的根目錄路徑
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_config_base_path`
|
||||
|
||||
### 列出配置文件
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_config_list`
|
||||
|
||||
### 獲取配置文件內容
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_config_get`
|
||||
|
||||
### 添加新的配置文件
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_config_add`
|
||||
|
||||
### 修改現有配置文件
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_config_modify`
|
||||
|
||||
### 重命名配置文件
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_config_rename`
|
||||
|
||||
### 創建配置目錄
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_config_mkdir`
|
||||
|
||||
### 歷史記錄
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_config_history`
|
||||
|
||||
## 使用示例
|
||||
|
||||
以下是一些使用 MCP 配置文件管理功能的示例:
|
||||
|
||||
### 獲取基礎路徑
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "nginx_config_base_path",
|
||||
"parameters": {}
|
||||
}
|
||||
```
|
||||
|
||||
返回結果示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"base_path": "/etc/nginx"
|
||||
}
|
||||
```
|
||||
|
||||
### 列出配置文件
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "nginx_config_list",
|
||||
"parameters": {
|
||||
"path": "/etc/nginx/conf.d"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
返回結果示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"files": [
|
||||
{
|
||||
"name": "default.conf",
|
||||
"is_dir": false,
|
||||
"path": "/etc/nginx/conf.d/default.conf"
|
||||
},
|
||||
{
|
||||
"name": "example.conf",
|
||||
"is_dir": false,
|
||||
"path": "/etc/nginx/conf.d/example.conf"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 獲取配置文件內容
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "nginx_config_get",
|
||||
"parameters": {
|
||||
"path": "/etc/nginx/conf.d/default.conf"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 修改配置文件
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "nginx_config_modify",
|
||||
"parameters": {
|
||||
"path": "/etc/nginx/conf.d/default.conf",
|
||||
"content": "server {\n listen 80;\n server_name example.com;\n location / {\n root /usr/share/nginx/html;\n index index.html;\n }\n}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 注意事項
|
||||
|
||||
- 所有路徑操作都是相對於 Nginx 配置基礎路徑的
|
||||
- 配置文件修改會自動備份,可通過歷史記錄功能恢復
|
||||
- 某些操作可能需要驗證配置文件語法正確性
|
22
docs/zh_TW/guide/mcp-nginx.md
Normal file
22
docs/zh_TW/guide/mcp-nginx.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
# MCP Nginx 服務管理
|
||||
|
||||
## 簡介
|
||||
|
||||
MCP Nginx 服務管理模組提供了一組工具和資源,用於監控和控制 Nginx 服務。這些功能使 AI 代理和自動化工具能夠查詢 Nginx 狀態、重新加載配置和重啟服務,而無需通過傳統命令行界面。
|
||||
|
||||
## 功能列表
|
||||
|
||||
### 獲取 Nginx 狀態
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_status`
|
||||
|
||||
### 重新加載 Nginx
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_reload`
|
||||
|
||||
### 重啟 Nginx 服務
|
||||
|
||||
- 類型:`tool`
|
||||
- 名稱:`nginx_restart`
|
43
docs/zh_TW/guide/mcp.md
Normal file
43
docs/zh_TW/guide/mcp.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
# MCP 模組
|
||||
|
||||
## 簡介
|
||||
|
||||
MCP(Model Context Protocol)是 Nginx UI 提供的一個特殊介面,允許 AI 代理與 Nginx UI 互動。通過 MCP,AI 模型可以訪問和管理 Nginx 配置文件、執行 Nginx 相關操作(如重啓、重載)以及獲取 Nginx 運行狀態。
|
||||
|
||||
## 功能概覽
|
||||
|
||||
MCP 模組主要分為兩大部分功能:
|
||||
|
||||
- [配置文件管理](./mcp-config.md) - 管理 Nginx 配置文件的各種操作
|
||||
- [Nginx 服務管理](./mcp-nginx.md) - 控制和監控 Nginx 服務狀態
|
||||
|
||||
## 介面
|
||||
|
||||
MCP 介面通過 `/mcp` 路徑提供 SSE 流式傳輸。
|
||||
|
||||
## 認證
|
||||
|
||||
MCP 介面通過 `node_secret` 查詢參數進行認證。
|
||||
|
||||
例如:
|
||||
|
||||
```
|
||||
http://localhost:9000/mcp?node_secret=<your_node_secret>
|
||||
```
|
||||
|
||||
### 資源(Resource)
|
||||
|
||||
資源是 MCP 提供的可讀取信息,例如 Nginx 狀態。
|
||||
|
||||
### 工具(Tool)
|
||||
|
||||
工具是 MCP 提供的可執行操作,例如重啓 Nginx、修改配置文件等。
|
||||
|
||||
## 使用場景
|
||||
|
||||
MCP 主要用於以下場景:
|
||||
|
||||
1. AI 驅動的 Nginx 配置管理
|
||||
2. 自動化運維工具集成
|
||||
3. 第三方系統與 Nginx UI 的集成
|
||||
4. 提供機器可讀的 API 以便於自動化腳本使用
|
Loading…
Add table
Add a link
Reference in a new issue