fix: use share paths, drop additional from list_dir, remove debug logging

Root cause: DSM expects share paths (/dev) not volume paths (/volume1/dev).
The 408 errors were triggered by any additional field on the wrong path format.

- list_shares: use share["path"] directly (e.g. /dev), drop real_path from
  additional — only volume_status remains
- list_dir: remove additional parameter entirely; table now shows name + type
  (isdir is returned by default); update docstring to show share path examples
- client.py: remove diagnostic REQUEST and RAW ERROR stderr logging
- tests: update assertions to match share paths and two-column table output

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-14 09:11:10 +02:00
parent cb92606217
commit a3e1a557c3
3 changed files with 23 additions and 66 deletions
+8 -23
View File
@@ -79,7 +79,8 @@ async def test_list_shares_success(config: AppConfig) -> None:
result = await tools["list_shares"]()
assert "data" in result
assert "/volume1/data" in result
assert "/data" in result # share path, not volume path
assert "/volume1/data" not in result
assert "photos" in result
assert "2 share(s) found" in result
# Check usage percentage appears
@@ -120,33 +121,21 @@ async def test_list_shares_dsm_error(config: AppConfig) -> None:
@pytest.mark.asyncio
async def test_list_dir_success(config: AppConfig) -> None:
"""list_dir returns a formatted table with files and directories."""
"""list_dir returns a formatted table with name and type columns."""
client = MagicMock()
client.request = AsyncMock(
return_value={
"total": 3,
"files": [
{
"name": "documents",
"isdir": True,
"additional": {"size": None, "time": {"mtime": 1700000000}},
},
{
"name": "photo.jpg",
"isdir": False,
"additional": {"size": 2_500_000, "time": {"mtime": 1700100000}},
},
{
"name": "readme.txt",
"isdir": False,
"additional": {"size": 1024, "time": {"mtime": 1700200000}},
},
{"name": "documents", "isdir": True},
{"name": "photo.jpg", "isdir": False},
{"name": "readme.txt", "isdir": False},
],
}
)
tools = _make_mcp_and_tools(config, client)
result = await tools["list_dir"](path="/volume1/data")
result = await tools["list_dir"](path="/dev")
assert "documents" in result
assert "photo.jpg" in result
@@ -164,11 +153,7 @@ async def test_list_dir_pagination(config: AppConfig) -> None:
return_value={
"total": 200,
"files": [
{
"name": f"file{i}.txt",
"isdir": False,
"additional": {"size": 100, "time": {"mtime": 1700000000 + i}},
}
{"name": f"file{i}.txt", "isdir": False}
for i in range(100)
],
}