Skip to main content
Glama

WebDAV MCP Server

by masx200
测试步骤.md11.9 kB
# MCP WebDAV Server 测试步骤指南 ## 环境配置 ### 1. Claude Code 配置 在 `C:\Users\msx\.claude.json` 中添加以下配置: ```json { "mcpServers": { "webdav": { "type": "stdio", "command": "node", "args": ["F:/projects/mcp-webdav-server/dist/index.js"], "env": { "WEBDAV_PASSWORD": "1234567890", "WEBDAV_USERNAME": "1234567890", "WEBDAV_AUTH_ENABLED": "true", "WEBDAV_ROOT_URL": "http://localhost:1900" } } } } ``` ### 2. WebDAV 服务器启动 ```bash # 启动 WebDAV 服务器 pnpx @masx200/webdav-cli --path=F:\knowledge-storage --username=1234567890 --password=1234567890 ``` **注意**: WebDAV 服务器默认运行在 `http://localhost:1900` ### 3. MCP 服务器构建 ```bash # 进入项目目录 cd F:\projects\mcp-webdav-server # 安装依赖 npm install # 构建项目 npm run build # 启动开发服务器(可选) npm run dev ``` ## 详细测试步骤 ### 步骤 1: 环境验证 **验证 WebDAV 服务器是否正常运行** ```bash # 测试 WebDAV 服务器连接 curl -u 1234567890:1234567890 http://localhost:1900/ ``` **验证 MCP 服务器配置** - 确保 Claude Code 配置文件正确 - 重启 Claude Code 以加载新的 MCP 服务器 ### 步骤 2: 基础 CRUD 操作测试 #### 2.1 文件创建测试 ```bash # 使用MCP工具创建测试文件 mcp__webdav__webdav_create_remote_file \ --path="/test-basic-file.txt" \ --content="这是一个基础测试文件\n包含多行内容\n用于测试CRUD操作\n第4行\n最后一行" ``` #### 2.2 文件读取测试 ```bash # 读取文件内容 mcp__webdav__webdav_get_remote_file \ --path="/test-basic-file.txt" ``` #### 2.3 文件更新测试 ```bash # 更新文件内容 mcp__webdav__webdav_update_remote_file \ --path="/test-basic-file.txt" \ --content="这是一个更新后的测试文件\n内容已修改\n第3行\n第4行\n最后一行(已更新)" ``` #### 2.4 目录创建测试 ```bash # 创建测试目录 mcp__webdav__webdav_create_remote_directory \ --path="/test-directory" ``` #### 2.5 目录列表测试 ```bash # 列出根目录内容 mcp__webdav__webdav_list_remote_directory \ --path="/" ``` #### 2.6 文件删除测试 ```bash # 删除测试文件 mcp__webdav__webdav_delete_remote_item \ --path="/test-basic-file.txt" ``` ### 步骤 3: 增强功能测试 #### 3.1 增强文件读取测试 **创建测试文件** ```bash mcp__webdav__webdav_create_remote_file \ --path="/test-enhanced.txt" \ --content="第1行:这是一个增强功能测试文件\n第2行:用于测试head和tail功能\n第3行:包含多行内容\n第4行:第4行内容\n第5行:第5行内容\n第6行:第6行内容\n第7行:第7行内容\n第8行:第8行内容\n第9行:第9行内容\n第10行:最后一行" ``` **测试 head 功能** ```bash # 读取前3行 mcp__webdav__webdav_read_remote_file \ --path="/test-enhanced.txt" \ --head=3 ``` **测试 tail 功能** ```bash # 读取后3行 mcp__webdav__webdav_read_remote_file \ --path="/test-enhanced.txt" \ --tail=3 ``` #### 3.2 智能文件编辑测试 **预览编辑(dry run)** ```bash mcp__webdav__webdav_edit_remote_file \ --path="/test-enhanced.txt" \ --edits='[{"oldText": "第5行:第5行内容", "newText": "第5行:第5行内容(已修改)"}]' \ --dryRun=true ``` **应用编辑** ```bash mcp__webdav__webdav_edit_remote_file \ --path="/test-enhanced.txt" \ --edits='[{"oldText": "第5行:第5行内容", "newText": "第5行:第5行内容(已修改)"}, {"oldText": "第7行:第7行内容", "newText": "第7行:第7行内容(已修改)"}]' \ --dryRun=false ``` #### 3.3 文件搜索测试 **创建测试文件和目录** ```bash # 创建搜索测试文件 mcp__webdav__webdav_create_remote_file \ --path="/test-search1.txt" \ --content="这是一个搜索测试文件1" mcp__webdav__webdav_create_remote_file \ --path="/test-search2.txt" \ --content="这是另一个搜索测试文件" # 创建子目录和嵌套文件 mcp__webdav__webdav_create_remote_directory \ --path="/subdir" mcp__webdav__webdav_create_remote_file \ --path="/subdir/nested-file.txt" \ --content="这是一个嵌套文件" ``` **测试搜索功能** ```bash # 搜索所有包含test的txt文件 mcp__webdav__webdav_search_files \ --path="/" \ --pattern="**/*test*.txt" ``` **测试排除模式** ```bash # 搜索所有txt文件但排除包含enhanced的文件 mcp__webdav__webdav_search_files \ --path="/" \ --pattern="**/*.txt" \ --excludePatterns='["**/*enhanced*"]' ``` ### 步骤 4: 目录操作和文件信息测试 #### 4.1 增强目录列表测试 **按名称排序** ```bash mcp__webdav__webdav_list_directory_with_sizes \ --path="/" \ --sortBy="name" ``` **按大小排序** ```bash mcp__webdav__webdav_list_directory_with_sizes \ --path="/" \ --sortBy="size" ``` #### 4.2 目录树测试 ```bash # 获取完整目录树 mcp__webdav__webdav_get_directory_tree \ --path="/" ``` #### 4.3 文件信息测试 ```bash # 获取文件详细信息 mcp__webdav__webdav_get_file_info \ --path="/test-enhanced.txt" # 获取目录详细信息 mcp__webdav__webdav_get_file_info \ --path="/subdir" ``` #### 4.4 移动和复制测试 **移动文件** ```bash mcp__webdav__webdav_move_remote_item \ --fromPath="/test-search1.txt" \ --toPath="/moved-search1.txt" ``` **复制文件** ```bash mcp__webdav__webdav_copy_remote_item \ --fromPath="/test-search2.txt" \ --toPath="/copied-search2.txt" ``` ### 步骤 5: 多文件操作测试 ```bash # 批量读取多个文件(包含不存在文件) mcp__webdav__webdav_read_multiple_files \ --paths='["/test-enhanced.txt", "/moved-search1.txt", "/test-search2.txt", "/subdir/nested-file.txt", "/nonexistent-file.txt"]' ``` ### 步骤 6: 错误处理测试 #### 6.1 文件不存在错误 ```bash # 尝试读取不存在的文件 mcp__webdav__webdav_get_remote_file \ --path="/nonexistent-file.txt" ``` #### 6.2 重复创建错误 ```bash # 尝试重复创建文件(不启用overwrite) mcp__webdav__webdav_create_remote_file \ --path="/test-enhanced.txt" \ --content="重复创建测试" \ --overwrite=false ``` #### 6.3 编辑不存在文本错误 ```bash # 尝试编辑不存在的文本 mcp__webdav__webdav_edit_remote_file \ --path="/test-enhanced.txt" \ --edits='[{"oldText": "不存在的文本", "newText": "替换文本"}]' \ --dryRun=true ``` #### 6.4 参数验证错误 ```bash # 尝试同时使用head和tail参数 mcp__webdav__webdav_read_remote_file \ --path="/test-enhanced.txt" \ --head=3 \ --tail=3 ``` ### 步骤 7: 清理测试环境 ```bash # 删除所有测试文件和目录 mcp__webdav__webdav_delete_remote_item --path="/test-enhanced.txt" mcp__webdav__webdav_delete_remote_item --path="/moved-search1.txt" mcp__webdav__webdav_delete_remote_item --path="/copied-search2.txt" mcp__webdav__webdav_delete_remote_item --path="/test-search2.txt" mcp__webdav__webdav_delete_remote_item --path="/subdir/nested-file.txt" mcp__webdav__webdav_delete_remote_item --path="/subdir" mcp__webdav__webdav_delete_remote_item --path="/test-directory" ``` ## 验证清单 ### 基础功能验证 - [x] 文件创建成功 - [x] 文件读取正确 - [x] 文件更新成功 - [x] 文件删除成功 - [x] 目录创建成功 - [x] 目录列表正确 ### 增强功能验证 - [x] head 读取功能正常 - [x] tail 读取功能正常 - [x] 智能编辑功能正常 - [x] diff 预览功能正常 - [x] 文件搜索功能正常 - [x] 排除模式功能正常 ### 高级功能验证 - [x] 目录列表排序正常 - [x] 目录树生成正常 - [x] 文件信息获取正常 - [x] 文件移动功能正常 - [x] 文件复制功能正常 - [x] 批量文件操作正常 ### 错误处理验证 - [x] 文件不存在错误处理正常 - [x] 重复操作错误处理正常 - [x] 参数验证错误处理正常 - [x] 批量操作错误隔离正常 ## 故障排除 ### 常见问题 #### 1. WebDAV 服务器连接失败 ```bash # 检查WebDAV服务器状态 curl -u 1234567890:1234567890 http://localhost:1900/ # 如果连接失败,重新启动WebDAV服务器 pnpx @masx200/webdav-cli --path=F:\knowledge-storage --username=1234567890 --password=1234567890 ``` #### 2. MCP 服务器配置问题 ```bash # 检查MCP服务器构建状态 cd F:\projects\mcp-webdav-server npm run build # 检查dist目录是否存在 ls -la dist/ ``` #### 3. 权限问题 ```bash # 确保WebDAV服务器路径有读写权限 ls -la F:\knowledge-storage # 确保MCP服务器有执行权限 chmod +x F:\projects\mcp-webdav-server\dist\index.js ``` #### 4. 端口冲突 ```bash # 检查端口1900是否被占用 netstat -an | grep 1900 # 如果端口被占用,可以修改WebDAV服务器端口或停止占用端口的进程 ``` ### 日志查看 #### WebDAV 服务器日志 WebDAV 服务器的日志通常在控制台输出,包含请求和响应信息。 #### MCP 服务器日志 MCP 服务器的日志可以在 Claude Code 的调试面板中查看,或者在启动开发服务器时在控制台输出。 ```bash # 启动开发服务器查看详细日志 cd F:\projects\mcp-webdav-server npm run dev ``` ## 性能测试 ### 批量操作性能测试 ```bash # 创建大量测试文件 for i in {1..100}; do mcp__webdav__webdav_create_remote_file \ --path="/perf-test-$i.txt" \ --content="性能测试文件 $i" done # 批量读取性能测试 mcp__webdav__webdav_read_multiple_files \ --paths='["/perf-test-1.txt", "/perf-test-2.txt", ..., "/perf-test-100.txt"]' # 清理性能测试文件 for i in {1..100}; do mcp__webdav__webdav_delete_remote_item --path="/perf-test-$i.txt" done ``` ### 大文件处理测试 ```bash # 创建大文件 mcp__webdav__webdav_create_remote_file \ --path="/large-file.txt" \ --content="$(cat /dev/urandom | head -c 1000000 | base64)" # 测试大文件读取(使用head/tail) mcp__webdav__webdav_read_remote_file \ --path="/large-file.txt" \ --head=10 # 清理大文件 mcp__webdav__webdav_delete_remote_item --path="/large-file.txt" ``` ## 安全测试 ### 权限验证测试 ```bash # 尝试使用错误的密码访问 curl -u 1234567890:wrongpassword http://localhost:1900/ # 验证访问被拒绝 ``` ### 路径遍历测试 ```bash # 尝试路径遍历攻击 mcp__webdav__webdav_get_remote_file --path="../../../etc/passwd" mcp__webdav__webdav_list_remote_directory --path="../../" ``` ### 输入验证测试 ```bash # 尝试特殊字符和恶意输入 mcp__webdav__webdav_create_remote_file \ --path="/malicious<>file.txt" \ --content="恶意内容测试" mcp__webdav__webdav_search_files \ --path="/" \ --pattern="*; rm -rf *" ``` ## 测试完成后的清理 测试完成后,建议删除所有测试文件和目录,保持 WebDAV 服务器整洁: ```bash # 删除所有测试相关文件 mcp__webdav__webdav_delete_remote_item --path="/test-enhanced.txt" mcp__webdav__webdav_delete_remote_item --path="/moved-search1.txt" mcp__webdav__webdav_delete_remote_item --path="/copied-search2.txt" mcp__webdav__webdav_delete_remote_item --path="/test-search2.txt" mcp__webdav__webdav_delete_remote_item --path="/subdir" mcp__webdav__webdav_delete_remote_item --path="/test-directory" ``` ## 注意事项 1. **数据备份**: 在进行删除操作前,确保重要数据已备份 2. **权限控制**: 确保 WebDAV 服务器的路径设置正确,避免访问敏感目录 3. **网络稳定性**: 确保网络连接稳定,避免测试过程中断 4. **资源使用**: 注意监控服务器资源使用情况,避免过度占用 5. **测试隔离**: 建议在测试环境中进行,避免影响生产数据 --- _本测试步骤指南涵盖了 MCP WebDAV Server 的所有功能测试,请按照步骤逐一执行验证。_

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/masx200/mcp-webdav-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server