astrbotmcp 0.3.1__tar.gz → 0.4.1__tar.gz
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.
- {astrbotmcp-0.3.1/astrbotmcp.egg-info → astrbotmcp-0.4.1}/PKG-INFO +33 -42
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/README.md +32 -41
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/astrbot_client.py +115 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/config.py +0 -9
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/server.py +10 -2
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/__init__.py +5 -4
- astrbotmcp-0.4.1/astrbot_mcp/tools/mcp_panel_tools.py +135 -0
- astrbotmcp-0.4.1/astrbot_mcp/tools/message/__init__.py +3 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/message/webchat.py +86 -55
- astrbotmcp-0.4.1/astrbot_mcp/tools/plugin_admin_tools.py +344 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/plugin_market_tools.py +28 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools.py +6 -2
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1/astrbotmcp.egg-info}/PKG-INFO +33 -42
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbotmcp.egg-info/SOURCES.txt +2 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/pyproject.toml +1 -1
- astrbotmcp-0.4.1/tests/test_smoke.py +97 -0
- astrbotmcp-0.3.1/astrbot_mcp/tools/message/__init__.py +0 -4
- astrbotmcp-0.3.1/tests/test_smoke.py +0 -24
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/LICENSE.txt +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/__init__.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/config_search_tool.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/config_tools.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/control_tools.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/helpers.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/log_tools.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/message/cache.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/message/direct.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/message/quote.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/message/utils.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/platform_tools.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/session_tools.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbot_mcp/tools/types.py +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbotmcp.egg-info/dependency_links.txt +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbotmcp.egg-info/entry_points.txt +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbotmcp.egg-info/requires.txt +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/astrbotmcp.egg-info/top_level.txt +0 -0
- {astrbotmcp-0.3.1 → astrbotmcp-0.4.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astrbotmcp
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Add your description here
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -16,9 +16,7 @@ Dynamic: license-file
|
|
|
16
16
|
|
|
17
17
|
[](https://lobehub.com/mcp/xunxiing-astrbotmcp)
|
|
18
18
|
|
|
19
|
-
> **AstrBot 无法通过 MCP
|
|
20
|
-
|
|
21
|
-
### 警告与免责声明
|
|
19
|
+
> **AstrBot 无法通过 MCP 控制自身。本项目填补了这一空白,为Astrbot开发者提供AI AGENT时代调试插件的自动化工具**
|
|
22
20
|
|
|
23
21
|
⚠️ **本项目提供的是运维级控制能力,使用时请注意:**
|
|
24
22
|
|
|
@@ -27,33 +25,12 @@ Dynamic: license-file
|
|
|
27
25
|
3. **生产环境** - 建议仅在开发/测试环境使用控制面功能
|
|
28
26
|
4. **数据安全** - 日志可能包含敏感信息,注意脱敏处理
|
|
29
27
|
|
|
30
|
-
**本项目与 AstrBot 官方无直接关联,由社区独立维护。**
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
### 这个项目到底在干什么
|
|
35
|
-
|
|
36
|
-
#### AstrBot 自身的 MCP 控制面
|
|
37
|
-
|
|
38
|
-
通过 MCP tool 实现:
|
|
39
|
-
|
|
40
|
-
- **重启 AstrBot Core** - 进程级控制,直接调用 `/api/stat/restart-core`
|
|
41
|
-
- **运行状态监听** - 实时日志流、平台状态监控
|
|
42
|
-
- **配置热加载** - 动态读取/修改配置
|
|
43
|
-
- **发送信息** -自动化测试插件
|
|
44
|
-
- **浏览插件市场**
|
|
45
|
-
|
|
46
|
-
#### 为astrbot开发者提供AI AGENT时代调试插件的自动化工具
|
|
47
|
-
|
|
48
|
-
---
|
|
28
|
+
### **本项目与 AstrBot 官方无直接关联,由社区独立维护。**
|
|
49
29
|
|
|
50
30
|
### 快速开始
|
|
51
31
|
|
|
52
32
|
#### 安装
|
|
53
33
|
|
|
54
|
-
<details>
|
|
55
|
-
<summary>通过 PyPI 或 uv 安装</summary>
|
|
56
|
-
|
|
57
34
|
```bash
|
|
58
35
|
# 通过 PyPI 安装(推荐)
|
|
59
36
|
pip install astrbotmcp
|
|
@@ -62,7 +39,8 @@ pip install astrbotmcp
|
|
|
62
39
|
uv add astrbotmcp
|
|
63
40
|
```
|
|
64
41
|
|
|
65
|
-
|
|
42
|
+
<details>
|
|
43
|
+
<summary>通过 PyPI 或 uv 安装</summary>
|
|
66
44
|
|
|
67
45
|
```json
|
|
68
46
|
{
|
|
@@ -85,6 +63,8 @@ uv add astrbotmcp
|
|
|
85
63
|
}
|
|
86
64
|
```
|
|
87
65
|
|
|
66
|
+
安装完成后,您可以通过以下方式在 MCP 客户端中配置:
|
|
67
|
+
|
|
88
68
|
</details>
|
|
89
69
|
|
|
90
70
|
<details>
|
|
@@ -105,7 +85,8 @@ npm install -g astrbotmcp
|
|
|
105
85
|
"astrbot-mcp": {
|
|
106
86
|
"command": "npx",
|
|
107
87
|
"args": [
|
|
108
|
-
"
|
|
88
|
+
"-y",
|
|
89
|
+
"@xunxiing/astrbot-mcp@latest"
|
|
109
90
|
],
|
|
110
91
|
"env": {
|
|
111
92
|
"ASTRBOT_BASE_URL": "http://127.0.0.1:6185",
|
|
@@ -122,14 +103,15 @@ npm install -g astrbotmcp
|
|
|
122
103
|
|
|
123
104
|
#### 环境变量说明
|
|
124
105
|
|
|
125
|
-
| 变量
|
|
126
|
-
|
|
127
|
-
| `ASTRBOT_BASE_URL`
|
|
128
|
-
| `ASTRBOT_TIMEOUT`
|
|
129
|
-
| `ASTRBOT_USERNAME`
|
|
130
|
-
| `ASTRBOT_PASSWORD`
|
|
131
|
-
| `ASTRBOT_LOG_LEVEL`
|
|
132
|
-
| `ASTRBOTMCP_DISABLE_PROXY` | 是否禁用代理(防止本地请求被代理拦截)
|
|
106
|
+
| 变量 | 说明 | 默认值 |
|
|
107
|
+
| ---------------------------- | -------------------------------------------------------| ------------------------- |
|
|
108
|
+
| `ASTRBOT_BASE_URL` | AstrBot Dashboard 地址 | `http://127.0.0.1:6185` |
|
|
109
|
+
| `ASTRBOT_TIMEOUT` | HTTP 请求超时时间 | `30` |
|
|
110
|
+
| `ASTRBOT_USERNAME` | Dashboard 用户名 | - |
|
|
111
|
+
| `ASTRBOT_PASSWORD` | Dashboard 密码 | - |
|
|
112
|
+
| `ASTRBOT_LOG_LEVEL` | 日志级别 | `INFO` |
|
|
113
|
+
| `ASTRBOTMCP_DISABLE_PROXY` | 是否禁用代理(防止本地请求被代理拦截) | `true` |
|
|
114
|
+
| `ASTRBOTMCP_PLUGIN_PROXY` | 插件 URL 安装默认代理前缀(`install_astrbot_plugin`) | `https://gh-proxy.com` |
|
|
133
115
|
|
|
134
116
|
#### 代理配置说明
|
|
135
117
|
|
|
@@ -138,10 +120,9 @@ npm install -g astrbotmcp
|
|
|
138
120
|
**解决方案:**
|
|
139
121
|
|
|
140
122
|
1. **默认行为**:AstrBot MCP 默认禁用代理(`ASTRBOTMCP_DISABLE_PROXY=true`),确保本地请求直接发送到 AstrBot。
|
|
141
|
-
|
|
142
123
|
2. **如果需要使用代理**:设置 `ASTRBOTMCP_DISABLE_PROXY=false`,但请注意这可能导致本地 API 请求失败。
|
|
143
|
-
|
|
144
124
|
3. **推荐配置**:对于本地 AstrBot 实例,始终禁用代理:
|
|
125
|
+
|
|
145
126
|
```json
|
|
146
127
|
{
|
|
147
128
|
"mcpServers": {
|
|
@@ -180,13 +161,18 @@ npm install -g astrbotmcp
|
|
|
180
161
|
|
|
181
162
|
#### 消息工具
|
|
182
163
|
|
|
183
|
-
- `send_platform_message` - 通过 Web Chat API
|
|
184
|
-
- `send_platform_message_direct` - 直接发送到平台(绕过 LLM)
|
|
164
|
+
- `send_platform_message` - 通过 Web Chat API 发送消息链(仅 WebUI;无需 `platform_id` / `target_id`)
|
|
185
165
|
- `get_platform_session_messages` - 读取会话消息历史
|
|
186
166
|
|
|
187
167
|
#### 插件市场
|
|
188
168
|
|
|
189
169
|
- `browse_plugin_market` - 浏览插件市场(搜索/排序)
|
|
170
|
+
- `install_astrbot_plugin` - Install plugin via URL or local zip path (proxy enabled by default)
|
|
171
|
+
- `configure_astrbot_plugin_json` - Configure plugin JSON by reusing AstrBot config ops
|
|
172
|
+
|
|
173
|
+
#### MCP 面板
|
|
174
|
+
|
|
175
|
+
- `manage_mcp_config_panel` - Access MCP panel APIs (`list` / `add` / `update` / `delete` / `test`)
|
|
190
176
|
|
|
191
177
|
---
|
|
192
178
|
|
|
@@ -211,12 +197,18 @@ logs = get_astrbot_logs(wait_seconds=10)
|
|
|
211
197
|
```python
|
|
212
198
|
# 发送带图片的消息链
|
|
213
199
|
send_platform_message(
|
|
214
|
-
platform_id="webchat",
|
|
215
200
|
message="Hello from MCP",
|
|
216
201
|
images=["/path/to/image.png"]
|
|
217
202
|
)
|
|
218
203
|
```
|
|
219
204
|
|
|
205
|
+
```python
|
|
206
|
+
# 插件命令请直接发送纯文本,不要命令前缀
|
|
207
|
+
send_platform_message(
|
|
208
|
+
message="抽老婆帮助"
|
|
209
|
+
)
|
|
210
|
+
```
|
|
211
|
+
|
|
220
212
|
---
|
|
221
213
|
|
|
222
214
|
### 技术架构
|
|
@@ -256,4 +248,3 @@ uv run --project . astrbot-mcp
|
|
|
256
248
|
### 许可证
|
|
257
249
|
|
|
258
250
|
MIT License - 详见 [LICENSE](LICENSE.txt) 文件。
|
|
259
|
-
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://lobehub.com/mcp/xunxiing-astrbotmcp)
|
|
4
4
|
|
|
5
|
-
> **AstrBot 无法通过 MCP
|
|
6
|
-
|
|
7
|
-
### 警告与免责声明
|
|
5
|
+
> **AstrBot 无法通过 MCP 控制自身。本项目填补了这一空白,为Astrbot开发者提供AI AGENT时代调试插件的自动化工具**
|
|
8
6
|
|
|
9
7
|
⚠️ **本项目提供的是运维级控制能力,使用时请注意:**
|
|
10
8
|
|
|
@@ -13,33 +11,12 @@
|
|
|
13
11
|
3. **生产环境** - 建议仅在开发/测试环境使用控制面功能
|
|
14
12
|
4. **数据安全** - 日志可能包含敏感信息,注意脱敏处理
|
|
15
13
|
|
|
16
|
-
**本项目与 AstrBot 官方无直接关联,由社区独立维护。**
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
### 这个项目到底在干什么
|
|
21
|
-
|
|
22
|
-
#### AstrBot 自身的 MCP 控制面
|
|
23
|
-
|
|
24
|
-
通过 MCP tool 实现:
|
|
25
|
-
|
|
26
|
-
- **重启 AstrBot Core** - 进程级控制,直接调用 `/api/stat/restart-core`
|
|
27
|
-
- **运行状态监听** - 实时日志流、平台状态监控
|
|
28
|
-
- **配置热加载** - 动态读取/修改配置
|
|
29
|
-
- **发送信息** -自动化测试插件
|
|
30
|
-
- **浏览插件市场**
|
|
31
|
-
|
|
32
|
-
#### 为astrbot开发者提供AI AGENT时代调试插件的自动化工具
|
|
33
|
-
|
|
34
|
-
---
|
|
14
|
+
### **本项目与 AstrBot 官方无直接关联,由社区独立维护。**
|
|
35
15
|
|
|
36
16
|
### 快速开始
|
|
37
17
|
|
|
38
18
|
#### 安装
|
|
39
19
|
|
|
40
|
-
<details>
|
|
41
|
-
<summary>通过 PyPI 或 uv 安装</summary>
|
|
42
|
-
|
|
43
20
|
```bash
|
|
44
21
|
# 通过 PyPI 安装(推荐)
|
|
45
22
|
pip install astrbotmcp
|
|
@@ -48,7 +25,8 @@ pip install astrbotmcp
|
|
|
48
25
|
uv add astrbotmcp
|
|
49
26
|
```
|
|
50
27
|
|
|
51
|
-
|
|
28
|
+
<details>
|
|
29
|
+
<summary>通过 PyPI 或 uv 安装</summary>
|
|
52
30
|
|
|
53
31
|
```json
|
|
54
32
|
{
|
|
@@ -71,6 +49,8 @@ uv add astrbotmcp
|
|
|
71
49
|
}
|
|
72
50
|
```
|
|
73
51
|
|
|
52
|
+
安装完成后,您可以通过以下方式在 MCP 客户端中配置:
|
|
53
|
+
|
|
74
54
|
</details>
|
|
75
55
|
|
|
76
56
|
<details>
|
|
@@ -91,7 +71,8 @@ npm install -g astrbotmcp
|
|
|
91
71
|
"astrbot-mcp": {
|
|
92
72
|
"command": "npx",
|
|
93
73
|
"args": [
|
|
94
|
-
"
|
|
74
|
+
"-y",
|
|
75
|
+
"@xunxiing/astrbot-mcp@latest"
|
|
95
76
|
],
|
|
96
77
|
"env": {
|
|
97
78
|
"ASTRBOT_BASE_URL": "http://127.0.0.1:6185",
|
|
@@ -108,14 +89,15 @@ npm install -g astrbotmcp
|
|
|
108
89
|
|
|
109
90
|
#### 环境变量说明
|
|
110
91
|
|
|
111
|
-
| 变量
|
|
112
|
-
|
|
113
|
-
| `ASTRBOT_BASE_URL`
|
|
114
|
-
| `ASTRBOT_TIMEOUT`
|
|
115
|
-
| `ASTRBOT_USERNAME`
|
|
116
|
-
| `ASTRBOT_PASSWORD`
|
|
117
|
-
| `ASTRBOT_LOG_LEVEL`
|
|
118
|
-
| `ASTRBOTMCP_DISABLE_PROXY` | 是否禁用代理(防止本地请求被代理拦截)
|
|
92
|
+
| 变量 | 说明 | 默认值 |
|
|
93
|
+
| ---------------------------- | -------------------------------------------------------| ------------------------- |
|
|
94
|
+
| `ASTRBOT_BASE_URL` | AstrBot Dashboard 地址 | `http://127.0.0.1:6185` |
|
|
95
|
+
| `ASTRBOT_TIMEOUT` | HTTP 请求超时时间 | `30` |
|
|
96
|
+
| `ASTRBOT_USERNAME` | Dashboard 用户名 | - |
|
|
97
|
+
| `ASTRBOT_PASSWORD` | Dashboard 密码 | - |
|
|
98
|
+
| `ASTRBOT_LOG_LEVEL` | 日志级别 | `INFO` |
|
|
99
|
+
| `ASTRBOTMCP_DISABLE_PROXY` | 是否禁用代理(防止本地请求被代理拦截) | `true` |
|
|
100
|
+
| `ASTRBOTMCP_PLUGIN_PROXY` | 插件 URL 安装默认代理前缀(`install_astrbot_plugin`) | `https://gh-proxy.com` |
|
|
119
101
|
|
|
120
102
|
#### 代理配置说明
|
|
121
103
|
|
|
@@ -124,10 +106,9 @@ npm install -g astrbotmcp
|
|
|
124
106
|
**解决方案:**
|
|
125
107
|
|
|
126
108
|
1. **默认行为**:AstrBot MCP 默认禁用代理(`ASTRBOTMCP_DISABLE_PROXY=true`),确保本地请求直接发送到 AstrBot。
|
|
127
|
-
|
|
128
109
|
2. **如果需要使用代理**:设置 `ASTRBOTMCP_DISABLE_PROXY=false`,但请注意这可能导致本地 API 请求失败。
|
|
129
|
-
|
|
130
110
|
3. **推荐配置**:对于本地 AstrBot 实例,始终禁用代理:
|
|
111
|
+
|
|
131
112
|
```json
|
|
132
113
|
{
|
|
133
114
|
"mcpServers": {
|
|
@@ -166,13 +147,18 @@ npm install -g astrbotmcp
|
|
|
166
147
|
|
|
167
148
|
#### 消息工具
|
|
168
149
|
|
|
169
|
-
- `send_platform_message` - 通过 Web Chat API
|
|
170
|
-
- `send_platform_message_direct` - 直接发送到平台(绕过 LLM)
|
|
150
|
+
- `send_platform_message` - 通过 Web Chat API 发送消息链(仅 WebUI;无需 `platform_id` / `target_id`)
|
|
171
151
|
- `get_platform_session_messages` - 读取会话消息历史
|
|
172
152
|
|
|
173
153
|
#### 插件市场
|
|
174
154
|
|
|
175
155
|
- `browse_plugin_market` - 浏览插件市场(搜索/排序)
|
|
156
|
+
- `install_astrbot_plugin` - Install plugin via URL or local zip path (proxy enabled by default)
|
|
157
|
+
- `configure_astrbot_plugin_json` - Configure plugin JSON by reusing AstrBot config ops
|
|
158
|
+
|
|
159
|
+
#### MCP 面板
|
|
160
|
+
|
|
161
|
+
- `manage_mcp_config_panel` - Access MCP panel APIs (`list` / `add` / `update` / `delete` / `test`)
|
|
176
162
|
|
|
177
163
|
---
|
|
178
164
|
|
|
@@ -197,12 +183,18 @@ logs = get_astrbot_logs(wait_seconds=10)
|
|
|
197
183
|
```python
|
|
198
184
|
# 发送带图片的消息链
|
|
199
185
|
send_platform_message(
|
|
200
|
-
platform_id="webchat",
|
|
201
186
|
message="Hello from MCP",
|
|
202
187
|
images=["/path/to/image.png"]
|
|
203
188
|
)
|
|
204
189
|
```
|
|
205
190
|
|
|
191
|
+
```python
|
|
192
|
+
# 插件命令请直接发送纯文本,不要命令前缀
|
|
193
|
+
send_platform_message(
|
|
194
|
+
message="抽老婆帮助"
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
206
198
|
---
|
|
207
199
|
|
|
208
200
|
### 技术架构
|
|
@@ -242,4 +234,3 @@ uv run --project . astrbot-mcp
|
|
|
242
234
|
### 许可证
|
|
243
235
|
|
|
244
236
|
MIT License - 详见 [LICENSE](LICENSE.txt) 文件。
|
|
245
|
-
|
|
@@ -402,6 +402,38 @@ class AstrBotClient:
|
|
|
402
402
|
response = await self._request("POST", "/api/config/astrbot/update", json_body=payload)
|
|
403
403
|
return response.json()
|
|
404
404
|
|
|
405
|
+
async def get_plugin_config(
|
|
406
|
+
self,
|
|
407
|
+
*,
|
|
408
|
+
plugin_name: str,
|
|
409
|
+
) -> Dict[str, Any]:
|
|
410
|
+
"""
|
|
411
|
+
Get plugin config via /api/config/get?plugin_name=<name>.
|
|
412
|
+
"""
|
|
413
|
+
response = await self._request(
|
|
414
|
+
"GET",
|
|
415
|
+
"/api/config/get",
|
|
416
|
+
params={"plugin_name": plugin_name},
|
|
417
|
+
)
|
|
418
|
+
return response.json()
|
|
419
|
+
|
|
420
|
+
async def update_plugin_config(
|
|
421
|
+
self,
|
|
422
|
+
*,
|
|
423
|
+
plugin_name: str,
|
|
424
|
+
config: Dict[str, Any],
|
|
425
|
+
) -> Dict[str, Any]:
|
|
426
|
+
"""
|
|
427
|
+
Update plugin config via /api/config/plugin/update?plugin_name=<name>.
|
|
428
|
+
"""
|
|
429
|
+
response = await self._request(
|
|
430
|
+
"POST",
|
|
431
|
+
"/api/config/plugin/update",
|
|
432
|
+
params={"plugin_name": plugin_name},
|
|
433
|
+
json_body=config,
|
|
434
|
+
)
|
|
435
|
+
return response.json()
|
|
436
|
+
|
|
405
437
|
async def list_session_rules(
|
|
406
438
|
self,
|
|
407
439
|
*,
|
|
@@ -458,6 +490,40 @@ class AstrBotClient:
|
|
|
458
490
|
response = await self._request("GET", "/api/plugin/market_list", params=params or None)
|
|
459
491
|
return response.json()
|
|
460
492
|
|
|
493
|
+
async def install_plugin_from_url(
|
|
494
|
+
self,
|
|
495
|
+
*,
|
|
496
|
+
url: str,
|
|
497
|
+
proxy: str | None = None,
|
|
498
|
+
) -> Dict[str, Any]:
|
|
499
|
+
"""
|
|
500
|
+
Install a plugin from repository URL via /api/plugin/install.
|
|
501
|
+
"""
|
|
502
|
+
payload: Dict[str, Any] = {"url": url}
|
|
503
|
+
if proxy:
|
|
504
|
+
payload["proxy"] = proxy
|
|
505
|
+
response = await self._request("POST", "/api/plugin/install", json_body=payload)
|
|
506
|
+
return response.json()
|
|
507
|
+
|
|
508
|
+
async def install_plugin_from_file(
|
|
509
|
+
self,
|
|
510
|
+
file_path: str,
|
|
511
|
+
) -> Dict[str, Any]:
|
|
512
|
+
"""
|
|
513
|
+
Install a plugin from uploaded zip file via /api/plugin/install-upload.
|
|
514
|
+
"""
|
|
515
|
+
send_name = os.path.basename(file_path)
|
|
516
|
+
with open(file_path, "rb") as f:
|
|
517
|
+
files = {
|
|
518
|
+
"file": (send_name, f, "application/zip"),
|
|
519
|
+
}
|
|
520
|
+
response = await self._request(
|
|
521
|
+
"POST",
|
|
522
|
+
"/api/plugin/install-upload",
|
|
523
|
+
files=files,
|
|
524
|
+
)
|
|
525
|
+
return response.json()
|
|
526
|
+
|
|
461
527
|
# ---- Chat / platform session APIs --------------------------------
|
|
462
528
|
|
|
463
529
|
async def create_platform_session(
|
|
@@ -692,3 +758,52 @@ class AstrBotClient:
|
|
|
692
758
|
"""
|
|
693
759
|
response = await self._request("GET", "/api/stat/version")
|
|
694
760
|
return response.json()
|
|
761
|
+
|
|
762
|
+
# ---- MCP panel APIs ----------------------------------------------
|
|
763
|
+
|
|
764
|
+
async def get_mcp_servers(self) -> Dict[str, Any]:
|
|
765
|
+
"""
|
|
766
|
+
Get MCP server list from panel API /api/tools/mcp/servers.
|
|
767
|
+
"""
|
|
768
|
+
response = await self._request("GET", "/api/tools/mcp/servers")
|
|
769
|
+
return response.json()
|
|
770
|
+
|
|
771
|
+
async def add_mcp_server(self, payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
772
|
+
"""
|
|
773
|
+
Add MCP server via panel API /api/tools/mcp/add.
|
|
774
|
+
"""
|
|
775
|
+
response = await self._request("POST", "/api/tools/mcp/add", json_body=payload)
|
|
776
|
+
return response.json()
|
|
777
|
+
|
|
778
|
+
async def update_mcp_server(self, payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
779
|
+
"""
|
|
780
|
+
Update MCP server via panel API /api/tools/mcp/update.
|
|
781
|
+
"""
|
|
782
|
+
response = await self._request("POST", "/api/tools/mcp/update", json_body=payload)
|
|
783
|
+
return response.json()
|
|
784
|
+
|
|
785
|
+
async def delete_mcp_server(self, *, name: str) -> Dict[str, Any]:
|
|
786
|
+
"""
|
|
787
|
+
Delete MCP server via panel API /api/tools/mcp/delete.
|
|
788
|
+
"""
|
|
789
|
+
response = await self._request(
|
|
790
|
+
"POST",
|
|
791
|
+
"/api/tools/mcp/delete",
|
|
792
|
+
json_body={"name": name},
|
|
793
|
+
)
|
|
794
|
+
return response.json()
|
|
795
|
+
|
|
796
|
+
async def test_mcp_server_connection(
|
|
797
|
+
self,
|
|
798
|
+
*,
|
|
799
|
+
mcp_server_config: Dict[str, Any],
|
|
800
|
+
) -> Dict[str, Any]:
|
|
801
|
+
"""
|
|
802
|
+
Test MCP connection via panel API /api/tools/mcp/test.
|
|
803
|
+
"""
|
|
804
|
+
response = await self._request(
|
|
805
|
+
"POST",
|
|
806
|
+
"/api/tools/mcp/test",
|
|
807
|
+
json_body={"mcp_server_config": mcp_server_config},
|
|
808
|
+
)
|
|
809
|
+
return response.json()
|
|
@@ -15,7 +15,6 @@ class AstrBotSettings:
|
|
|
15
15
|
default_provider: str | None = None
|
|
16
16
|
default_model: str | None = None
|
|
17
17
|
file_root: str | None = None
|
|
18
|
-
direct_media_mode: str | None = None
|
|
19
18
|
disable_proxy: bool = True # 默认禁用代理,防止本地请求被代理拦截
|
|
20
19
|
|
|
21
20
|
|
|
@@ -41,10 +40,6 @@ def get_settings() -> AstrBotSettings:
|
|
|
41
40
|
- ASTRBOT_DEFAULT_PROVIDER: Default provider id to use for /api/chat/send.
|
|
42
41
|
- ASTRBOT_DEFAULT_MODEL: Default model id to use for /api/chat/send.
|
|
43
42
|
- ASTRBOTMCP_FILE_ROOT: Base directory for resolving relative local file_path.
|
|
44
|
-
- ASTRBOTMCP_DIRECT_MEDIA_MODE: How send_platform_message_direct handles local media:
|
|
45
|
-
- auto (default): try local path first, then fallback to upload+URL.
|
|
46
|
-
- local: always send local absolute paths to AstrBot platform adapters.
|
|
47
|
-
- upload: upload to AstrBot first and send an http(s) URL.
|
|
48
43
|
"""
|
|
49
44
|
base_url = _get_env("ASTRBOT_BASE_URL")
|
|
50
45
|
if not base_url:
|
|
@@ -69,9 +64,6 @@ def get_settings() -> AstrBotSettings:
|
|
|
69
64
|
default_provider = _get_env("ASTRBOT_DEFAULT_PROVIDER")
|
|
70
65
|
default_model = _get_env("ASTRBOT_DEFAULT_MODEL")
|
|
71
66
|
file_root = _get_env("ASTRBOTMCP_FILE_ROOT") or _get_env("ASTRBOT_MCP_FILE_ROOT")
|
|
72
|
-
direct_media_mode = _get_env("ASTRBOTMCP_DIRECT_MEDIA_MODE") or _get_env(
|
|
73
|
-
"ASTRBOT_MCP_DIRECT_MEDIA_MODE"
|
|
74
|
-
)
|
|
75
67
|
|
|
76
68
|
# 默认禁用代理,除非明确设置为false
|
|
77
69
|
disable_proxy_str = _get_env("ASTRBOTMCP_DISABLE_PROXY")
|
|
@@ -87,6 +79,5 @@ def get_settings() -> AstrBotSettings:
|
|
|
87
79
|
default_provider=default_provider,
|
|
88
80
|
default_model=default_model,
|
|
89
81
|
file_root=file_root,
|
|
90
|
-
direct_media_mode=direct_media_mode,
|
|
91
82
|
disable_proxy=disable_proxy,
|
|
92
83
|
)
|
|
@@ -15,6 +15,7 @@ server = FastMCP(
|
|
|
15
15
|
"MCP server for interacting with an existing AstrBot instance. "
|
|
16
16
|
"Provides tools to read logs, list configured message platforms, "
|
|
17
17
|
"send message chains (including files) via the web chat API, "
|
|
18
|
+
"install/configure plugins, manage MCP panel config, "
|
|
18
19
|
"restart AstrBot core, read platform session message history, "
|
|
19
20
|
"and browse the AstrBot plugin market."
|
|
20
21
|
),
|
|
@@ -23,7 +24,6 @@ server = FastMCP(
|
|
|
23
24
|
# Register tools with FastMCP
|
|
24
25
|
server.tool(astrbot_tools.get_astrbot_logs, name="get_astrbot_logs")
|
|
25
26
|
server.tool(astrbot_tools.get_message_platforms, name="get_message_platforms")
|
|
26
|
-
server.tool(astrbot_tools.send_platform_message_direct, name="send_platform_message_direct")
|
|
27
27
|
server.tool(astrbot_tools.send_platform_message, name="send_platform_message")
|
|
28
28
|
server.tool(astrbot_tools.restart_astrbot, name="restart_astrbot")
|
|
29
29
|
server.tool(
|
|
@@ -31,6 +31,12 @@ server.tool(
|
|
|
31
31
|
name="get_platform_session_messages",
|
|
32
32
|
)
|
|
33
33
|
server.tool(astrbot_tools.browse_plugin_market, name="browse_plugin_market")
|
|
34
|
+
server.tool(astrbot_tools.install_astrbot_plugin, name="install_astrbot_plugin")
|
|
35
|
+
server.tool(
|
|
36
|
+
astrbot_tools.configure_astrbot_plugin_json,
|
|
37
|
+
name="configure_astrbot_plugin_json",
|
|
38
|
+
)
|
|
39
|
+
server.tool(astrbot_tools.manage_mcp_config_panel, name="manage_mcp_config_panel")
|
|
34
40
|
server.tool(astrbot_tools.list_astrbot_config_files, name="list_astrbot_config_files")
|
|
35
41
|
server.tool(astrbot_tools.inspect_astrbot_config, name="inspect_astrbot_config")
|
|
36
42
|
server.tool(astrbot_tools.apply_astrbot_config_ops, name="apply_astrbot_config_ops")
|
|
@@ -49,10 +55,12 @@ def astrbot_info():
|
|
|
49
55
|
"get_astrbot_logs",
|
|
50
56
|
"get_message_platforms",
|
|
51
57
|
"send_platform_message",
|
|
52
|
-
"send_platform_message_direct",
|
|
53
58
|
"restart_astrbot",
|
|
54
59
|
"get_platform_session_messages",
|
|
55
60
|
"browse_plugin_market",
|
|
61
|
+
"install_astrbot_plugin",
|
|
62
|
+
"configure_astrbot_plugin_json",
|
|
63
|
+
"manage_mcp_config_panel",
|
|
56
64
|
"list_astrbot_config_files",
|
|
57
65
|
"inspect_astrbot_config",
|
|
58
66
|
"apply_astrbot_config_ops",
|
|
@@ -20,11 +20,12 @@ from .control_tools import restart_astrbot
|
|
|
20
20
|
from .log_tools import get_astrbot_logs
|
|
21
21
|
from .message import (
|
|
22
22
|
send_platform_message,
|
|
23
|
-
send_platform_message_direct,
|
|
24
23
|
)
|
|
25
24
|
from .platform_tools import get_message_platforms
|
|
26
25
|
from .session_tools import get_platform_session_messages
|
|
27
26
|
from .plugin_market_tools import browse_plugin_market
|
|
27
|
+
from .plugin_admin_tools import install_astrbot_plugin, configure_astrbot_plugin_json
|
|
28
|
+
from .mcp_panel_tools import manage_mcp_config_panel
|
|
28
29
|
from .config_tools import (
|
|
29
30
|
list_astrbot_config_files,
|
|
30
31
|
inspect_astrbot_config,
|
|
@@ -40,7 +41,6 @@ from .helpers import (
|
|
|
40
41
|
_as_file_uri,
|
|
41
42
|
_attachment_download_url,
|
|
42
43
|
_astrbot_connect_hint,
|
|
43
|
-
_direct_media_mode,
|
|
44
44
|
_httpx_error_detail,
|
|
45
45
|
_resolve_local_file_path,
|
|
46
46
|
)
|
|
@@ -49,11 +49,13 @@ __all__ = [
|
|
|
49
49
|
# 工具函数
|
|
50
50
|
"get_astrbot_logs",
|
|
51
51
|
"get_message_platforms",
|
|
52
|
-
"send_platform_message_direct",
|
|
53
52
|
"send_platform_message",
|
|
54
53
|
"restart_astrbot",
|
|
55
54
|
"get_platform_session_messages",
|
|
56
55
|
"browse_plugin_market",
|
|
56
|
+
"install_astrbot_plugin",
|
|
57
|
+
"configure_astrbot_plugin_json",
|
|
58
|
+
"manage_mcp_config_panel",
|
|
57
59
|
"list_astrbot_config_files",
|
|
58
60
|
"inspect_astrbot_config",
|
|
59
61
|
"apply_astrbot_config_ops",
|
|
@@ -67,6 +69,5 @@ __all__ = [
|
|
|
67
69
|
"_attachment_download_url",
|
|
68
70
|
"_astrbot_connect_hint",
|
|
69
71
|
"_httpx_error_detail",
|
|
70
|
-
"_direct_media_mode",
|
|
71
72
|
"_as_file_uri",
|
|
72
73
|
]
|