astrbotmcp 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl

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.
@@ -281,6 +281,48 @@ class AstrBotClient:
281
281
  response = await self._request("GET", "/api/config/platform/list")
282
282
  return response.json()
283
283
 
284
+ async def get_abconf_list(self) -> Dict[str, Any]:
285
+ """Call /api/config/abconfs and return the parsed JSON."""
286
+ response = await self._request("GET", "/api/config/abconfs")
287
+ return response.json()
288
+
289
+ async def get_abconf(
290
+ self,
291
+ *,
292
+ conf_id: str | None = None,
293
+ system_config: bool = False,
294
+ ) -> Dict[str, Any]:
295
+ """
296
+ Call /api/config/abconf and return the parsed JSON.
297
+
298
+ Args:
299
+ conf_id: Config file id to fetch.
300
+ system_config: If True, fetch system default config (AstrBot side expects system_config=1).
301
+ """
302
+ params: Dict[str, Any] = {}
303
+ if system_config:
304
+ params["system_config"] = "1"
305
+ if conf_id is not None:
306
+ params["id"] = conf_id
307
+ response = await self._request("GET", "/api/config/abconf", params=params or None)
308
+ return response.json()
309
+
310
+ async def update_astrbot_config(
311
+ self,
312
+ *,
313
+ conf_id: str,
314
+ config: Dict[str, Any],
315
+ ) -> Dict[str, Any]:
316
+ """
317
+ Update AstrBot core config via /api/config/astrbot/update (auto save + hot reload on AstrBot side).
318
+ """
319
+ payload: Dict[str, Any] = {
320
+ "conf_id": conf_id,
321
+ "config": config,
322
+ }
323
+ response = await self._request("POST", "/api/config/astrbot/update", json_body=payload)
324
+ return response.json()
325
+
284
326
  # ---- Plugin / market APIs ----------------------------------------
285
327
 
286
328
  async def get_plugin_market_list(
astrbot_mcp/server.py CHANGED
@@ -26,6 +26,10 @@ server.tool(
26
26
  name="get_platform_session_messages",
27
27
  )
28
28
  server.tool(astrbot_tools.browse_plugin_market, name="browse_plugin_market")
29
+ server.tool(astrbot_tools.list_astrbot_config_files, name="list_astrbot_config_files")
30
+ server.tool(astrbot_tools.inspect_astrbot_config, name="inspect_astrbot_config")
31
+ server.tool(astrbot_tools.apply_astrbot_config_ops, name="apply_astrbot_config_ops")
32
+ server.tool(astrbot_tools.search_astrbot_config_paths, name="search_astrbot_config_paths")
29
33
 
30
34
 
31
35
  @server.resource("astrbot://info")
@@ -44,6 +48,10 @@ def astrbot_info():
44
48
  "restart_astrbot",
45
49
  "get_platform_session_messages",
46
50
  "browse_plugin_market",
51
+ "list_astrbot_config_files",
52
+ "inspect_astrbot_config",
53
+ "apply_astrbot_config_ops",
54
+ "search_astrbot_config_paths",
47
55
  ],
48
56
  }
49
57
 
