svn-mcp 0.3.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.
- svn_mcp-0.3.0/LICENSE +201 -0
- svn_mcp-0.3.0/NOTICE +14 -0
- svn_mcp-0.3.0/PKG-INFO +222 -0
- svn_mcp-0.3.0/README.md +205 -0
- svn_mcp-0.3.0/pyproject.toml +26 -0
- svn_mcp-0.3.0/setup.cfg +4 -0
- svn_mcp-0.3.0/svn_mcp.egg-info/PKG-INFO +222 -0
- svn_mcp-0.3.0/svn_mcp.egg-info/SOURCES.txt +12 -0
- svn_mcp-0.3.0/svn_mcp.egg-info/dependency_links.txt +1 -0
- svn_mcp-0.3.0/svn_mcp.egg-info/entry_points.txt +2 -0
- svn_mcp-0.3.0/svn_mcp.egg-info/requires.txt +1 -0
- svn_mcp-0.3.0/svn_mcp.egg-info/top_level.txt +1 -0
- svn_mcp-0.3.0/svn_mcp_server.py +1160 -0
- svn_mcp-0.3.0/tests/test_svn_rollback.py +348 -0
svn_mcp-0.3.0/LICENSE
ADDED
|
@@ -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 Derivative
|
|
95
|
+
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 do
|
|
117
|
+
not modify the License. You may add Your own attribution notices
|
|
118
|
+
within Derivative Works that You distribute, alongside or as an
|
|
119
|
+
addendum to the NOTICE text from the Work, provided that such
|
|
120
|
+
additional attribution notices cannot be construed as modifying
|
|
121
|
+
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 hira
|
|
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.
|
svn_mcp-0.3.0/NOTICE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
svn-mcp-server
|
|
2
|
+
Copyright 2026 hira
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
This project is an independent reimplementation. It was inspired by, and
|
|
11
|
+
designed to interoperate with, the following prior MIT-licensed projects:
|
|
12
|
+
* gcorroto/mcp-svn (Node/TypeScript) - https://github.com/gcorroto/mcp-svn
|
|
13
|
+
* manavdesai27/mcp-server-svn (Python) - https://github.com/manavdesai27/mcp-server-svn
|
|
14
|
+
No source code from those projects is included here.
|
svn_mcp-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: svn-mcp
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Unicode-safe (CJK/Japanese path) SVN MCP server with env-based auth and XML-parsed output
|
|
5
|
+
Author-email: hira <ship.hiramatsu@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Keywords: mcp,svn,subversion,model-context-protocol,unicode,cjk
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Topic :: Software Development :: Version Control
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
License-File: NOTICE
|
|
15
|
+
Requires-Dist: mcp<2,>=1.2.0
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# svn-mcp-server
|
|
19
|
+
|
|
20
|
+
一个单文件的 **Subversion(SVN)** [模型上下文协议(MCP)](https://modelcontextprotocol.io)服务器,专为 **Windows 下包含非 ASCII 字符(中日韩文字)的路径**提供可靠支持。
|
|
21
|
+
|
|
22
|
+
本项目的起因是:两款现有的 SVN MCP 服务器在日文 Windows 环境下都存在问题。其中,Node 实现因 CP932 与 UTF-8 编码差异导致日文路径乱码,另一款 Python 实现则会返回空结果,并在输出为空时崩溃。本服务器保留了两者的优点,并修复了这些问题。
|
|
23
|
+
|
|
24
|
+
## 项目特点
|
|
25
|
+
|
|
26
|
+
- **支持 Unicode 参数。** 使用**参数列表和** `shell=False` 启动命令,在 Windows 上以 Unicode 形式将路径或 URL 传递给 `CreateProcessW`,避免日文等字符乱码。
|
|
27
|
+
- **显式使用 UTF-8 解码。** 以字节形式捕获输出,再使用 UTF-8 解码(`errors="replace"`),不受控制台代码页影响。
|
|
28
|
+
- **通过 XML 解析输出。** `info` / `status` / `log` / `list` 使用 `--xml` 输出,并通过 `ElementTree` 解析,确保结果结构化且可靠,避免 `log` 意外返回空结果。
|
|
29
|
+
- **通过环境变量配置身份验证。** 将 `SVN_USERNAME` / `SVN_PASSWORD` 作为 `--username` / `--password` 参数传入,并使用 `--non-interactive`,不依赖操作系统的凭据缓存。
|
|
30
|
+
- **安全处理空输出。** 工作副本没有改动时返回空列表,而不是抛出异常。
|
|
31
|
+
|
|
32
|
+
## 环境要求
|
|
33
|
+
|
|
34
|
+
- Python >= 3.10
|
|
35
|
+
- `PATH` 中可用的 `svn` 命令行客户端(例如 SlikSVN、TortoiseSVN CLI、CollabNet)
|
|
36
|
+
- `mcp>=1.2.0,<2`(自动安装,使用 MCP 1.x 提供的 `mcp.server.fastmcp`)
|
|
37
|
+
|
|
38
|
+
## 安装
|
|
39
|
+
|
|
40
|
+
### 从 PyPI 安装
|
|
41
|
+
|
|
42
|
+
在准备运行 `svn-mcp` 的 Python 环境中执行:
|
|
43
|
+
|
|
44
|
+
```powershell
|
|
45
|
+
python -m pip install svn-mcp-server
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
更新到 PyPI 上的最新发布版本:
|
|
49
|
+
|
|
50
|
+
```powershell
|
|
51
|
+
python -m pip install --upgrade svn-mcp-server
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
以上安装方式都会提供 `svn-mcp` 启动命令;SVN 命令行客户端仍需单独安装。
|
|
55
|
+
|
|
56
|
+
## 配置(Claude Desktop / Cowork)
|
|
57
|
+
|
|
58
|
+
将以下内容添加到 `claude_desktop_config.json`(Windows 路径:`%APPDATA%\Claude\claude_desktop_config.json`):
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"svn": {
|
|
64
|
+
"command": "svn-mcp",
|
|
65
|
+
"env": {
|
|
66
|
+
"SVN_WORKING_DIRECTORY": "C:\\path\\to\\working\\copy",
|
|
67
|
+
"SVN_USERNAME": "your_user",
|
|
68
|
+
"SVN_PASSWORD": "your_password",
|
|
69
|
+
"SVN_TIMEOUT": "120000",
|
|
70
|
+
"PYTHONUTF8": "1",
|
|
71
|
+
"PYTHONIOENCODING": "utf-8"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 环境变量
|
|
79
|
+
|
|
80
|
+
| 变量 | 说明 | 默认值 |
|
|
81
|
+
| ---- | ---- | ------ |
|
|
82
|
+
| `SVN_PATH` | `svn` 可执行文件的路径 | `svn` |
|
|
83
|
+
| `SVN_WORKING_DIRECTORY` | 命令的默认工作目录 | 进程当前工作目录 |
|
|
84
|
+
| `SVN_USERNAME` | 用于身份验证的用户名 | 无 |
|
|
85
|
+
| `SVN_PASSWORD` | 用于身份验证的密码 | 无 |
|
|
86
|
+
| `SVN_CONFIG_DIR` | 通过 `--config-dir` 传递给 SVN 的配置目录 | 无 |
|
|
87
|
+
| `SVN_TRUST_SERVER_CERT` | 设置为 `1` / `true` 时接受自签名证书 | 关闭 |
|
|
88
|
+
| `SVN_TIMEOUT` | 每条命令的超时时间,单位为毫秒 | `120000` |
|
|
89
|
+
|
|
90
|
+
## 工具
|
|
91
|
+
|
|
92
|
+
### 读取与检查
|
|
93
|
+
|
|
94
|
+
| 工具 | 说明 |
|
|
95
|
+
| ---- | ---- |
|
|
96
|
+
| `svn_version` | 查看 SVN 客户端版本 |
|
|
97
|
+
| `svn_health_check` | 检查 SVN 是否可用及工作副本状态 |
|
|
98
|
+
| `svn_whoami` | 查看当前 SVN 用户名 |
|
|
99
|
+
| `svn_info` | 查看路径或 URL 的详细信息 |
|
|
100
|
+
| `svn_status` | 查看工作副本中的文件状态 |
|
|
101
|
+
| `svn_log` | 查看提交历史 |
|
|
102
|
+
| `svn_log_search` | 按作者、提交说明或版本范围搜索提交 |
|
|
103
|
+
| `svn_diff` | 查看版本之间的差异 |
|
|
104
|
+
| `svn_diff_stats` | 根据差异按文件和扩展名统计新增、删除行数 |
|
|
105
|
+
| `svn_list` | 列出目录内容 |
|
|
106
|
+
| `svn_cat` | 读取文件内容(读取本地文件或通过 `svn cat` 获取) |
|
|
107
|
+
| `svn_grep` | 在工作副本中使用正则表达式进行全文搜索 |
|
|
108
|
+
|
|
109
|
+
### 检出与更新
|
|
110
|
+
|
|
111
|
+
| 工具 | 说明 |
|
|
112
|
+
| ---- | ---- |
|
|
113
|
+
| `svn_checkout` | 将指定 URL 的内容检出到本地路径 |
|
|
114
|
+
| `svn_update` | 更新工作副本(支持通过 `set_depth` 设置稀疏检出深度) |
|
|
115
|
+
| `svn_cleanup` | 清理中断操作留下的状态 |
|
|
116
|
+
|
|
117
|
+
### 写入操作
|
|
118
|
+
|
|
119
|
+
| 工具 | 说明 |
|
|
120
|
+
| ---- | ---- |
|
|
121
|
+
| `svn_add` | 将文件加入版本控制,等待提交 |
|
|
122
|
+
| `svn_commit` | 提交更改(**需要人工审核**) |
|
|
123
|
+
| `svn_delete` | 删除文件或 URL(**需要人工审核**) |
|
|
124
|
+
| `svn_revert` | 撤销本地未提交更改 |
|
|
125
|
+
| `svn_rollback` | 反向合并已提交版本,在本地生成回退修改,不自动提交 |
|
|
126
|
+
|
|
127
|
+
> **写入操作注意事项:** `svn_commit` 和针对版本库 URL 的 `svn_delete` 会修改版本库。仅在经过明确的人工审核与批准后使用。
|
|
128
|
+
|
|
129
|
+
### 开发规模统计
|
|
130
|
+
|
|
131
|
+
以下工具用于统计本地已检出项目的规模与开发活动。
|
|
132
|
+
|
|
133
|
+
| 工具 | 说明 |
|
|
134
|
+
| ---- | ---- |
|
|
135
|
+
| `svn_loc_stats` | 按文件扩展名统计代码行数(总行数 / 代码行 / 注释行 / 空行) |
|
|
136
|
+
| `svn_file_loc_export` | 将逐文件代码行数导出为本地 CSV / TSV / JSONL 文件,默认仅返回摘要 |
|
|
137
|
+
| `svn_commit_stats` | 按作者和/或自然月汇总提交活动 |
|
|
138
|
+
| `svn_size_stats` | 按扩展名统计文件数量和字节大小,并列出最大的文件 |
|
|
139
|
+
|
|
140
|
+
#### `svn_loc_stats`
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
svn_loc_stats(path=None, extensions=None, filename_pattern=None, group_by="extension")
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
遍历工作副本,将每一行归类为**代码行**、**注释行**或**空行**。根据 `group_by` 指定的方式分组,并在 `total` 项中汇总结果。
|
|
147
|
+
|
|
148
|
+
- `path` — 扫描根目录,默认为 `SVN_WORKING_DIRECTORY`。
|
|
149
|
+
- `extensions` — 要包含的扩展名列表,例如 `[".java", ".xml"]`,默认使用内置的文本文件扩展名集合。
|
|
150
|
+
- `filename_pattern` — 按文件名进行 glob 模式筛选,例如 `"accept_*"` 或 `"*Form.java"`。当文件名遵循命名规范时,可用于按业务类别前缀汇总。
|
|
151
|
+
- `group_by` — 结果分组方式:
|
|
152
|
+
- `"extension"`(默认)— 按文件扩展名分组。
|
|
153
|
+
- `"dirname"` — 按相对于 `path` 的目录路径分组。
|
|
154
|
+
- `"prefix_N"` — 按文件名的前 N 个字符分组,例如 `"prefix_3"`。
|
|
155
|
+
- `"filename_stem"` — 按不含扩展名的文件名分组。
|
|
156
|
+
|
|
157
|
+
#### `svn_commit_stats`
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
svn_commit_stats(repo_path=None, limit=None, revision=None,
|
|
161
|
+
group_by_author=True, group_by_month=False)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
解析 `svn log --verbose --xml` 的输出,汇总提交次数和变更路径数量。
|
|
165
|
+
|
|
166
|
+
- `group_by_author` — 是否包含按作者分组的统计,默认为 `true`。
|
|
167
|
+
- `group_by_month` — 是否包含按月份分组的统计,默认为 `false`。
|
|
168
|
+
- `limit` / `revision` — 含义与 `svn_log` 中的同名参数一致。
|
|
169
|
+
|
|
170
|
+
#### `svn_file_loc_export`
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
svn_file_loc_export(path, extensions=None, exclude_patterns=None,
|
|
174
|
+
output_path=None, output_format="csv",
|
|
175
|
+
include_svn_revision=False)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
递归扫描 `path`,将每个文件的统计结果作为一条记录写入本地文件。
|
|
179
|
+
默认仅返回摘要,包括文件总数、总行数,以及按扩展名汇总的代码行、注释行和空行数,避免通过 MCP 响应传回完整文件列表而触发 token 数量或超时限制。满足下述内联条件时,也可在响应中返回逐文件记录。
|
|
180
|
+
|
|
181
|
+
| 参数 | 说明 |
|
|
182
|
+
| ---- | ---- |
|
|
183
|
+
| `path` | 扫描根路径(必填)。相对路径以 `SVN_WORKING_DIRECTORY` 为基准解析。 |
|
|
184
|
+
| `extensions` | 要包含的扩展名列表,例如 `[".java", ".jsp", ".sql"]`。默认使用内置的文本文件扩展名集合。 |
|
|
185
|
+
| `exclude_patterns` | 要排除的 glob 模式,匹配使用正斜杠的相对路径,例如 `["*/test/*"]`。 |
|
|
186
|
+
| `output_path` | 输出文件的保存路径。省略时,在 `path` 旁自动生成 `_loc_export_<timestamp>.csv`。 |
|
|
187
|
+
| `output_format` | `"csv"`(默认,使用带 BOM 的 UTF-8 编码以兼容 Excel)、`"tsv"` 或 `"jsonl"`。 |
|
|
188
|
+
| `include_svn_revision` | 为 `true` 时,通过 `svn info` 获取每个文件的最后修改版本号。每个文件会额外调用一次 SVN,仅在需要时启用。 |
|
|
189
|
+
| `inline_if_small` | 为 `true`(默认)且文件数量 ≤ `inline_threshold` 时,在响应的 `files` 字段中包含逐文件记录,便于 Claude 直接处理数据,无需读取 CSV。 |
|
|
190
|
+
| `inline_threshold` | 允许内联返回的最大文件数量,默认为 `10000`。超过该值时,仅返回摘要和 `output_file` 路径。 |
|
|
191
|
+
|
|
192
|
+
**输出文件列名:** `relative_path`、`extension`、`total`、`code`、`comment`、`blank`、`size_bytes`、`last_revision`
|
|
193
|
+
|
|
194
|
+
#### `svn_diff_stats`
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
svn_diff_stats(repo_path=None, revision=None, old_revision=None, new_revision=None,
|
|
198
|
+
extensions=None)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
运行 `svn diff` 并解析统一差异格式的输出,统计每个文件的新增和删除行数。返回按新增与删除行数之和排序的逐文件列表、按扩展名分组的统计,以及 `total` 汇总(`files_changed`、`added`、`removed`、`delta`)。
|
|
202
|
+
|
|
203
|
+
- 参数与 `svn_diff` 一致。
|
|
204
|
+
- `extensions` — 仅统计指定扩展名的文件,例如 `[".java"]`。
|
|
205
|
+
|
|
206
|
+
#### `svn_size_stats`
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
svn_size_stats(path=None, extensions=None, top_n=20)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
从工作副本的文件系统中收集文件大小,返回按扩展名统计的文件数量与字节总数、整体大小(字节和 MB),以及最大的 `top_n` 个文件。
|
|
213
|
+
|
|
214
|
+
- 自动排除 `.svn` 元数据目录。
|
|
215
|
+
|
|
216
|
+
## 致谢
|
|
217
|
+
|
|
218
|
+
本项目为独立重新实现,参考了以下两个采用 MIT 许可证的项目,并与其兼容,未复制其代码:[gcorroto/mcp-svn](https://github.com/gcorroto/mcp-svn) 和 [manavdesai27/mcp-server-svn](https://github.com/manavdesai27/mcp-server-svn)。
|
|
219
|
+
|
|
220
|
+
## 许可证
|
|
221
|
+
|
|
222
|
+
Apache-2.0。详见 [LICENSE](LICENSE) 和 [NOTICE](NOTICE)。
|
svn_mcp-0.3.0/README.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# svn-mcp-server
|
|
2
|
+
|
|
3
|
+
一个单文件的 **Subversion(SVN)** [模型上下文协议(MCP)](https://modelcontextprotocol.io)服务器,专为 **Windows 下包含非 ASCII 字符(中日韩文字)的路径**提供可靠支持。
|
|
4
|
+
|
|
5
|
+
本项目的起因是:两款现有的 SVN MCP 服务器在日文 Windows 环境下都存在问题。其中,Node 实现因 CP932 与 UTF-8 编码差异导致日文路径乱码,另一款 Python 实现则会返回空结果,并在输出为空时崩溃。本服务器保留了两者的优点,并修复了这些问题。
|
|
6
|
+
|
|
7
|
+
## 项目特点
|
|
8
|
+
|
|
9
|
+
- **支持 Unicode 参数。** 使用**参数列表和** `shell=False` 启动命令,在 Windows 上以 Unicode 形式将路径或 URL 传递给 `CreateProcessW`,避免日文等字符乱码。
|
|
10
|
+
- **显式使用 UTF-8 解码。** 以字节形式捕获输出,再使用 UTF-8 解码(`errors="replace"`),不受控制台代码页影响。
|
|
11
|
+
- **通过 XML 解析输出。** `info` / `status` / `log` / `list` 使用 `--xml` 输出,并通过 `ElementTree` 解析,确保结果结构化且可靠,避免 `log` 意外返回空结果。
|
|
12
|
+
- **通过环境变量配置身份验证。** 将 `SVN_USERNAME` / `SVN_PASSWORD` 作为 `--username` / `--password` 参数传入,并使用 `--non-interactive`,不依赖操作系统的凭据缓存。
|
|
13
|
+
- **安全处理空输出。** 工作副本没有改动时返回空列表,而不是抛出异常。
|
|
14
|
+
|
|
15
|
+
## 环境要求
|
|
16
|
+
|
|
17
|
+
- Python >= 3.10
|
|
18
|
+
- `PATH` 中可用的 `svn` 命令行客户端(例如 SlikSVN、TortoiseSVN CLI、CollabNet)
|
|
19
|
+
- `mcp>=1.2.0,<2`(自动安装,使用 MCP 1.x 提供的 `mcp.server.fastmcp`)
|
|
20
|
+
|
|
21
|
+
## 安装
|
|
22
|
+
|
|
23
|
+
### 从 PyPI 安装
|
|
24
|
+
|
|
25
|
+
在准备运行 `svn-mcp` 的 Python 环境中执行:
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
python -m pip install svn-mcp-server
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
更新到 PyPI 上的最新发布版本:
|
|
32
|
+
|
|
33
|
+
```powershell
|
|
34
|
+
python -m pip install --upgrade svn-mcp-server
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
以上安装方式都会提供 `svn-mcp` 启动命令;SVN 命令行客户端仍需单独安装。
|
|
38
|
+
|
|
39
|
+
## 配置(Claude Desktop / Cowork)
|
|
40
|
+
|
|
41
|
+
将以下内容添加到 `claude_desktop_config.json`(Windows 路径:`%APPDATA%\Claude\claude_desktop_config.json`):
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"mcpServers": {
|
|
46
|
+
"svn": {
|
|
47
|
+
"command": "svn-mcp",
|
|
48
|
+
"env": {
|
|
49
|
+
"SVN_WORKING_DIRECTORY": "C:\\path\\to\\working\\copy",
|
|
50
|
+
"SVN_USERNAME": "your_user",
|
|
51
|
+
"SVN_PASSWORD": "your_password",
|
|
52
|
+
"SVN_TIMEOUT": "120000",
|
|
53
|
+
"PYTHONUTF8": "1",
|
|
54
|
+
"PYTHONIOENCODING": "utf-8"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 环境变量
|
|
62
|
+
|
|
63
|
+
| 变量 | 说明 | 默认值 |
|
|
64
|
+
| ---- | ---- | ------ |
|
|
65
|
+
| `SVN_PATH` | `svn` 可执行文件的路径 | `svn` |
|
|
66
|
+
| `SVN_WORKING_DIRECTORY` | 命令的默认工作目录 | 进程当前工作目录 |
|
|
67
|
+
| `SVN_USERNAME` | 用于身份验证的用户名 | 无 |
|
|
68
|
+
| `SVN_PASSWORD` | 用于身份验证的密码 | 无 |
|
|
69
|
+
| `SVN_CONFIG_DIR` | 通过 `--config-dir` 传递给 SVN 的配置目录 | 无 |
|
|
70
|
+
| `SVN_TRUST_SERVER_CERT` | 设置为 `1` / `true` 时接受自签名证书 | 关闭 |
|
|
71
|
+
| `SVN_TIMEOUT` | 每条命令的超时时间,单位为毫秒 | `120000` |
|
|
72
|
+
|
|
73
|
+
## 工具
|
|
74
|
+
|
|
75
|
+
### 读取与检查
|
|
76
|
+
|
|
77
|
+
| 工具 | 说明 |
|
|
78
|
+
| ---- | ---- |
|
|
79
|
+
| `svn_version` | 查看 SVN 客户端版本 |
|
|
80
|
+
| `svn_health_check` | 检查 SVN 是否可用及工作副本状态 |
|
|
81
|
+
| `svn_whoami` | 查看当前 SVN 用户名 |
|
|
82
|
+
| `svn_info` | 查看路径或 URL 的详细信息 |
|
|
83
|
+
| `svn_status` | 查看工作副本中的文件状态 |
|
|
84
|
+
| `svn_log` | 查看提交历史 |
|
|
85
|
+
| `svn_log_search` | 按作者、提交说明或版本范围搜索提交 |
|
|
86
|
+
| `svn_diff` | 查看版本之间的差异 |
|
|
87
|
+
| `svn_diff_stats` | 根据差异按文件和扩展名统计新增、删除行数 |
|
|
88
|
+
| `svn_list` | 列出目录内容 |
|
|
89
|
+
| `svn_cat` | 读取文件内容(读取本地文件或通过 `svn cat` 获取) |
|
|
90
|
+
| `svn_grep` | 在工作副本中使用正则表达式进行全文搜索 |
|
|
91
|
+
|
|
92
|
+
### 检出与更新
|
|
93
|
+
|
|
94
|
+
| 工具 | 说明 |
|
|
95
|
+
| ---- | ---- |
|
|
96
|
+
| `svn_checkout` | 将指定 URL 的内容检出到本地路径 |
|
|
97
|
+
| `svn_update` | 更新工作副本(支持通过 `set_depth` 设置稀疏检出深度) |
|
|
98
|
+
| `svn_cleanup` | 清理中断操作留下的状态 |
|
|
99
|
+
|
|
100
|
+
### 写入操作
|
|
101
|
+
|
|
102
|
+
| 工具 | 说明 |
|
|
103
|
+
| ---- | ---- |
|
|
104
|
+
| `svn_add` | 将文件加入版本控制,等待提交 |
|
|
105
|
+
| `svn_commit` | 提交更改(**需要人工审核**) |
|
|
106
|
+
| `svn_delete` | 删除文件或 URL(**需要人工审核**) |
|
|
107
|
+
| `svn_revert` | 撤销本地未提交更改 |
|
|
108
|
+
| `svn_rollback` | 反向合并已提交版本,在本地生成回退修改,不自动提交 |
|
|
109
|
+
|
|
110
|
+
> **写入操作注意事项:** `svn_commit` 和针对版本库 URL 的 `svn_delete` 会修改版本库。仅在经过明确的人工审核与批准后使用。
|
|
111
|
+
|
|
112
|
+
### 开发规模统计
|
|
113
|
+
|
|
114
|
+
以下工具用于统计本地已检出项目的规模与开发活动。
|
|
115
|
+
|
|
116
|
+
| 工具 | 说明 |
|
|
117
|
+
| ---- | ---- |
|
|
118
|
+
| `svn_loc_stats` | 按文件扩展名统计代码行数(总行数 / 代码行 / 注释行 / 空行) |
|
|
119
|
+
| `svn_file_loc_export` | 将逐文件代码行数导出为本地 CSV / TSV / JSONL 文件,默认仅返回摘要 |
|
|
120
|
+
| `svn_commit_stats` | 按作者和/或自然月汇总提交活动 |
|
|
121
|
+
| `svn_size_stats` | 按扩展名统计文件数量和字节大小,并列出最大的文件 |
|
|
122
|
+
|
|
123
|
+
#### `svn_loc_stats`
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
svn_loc_stats(path=None, extensions=None, filename_pattern=None, group_by="extension")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
遍历工作副本,将每一行归类为**代码行**、**注释行**或**空行**。根据 `group_by` 指定的方式分组,并在 `total` 项中汇总结果。
|
|
130
|
+
|
|
131
|
+
- `path` — 扫描根目录,默认为 `SVN_WORKING_DIRECTORY`。
|
|
132
|
+
- `extensions` — 要包含的扩展名列表,例如 `[".java", ".xml"]`,默认使用内置的文本文件扩展名集合。
|
|
133
|
+
- `filename_pattern` — 按文件名进行 glob 模式筛选,例如 `"accept_*"` 或 `"*Form.java"`。当文件名遵循命名规范时,可用于按业务类别前缀汇总。
|
|
134
|
+
- `group_by` — 结果分组方式:
|
|
135
|
+
- `"extension"`(默认)— 按文件扩展名分组。
|
|
136
|
+
- `"dirname"` — 按相对于 `path` 的目录路径分组。
|
|
137
|
+
- `"prefix_N"` — 按文件名的前 N 个字符分组,例如 `"prefix_3"`。
|
|
138
|
+
- `"filename_stem"` — 按不含扩展名的文件名分组。
|
|
139
|
+
|
|
140
|
+
#### `svn_commit_stats`
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
svn_commit_stats(repo_path=None, limit=None, revision=None,
|
|
144
|
+
group_by_author=True, group_by_month=False)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
解析 `svn log --verbose --xml` 的输出,汇总提交次数和变更路径数量。
|
|
148
|
+
|
|
149
|
+
- `group_by_author` — 是否包含按作者分组的统计,默认为 `true`。
|
|
150
|
+
- `group_by_month` — 是否包含按月份分组的统计,默认为 `false`。
|
|
151
|
+
- `limit` / `revision` — 含义与 `svn_log` 中的同名参数一致。
|
|
152
|
+
|
|
153
|
+
#### `svn_file_loc_export`
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
svn_file_loc_export(path, extensions=None, exclude_patterns=None,
|
|
157
|
+
output_path=None, output_format="csv",
|
|
158
|
+
include_svn_revision=False)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
递归扫描 `path`,将每个文件的统计结果作为一条记录写入本地文件。
|
|
162
|
+
默认仅返回摘要,包括文件总数、总行数,以及按扩展名汇总的代码行、注释行和空行数,避免通过 MCP 响应传回完整文件列表而触发 token 数量或超时限制。满足下述内联条件时,也可在响应中返回逐文件记录。
|
|
163
|
+
|
|
164
|
+
| 参数 | 说明 |
|
|
165
|
+
| ---- | ---- |
|
|
166
|
+
| `path` | 扫描根路径(必填)。相对路径以 `SVN_WORKING_DIRECTORY` 为基准解析。 |
|
|
167
|
+
| `extensions` | 要包含的扩展名列表,例如 `[".java", ".jsp", ".sql"]`。默认使用内置的文本文件扩展名集合。 |
|
|
168
|
+
| `exclude_patterns` | 要排除的 glob 模式,匹配使用正斜杠的相对路径,例如 `["*/test/*"]`。 |
|
|
169
|
+
| `output_path` | 输出文件的保存路径。省略时,在 `path` 旁自动生成 `_loc_export_<timestamp>.csv`。 |
|
|
170
|
+
| `output_format` | `"csv"`(默认,使用带 BOM 的 UTF-8 编码以兼容 Excel)、`"tsv"` 或 `"jsonl"`。 |
|
|
171
|
+
| `include_svn_revision` | 为 `true` 时,通过 `svn info` 获取每个文件的最后修改版本号。每个文件会额外调用一次 SVN,仅在需要时启用。 |
|
|
172
|
+
| `inline_if_small` | 为 `true`(默认)且文件数量 ≤ `inline_threshold` 时,在响应的 `files` 字段中包含逐文件记录,便于 Claude 直接处理数据,无需读取 CSV。 |
|
|
173
|
+
| `inline_threshold` | 允许内联返回的最大文件数量,默认为 `10000`。超过该值时,仅返回摘要和 `output_file` 路径。 |
|
|
174
|
+
|
|
175
|
+
**输出文件列名:** `relative_path`、`extension`、`total`、`code`、`comment`、`blank`、`size_bytes`、`last_revision`
|
|
176
|
+
|
|
177
|
+
#### `svn_diff_stats`
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
svn_diff_stats(repo_path=None, revision=None, old_revision=None, new_revision=None,
|
|
181
|
+
extensions=None)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
运行 `svn diff` 并解析统一差异格式的输出,统计每个文件的新增和删除行数。返回按新增与删除行数之和排序的逐文件列表、按扩展名分组的统计,以及 `total` 汇总(`files_changed`、`added`、`removed`、`delta`)。
|
|
185
|
+
|
|
186
|
+
- 参数与 `svn_diff` 一致。
|
|
187
|
+
- `extensions` — 仅统计指定扩展名的文件,例如 `[".java"]`。
|
|
188
|
+
|
|
189
|
+
#### `svn_size_stats`
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
svn_size_stats(path=None, extensions=None, top_n=20)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
从工作副本的文件系统中收集文件大小,返回按扩展名统计的文件数量与字节总数、整体大小(字节和 MB),以及最大的 `top_n` 个文件。
|
|
196
|
+
|
|
197
|
+
- 自动排除 `.svn` 元数据目录。
|
|
198
|
+
|
|
199
|
+
## 致谢
|
|
200
|
+
|
|
201
|
+
本项目为独立重新实现,参考了以下两个采用 MIT 许可证的项目,并与其兼容,未复制其代码:[gcorroto/mcp-svn](https://github.com/gcorroto/mcp-svn) 和 [manavdesai27/mcp-server-svn](https://github.com/manavdesai27/mcp-server-svn)。
|
|
202
|
+
|
|
203
|
+
## 许可证
|
|
204
|
+
|
|
205
|
+
Apache-2.0。详见 [LICENSE](LICENSE) 和 [NOTICE](NOTICE)。
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "svn-mcp"
|
|
7
|
+
version = "0.3.0"
|
|
8
|
+
description = "Unicode-safe (CJK/Japanese path) SVN MCP server with env-based auth and XML-parsed output"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
13
|
+
authors = [{ name = "hira", email = "ship.hiramatsu@gmail.com" }]
|
|
14
|
+
keywords = ["mcp", "svn", "subversion", "model-context-protocol", "unicode", "cjk"]
|
|
15
|
+
dependencies = ["mcp>=1.2.0,<2"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Topic :: Software Development :: Version Control",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.scripts]
|
|
23
|
+
svn-mcp = "svn_mcp_server:main"
|
|
24
|
+
|
|
25
|
+
[tool.setuptools]
|
|
26
|
+
py-modules = ["svn_mcp_server"]
|
svn_mcp-0.3.0/setup.cfg
ADDED