minas-webdav 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,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 g1394
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,9 @@
1
+ minas-webdav
2
+ Copyright 2026 g1394
3
+
4
+ This product is licensed under the Apache License, Version 2.0.
5
+ See the LICENSE file for the full license text.
6
+
7
+ Xiaomi, MiMo, MINAS and related marks are trademarks of their respective
8
+ owners. This project is an independent toolkit and is not affiliated with
9
+ or endorsed by Xiaomi.
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: minas-webdav
3
+ Version: 0.1.0
4
+ Summary: Xiaomi Smart Storage (MINAS) WebDAV control toolkit: CLI, probe, local proxy
5
+ Author: LUgABeEEE
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/LUgABeEEE/minas-webdav
8
+ Project-URL: Documentation, https://github.com/LUgABeEEE/minas-webdav#readme
9
+ Project-URL: Source, https://github.com/LUgABeEEE/minas-webdav
10
+ Project-URL: Issues, https://github.com/LUgABeEEE/minas-webdav/issues
11
+ Keywords: xiaomi,minas,webdav,nas,mcp,cli,agent
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Environment :: Console
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Topic :: System :: Filesystems
18
+ Classifier: Topic :: Utilities
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Provides-Extra: mcp
24
+ Requires-Dist: mcp<3,>=2; extra == "mcp"
25
+ Dynamic: license-file
26
+
27
+ # minas-webdav
28
+
29
+ 小米智能存储(Xiaomi Smart Storage / MINAS)**WebDAV 控制工具箱**——不挂盘、不依赖 Samba,直接通过设备的 HTTPS WebDAV 端点(`:5000`)控制整个 `/pool0/data` 存储池。
30
+
31
+ 三条能力线:
32
+
33
+ | 入口 | 作用 |
34
+ |---|---|
35
+ | `python -m minas_webdav <cmd>` | 文件 CLI:列目录、统计、上传下载、移动复制、删除 |
36
+ | `python -m minas_webdav probe` | 协议能力探测:读写全链路 + 认证 + 锁 |
37
+ | `python -m minas_webdav proxy` | 本机反向代理(`127.0.0.1:8899`),供 Windows `net use` 挂 N 盘 |
38
+
39
+ ## 安装
40
+
41
+ ```bash
42
+ pipx install minas-webdav # CLI(推荐)
43
+ pip install "minas-webdav[mcp]" # 需要 MCP server 时加 extra
44
+ ```
45
+
46
+ 要求 Python ≥ 3.10。除 `[mcp]` extra 外**无第三方依赖**(只用标准库)。
47
+ 不装也可以:`PYTHONPATH=. python3 -m minas_webdav --help`。
48
+
49
+ ## 前置条件
50
+
51
+ 配套环境、设备版本与兼容性说明见 **[docs/ENVIRONMENT.md](docs/ENVIRONMENT.md)**(Windows 11 / Python 3.10+ / 小米智能存储官方客户端 1.0.8.170 / `mcp` 2.x;NAS 服务面:nginx/1.24.0 + DAV:1,2)。
52
+
53
+ 1. NAS 与本机同一局域网(默认 `192.168.1.100:5000`)
54
+ 2. 官方客户端已登录过(证书在 `%LOCALAPPDATA%\minasCert\`)
55
+ 3. 凭据文件在**仓库外**:`%LOCALAPPDATA%\minasCred\credentials.env`
56
+
57
+ ```text
58
+ MINAS_USER=...
59
+ MINAS_PASS=...
60
+ ```
61
+
62
+ 4. 非机密配置:复制 `minas_webdav/minas_config.example.json` 为
63
+ `minas_webdav/minas_config.json`(已 gitignore),填入真实 `host` / `cn`
64
+
65
+ ## 快速开始
66
+
67
+ ```bash
68
+ # 列目录(JSON 输出适合 agent)
69
+ python -m minas_webdav ls /pool0/data --json
70
+
71
+ # 存储池容量
72
+ python -m minas_webdav df
73
+
74
+ # 上传 / 下载(中文路径直接写)
75
+ python -m minas_webdav put ./local.txt "/pool0/data/agent操作区/a.txt"
76
+ python -m minas_webdav get "/pool0/data/agent操作区/a.txt" ./back.txt
77
+
78
+ # 整理
79
+ python -m minas_webdav mkdir /pool0/data/work
80
+ python -m minas_webdav mv /pool0/data/a.txt /pool0/data/work/a.txt
81
+ python -m minas_webdav cp /pool0/data/a.txt /pool0/data/a-copy.txt
82
+ python -m minas_webdav rm /pool0/data/work -r # 递删前务必确认!
83
+
84
+ # 能力探测(写测试用唯一路径,自动清理)
85
+ python -m minas_webdav probe
86
+
87
+ # 本地代理(供挂 N 盘 / Explorer 使用)
88
+ python -m minas_webdav proxy
89
+ ```
90
+
91
+ 也可 `pip install -e .` 后直接用 `minas-webdav` / `minas-webdav-proxy` / `minas-webdav-probe` 命令。
92
+
93
+ ### 挂 N 盘(可选)
94
+
95
+ ```powershell
96
+ .\scripts\挂载NAS为N盘.ps1 # 自动拉起代理 + net use N:
97
+ .\scripts\删除N盘文件.ps1 <路径> # 删掉资源管理器删不动的文件
98
+ ```
99
+
100
+ ## 命令一览
101
+
102
+ | 命令 | 作用 |
103
+ |---|---|
104
+ | `ls` `stat` `tree` `find` | 浏览(`--max-depth` 防全盘递归) |
105
+ | `du` `df` | 目录体积 / 存储池容量 |
106
+ | `get` `put` `cat` | 传输 / 查看文本 |
107
+ | `mkdir` `mv` `cp` `rm` | 整理(`rm -r` 需用户确认) |
108
+
109
+ 退出码:`0` 成功 · `1` 错误 · `2` 不存在 · `3` 认证/网络。
110
+
111
+ ## 项目结构
112
+
113
+ ```text
114
+ minas_webdav/
115
+ config.py # 配置与凭据加载(minas_config.json + credentials.env)
116
+ cli.py # 文件 CLI
117
+ probe.py # 能力探测
118
+ proxy.py # 本机反向代理(WebClient 兼容调优)
119
+ scripts/ # 挂 N 盘 / 清理脚本 + rclone.zip
120
+ docs/ # webdav-surface.md 协议实测结论
121
+ ```
122
+
123
+ ## 协议要点(详见 [docs/webdav-surface.md](docs/webdav-surface.md))
124
+
125
+ - `Host`/SNI 必须用**设备 CN**(`nas.<uid>.<hash>`),不能裸用 IP
126
+ - `PROPFIND Depth: infinity` 被拒(403),递归必须逐层 `Depth: 1`
127
+ - `MOVE`/`COPY` 的 `Destination` 用**百分号编码的纯路径**;IP 形式的 URL 会 400
128
+ - 无认证访问返回 451;Basic 即可,mTLS 可选
129
+
130
+ ## 安全约束
131
+
132
+ - 凭据与设备 CN 不进 Git(`.gitignore` 已挡 `minas_config.json` / `*.env`)
133
+ - 不写日志、不打印密码;不碰 SSH/Docker/固件
134
+ - 递归删除、批量动照片/备份目录前必须征得用户同意
135
+
136
+ ## Agent 接入
137
+
138
+ 本项目同时提供两种 agent 接入方式(设计见 [docs/agent-integration-design.md](docs/agent-integration-design.md)):
139
+
140
+ | 方式 | 位置 | 说明 |
141
+ |---|---|---|
142
+ | **Skill** | 仓库 `skill/` → 拷到 `~/.config/mimocode/skills/minas-webdav/` | SKILL.md 触发 + 调本 CLI;全局可用 |
143
+ | **MCP** | `mcp_server.py` + `mimocode.jsonc` 注册 `minas-webdav` | 14 个 `nas_*` 工具(stdio);`nas_rm` 递归必须 `confirm=true` |
144
+
145
+ 安装 Skill(MiMoCode):
146
+
147
+ ```powershell
148
+ Copy-Item -Recurse skill "$HOME\.config\mimocode\skills\minas-webdav"
149
+ ```
150
+
151
+ 注册 MCP(`~/.config/mimocode/mimocode.jsonc` 的 `mcp` 段):
152
+
153
+ ```jsonc
154
+ "minas-webdav": {
155
+ "type": "local",
156
+ "command": ["<python>", "-m", "minas_webdav.mcp_server"],
157
+ "environment": { "PYTHONPATH": "<本仓库路径>" },
158
+ "enabled": true
159
+ }
160
+ ```
161
+
162
+ MCP 依赖装在项目 venv(`pip install mcp`,2.x)。改 CLI 后请同步更新 SKILL.md 命令表与 MCP 工具签名。
163
+
164
+ ## License
165
+
166
+ Apache-2.0,见 [LICENSE](LICENSE) 与 [NOTICE](NOTICE)。与 Xiaomi 无关联。
167
+
168
+ ## 相关
169
+
170
+ - 挂 N 盘可选 [rclone](https://rclone.com)(官方下载;仓库不打包二进制)
171
+ - Samba 通道(仅 Z: 备份共享)是另一套:`minas-skill`(SMB 445)
@@ -0,0 +1,145 @@
1
+ # minas-webdav
2
+
3
+ 小米智能存储(Xiaomi Smart Storage / MINAS)**WebDAV 控制工具箱**——不挂盘、不依赖 Samba,直接通过设备的 HTTPS WebDAV 端点(`:5000`)控制整个 `/pool0/data` 存储池。
4
+
5
+ 三条能力线:
6
+
7
+ | 入口 | 作用 |
8
+ |---|---|
9
+ | `python -m minas_webdav <cmd>` | 文件 CLI:列目录、统计、上传下载、移动复制、删除 |
10
+ | `python -m minas_webdav probe` | 协议能力探测:读写全链路 + 认证 + 锁 |
11
+ | `python -m minas_webdav proxy` | 本机反向代理(`127.0.0.1:8899`),供 Windows `net use` 挂 N 盘 |
12
+
13
+ ## 安装
14
+
15
+ ```bash
16
+ pipx install minas-webdav # CLI(推荐)
17
+ pip install "minas-webdav[mcp]" # 需要 MCP server 时加 extra
18
+ ```
19
+
20
+ 要求 Python ≥ 3.10。除 `[mcp]` extra 外**无第三方依赖**(只用标准库)。
21
+ 不装也可以:`PYTHONPATH=. python3 -m minas_webdav --help`。
22
+
23
+ ## 前置条件
24
+
25
+ 配套环境、设备版本与兼容性说明见 **[docs/ENVIRONMENT.md](docs/ENVIRONMENT.md)**(Windows 11 / Python 3.10+ / 小米智能存储官方客户端 1.0.8.170 / `mcp` 2.x;NAS 服务面:nginx/1.24.0 + DAV:1,2)。
26
+
27
+ 1. NAS 与本机同一局域网(默认 `192.168.1.100:5000`)
28
+ 2. 官方客户端已登录过(证书在 `%LOCALAPPDATA%\minasCert\`)
29
+ 3. 凭据文件在**仓库外**:`%LOCALAPPDATA%\minasCred\credentials.env`
30
+
31
+ ```text
32
+ MINAS_USER=...
33
+ MINAS_PASS=...
34
+ ```
35
+
36
+ 4. 非机密配置:复制 `minas_webdav/minas_config.example.json` 为
37
+ `minas_webdav/minas_config.json`(已 gitignore),填入真实 `host` / `cn`
38
+
39
+ ## 快速开始
40
+
41
+ ```bash
42
+ # 列目录(JSON 输出适合 agent)
43
+ python -m minas_webdav ls /pool0/data --json
44
+
45
+ # 存储池容量
46
+ python -m minas_webdav df
47
+
48
+ # 上传 / 下载(中文路径直接写)
49
+ python -m minas_webdav put ./local.txt "/pool0/data/agent操作区/a.txt"
50
+ python -m minas_webdav get "/pool0/data/agent操作区/a.txt" ./back.txt
51
+
52
+ # 整理
53
+ python -m minas_webdav mkdir /pool0/data/work
54
+ python -m minas_webdav mv /pool0/data/a.txt /pool0/data/work/a.txt
55
+ python -m minas_webdav cp /pool0/data/a.txt /pool0/data/a-copy.txt
56
+ python -m minas_webdav rm /pool0/data/work -r # 递删前务必确认!
57
+
58
+ # 能力探测(写测试用唯一路径,自动清理)
59
+ python -m minas_webdav probe
60
+
61
+ # 本地代理(供挂 N 盘 / Explorer 使用)
62
+ python -m minas_webdav proxy
63
+ ```
64
+
65
+ 也可 `pip install -e .` 后直接用 `minas-webdav` / `minas-webdav-proxy` / `minas-webdav-probe` 命令。
66
+
67
+ ### 挂 N 盘(可选)
68
+
69
+ ```powershell
70
+ .\scripts\挂载NAS为N盘.ps1 # 自动拉起代理 + net use N:
71
+ .\scripts\删除N盘文件.ps1 <路径> # 删掉资源管理器删不动的文件
72
+ ```
73
+
74
+ ## 命令一览
75
+
76
+ | 命令 | 作用 |
77
+ |---|---|
78
+ | `ls` `stat` `tree` `find` | 浏览(`--max-depth` 防全盘递归) |
79
+ | `du` `df` | 目录体积 / 存储池容量 |
80
+ | `get` `put` `cat` | 传输 / 查看文本 |
81
+ | `mkdir` `mv` `cp` `rm` | 整理(`rm -r` 需用户确认) |
82
+
83
+ 退出码:`0` 成功 · `1` 错误 · `2` 不存在 · `3` 认证/网络。
84
+
85
+ ## 项目结构
86
+
87
+ ```text
88
+ minas_webdav/
89
+ config.py # 配置与凭据加载(minas_config.json + credentials.env)
90
+ cli.py # 文件 CLI
91
+ probe.py # 能力探测
92
+ proxy.py # 本机反向代理(WebClient 兼容调优)
93
+ scripts/ # 挂 N 盘 / 清理脚本 + rclone.zip
94
+ docs/ # webdav-surface.md 协议实测结论
95
+ ```
96
+
97
+ ## 协议要点(详见 [docs/webdav-surface.md](docs/webdav-surface.md))
98
+
99
+ - `Host`/SNI 必须用**设备 CN**(`nas.<uid>.<hash>`),不能裸用 IP
100
+ - `PROPFIND Depth: infinity` 被拒(403),递归必须逐层 `Depth: 1`
101
+ - `MOVE`/`COPY` 的 `Destination` 用**百分号编码的纯路径**;IP 形式的 URL 会 400
102
+ - 无认证访问返回 451;Basic 即可,mTLS 可选
103
+
104
+ ## 安全约束
105
+
106
+ - 凭据与设备 CN 不进 Git(`.gitignore` 已挡 `minas_config.json` / `*.env`)
107
+ - 不写日志、不打印密码;不碰 SSH/Docker/固件
108
+ - 递归删除、批量动照片/备份目录前必须征得用户同意
109
+
110
+ ## Agent 接入
111
+
112
+ 本项目同时提供两种 agent 接入方式(设计见 [docs/agent-integration-design.md](docs/agent-integration-design.md)):
113
+
114
+ | 方式 | 位置 | 说明 |
115
+ |---|---|---|
116
+ | **Skill** | 仓库 `skill/` → 拷到 `~/.config/mimocode/skills/minas-webdav/` | SKILL.md 触发 + 调本 CLI;全局可用 |
117
+ | **MCP** | `mcp_server.py` + `mimocode.jsonc` 注册 `minas-webdav` | 14 个 `nas_*` 工具(stdio);`nas_rm` 递归必须 `confirm=true` |
118
+
119
+ 安装 Skill(MiMoCode):
120
+
121
+ ```powershell
122
+ Copy-Item -Recurse skill "$HOME\.config\mimocode\skills\minas-webdav"
123
+ ```
124
+
125
+ 注册 MCP(`~/.config/mimocode/mimocode.jsonc` 的 `mcp` 段):
126
+
127
+ ```jsonc
128
+ "minas-webdav": {
129
+ "type": "local",
130
+ "command": ["<python>", "-m", "minas_webdav.mcp_server"],
131
+ "environment": { "PYTHONPATH": "<本仓库路径>" },
132
+ "enabled": true
133
+ }
134
+ ```
135
+
136
+ MCP 依赖装在项目 venv(`pip install mcp`,2.x)。改 CLI 后请同步更新 SKILL.md 命令表与 MCP 工具签名。
137
+
138
+ ## License
139
+
140
+ Apache-2.0,见 [LICENSE](LICENSE) 与 [NOTICE](NOTICE)。与 Xiaomi 无关联。
141
+
142
+ ## 相关
143
+
144
+ - 挂 N 盘可选 [rclone](https://rclone.com)(官方下载;仓库不打包二进制)
145
+ - Samba 通道(仅 Z: 备份共享)是另一套:`minas-skill`(SMB 445)
@@ -0,0 +1,7 @@
1
+ """minas-webdav — Xiaomi Smart Storage (MINAS) WebDAV control toolkit.
2
+
3
+ Talks to the NAS WebDAV endpoint (HTTPS :5000) directly: list, transfer,
4
+ organize, probe capabilities, and run a local reverse proxy for drive mapping.
5
+ """
6
+
7
+ __version__ = "0.1.0"
@@ -0,0 +1,21 @@
1
+ """Entry point: python -m minas_webdav [probe|proxy|<cli-command>] ..."""
2
+ import sys
3
+
4
+
5
+ def main(argv: list[str] | None = None) -> int:
6
+ argv = list(sys.argv[1:] if argv is None else argv)
7
+ if argv and argv[0] == "probe":
8
+ from .probe import run
9
+
10
+ return run(argv[1:])
11
+ if argv and argv[0] == "proxy":
12
+ from .proxy import run
13
+
14
+ return run(argv[1:])
15
+ from .cli import main as cli_main
16
+
17
+ return cli_main(argv)
18
+
19
+
20
+ if __name__ == "__main__":
21
+ sys.exit(main())