astrbot_mcp/tools.py CHANGED
@@ -16,13 +16,17 @@ Example:
16
16
  """
17
17
 
18
18
  # 导入所有工具函数,保持向后兼容
19
- from .tools import (
19
+ from . import (
20
20
  get_astrbot_logs,
21
21
  get_message_platforms,
22
22
  send_platform_message_direct,
23
23
  send_platform_message,
24
24
  restart_astrbot,
25
25
  get_platform_session_messages,
26
+ list_astrbot_config_files,
27
+ inspect_astrbot_config,
28
+ apply_astrbot_config_ops,
29
+ search_astrbot_config_paths,
26
30
  MessagePart,
27
31
  )
28
32
 
@@ -33,5 +37,9 @@ __all__ = [
33
37
  "send_platform_message",
34
38
  "restart_astrbot",
35
39
  "get_platform_session_messages",
40
+ "list_astrbot_config_files",
41
+ "inspect_astrbot_config",
42
+ "apply_astrbot_config_ops",
43
+ "search_astrbot_config_paths",
36
44
  "MessagePart",
37
45
  ]
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: astrbotmcp
3
+ Version: 0.2.3
4
+ Summary: Add your description here
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE.txt
8
+ Requires-Dist: fastmcp>=2.13.3
9
+ Requires-Dist: httpx>=0.28.1
10
+ Dynamic: license-file
11
+
12
+ ## AstrBot MCP
13
+
14
+ [![MCP Badge](https://lobehub.com/badge/mcp/xunxiing-astrbotmcp)](https://lobehub.com/mcp/xunxiing-astrbotmcp)
15
+
16
+ > **AstrBot 无法通过 MCP 控制自身。本项目填补了这一空白。**
17
+
18
+ ### 警告与免责声明
19
+
20
+ ⚠️ **本项目提供的是运维级控制能力,使用时请注意:**
21
+
22
+ 1. **重启风险** - `restart_astrbot` 会中断所有正在进行的对话
23
+ 2. **权限管理** - 确保 MCP 客户端的访问权限受控
24
+ 3. **生产环境** - 建议仅在开发/测试环境使用控制面功能
25
+ 4. **数据安全** - 日志可能包含敏感信息,注意脱敏处理
26
+
27
+ **本项目与 AstrBot 官方无直接关联,由社区独立维护。**
28
+
29
+ ---
30
+ ### 这个项目到底在干什么
31
+
32
+ #### AstrBot 自身的 MCP 控制面
33
+
34
+ 通过 MCP tool 实现:
35
+
36
+ - **重启 AstrBot Core** - 进程级控制,直接调用 `/api/stat/restart-core`
37
+ - **运行状态监听** - 实时日志流、平台状态监控
38
+ - **配置热加载** - 动态读取/修改配置
39
+ - **发送信息** -自动化测试插件
40
+ - **浏览插件市场**
41
+
42
+ #### 为astrbot开发者提供AI AGENT时代调试插件的自动化工具
43
+
44
+ ---
45
+
46
+ ### 快速开始
47
+
48
+ #### 安装
49
+
50
+ ```bash
51
+ # 通过 PyPI 安装(推荐)
52
+ pip install astrbotmcp
53
+
54
+ # 或通过 uv
55
+ uv add astrbotmcp
56
+ ```
57
+
58
+ #### MCP 客户端配置
59
+
60
+ 在 Cursor、Cline、Claude Desktop 等支持 MCP 的客户端中配置:
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "astrbot-mcp": {
66
+ "command": "uvx",
67
+ "args": [
68
+ "--from",
69
+ "astrbotmcp",
70
+ "astrbot-mcp"
71
+ ],
72
+ "env": {
73
+ "ASTRBOT_BASE_URL": "http://127.0.0.1:6185",
74
+ "ASTRBOT_TIMEOUT": "30",
75
+ "ASTRBOT_USERNAME": "your_username",
76
+ "ASTRBOT_PASSWORD": "your_password"
77
+ }
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ #### 环境变量说明
84
+
85
+ | 变量 | 说明 | 默认值 |
86
+ |------|------|--------|
87
+ | `ASTRBOT_BASE_URL` | AstrBot Dashboard 地址 | `http://127.0.0.1:6185` |
88
+ | `ASTRBOT_TIMEOUT` | HTTP 请求超时时间 | `30` |
89
+ | `ASTRBOT_USERNAME` | Dashboard 用户名 | - |
90
+ | `ASTRBOT_PASSWORD` | Dashboard 密码 | - |
91
+ | `ASTRBOT_LOG_LEVEL` | 日志级别 | `INFO` |
92
+
93
+ ---
94
+
95
+ ### 可用 MCP Tools
96
+
97
+ #### 控制面工具
98
+
99
+ - `restart_astrbot` - 重启 AstrBot Core
100
+ - `get_astrbot_logs` - 获取实时/历史日志
101
+ - `get_message_platforms` - 列出已配置的消息平台
102
+
103
+ #### 配置工具
104
+
105
+ - `list_astrbot_config_files` - 列出所有 AstrBot 配置文件(`/api/config/abconfs`)
106
+ - `inspect_astrbot_config` - 分层查看 JSON 配置节点(key / array length / value)
107
+ - `apply_astrbot_config_ops` - 批量 `set` / `add_key` / `append`,并自动保存 + 热重载(`/api/config/astrbot/update`)
108
+ - `search_astrbot_config_paths` - 按 key(可选再按 value)搜索配置,返回匹配项的路径(不返回大段内容)
109
+
110
+ #### 消息工具
111
+
112
+ - `send_platform_message` - 通过 Web Chat API 发送消息链
113
+ - `send_platform_message_direct` - 直接发送到平台(绕过 LLM)
114
+ - `get_platform_session_messages` - 读取会话消息历史
115
+
116
+ #### 插件市场
117
+
118
+ - `browse_plugin_market` - 浏览插件市场(搜索/排序)
119
+
120
+ ---
121
+
122
+ ### 使用示例
123
+
124
+ #### 在 Agent 中重启 AstrBot
125
+
126
+ ```python
127
+ # Agent 可以直接调用
128
+ restart_astrbot()
129
+ ```
130
+
131
+ #### 监控 AstrBot 日志
132
+
133
+ ```python
134
+ # 实时获取最新日志
135
+ logs = get_astrbot_logs(wait_seconds=10)
136
+ ```
137
+
138
+ #### 发送消息到指定平台
139
+
140
+ ```python
141
+ # 发送带图片的消息链
142
+ send_platform_message(
143
+ platform_id="webchat",
144
+ message="Hello from MCP",
145
+ images=["/path/to/image.png"]
146
+ )
147
+ ```
148
+
149
+ ---
150
+
151
+ ### 技术架构
152
+
153
+ ```
154
+ ┌─────────────────┐ HTTP API ┌──────────────────┐
155
+ │ MCP Client │───────────────────>│ astrbot-mcp │
156
+ │ (Cursor/Cline) │ (MCP Protocol) │ (FastMCP Server)│
157
+ └─────────────────┘ └────────┬─────────┘
158
+
159
+ │ HTTP
160
+
161
+ ┌─────────────────┐ ┌──────────────────┐
162
+ │ AstrBot Core │<───────────────────│ AstrBot │
163
+ │ + Plugins │ (Dashboard API) │ Dashboard │
164
+ └─────────────────┘ └──────────────────┘
165
+ ```
166
+
167
+ ---
168
+
169
+
170
+ ### 开发与贡献
171
+
172
+ ```bash
173
+ # 克隆项目
174
+ git clone https://github.com/yourusername/astrbot-mcp.git
175
+ cd astrbot-mcp
176
+
177
+ # 安装依赖
178
+ uv sync
179
+
180
+ # 本地运行
181
+ uv run --project . astrbot-mcp
182
+ ```
183
+
184
+ ---
185
+
186
+ ### 许可证
187
+
188
+ MIT License - 详见 [LICENSE](LICENSE.txt) 文件
@@ -0,0 +1,11 @@
1
+ astrbot_mcp/__init__.py,sha256=nDTFGuA6IlvCywUVliWHmmFBkQQsnLVgnZDFYfdALbo,370
2
+ astrbot_mcp/astrbot_client.py,sha256=Kvcsk4gQytjZDoxLAXE7S6cmZjHGHzeNopzYnSyz9H0,19734
3
+ astrbot_mcp/config.py,sha256=C5F0pHVGZkmxCGMPU9ns0G4whiy-ZCqfnQwUFuNmsLY,2820
4
+ astrbot_mcp/server.py,sha256=SJWvmr1Nr7A_n5K8FlPUShNOLfNJd95kZwZK9knrbXk,2376
5
+ astrbot_mcp/tools.py,sha256=rBL89W_4B7djcuGwBekLp-6pqi8dbmic8P3LJUIForI,1261
6
+ astrbotmcp-0.2.3.dist-info/licenses/LICENSE.txt,sha256=5AYBumh99nqD7WWRY18ySSOIUKrj3bkAhVAiY-k8ZRo,1061
7
+ astrbotmcp-0.2.3.dist-info/METADATA,sha256=QaT7bN6KioAxmNd8p2n-ZTCOl3htCA79x-SjDUBh9co,5120
8
+ astrbotmcp-0.2.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ astrbotmcp-0.2.3.dist-info/entry_points.txt,sha256=XmfseRwldB3CJKlViESKuZNmw37qV2B57to8EQqvd5Q,56
10
+ astrbotmcp-0.2.3.dist-info/top_level.txt,sha256=yi4CO_u3RImIkeQ562K9EbEc0nnKVgHQupSZ_X1GEO0,12
11
+ astrbotmcp-0.2.3.dist-info/RECORD,,
@@ -1,90 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: astrbotmcp
3
- Version: 0.2.1
4
- Summary: Add your description here
5
- Requires-Python: >=3.10
6
- Description-Content-Type: text/markdown
7
- License-File: LICENSE.txt
8
- Requires-Dist: fastmcp>=2.13.3
9
- Requires-Dist: httpx>=0.28.1
10
- Dynamic: license-file
11
-
12
- ## AstrBot MCP Server
13
-
14
- [![MCP Badge](https://lobehub.com/badge/mcp/xunxiing-astrbotmcp)](https://lobehub.com/mcp/xunxiing-astrbotmcp)
15
-
16
- 本项目是一个基于 FastMCP 的 AstrBot MCP 服务器,通过 HTTP 与已有的 AstrBot 实例交互。
17
-
18
- 当前包含的 MCP 工具(tools):
19
- - `get_astrbot_logs`:查看日志(历史/实时)
20
- - `get_message_platforms`:列出已配置平台
21
- - `send_platform_message` / `send_platform_message_direct`:发送消息链
22
- - `get_platform_session_messages`:读取会话消息历史
23
- - `restart_astrbot`:重启 AstrBot Core
24
- - `browse_plugin_market`:浏览插件市场(搜索/按更新时间排序)
25
-
26
- ### 本地运行
27
-
28
- 在项目根目录执行(需要安装 `uv`):
29
-
30
- ```bash
31
- uv sync
32
- uv run --project . astrbot-mcp
33
- ```
34
-
35
- 如果看到 FastMCP 的 banner,说明服务启动成功。
36
-
37
- ### MCP 配置(使用 uv + console script)
38
-
39
- 在支持 MCP 的客户端中,推荐使用如下配置来启动本服务(示例为 JSON):
40
-
41
- ```json
42
- {
43
- "mcpServers": {
44
- "astrbot-mcp": {
45
- "command": "uvx",
46
- "args": [
47
- "--from",
48
- "astrbotmcp",
49
- "astrbot-mcp.exe"
50
- ],
51
- "env": {
52
- "ASTRBOT_BASE_URL": "http://127.0.0.1:6185",
53
- "ASTRBOT_TIMEOUT": "30",
54
- "ASTRBOT_USERNAME": "your_username",
55
- "ASTRBOT_PASSWORD": "your_password"
56
- }
57
- }
58
- }
59
- }
60
- ```
61
-
62
- ```json{
63
- "mcpServers": {
64
- "astrbot-mcp": {
65
- "command": "uv",
66
- "args": [
67
- "run",
68
- "--project",
69
- "D:/程序/astrbotmcp",
70
- "python",
71
- "-m",
72
- "astrbot_mcp.server"
73
- ],
74
- "env": {
75
- "ASTRBOT_BASE_URL": "http://127.0.0.1:6185",
76
- "ASTRBOT_TIMEOUT": "30",
77
- "ASTRBOT_USERNAME": "user",
78
- "ASTRBOT_PASSWORD": "password"
79
- }
80
- }
81
- }
82
- }
83
- ```
84
-
85
- 注意:
86
-
87
- - 使用 `uv` 而不是系统 `python`,避免跑到全局 Python 3.13 环境。
88
- - 使用 `--project /path/to/astrbotmcp` 指定项目路径。
89
- - 使用 `astrbot-mcp`(console script),它会调用 `astrbot_mcp.server:main`。
90
- - 请您务必配置pypl代理:setx UV_INDEX_URL https://pypi.tuna.tsinghua.edu.cn/simple
@@ -1,11 +0,0 @@
1
- astrbot_mcp/__init__.py,sha256=nDTFGuA6IlvCywUVliWHmmFBkQQsnLVgnZDFYfdALbo,370
2
- astrbot_mcp/astrbot_client.py,sha256=XvvLDhPZF-YakqhJqpbB-NP6ybFd3uwp3Qxnvums03I,18310
3
- astrbot_mcp/config.py,sha256=C5F0pHVGZkmxCGMPU9ns0G4whiy-ZCqfnQwUFuNmsLY,2820
4
- astrbot_mcp/server.py,sha256=CRB29LfrKGDHRk1Al-DI6l5oV3QV-2CTqnmTyrEDQk4,1870
5
- astrbot_mcp/tools.py,sha256=WpVNHmu6NzbLXgDmgZCBiNo9WY4BqLw4NqZeU_eNCSs,1014
6
- astrbotmcp-0.2.1.dist-info/licenses/LICENSE.txt,sha256=5AYBumh99nqD7WWRY18ySSOIUKrj3bkAhVAiY-k8ZRo,1061
7
- astrbotmcp-0.2.1.dist-info/METADATA,sha256=2kVmBYByN-rrDs4k5gKD7FMxCbEtRrY347aNZmhNQ1k,2265
8
- astrbotmcp-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- astrbotmcp-0.2.1.dist-info/entry_points.txt,sha256=XmfseRwldB3CJKlViESKuZNmw37qV2B57to8EQqvd5Q,56
10
- astrbotmcp-0.2.1.dist-info/top_level.txt,sha256=yi4CO_u3RImIkeQ562K9EbEc0nnKVgHQupSZ_X1GEO0,12
11
- astrbotmcp-0.2.1.dist-info/RECORD,,