Major improvements following best-in-class MCP patterns: - Token efficiency: new formatters.py with compact JSON (no indent), short device IDs, character-limit truncation; all read tools gain concise=true (default) / concise=false toggle via ReadParams base - Models: ReadParams/WriteParams hierarchy replaces flat models; backward-compatible aliases preserved for tests - New tools: syncthing_remote_need (debug remote sync gaps), syncthing_device_stats (per-device statistics) - SKILL.md: LLM skill guide with token rules, quick-start table, workflows, tool reference, and troubleshooting - Cloudflare Tunnel: docker-compose.tunnel.yml for zero-trust HTTP deployment alongside existing Traefik/ACME support - Fix duplicate dependencies in pyproject.toml; bump to v0.3.0 https://claude.ai/code/session_018efEinU8ypT2jHeex6o9PC
63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
"""Tests for device tools (list, completion, connections, stats)."""
|
|
|
|
import json
|
|
|
|
import pytest
|
|
|
|
from syncthing_mcp.models import DeviceInput, EmptyInput
|
|
from syncthing_mcp.registry import reload_instances
|
|
from tests.conftest import (
|
|
BASE_URL,
|
|
DEVICE_ID_LOCAL,
|
|
DEVICE_ID_REMOTE,
|
|
make_completion,
|
|
)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _setup(single_instance_env):
|
|
reload_instances()
|
|
yield
|
|
reload_instances()
|
|
|
|
|
|
class TestListDevices:
|
|
async def test_returns_devices(self, mock_api):
|
|
from syncthing_mcp.tools.devices import syncthing_list_devices
|
|
|
|
result = json.loads(await syncthing_list_devices(EmptyInput()))
|
|
assert len(result) == 2
|
|
names = {d["name"] for d in result}
|
|
assert "local-dev" in names
|
|
assert "remote-dev" in names
|
|
|
|
|
|
class TestDeviceCompletion:
|
|
async def test_fully_synced(self, mock_api):
|
|
from syncthing_mcp.tools.devices import syncthing_device_completion
|
|
|
|
mock_api.get("/rest/db/completion").respond(json=make_completion(100.0))
|
|
result = json.loads(await syncthing_device_completion(
|
|
DeviceInput(device_id=DEVICE_ID_REMOTE)
|
|
))
|
|
assert result["completion"] == 100.0
|
|
assert result["needSize"] == "0.0 B"
|
|
|
|
|
|
class TestConnections:
|
|
async def test_returns_connections(self, mock_api):
|
|
from syncthing_mcp.tools.devices import syncthing_connections
|
|
|
|
result = json.loads(await syncthing_connections(EmptyInput()))
|
|
assert len(result) == 2
|
|
assert any(c["connected"] for c in result)
|
|
|
|
|
|
class TestDeviceStats:
|
|
async def test_returns_stats(self, mock_api):
|
|
from syncthing_mcp.tools.devices import syncthing_device_stats
|
|
|
|
result = json.loads(await syncthing_device_stats(EmptyInput()))
|
|
assert len(result) >= 1
|
|
assert "lastSeen" in result[0]
|