webdav-knowledge-mcp 1.0.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.
- webdav_knowledge_mcp-1.0.0/CHANGELOG.md +9 -0
- webdav_knowledge_mcp-1.0.0/CONTRIBUTING.md +12 -0
- webdav_knowledge_mcp-1.0.0/LICENSE +202 -0
- webdav_knowledge_mcp-1.0.0/MANIFEST.in +4 -0
- webdav_knowledge_mcp-1.0.0/NOTICE +22 -0
- webdav_knowledge_mcp-1.0.0/PKG-INFO +65 -0
- webdav_knowledge_mcp-1.0.0/README.md +73 -0
- webdav_knowledge_mcp-1.0.0/README.pypi.md +36 -0
- webdav_knowledge_mcp-1.0.0/SECURITY.md +8 -0
- webdav_knowledge_mcp-1.0.0/docs/architecture.md +72 -0
- webdav_knowledge_mcp-1.0.0/docs/open_source.md +18 -0
- webdav_knowledge_mcp-1.0.0/docs/usage.md +289 -0
- webdav_knowledge_mcp-1.0.0/examples/cursor_mcp.json +11 -0
- webdav_knowledge_mcp-1.0.0/pyproject.toml +42 -0
- webdav_knowledge_mcp-1.0.0/setup.cfg +4 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/__init__.py +1 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/config.py +37 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/content.py +72 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/dav_metadata.py +95 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/documents.py +75 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/embedding.py +98 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/index.py +391 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/markdown.py +136 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/pdf.py +138 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/rag.py +94 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/semantic.py +296 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/server.py +179 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/smoke.py +58 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp/webdav.py +383 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp.egg-info/PKG-INFO +65 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp.egg-info/SOURCES.txt +42 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp.egg-info/dependency_links.txt +1 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp.egg-info/entry_points.txt +4 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp.egg-info/requires.txt +13 -0
- webdav_knowledge_mcp-1.0.0/src/webdav_knowledge_mcp.egg-info/top_level.txt +1 -0
- webdav_knowledge_mcp-1.0.0/tests/test_content.py +69 -0
- webdav_knowledge_mcp-1.0.0/tests/test_index.py +287 -0
- webdav_knowledge_mcp-1.0.0/tests/test_integration.py +107 -0
- webdav_knowledge_mcp-1.0.0/tests/test_markdown.py +64 -0
- webdav_knowledge_mcp-1.0.0/tests/test_mvp.py +18 -0
- webdav_knowledge_mcp-1.0.0/tests/test_pdf.py +230 -0
- webdav_knowledge_mcp-1.0.0/tests/test_rag.py +75 -0
- webdav_knowledge_mcp-1.0.0/tests/test_semantic.py +116 -0
- webdav_knowledge_mcp-1.0.0/tests/test_text_tools.py +563 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
- Browse WebDAV directories, search filenames and text, and read UTF-8 files or structured Markdown.
|
|
6
|
+
- Extract text-layer PDFs by physical page and update a local SQLite document index incrementally.
|
|
7
|
+
- Generate optional local CPU embeddings and rank passages by semantic similarity.
|
|
8
|
+
- Return verified source excerpts with file paths, text line ranges or PDF pages. Report insufficient evidence when the excerpts cannot be verified.
|
|
9
|
+
- Install from a wheel or run a non-root Docker image with stdio transport and persistent local data.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# 贡献指南
|
|
2
|
+
|
|
3
|
+
使用 Python 3.10 或更高版本,在独立虚拟环境安装开发依赖。
|
|
4
|
+
|
|
5
|
+
```console
|
|
6
|
+
python -m pip install -e ".[dev]"
|
|
7
|
+
python -m pytest -q
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Windows 的语义依赖启动测试需要 `.[dev,semantic]`。常规测试使用合成 WebDAV 和真实 stdio 客户端。工具修改应复用现有接口、预算和错误语义,新的行为用可重现的合成样例验证。
|
|
11
|
+
|
|
12
|
+
提交你有权以项目 Apache-2.0 许可发布的内容,注明引用的源代码、文档或素材及其许可。使用脱敏的运行记录和仿真的账号配置。 [架构](docs/architecture.md) · [安全报告](SECURITY.md) · [许可证](LICENSE)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
WebDAV Knowledge MCP
|
|
2
|
+
Copyright 2026 Neville
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0.
|
|
5
|
+
This project is an independent integration and is not affiliated with,
|
|
6
|
+
sponsored by, or endorsed by Nutstore. Nutstore and 坚果云 are trademarks
|
|
7
|
+
of their owner and are used here only to identify the compatible service.
|
|
8
|
+
|
|
9
|
+
The following packages are separate dependencies and are not relicensed
|
|
10
|
+
under Apache-2.0:
|
|
11
|
+
|
|
12
|
+
- mcp, MIT License
|
|
13
|
+
- webdavclient3, MIT License
|
|
14
|
+
- python-dotenv, BSD-3-Clause License
|
|
15
|
+
- pydantic, MIT License
|
|
16
|
+
- markdown-it-py and mdit-py-plugins, MIT License
|
|
17
|
+
- pypdf, BSD-3-Clause License
|
|
18
|
+
- FastEmbed (optional), Apache License 2.0
|
|
19
|
+
|
|
20
|
+
The public BAAI/bge-small-zh-v1.5 model and the Qdrant ONNX conversion
|
|
21
|
+
are identified by their publishers as MIT licensed. Model weights are
|
|
22
|
+
obtained separately during model preparation. See docs/open_source.md.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: webdav-knowledge-mcp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Read-only search and source-grounded answers for WebDAV knowledge bases
|
|
5
|
+
Author: Neville
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/EI-robot/webdav-knowledge-mcp
|
|
8
|
+
Project-URL: Issues, https://github.com/EI-robot/webdav-knowledge-mcp/issues
|
|
9
|
+
Keywords: mcp,webdav,document-search,rag
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
License-File: NOTICE
|
|
17
|
+
Requires-Dist: mcp<2,>=1.12
|
|
18
|
+
Requires-Dist: webdavclient3<4,>=3.14
|
|
19
|
+
Requires-Dist: python-dotenv<2,>=1
|
|
20
|
+
Requires-Dist: pydantic<3,>=2.8
|
|
21
|
+
Requires-Dist: markdown-it-py<5,>=3
|
|
22
|
+
Requires-Dist: mdit-py-plugins<1,>=0.4
|
|
23
|
+
Requires-Dist: pypdf<8,>=7.2
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest<10,>=8; extra == "dev"
|
|
26
|
+
Provides-Extra: semantic
|
|
27
|
+
Requires-Dist: fastembed<0.10,>=0.9.1; extra == "semantic"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# WebDAV Knowledge MCP
|
|
31
|
+
|
|
32
|
+
A read-only MCP server for WebDAV document collections. Browse files, read Markdown and text-layer PDFs, maintain a local SQLite index, and retrieve evidence with file paths and text lines or PDF pages.
|
|
33
|
+
|
|
34
|
+
This independent project by Neville is licensed under Apache-2.0. It has been tested with Nutstore WebDAV using user-supplied application passwords. Nutstore identifies the compatible service.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
Use Python 3.10 or newer in a virtual environment.
|
|
39
|
+
|
|
40
|
+
```console
|
|
41
|
+
python -m pip install "webdav-knowledge-mcp==1.0.0"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Create a local dotenv file with your WebDAV server address and credentials.
|
|
45
|
+
|
|
46
|
+
```dotenv
|
|
47
|
+
NUTSTORE_URL=https://dav.jianguoyun.com/dav/
|
|
48
|
+
NUTSTORE_USERNAME=you@example.com
|
|
49
|
+
NUTSTORE_PASSWORD=your-app-password
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Configure your MCP client to launch `webdav-knowledge-mcp` over stdio. Set `NUTSTORE_ENV_FILE` to the dotenv file's absolute path. Run `webdav-knowledge-smoke --registration-only` to check startup and tool discovery. Call `check_connection` in the client to verify the WebDAV configuration.
|
|
53
|
+
|
|
54
|
+
## Semantic search and answers
|
|
55
|
+
|
|
56
|
+
```console
|
|
57
|
+
python -m pip install "webdav-knowledge-mcp[semantic]==1.0.0"
|
|
58
|
+
python -m webdav_knowledge_mcp.embedding
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The preparation command downloads a public model for local CPU inference. Run `sync_index` and `sync_embeddings` for the same directory. The client selects excerpts returned by `retrieve_rag_context`; `finalize_rag_answer` verifies each excerpt against the local index. Insufficient evidence yields an explicit status. Scanned PDF pages need OCR before indexing.
|
|
62
|
+
|
|
63
|
+
The SQLite index stores document text locally. Hosted client models may receive excerpts when they are included in the client's context.
|
|
64
|
+
|
|
65
|
+
[Usage guide](https://github.com/EI-robot/webdav-knowledge-mcp/blob/master/docs/usage.md) · [Security](https://github.com/EI-robot/webdav-knowledge-mcp/blob/master/SECURITY.md) · [License](https://github.com/EI-robot/webdav-knowledge-mcp/blob/master/LICENSE)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# WebDAV Knowledge MCP
|
|
2
|
+
|
|
3
|
+
面向 WebDAV 文档库的只读 MCP 服务。让 MCP 客户端浏览和搜索文档,读取 Markdown 与有文本层的 PDF,并用带文件路径和行号或页码的原文证据回答问题。
|
|
4
|
+
|
|
5
|
+
已在坚果云 WebDAV 上测试。只需你自己的 WebDAV 账号和应用密码。[坚果云 WebDAV 配置说明](https://help.jianguoyun.com/?p=2064)
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
需要 Python 3.10 或更高版本。以下命令适用于 Windows PowerShell。
|
|
10
|
+
|
|
11
|
+
```powershell
|
|
12
|
+
python -m venv .venv
|
|
13
|
+
.\.venv\Scripts\python.exe -m pip install "webdav-knowledge-mcp==1.0.0"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
需要语义检索和带引用的问答时,安装语义扩展并下载本地模型。
|
|
17
|
+
|
|
18
|
+
```powershell
|
|
19
|
+
.\.venv\Scripts\python.exe -m pip install "webdav-knowledge-mcp[semantic]==1.0.0"
|
|
20
|
+
.\.venv\Scripts\python.exe -m webdav_knowledge_mcp.embedding
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
[源码安装、macOS/Linux 和 Docker](docs/usage.md) · [PyPI 首发验收](docs/installation.md)
|
|
24
|
+
|
|
25
|
+
## 配置客户端
|
|
26
|
+
|
|
27
|
+
创建本地 `.env` 文件。使用坚果云时,密码填写为第三方应用密码。
|
|
28
|
+
|
|
29
|
+
```dotenv
|
|
30
|
+
NUTSTORE_URL=https://dav.jianguoyun.com/dav/
|
|
31
|
+
NUTSTORE_USERNAME=you@example.com
|
|
32
|
+
NUTSTORE_PASSWORD=your-app-password
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
在客户端添加 stdio MCP 服务器。将两个路径替换为本机的实际绝对路径。
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"webdav-knowledge": {
|
|
41
|
+
"command": "C:\\path\\to\\.venv\\Scripts\\webdav-knowledge-mcp.exe",
|
|
42
|
+
"env": {
|
|
43
|
+
"NUTSTORE_ENV_FILE": "C:\\path\\to\\.env"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
在 macOS 或 Linux 上将可执行文件路径指向虚拟环境的 `.venv/bin/webdav-knowledge-mcp`。先运行 `webdav-knowledge-smoke --registration-only` 检查 MCP 启动和工具注册,再调用 `check_connection` 检查 WebDAV 登录。
|
|
51
|
+
|
|
52
|
+
## 查找文档与引用
|
|
53
|
+
|
|
54
|
+
| 任务 | 工具 |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| 浏览目录和按文件名查找 | `list_directory`、`search_file` |
|
|
57
|
+
| 读取文本、Markdown 结构或 PDF 指定页 | `read_file`、`read_markdown`、`read_pdf` |
|
|
58
|
+
| 查正文或维护 SQLite 索引 | `search_content`、`sync_index`、`index_status`、`search_index` |
|
|
59
|
+
| 基于已索引的文档做语义检索和带引用的问答 | `sync_embeddings`、`search_semantic`、`retrieve_rag_context`、`finalize_rag_answer` |
|
|
60
|
+
|
|
61
|
+
对同一个目录运行 `sync_index` 和 `sync_embeddings` 后,客户端可检索证据,再提交摘录。服务端复核原文并返回文件路径、文本行号或 PDF 物理页码。证据不足时会返回 `insufficient_evidence`。扫描版 PDF 需先做 OCR。[完整工具示例](docs/usage.md#用原文证据回答)
|
|
62
|
+
|
|
63
|
+
## 数据与许可
|
|
64
|
+
|
|
65
|
+
WebDAV 访问为只读。索引包含正文,保存在本机 SQLite。向量在本地生成,使用托管模型的客户端可能把返回的片段发送给模型服务。WebDAV 路径范围由账户授权和配置的 URL 决定。[数据说明与安全报告](SECURITY.md)
|
|
66
|
+
|
|
67
|
+
本项目由 Neville 独立开发,按 Apache-2.0 发行。坚果云名称用于说明兼容性。[LICENSE](LICENSE) · [NOTICE](NOTICE) · [第三方许可说明](docs/open_source.md)
|
|
68
|
+
|
|
69
|
+
## 参与开发
|
|
70
|
+
|
|
71
|
+
`src/webdav_knowledge_mcp/` 包含 MCP 入口、WebDAV 适配、文档解析和检索逻辑。`tests/` 使用本地 WebDAV 夹具和实际 MCP 子进程进行测试。
|
|
72
|
+
|
|
73
|
+
[架构](docs/architecture.md) · [贡献指南](CONTRIBUTING.md) · [验收记录](docs/installation.md) · [ROADMAP](docs/ROADMAP.md)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# WebDAV Knowledge MCP
|
|
2
|
+
|
|
3
|
+
A read-only MCP server for WebDAV document collections. Browse files, read Markdown and text-layer PDFs, maintain a local SQLite index, and retrieve evidence with file paths and text lines or PDF pages.
|
|
4
|
+
|
|
5
|
+
This independent project by Neville is licensed under Apache-2.0. It has been tested with Nutstore WebDAV using user-supplied application passwords. Nutstore identifies the compatible service.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Use Python 3.10 or newer in a virtual environment.
|
|
10
|
+
|
|
11
|
+
```console
|
|
12
|
+
python -m pip install "webdav-knowledge-mcp==1.0.0"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Create a local dotenv file with your WebDAV server address and credentials.
|
|
16
|
+
|
|
17
|
+
```dotenv
|
|
18
|
+
NUTSTORE_URL=https://dav.jianguoyun.com/dav/
|
|
19
|
+
NUTSTORE_USERNAME=you@example.com
|
|
20
|
+
NUTSTORE_PASSWORD=your-app-password
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Configure your MCP client to launch `webdav-knowledge-mcp` over stdio. Set `NUTSTORE_ENV_FILE` to the dotenv file's absolute path. Run `webdav-knowledge-smoke --registration-only` to check startup and tool discovery. Call `check_connection` in the client to verify the WebDAV configuration.
|
|
24
|
+
|
|
25
|
+
## Semantic search and answers
|
|
26
|
+
|
|
27
|
+
```console
|
|
28
|
+
python -m pip install "webdav-knowledge-mcp[semantic]==1.0.0"
|
|
29
|
+
python -m webdav_knowledge_mcp.embedding
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The preparation command downloads a public model for local CPU inference. Run `sync_index` and `sync_embeddings` for the same directory. The client selects excerpts returned by `retrieve_rag_context`; `finalize_rag_answer` verifies each excerpt against the local index. Insufficient evidence yields an explicit status. Scanned PDF pages need OCR before indexing.
|
|
33
|
+
|
|
34
|
+
The SQLite index stores document text locally. Hosted client models may receive excerpts when they are included in the client's context.
|
|
35
|
+
|
|
36
|
+
[Usage guide](https://github.com/EI-robot/webdav-knowledge-mcp/blob/master/docs/usage.md) · [Security](https://github.com/EI-robot/webdav-knowledge-mcp/blob/master/SECURITY.md) · [License](https://github.com/EI-robot/webdav-knowledge-mcp/blob/master/LICENSE)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# 安全与数据
|
|
2
|
+
|
|
3
|
+
发现可能泄露凭据或读取越权资料的问题,请私下联系仓库维护者。仓库启用了私密漏洞报告时,可以走 GitHub Security Advisories。报告应附版本、平台和使用合成数据的最小复现。 [GitHub 私密漏洞报告说明](https://docs.github.com/en/code-security/security-advisories/working-with-repository-security-advisories/privately-reporting-a-security-vulnerability)
|
|
4
|
+
|
|
5
|
+
- 第三方应用密码用于向配置的坚果云 WebDAV 服务认证。将 dotenv 文件保存在本机或以只读方式挂载,需要撤销访问时在账户中删除应用密码。
|
|
6
|
+
- SQLite 索引包含文件路径、原文及向量。持久卷、数据库、日志和备份都应按原始资料的敏感度保护。
|
|
7
|
+
- Embedding 在本地运行。MCP 工具返回的资料会进入客户端;若客户端使用托管聊天模型,文档摘录可能离开本机。
|
|
8
|
+
- 将文档、链接和工具返回的正文作为待核对资料。客户端和模型决定如何处理上下文。
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# 项目架构
|
|
2
|
+
|
|
3
|
+
MCP 客户端 → stdio MCP(server.py)→ WebDAV 适配器(webdav.py)→ 坚果云。
|
|
4
|
+
|
|
5
|
+
`server.py` 注册 MCP 工具,保留命令入口和接口文档。`documents.py` 将远端 Markdown、PDF 读取的格式检查、下载预算和解析流程集中在一起。`markdown.py` 和 `pdf.py` 处理各自的文档格式,在线读取与增量索引共享解析实现。`index.py`、`semantic.py` 和 `rag.py` 分别负责正文索引、向量检索和引用核验。
|
|
6
|
+
|
|
7
|
+
仓库使用 `src/` 布局,`tests/` 覆盖模块行为和真实 stdio,`examples/` 存放客户配置,`docs/` 保存使用手册、设计和验收记录。结构参考官方 MCP Python SDK 和 PyPA build,发布仍由 `pyproject.toml` 描述。 [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) · [PyPA build](https://github.com/pypa/build)
|
|
8
|
+
|
|
9
|
+
配置加载由 config.py 负责,环境变量优先于指定 .env 文件。服务启动不访问远端,
|
|
10
|
+
工具调用时才校验凭据,便于区分「协议是否启动」与「账号是否可用」。
|
|
11
|
+
|
|
12
|
+
WebDAV URL 分解为 origin 与 root,避免第三方库将 /dav/ 自身当成子目录。
|
|
13
|
+
列表返回直接子项的名称,目录名称以 / 结尾,不递归扫描。
|
|
14
|
+
|
|
15
|
+
工具由 FastMCP 调度。在线工具为 check_connection、list_directory、read_file、
|
|
16
|
+
read_markdown、read_pdf、search_file、search_content。本地索引工具为 sync_index、index_status、
|
|
17
|
+
search_index、sync_embeddings 和 search_semantic。RAG 工具为 retrieve_rag_context 和 finalize_rag_answer。
|
|
18
|
+
坚果云访问保持只读。远端请求设置超时。
|
|
19
|
+
|
|
20
|
+
read_file 用现有 HTTP Session 发起流式 GET,按收到的实际字节数限制内存,
|
|
21
|
+
最大 1 MiB,解码为 UTF-8(支持 BOM)。超限直接报错,不截断正文;只允许支持的
|
|
22
|
+
文本后缀并拒绝二进制控制字符。response 上下文管理器保证成功及异常路径均关闭响应。
|
|
23
|
+
GET 不跟随重定向,避免读取偏离指定 WebDAV 根目录的资源。
|
|
24
|
+
|
|
25
|
+
search_file 用 deque 实现广度优先遍历,队列记录相对目录和深度,文件名按 casefold
|
|
26
|
+
做子串匹配。分别限制深度、目录数、处理条目数与返回条数;结果包含扫描计数以及
|
|
27
|
+
truncated/limit_reasons。非递归查询的范围本身只包含直接子项,不因此标记截断。
|
|
28
|
+
文件名搜索只查在线目录,不下载正文。单个目录响应有 4 MiB 上限。
|
|
29
|
+
|
|
30
|
+
search_content 复用同一私有广度优先遍历。文本后缀文件由有界 GET 读取,匹配和片段在
|
|
31
|
+
content.py 中完成。结果含行号和最多 200 字符的片段,并单独报告 file_errors 与预算截断。
|
|
32
|
+
|
|
33
|
+
index.py 使用标准库 SQLite 持久化正文和元数据,以 URL、账号和起始目录隔离索引。
|
|
34
|
+
同步复用目录遍历及有界文件读取。所有目录查询使用 dav_metadata.py 检查 PROPFIND 清单的
|
|
35
|
+
子项状态、资源类型和 href。相同强 ETag 可直接沿用已读版本。只有文件 GET 提供 ETag 时用
|
|
36
|
+
`If-None-Match` 探测,收到 304 后复用缓存。缺少有效标记时重新下载并比较 SHA-256。
|
|
37
|
+
同步使用单个 SQLite 写事务更新文档和覆盖状态,预算中止或网络失败时保留未看到的旧记录。
|
|
38
|
+
搜索流式读取已有索引文档并复用子串匹配,保持远端扫描与本地检索的结果语义一致。
|
|
39
|
+
|
|
40
|
+
markdown.py 通过 [markdown-it-py 的 token 位置](https://markdown-it-py.readthedocs.io/en/latest/using.html)
|
|
41
|
+
切出原文块,使用扩展识别 frontmatter 和美元符号公式。结果附上标题路径和行号。
|
|
42
|
+
`search_index(include_headings=True)` 只解析已命中的本地 Markdown 文档。
|
|
43
|
+
线上和本地检索与 Markdown 解析共用 CRLF、LF、CR 行号约定。
|
|
44
|
+
项目不渲染 HTML、不请求链接目标、不执行文档内容。
|
|
45
|
+
|
|
46
|
+
documents.py 从有界 WebDAV GET 接收二进制,pdf.py 在可超时终止的子进程中运行 pypdf 文本层提取。
|
|
47
|
+
除单文件下载和同步总量外,还限制输出页数、字符数及解析器的页树、数据流和解压资源。
|
|
48
|
+
早期文本索引升级时保留原记录,旧范围在首次重新同步前报告 `pdf_sync_required`。
|
|
49
|
+
PDF 页文本按 scope/path/page 存在 SQLite 的 pdf_pages 表中,与文档记录一起更新或删除。
|
|
50
|
+
匹配在页内运行,因此 PDF 引用只需要物理页码,不依赖提取后的临时行号。
|
|
51
|
+
|
|
52
|
+
semantic.py 在同一个 SQLite 数据库中保存分块、来源摘要和单位化的 Float32 向量。
|
|
53
|
+
每块最多 320 个字符,按空行和长度分块,PDF 块保持页内边界。文本块记录原文的起止行。
|
|
54
|
+
检索用余弦相似度对当前范围内的分块排序,并按 scope/path/digest 与当前正文索引关联,
|
|
55
|
+
正文更新或删除时原向量立即退出结果。下一次向量同步清理这些旧记录。
|
|
56
|
+
向量索引记录模型名、权重和 tokenizer 指纹、维度及分块版本,身份变化时仅重建相应范围。
|
|
57
|
+
embedding.py 通过 [FastEmbed](https://qdrant.github.io/fastembed/Getting%20Started/) 在本机 CPU 推理。
|
|
58
|
+
模型下载是独立步骤,服务运行时只使用本地缓存。
|
|
59
|
+
|
|
60
|
+
rag.py 通过语义检索提供最多 8 个候选。证据 ID 由问题、目录、模型版本和来源内容派生。
|
|
61
|
+
客户端模型选择可直接回答问题的片段,并提交证据 ID 和摘录。服务端重复查询当前索引,
|
|
62
|
+
按 ID 和原文子串核对选择,再从索引计算文本行范围或 PDF 物理页。空选择或无法复核的选择
|
|
63
|
+
返回 `insufficient_evidence`。回答由复核成功的原文摘录组成,客户端模型负责判断语义支持。
|
|
64
|
+
这两步只读取本地索引。文档片段作为不可信数据传递,工具也会按原文显示引用中的 Markdown。
|
|
65
|
+
|
|
66
|
+
坚果云实际验证中,子目录 HEAD 返回 403,PROPFIND 返回 207。适配器使用已有 Client 的
|
|
67
|
+
HTTP Session 和 URL 拼接,通过带 Depth: 1 的 PROPFIND 获取清单。目录请求禁用重定向,
|
|
68
|
+
校验 HTTP 207、DAV multistatus 结构、查询集合 href 和直接子项。解析失败统一返回脱敏错误。
|
|
69
|
+
本地回归测试覆盖 HEAD 被禁用时子目录搜索仍能成功,以及不存在目录时返回错误。
|
|
70
|
+
|
|
71
|
+
SDK 依赖范围限定在 MCP 1.x;本次验证版本为 mcp 1.30.0、webdavclient3 3.14.7、
|
|
72
|
+
python-dotenv 1.2.4。升级跨主版本前需要重新验证客户端和服务端接口。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# 开源许可与发布边界
|
|
2
|
+
|
|
3
|
+
项目源码使用 Apache-2.0。能够授权的原创代码可按该许可分发,分发时附上许可文本和适用归属声明。版权归属仍取决于代码来源和作者的授权。含雇主、客户、共同作者或第三方代码时,需要先核对相应权利。GitHub 仓库权限和 PyPI 上传权限分别核验。 [Apache-2.0 条文](https://www.apache.org/licenses/LICENSE-2.0.html)
|
|
4
|
+
|
|
5
|
+
| 范围 | 发布处理 |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| 原创源码、合成测试资料 | 保留 `LICENSE`、`NOTICE`。第三方代码的许可与归属单独核对。公开仓库能读到代码的事实本身不授予复制或再许可权 |
|
|
8
|
+
| Python 依赖 | wheel 和 sdist 声明依赖,pip 分别安装依赖工件,依赖作者原有许可继续有效。`NOTICE` 列出直接运行依赖及可选推理库 |
|
|
9
|
+
| Docker 镜像 | 镜像含 Python、Debian 软件包和传递依赖。公开分发镜像前按镜像摘要核对这些包的许可、归属和适用源代码义务。CI 构建的镜像用于验收 |
|
|
10
|
+
| Embedding | BAAI 模型及 Qdrant ONNX 版公开标注 MIT。权重在模型准备阶段单独获取,存入本机或挂载卷 |
|
|
11
|
+
| 商标与坚果云条款 | 用产品名说明兼容性,使用用户授权的 WebDAV 和第三方应用密码,遵守服务使用规则及请求配额。避免官方背书表述和品牌图样 |
|
|
12
|
+
| 个人资料 | 核对将公开的包、样例、日志和 Git 历史,排除凭据、真实文件、索引和私人路径。使用托管模型前按资料性质确认可共享范围 |
|
|
13
|
+
|
|
14
|
+
本项目文档中的第三方依赖说明基于构建环境的包元数据,依赖升级后应核对实际版本随附的许可。 [BAAI 模型卡](https://huggingface.co/BAAI/bge-small-zh-v1.5) · [Qdrant ONNX 模型卡](https://huggingface.co/Qdrant/bge-small-zh-v1.5) · [坚果云服务条款](https://help.jianguoyun.com/?page_id=490) · [WebDAV 授权与频率说明](https://help.jianguoyun.com/?p=2064)
|
|
15
|
+
|
|
16
|
+
PyPI 工件能被公众下载。公开 GitHub 仓库会额外公开其历史和协作记录,应单独检查和决定公开范围。 [PyPI 分发说明](https://docs.pypi.org/publishing/troubleshooting/#can-i-publish-private-packages-to-pypi)
|
|
17
|
+
|
|
18
|
+
公开发行包含本项目有权授权的源码、合成测试资料和使用文档。测试 PDF 在测试运行时生成。发布前检查代码来源、工件清单和许可文件,并复核包内是否包含私有数据。[安装和验收](https://github.com/EI-robot/webdav-knowledge-mcp/blob/master/docs/installation.md)
|