noticeme-srv 0.1.0__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.
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ *.db-journal
7
+ *.db-wal
8
+ .venv/
@@ -0,0 +1,274 @@
1
+ Metadata-Version: 2.5
2
+ Name: noticeme-srv
3
+ Version: 0.1.0
4
+ Summary: Notification system with sources, channels, real-time push, and MCP support
5
+ Project-URL: Homepage, https://github.com/CandyXT/NoticeMe
6
+ Project-URL: Repository, https://github.com/CandyXT/NoticeMe
7
+ Project-URL: Issues, https://github.com/CandyXT/NoticeMe/issues
8
+ Author: CandyXT
9
+ License-Expression: MIT
10
+ Keywords: mcp,mqtt,notification,realtime,webhook
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Framework :: FastAPI
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: System :: Monitoring
15
+ Requires-Python: >=3.11
16
+ Requires-Dist: aiomqtt>=2.0
17
+ Requires-Dist: click>=8.0
18
+ Requires-Dist: fastapi>=0.115
19
+ Requires-Dist: httpx>=0.27
20
+ Requires-Dist: mcp>=1.0
21
+ Requires-Dist: pydantic>=2.0
22
+ Requires-Dist: uvicorn>=0.30
23
+ Requires-Dist: websockets>=14.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest; extra == 'dev'
26
+ Requires-Dist: ruff; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # NoticeMe
30
+
31
+ 轻量级通知管理系统,支持多通知源、多通知渠道、实时通知、MCP 协议接入。
32
+
33
+ ## 特性
34
+
35
+ - **通知源**: Webhook (HTTP API) 或 MQTT 订阅
36
+ - **通知渠道**: MQTT 发布 或 API 请求转发
37
+ - **实时通知**: 持久化显示,ID 标识,WebSocket 实时推送,可编辑更新
38
+ - **普通通知**: 一次性推送,fire-and-forget
39
+ - **源→渠道映射**: 每个通知源可配置多个输出渠道
40
+ - **历史记录**: 完整记录创建/更新/推送/清除操作
41
+ - **MCP 服务器**: stdio (编辑器/Agent 集成) + streamable-http (共用 API 端口)
42
+ - **CLI 工具**: `nme` 命令行管理源、渠道、通知
43
+ - **Web UI**: 深色主题 SPA,手机自适应
44
+ - **轻量存储**: SQLite,零外部依赖
45
+
46
+ ## 安装
47
+
48
+ ```bash
49
+ pip install noticeme-srv
50
+ ```
51
+
52
+ 或从源码安装:
53
+
54
+ ```bash
55
+ git clone https://github.com/CandyXT/NoticeMe.git
56
+ cd NoticeMe
57
+ pip install -e .
58
+ ```
59
+
60
+ ## 快速开始
61
+
62
+ ```bash
63
+ # 启动服务 (API + WebUI + WebSocket + MCP streamable-http)
64
+ nme serve
65
+
66
+ # 或指定参数
67
+ nme serve --host 0.0.0.0 --port 8200 --reload
68
+ ```
69
+
70
+ 访问: `http://localhost:8200`
71
+
72
+ 数据存储在 `~/.noticeme/` (SQLite 数据库)
73
+
74
+ ## CLI 命令
75
+
76
+ ```bash
77
+ nme --version # 查看版本
78
+
79
+ # 服务器
80
+ nme serve # 启动 HTTP 服务器
81
+ nme serve --port 8200 # 指定端口
82
+ nme serve --reload # 开发模式 (自动重载)
83
+
84
+ # MCP 服务器
85
+ nme mcp # 在 stdio 上运行 MCP 服务器
86
+
87
+ # 初始化
88
+ nme init # 初始化数据库
89
+
90
+ # 通知源
91
+ nme source list # 列出所有通知源
92
+ nme source add -n "监控" -t webhook
93
+ nme source add -n "IoT" -t mqtt --broker 192.168.1.100 --topic "devices/#"
94
+ nme source remove <id>
95
+ nme source map <source_id> <channel_id1> <channel_id2>
96
+
97
+ # 通知渠道
98
+ nme channel list # 列出所有渠道
99
+ nme channel add -n "飞书" -t api --url "https://open.feishu.cn/..."
100
+ nme channel add -n "MQTT转发" -t mqtt --broker localhost --topic "out"
101
+ nme channel remove <id>
102
+
103
+ # 推送通知
104
+ nme notify --title "部署完成" --content "v2.1.0 已上线" --level success
105
+ nme notify --id cpu-alert --title "CPU" --content "使用率 92%" --level warning
106
+
107
+ # 实时通知
108
+ nme realtime list # 列出活跃实时通知
109
+ nme realtime clear <id> # 清除单个
110
+ nme realtime clear # 清除全部
111
+
112
+ # 历史记录
113
+ nme history # 查看最近记录
114
+ nme history --limit 50
115
+ nme history --notification <id>
116
+ ```
117
+
118
+ ## MCP 服务器
119
+
120
+ ### stdio 模式 (编辑器/Agent 集成)
121
+
122
+ ```bash
123
+ nme mcp
124
+ ```
125
+
126
+ 在 Claude Desktop、Cursor 等 MCP 客户端中配置:
127
+
128
+ ```json
129
+ {
130
+ "mcpServers": {
131
+ "noticeme": {
132
+ "command": "nme",
133
+ "args": ["mcp"]
134
+ }
135
+ }
136
+ }
137
+ ```
138
+
139
+ ### streamable-http 模式
140
+
141
+ 与 API/WebUI 共用端口,端点: `http://localhost:8200/mcp`
142
+
143
+ ### MCP 工具列表
144
+
145
+ | 工具 | 说明 |
146
+ |------|------|
147
+ | `list_sources` | 列出通知源 |
148
+ | `create_source` | 创建通知源 |
149
+ | `delete_source` | 删除通知源 |
150
+ | `list_channels` | 列出通知渠道 |
151
+ | `create_channel` | 创建渠道 |
152
+ | `delete_channel` | 删除渠道 |
153
+ | `get_source_channels` | 获取源的渠道映射 |
154
+ | `set_source_channels` | 设置源的渠道映射 |
155
+ | `list_realtime_notifications` | 列出实时通知 |
156
+ | `push_realtime_notification` | 推送实时通知 |
157
+ | `update_realtime_notification` | 更新实时通知 |
158
+ | `clear_realtime_notification` | 清除实时通知 |
159
+ | `push_notification` | 推送普通通知 |
160
+ | `get_history` | 查询历史记录 |
161
+
162
+ ## API
163
+
164
+ ### 通知源
165
+
166
+ ```
167
+ GET /api/sources # 列表
168
+ POST /api/sources # 创建
169
+ GET /api/sources/{id} # 详情
170
+ PUT /api/sources/{id} # 编辑
171
+ DELETE /api/sources/{id} # 删除
172
+ GET /api/sources/{id}/channels # 获取映射
173
+ PUT /api/sources/{id}/channels # 设置映射
174
+ ```
175
+
176
+ ### 通知渠道
177
+
178
+ ```
179
+ GET /api/channels # 列表
180
+ POST /api/channels # 创建
181
+ GET /api/channels/{id} # 详情
182
+ PUT /api/channels/{id} # 编辑
183
+ DELETE /api/channels/{id} # 删除
184
+ ```
185
+
186
+ ### 通知推送
187
+
188
+ ```bash
189
+ # 实时通知 (带 ID,持久化)
190
+ curl -X POST http://localhost:8200/api/notifications/realtime \
191
+ -H "Content-Type: application/json" \
192
+ -d '{"id": "cpu", "title": "CPU 使用率", "content": "92%", "level": "warning"}'
193
+
194
+ # 更新实时通知
195
+ curl -X PUT http://localhost:8200/api/notifications/realtime/cpu \
196
+ -H "Content-Type: application/json" \
197
+ -d '{"content": "45%", "level": "success"}'
198
+
199
+ # 普通通知
200
+ curl -X POST http://localhost:8200/api/notifications/push \
201
+ -H "Content-Type: application/json" \
202
+ -d '{"title": "部署完成", "content": "v2.1.0"}'
203
+
204
+ # Webhook 入口
205
+ curl -X POST http://localhost:8200/hook/<source_id> \
206
+ -H "Content-Type: application/json" \
207
+ -d '{"id": "disk", "title": "磁盘不足", "level": "error"}'
208
+ ```
209
+
210
+ ### 实时通知管理
211
+
212
+ ```
213
+ GET /api/notifications/realtime # 列表
214
+ GET /api/notifications/realtime/{id} # 详情
215
+ PUT /api/notifications/realtime/{id} # 更新
216
+ DELETE /api/notifications/realtime/{id} # 删除单个
217
+ DELETE /api/notifications/realtime # 清空全部
218
+ ```
219
+
220
+ ### 历史记录
221
+
222
+ ```
223
+ GET /api/history # 最近记录
224
+ GET /api/history/{notification_id} # 指定通知的历史
225
+ ```
226
+
227
+ ### WebSocket
228
+
229
+ ```
230
+ WS /ws # 实时通知推送
231
+ ```
232
+
233
+ ## 目录结构
234
+
235
+ ```
236
+ NoticeMe/
237
+ ├── __init__.py # 包初始化 (版本号)
238
+ ├── app.py # FastAPI 应用工厂 + 路由注册
239
+ ├── main.py # 开发入口 (python -m NoticeMe.main)
240
+ ├── cli.py # Click CLI (nme 命令)
241
+ ├── mcp_server.py # MCP 服务器 (stdio + streamable-http)
242
+ ├── core/
243
+ │ ├── models.py # Pydantic 数据模型
244
+ │ ├── database.py # SQLite 数据层
245
+ │ ├── sources.py # 通知源管理 (Webhook/MQTT)
246
+ │ ├── channels.py # 通知渠道管理 (MQTT/API)
247
+ │ └── manager.py # 核心调度管理器
248
+ ├── static/
249
+ │ └── index.html # Web UI (Alpine.js + Tailwind)
250
+ ├── ~/.noticeme/ # 运行时数据 (数据库, 配置)
251
+ ├── .github/workflows/
252
+ │ └── release.yml # CI/CD (tag → GitHub Release + PyPI)
253
+ ├── pyproject.toml # 包配置
254
+ ├── requirements.txt # 依赖清单
255
+ └── README.md
256
+ ```
257
+
258
+ ## 技术栈
259
+
260
+ | 组件 | 选型 |
261
+ |------|------|
262
+ | 后端 | FastAPI + uvicorn |
263
+ | 实时通信 | WebSocket + aiomqtt |
264
+ | HTTP 客户端 | httpx |
265
+ | MCP 协议 | mcp SDK |
266
+ | 前端 | Alpine.js + Tailwind CSS CDN |
267
+ | 存储 | SQLite |
268
+ | CLI | Click |
269
+ | 打包 | hatchling |
270
+ | CI/CD | GitHub Actions |
271
+
272
+ ## 许可证
273
+
274
+ MIT License
@@ -0,0 +1,246 @@
1
+ # NoticeMe
2
+
3
+ 轻量级通知管理系统,支持多通知源、多通知渠道、实时通知、MCP 协议接入。
4
+
5
+ ## 特性
6
+
7
+ - **通知源**: Webhook (HTTP API) 或 MQTT 订阅
8
+ - **通知渠道**: MQTT 发布 或 API 请求转发
9
+ - **实时通知**: 持久化显示,ID 标识,WebSocket 实时推送,可编辑更新
10
+ - **普通通知**: 一次性推送,fire-and-forget
11
+ - **源→渠道映射**: 每个通知源可配置多个输出渠道
12
+ - **历史记录**: 完整记录创建/更新/推送/清除操作
13
+ - **MCP 服务器**: stdio (编辑器/Agent 集成) + streamable-http (共用 API 端口)
14
+ - **CLI 工具**: `nme` 命令行管理源、渠道、通知
15
+ - **Web UI**: 深色主题 SPA,手机自适应
16
+ - **轻量存储**: SQLite,零外部依赖
17
+
18
+ ## 安装
19
+
20
+ ```bash
21
+ pip install noticeme-srv
22
+ ```
23
+
24
+ 或从源码安装:
25
+
26
+ ```bash
27
+ git clone https://github.com/CandyXT/NoticeMe.git
28
+ cd NoticeMe
29
+ pip install -e .
30
+ ```
31
+
32
+ ## 快速开始
33
+
34
+ ```bash
35
+ # 启动服务 (API + WebUI + WebSocket + MCP streamable-http)
36
+ nme serve
37
+
38
+ # 或指定参数
39
+ nme serve --host 0.0.0.0 --port 8200 --reload
40
+ ```
41
+
42
+ 访问: `http://localhost:8200`
43
+
44
+ 数据存储在 `~/.noticeme/` (SQLite 数据库)
45
+
46
+ ## CLI 命令
47
+
48
+ ```bash
49
+ nme --version # 查看版本
50
+
51
+ # 服务器
52
+ nme serve # 启动 HTTP 服务器
53
+ nme serve --port 8200 # 指定端口
54
+ nme serve --reload # 开发模式 (自动重载)
55
+
56
+ # MCP 服务器
57
+ nme mcp # 在 stdio 上运行 MCP 服务器
58
+
59
+ # 初始化
60
+ nme init # 初始化数据库
61
+
62
+ # 通知源
63
+ nme source list # 列出所有通知源
64
+ nme source add -n "监控" -t webhook
65
+ nme source add -n "IoT" -t mqtt --broker 192.168.1.100 --topic "devices/#"
66
+ nme source remove <id>
67
+ nme source map <source_id> <channel_id1> <channel_id2>
68
+
69
+ # 通知渠道
70
+ nme channel list # 列出所有渠道
71
+ nme channel add -n "飞书" -t api --url "https://open.feishu.cn/..."
72
+ nme channel add -n "MQTT转发" -t mqtt --broker localhost --topic "out"
73
+ nme channel remove <id>
74
+
75
+ # 推送通知
76
+ nme notify --title "部署完成" --content "v2.1.0 已上线" --level success
77
+ nme notify --id cpu-alert --title "CPU" --content "使用率 92%" --level warning
78
+
79
+ # 实时通知
80
+ nme realtime list # 列出活跃实时通知
81
+ nme realtime clear <id> # 清除单个
82
+ nme realtime clear # 清除全部
83
+
84
+ # 历史记录
85
+ nme history # 查看最近记录
86
+ nme history --limit 50
87
+ nme history --notification <id>
88
+ ```
89
+
90
+ ## MCP 服务器
91
+
92
+ ### stdio 模式 (编辑器/Agent 集成)
93
+
94
+ ```bash
95
+ nme mcp
96
+ ```
97
+
98
+ 在 Claude Desktop、Cursor 等 MCP 客户端中配置:
99
+
100
+ ```json
101
+ {
102
+ "mcpServers": {
103
+ "noticeme": {
104
+ "command": "nme",
105
+ "args": ["mcp"]
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ ### streamable-http 模式
112
+
113
+ 与 API/WebUI 共用端口,端点: `http://localhost:8200/mcp`
114
+
115
+ ### MCP 工具列表
116
+
117
+ | 工具 | 说明 |
118
+ |------|------|
119
+ | `list_sources` | 列出通知源 |
120
+ | `create_source` | 创建通知源 |
121
+ | `delete_source` | 删除通知源 |
122
+ | `list_channels` | 列出通知渠道 |
123
+ | `create_channel` | 创建渠道 |
124
+ | `delete_channel` | 删除渠道 |
125
+ | `get_source_channels` | 获取源的渠道映射 |
126
+ | `set_source_channels` | 设置源的渠道映射 |
127
+ | `list_realtime_notifications` | 列出实时通知 |
128
+ | `push_realtime_notification` | 推送实时通知 |
129
+ | `update_realtime_notification` | 更新实时通知 |
130
+ | `clear_realtime_notification` | 清除实时通知 |
131
+ | `push_notification` | 推送普通通知 |
132
+ | `get_history` | 查询历史记录 |
133
+
134
+ ## API
135
+
136
+ ### 通知源
137
+
138
+ ```
139
+ GET /api/sources # 列表
140
+ POST /api/sources # 创建
141
+ GET /api/sources/{id} # 详情
142
+ PUT /api/sources/{id} # 编辑
143
+ DELETE /api/sources/{id} # 删除
144
+ GET /api/sources/{id}/channels # 获取映射
145
+ PUT /api/sources/{id}/channels # 设置映射
146
+ ```
147
+
148
+ ### 通知渠道
149
+
150
+ ```
151
+ GET /api/channels # 列表
152
+ POST /api/channels # 创建
153
+ GET /api/channels/{id} # 详情
154
+ PUT /api/channels/{id} # 编辑
155
+ DELETE /api/channels/{id} # 删除
156
+ ```
157
+
158
+ ### 通知推送
159
+
160
+ ```bash
161
+ # 实时通知 (带 ID,持久化)
162
+ curl -X POST http://localhost:8200/api/notifications/realtime \
163
+ -H "Content-Type: application/json" \
164
+ -d '{"id": "cpu", "title": "CPU 使用率", "content": "92%", "level": "warning"}'
165
+
166
+ # 更新实时通知
167
+ curl -X PUT http://localhost:8200/api/notifications/realtime/cpu \
168
+ -H "Content-Type: application/json" \
169
+ -d '{"content": "45%", "level": "success"}'
170
+
171
+ # 普通通知
172
+ curl -X POST http://localhost:8200/api/notifications/push \
173
+ -H "Content-Type: application/json" \
174
+ -d '{"title": "部署完成", "content": "v2.1.0"}'
175
+
176
+ # Webhook 入口
177
+ curl -X POST http://localhost:8200/hook/<source_id> \
178
+ -H "Content-Type: application/json" \
179
+ -d '{"id": "disk", "title": "磁盘不足", "level": "error"}'
180
+ ```
181
+
182
+ ### 实时通知管理
183
+
184
+ ```
185
+ GET /api/notifications/realtime # 列表
186
+ GET /api/notifications/realtime/{id} # 详情
187
+ PUT /api/notifications/realtime/{id} # 更新
188
+ DELETE /api/notifications/realtime/{id} # 删除单个
189
+ DELETE /api/notifications/realtime # 清空全部
190
+ ```
191
+
192
+ ### 历史记录
193
+
194
+ ```
195
+ GET /api/history # 最近记录
196
+ GET /api/history/{notification_id} # 指定通知的历史
197
+ ```
198
+
199
+ ### WebSocket
200
+
201
+ ```
202
+ WS /ws # 实时通知推送
203
+ ```
204
+
205
+ ## 目录结构
206
+
207
+ ```
208
+ NoticeMe/
209
+ ├── __init__.py # 包初始化 (版本号)
210
+ ├── app.py # FastAPI 应用工厂 + 路由注册
211
+ ├── main.py # 开发入口 (python -m NoticeMe.main)
212
+ ├── cli.py # Click CLI (nme 命令)
213
+ ├── mcp_server.py # MCP 服务器 (stdio + streamable-http)
214
+ ├── core/
215
+ │ ├── models.py # Pydantic 数据模型
216
+ │ ├── database.py # SQLite 数据层
217
+ │ ├── sources.py # 通知源管理 (Webhook/MQTT)
218
+ │ ├── channels.py # 通知渠道管理 (MQTT/API)
219
+ │ └── manager.py # 核心调度管理器
220
+ ├── static/
221
+ │ └── index.html # Web UI (Alpine.js + Tailwind)
222
+ ├── ~/.noticeme/ # 运行时数据 (数据库, 配置)
223
+ ├── .github/workflows/
224
+ │ └── release.yml # CI/CD (tag → GitHub Release + PyPI)
225
+ ├── pyproject.toml # 包配置
226
+ ├── requirements.txt # 依赖清单
227
+ └── README.md
228
+ ```
229
+
230
+ ## 技术栈
231
+
232
+ | 组件 | 选型 |
233
+ |------|------|
234
+ | 后端 | FastAPI + uvicorn |
235
+ | 实时通信 | WebSocket + aiomqtt |
236
+ | HTTP 客户端 | httpx |
237
+ | MCP 协议 | mcp SDK |
238
+ | 前端 | Alpine.js + Tailwind CSS CDN |
239
+ | 存储 | SQLite |
240
+ | CLI | Click |
241
+ | 打包 | hatchling |
242
+ | CI/CD | GitHub Actions |
243
+
244
+ ## 许可证
245
+
246
+ MIT License
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "noticeme-srv"
7
+ version = "0.1.0"
8
+ description = "Notification system with sources, channels, real-time push, and MCP support"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.11"
12
+ authors = [{ name = "CandyXT" }]
13
+ keywords = ["notification", "mqtt", "webhook", "mcp", "realtime"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Framework :: FastAPI",
17
+ "Programming Language :: Python :: 3",
18
+ "Topic :: System :: Monitoring",
19
+ ]
20
+ dependencies = [
21
+ "fastapi>=0.115",
22
+ "uvicorn>=0.30",
23
+ "httpx>=0.27",
24
+ "pydantic>=2.0",
25
+ "click>=8.0",
26
+ "aiomqtt>=2.0",
27
+ "websockets>=14.0",
28
+ "mcp>=1.0",
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ dev = ["pytest", "ruff"]
33
+
34
+ [project.scripts]
35
+ nme = "NoticeMe.cli:main"
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/CandyXT/NoticeMe"
39
+ Repository = "https://github.com/CandyXT/NoticeMe"
40
+ Issues = "https://github.com/CandyXT/NoticeMe/issues"
41
+
42
+ [tool.hatch.build.targets.sdist]
43
+ include = ["NoticeMe/"]
44
+
45
+ [tool.hatch.build.targets.wheel]
46
+ packages = ["NoticeMe"]
47
+
48
+ [tool.ruff]
49
+ target-version = "py311"
50
+ line-length = 120